patch_realtek.c 372 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279
  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_AUTO,
  93. ALC262_MODEL_LAST /* last tag */
  94. };
  95. /* ALC268 models */
  96. enum {
  97. ALC268_3ST,
  98. ALC268_AUTO,
  99. ALC268_MODEL_LAST /* last tag */
  100. };
  101. /* ALC861 models */
  102. enum {
  103. ALC861_3ST,
  104. ALC660_3ST,
  105. ALC861_3ST_DIG,
  106. ALC861_6ST_DIG,
  107. ALC861_UNIWILL_M31,
  108. ALC861_TOSHIBA,
  109. ALC861_ASUS,
  110. ALC861_ASUS_LAPTOP,
  111. ALC861_AUTO,
  112. ALC861_MODEL_LAST,
  113. };
  114. /* ALC861-VD models */
  115. enum {
  116. ALC660VD_3ST,
  117. ALC660VD_3ST_DIG,
  118. ALC861VD_3ST,
  119. ALC861VD_3ST_DIG,
  120. ALC861VD_6ST_DIG,
  121. ALC861VD_LENOVO,
  122. ALC861VD_DALLAS,
  123. ALC861VD_AUTO,
  124. ALC861VD_MODEL_LAST,
  125. };
  126. /* ALC662 models */
  127. enum {
  128. ALC662_3ST_2ch_DIG,
  129. ALC662_3ST_6ch_DIG,
  130. ALC662_3ST_6ch,
  131. ALC662_5ST_DIG,
  132. ALC662_LENOVO_101E,
  133. ALC662_AUTO,
  134. ALC662_MODEL_LAST,
  135. };
  136. /* ALC882 models */
  137. enum {
  138. ALC882_3ST_DIG,
  139. ALC882_6ST_DIG,
  140. ALC882_ARIMA,
  141. ALC882_W2JC,
  142. ALC882_TARGA,
  143. ALC882_ASUS_A7J,
  144. ALC885_MACPRO,
  145. ALC882_AUTO,
  146. ALC882_MODEL_LAST,
  147. };
  148. /* ALC883 models */
  149. enum {
  150. ALC883_3ST_2ch_DIG,
  151. ALC883_3ST_6ch_DIG,
  152. ALC883_3ST_6ch,
  153. ALC883_6ST_DIG,
  154. ALC883_TARGA_DIG,
  155. ALC883_TARGA_2ch_DIG,
  156. ALC883_ACER,
  157. ALC883_MEDION,
  158. ALC883_MEDION_MD2,
  159. ALC883_LAPTOP_EAPD,
  160. ALC883_LENOVO_101E_2ch,
  161. ALC883_LENOVO_NB0763,
  162. ALC888_LENOVO_MS7195_DIG,
  163. ALC883_AUTO,
  164. ALC883_MODEL_LAST,
  165. };
  166. /* for GPIO Poll */
  167. #define GPIO_MASK 0x03
  168. struct alc_spec {
  169. /* codec parameterization */
  170. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  171. unsigned int num_mixers;
  172. const struct hda_verb *init_verbs[5]; /* initialization verbs
  173. * don't forget NULL
  174. * termination!
  175. */
  176. unsigned int num_init_verbs;
  177. char *stream_name_analog; /* analog PCM stream */
  178. struct hda_pcm_stream *stream_analog_playback;
  179. struct hda_pcm_stream *stream_analog_capture;
  180. char *stream_name_digital; /* digital PCM stream */
  181. struct hda_pcm_stream *stream_digital_playback;
  182. struct hda_pcm_stream *stream_digital_capture;
  183. /* playback */
  184. struct hda_multi_out multiout; /* playback set-up
  185. * max_channels, dacs must be set
  186. * dig_out_nid and hp_nid are optional
  187. */
  188. /* capture */
  189. unsigned int num_adc_nids;
  190. hda_nid_t *adc_nids;
  191. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  192. /* capture source */
  193. unsigned int num_mux_defs;
  194. const struct hda_input_mux *input_mux;
  195. unsigned int cur_mux[3];
  196. /* channel model */
  197. const struct hda_channel_mode *channel_mode;
  198. int num_channel_mode;
  199. int need_dac_fix;
  200. /* PCM information */
  201. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  202. /* dynamic controls, init_verbs and input_mux */
  203. struct auto_pin_cfg autocfg;
  204. unsigned int num_kctl_alloc, num_kctl_used;
  205. struct snd_kcontrol_new *kctl_alloc;
  206. struct hda_input_mux private_imux;
  207. hda_nid_t private_dac_nids[5];
  208. /* hooks */
  209. void (*init_hook)(struct hda_codec *codec);
  210. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  211. /* for pin sensing */
  212. unsigned int sense_updated: 1;
  213. unsigned int jack_present: 1;
  214. };
  215. /*
  216. * configuration template - to be copied to the spec instance
  217. */
  218. struct alc_config_preset {
  219. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  220. * with spec
  221. */
  222. const struct hda_verb *init_verbs[5];
  223. unsigned int num_dacs;
  224. hda_nid_t *dac_nids;
  225. hda_nid_t dig_out_nid; /* optional */
  226. hda_nid_t hp_nid; /* optional */
  227. unsigned int num_adc_nids;
  228. hda_nid_t *adc_nids;
  229. hda_nid_t dig_in_nid;
  230. unsigned int num_channel_mode;
  231. const struct hda_channel_mode *channel_mode;
  232. int need_dac_fix;
  233. unsigned int num_mux_defs;
  234. const struct hda_input_mux *input_mux;
  235. void (*unsol_event)(struct hda_codec *, unsigned int);
  236. void (*init_hook)(struct hda_codec *);
  237. };
  238. /*
  239. * input MUX handling
  240. */
  241. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  242. struct snd_ctl_elem_info *uinfo)
  243. {
  244. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  245. struct alc_spec *spec = codec->spec;
  246. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  247. if (mux_idx >= spec->num_mux_defs)
  248. mux_idx = 0;
  249. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  250. }
  251. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  252. struct snd_ctl_elem_value *ucontrol)
  253. {
  254. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  255. struct alc_spec *spec = codec->spec;
  256. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  257. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  258. return 0;
  259. }
  260. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol)
  262. {
  263. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  264. struct alc_spec *spec = codec->spec;
  265. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  266. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  267. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  268. spec->adc_nids[adc_idx],
  269. &spec->cur_mux[adc_idx]);
  270. }
  271. /*
  272. * channel mode setting
  273. */
  274. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  275. struct snd_ctl_elem_info *uinfo)
  276. {
  277. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  278. struct alc_spec *spec = codec->spec;
  279. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  280. spec->num_channel_mode);
  281. }
  282. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  283. struct snd_ctl_elem_value *ucontrol)
  284. {
  285. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  286. struct alc_spec *spec = codec->spec;
  287. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  288. spec->num_channel_mode,
  289. spec->multiout.max_channels);
  290. }
  291. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_value *ucontrol)
  293. {
  294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  295. struct alc_spec *spec = codec->spec;
  296. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  297. spec->num_channel_mode,
  298. &spec->multiout.max_channels);
  299. if (err >= 0 && spec->need_dac_fix)
  300. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  301. return err;
  302. }
  303. /*
  304. * Control the mode of pin widget settings via the mixer. "pc" is used
  305. * instead of "%" to avoid consequences of accidently treating the % as
  306. * being part of a format specifier. Maximum allowed length of a value is
  307. * 63 characters plus NULL terminator.
  308. *
  309. * Note: some retasking pin complexes seem to ignore requests for input
  310. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  311. * are requested. Therefore order this list so that this behaviour will not
  312. * cause problems when mixer clients move through the enum sequentially.
  313. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  314. * March 2006.
  315. */
  316. static char *alc_pin_mode_names[] = {
  317. "Mic 50pc bias", "Mic 80pc bias",
  318. "Line in", "Line out", "Headphone out",
  319. };
  320. static unsigned char alc_pin_mode_values[] = {
  321. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  322. };
  323. /* The control can present all 5 options, or it can limit the options based
  324. * in the pin being assumed to be exclusively an input or an output pin. In
  325. * addition, "input" pins may or may not process the mic bias option
  326. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  327. * accept requests for bias as of chip versions up to March 2006) and/or
  328. * wiring in the computer.
  329. */
  330. #define ALC_PIN_DIR_IN 0x00
  331. #define ALC_PIN_DIR_OUT 0x01
  332. #define ALC_PIN_DIR_INOUT 0x02
  333. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  334. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  335. /* Info about the pin modes supported by the different pin direction modes.
  336. * For each direction the minimum and maximum values are given.
  337. */
  338. static signed char alc_pin_mode_dir_info[5][2] = {
  339. { 0, 2 }, /* ALC_PIN_DIR_IN */
  340. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  341. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  342. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  343. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  344. };
  345. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  346. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  347. #define alc_pin_mode_n_items(_dir) \
  348. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  349. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  350. struct snd_ctl_elem_info *uinfo)
  351. {
  352. unsigned int item_num = uinfo->value.enumerated.item;
  353. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  354. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  355. uinfo->count = 1;
  356. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  357. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  358. item_num = alc_pin_mode_min(dir);
  359. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  360. return 0;
  361. }
  362. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  363. struct snd_ctl_elem_value *ucontrol)
  364. {
  365. unsigned int i;
  366. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  367. hda_nid_t nid = kcontrol->private_value & 0xffff;
  368. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  369. long *valp = ucontrol->value.integer.value;
  370. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  371. AC_VERB_GET_PIN_WIDGET_CONTROL,
  372. 0x00);
  373. /* Find enumerated value for current pinctl setting */
  374. i = alc_pin_mode_min(dir);
  375. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  376. i++;
  377. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  378. return 0;
  379. }
  380. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. signed int change;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long val = *ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  392. val = alc_pin_mode_min(dir);
  393. change = pinctl != alc_pin_mode_values[val];
  394. if (change) {
  395. /* Set pin mode to that requested */
  396. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  397. alc_pin_mode_values[val]);
  398. /* Also enable the retasking pin's input/output as required
  399. * for the requested pin mode. Enum values of 2 or less are
  400. * input modes.
  401. *
  402. * Dynamically switching the input/output buffers probably
  403. * reduces noise slightly (particularly on input) so we'll
  404. * do it. However, having both input and output buffers
  405. * enabled simultaneously doesn't seem to be problematic if
  406. * this turns out to be necessary in the future.
  407. */
  408. if (val <= 2) {
  409. snd_hda_codec_write(codec, nid, 0,
  410. AC_VERB_SET_AMP_GAIN_MUTE,
  411. AMP_OUT_MUTE);
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_IN_UNMUTE(0));
  415. } else {
  416. snd_hda_codec_write(codec, nid, 0,
  417. AC_VERB_SET_AMP_GAIN_MUTE,
  418. AMP_IN_MUTE(0));
  419. snd_hda_codec_write(codec, nid, 0,
  420. AC_VERB_SET_AMP_GAIN_MUTE,
  421. AMP_OUT_UNMUTE);
  422. }
  423. }
  424. return change;
  425. }
  426. #define ALC_PIN_MODE(xname, nid, dir) \
  427. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  428. .info = alc_pin_mode_info, \
  429. .get = alc_pin_mode_get, \
  430. .put = alc_pin_mode_put, \
  431. .private_value = nid | (dir<<16) }
  432. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  433. * together using a mask with more than one bit set. This control is
  434. * currently used only by the ALC260 test model. At this stage they are not
  435. * needed for any "production" models.
  436. */
  437. #ifdef CONFIG_SND_DEBUG
  438. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  439. struct snd_ctl_elem_info *uinfo)
  440. {
  441. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  442. uinfo->count = 1;
  443. uinfo->value.integer.min = 0;
  444. uinfo->value.integer.max = 1;
  445. return 0;
  446. }
  447. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  448. struct snd_ctl_elem_value *ucontrol)
  449. {
  450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  451. hda_nid_t nid = kcontrol->private_value & 0xffff;
  452. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  453. long *valp = ucontrol->value.integer.value;
  454. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_GPIO_DATA, 0x00);
  456. *valp = (val & mask) != 0;
  457. return 0;
  458. }
  459. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  460. struct snd_ctl_elem_value *ucontrol)
  461. {
  462. signed int change;
  463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  464. hda_nid_t nid = kcontrol->private_value & 0xffff;
  465. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  466. long val = *ucontrol->value.integer.value;
  467. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_GPIO_DATA,
  469. 0x00);
  470. /* Set/unset the masked GPIO bit(s) as needed */
  471. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  472. if (val == 0)
  473. gpio_data &= ~mask;
  474. else
  475. gpio_data |= mask;
  476. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  477. return change;
  478. }
  479. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  480. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  481. .info = alc_gpio_data_info, \
  482. .get = alc_gpio_data_get, \
  483. .put = alc_gpio_data_put, \
  484. .private_value = nid | (mask<<16) }
  485. #endif /* CONFIG_SND_DEBUG */
  486. /* A switch control to allow the enabling of the digital IO pins on the
  487. * ALC260. This is incredibly simplistic; the intention of this control is
  488. * to provide something in the test model allowing digital outputs to be
  489. * identified if present. If models are found which can utilise these
  490. * outputs a more complete mixer control can be devised for those models if
  491. * necessary.
  492. */
  493. #ifdef CONFIG_SND_DEBUG
  494. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  495. struct snd_ctl_elem_info *uinfo)
  496. {
  497. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  498. uinfo->count = 1;
  499. uinfo->value.integer.min = 0;
  500. uinfo->value.integer.max = 1;
  501. return 0;
  502. }
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. }
  574. /* Enable GPIO mask and set output */
  575. static struct hda_verb alc_gpio1_init_verbs[] = {
  576. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  579. { }
  580. };
  581. static struct hda_verb alc_gpio2_init_verbs[] = {
  582. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  585. { }
  586. };
  587. static struct hda_verb alc_gpio3_init_verbs[] = {
  588. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  591. { }
  592. };
  593. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  594. * 31 ~ 16 : Manufacture ID
  595. * 15 ~ 8 : SKU ID
  596. * 7 ~ 0 : Assembly ID
  597. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  598. */
  599. static void alc_subsystem_id(struct hda_codec *codec,
  600. unsigned int porta, unsigned int porte,
  601. unsigned int portd)
  602. {
  603. unsigned int ass, tmp;
  604. ass = codec->subsystem_id;
  605. if (!(ass & 1))
  606. return;
  607. /* Override */
  608. tmp = (ass & 0x38) >> 3; /* external Amp control */
  609. switch (tmp) {
  610. case 1:
  611. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  612. break;
  613. case 3:
  614. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  615. break;
  616. case 7:
  617. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  618. break;
  619. case 5:
  620. switch (codec->vendor_id) {
  621. case 0x10ec0862:
  622. case 0x10ec0660:
  623. case 0x10ec0662:
  624. case 0x10ec0267:
  625. case 0x10ec0268:
  626. snd_hda_codec_write(codec, 0x14, 0,
  627. AC_VERB_SET_EAPD_BTLENABLE, 2);
  628. snd_hda_codec_write(codec, 0x15, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. return;
  631. }
  632. case 6:
  633. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  634. hda_nid_t port = 0;
  635. tmp = (ass & 0x1800) >> 11;
  636. switch (tmp) {
  637. case 0: port = porta; break;
  638. case 1: port = porte; break;
  639. case 2: port = portd; break;
  640. }
  641. if (port)
  642. snd_hda_codec_write(codec, port, 0,
  643. AC_VERB_SET_EAPD_BTLENABLE,
  644. 2);
  645. }
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  648. (tmp == 5 ? 0x3040 : 0x3050));
  649. break;
  650. }
  651. }
  652. /*
  653. * ALC880 3-stack model
  654. *
  655. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  656. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  657. * F-Mic = 0x1b, HP = 0x19
  658. */
  659. static hda_nid_t alc880_dac_nids[4] = {
  660. /* front, rear, clfe, rear_surr */
  661. 0x02, 0x05, 0x04, 0x03
  662. };
  663. static hda_nid_t alc880_adc_nids[3] = {
  664. /* ADC0-2 */
  665. 0x07, 0x08, 0x09,
  666. };
  667. /* The datasheet says the node 0x07 is connected from inputs,
  668. * but it shows zero connection in the real implementation on some devices.
  669. * Note: this is a 915GAV bug, fixed on 915GLV
  670. */
  671. static hda_nid_t alc880_adc_nids_alt[2] = {
  672. /* ADC1-2 */
  673. 0x08, 0x09,
  674. };
  675. #define ALC880_DIGOUT_NID 0x06
  676. #define ALC880_DIGIN_NID 0x0a
  677. static struct hda_input_mux alc880_capture_source = {
  678. .num_items = 4,
  679. .items = {
  680. { "Mic", 0x0 },
  681. { "Front Mic", 0x3 },
  682. { "Line", 0x2 },
  683. { "CD", 0x4 },
  684. },
  685. };
  686. /* channel source setting (2/6 channel selection for 3-stack) */
  687. /* 2ch mode */
  688. static struct hda_verb alc880_threestack_ch2_init[] = {
  689. /* set line-in to input, mute it */
  690. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  691. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  692. /* set mic-in to input vref 80%, mute it */
  693. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  694. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  695. { } /* end */
  696. };
  697. /* 6ch mode */
  698. static struct hda_verb alc880_threestack_ch6_init[] = {
  699. /* set line-in to output, unmute it */
  700. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  701. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  702. /* set mic-in to output, unmute it */
  703. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. { } /* end */
  706. };
  707. static struct hda_channel_mode alc880_threestack_modes[2] = {
  708. { 2, alc880_threestack_ch2_init },
  709. { 6, alc880_threestack_ch6_init },
  710. };
  711. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  712. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  713. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  714. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  715. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  716. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  717. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  719. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  728. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  730. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  731. {
  732. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  733. .name = "Channel Mode",
  734. .info = alc_ch_mode_info,
  735. .get = alc_ch_mode_get,
  736. .put = alc_ch_mode_put,
  737. },
  738. { } /* end */
  739. };
  740. /* capture mixer elements */
  741. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  742. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  743. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  744. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  745. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  746. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  747. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  748. {
  749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  750. /* The multiple "Capture Source" controls confuse alsamixer
  751. * So call somewhat different..
  752. * FIXME: the controls appear in the "playback" view!
  753. */
  754. /* .name = "Capture Source", */
  755. .name = "Input Source",
  756. .count = 3,
  757. .info = alc_mux_enum_info,
  758. .get = alc_mux_enum_get,
  759. .put = alc_mux_enum_put,
  760. },
  761. { } /* end */
  762. };
  763. /* capture mixer elements (in case NID 0x07 not available) */
  764. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  765. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  766. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  767. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  768. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  769. {
  770. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  771. /* The multiple "Capture Source" controls confuse alsamixer
  772. * So call somewhat different..
  773. * FIXME: the controls appear in the "playback" view!
  774. */
  775. /* .name = "Capture Source", */
  776. .name = "Input Source",
  777. .count = 2,
  778. .info = alc_mux_enum_info,
  779. .get = alc_mux_enum_get,
  780. .put = alc_mux_enum_put,
  781. },
  782. { } /* end */
  783. };
  784. /*
  785. * ALC880 5-stack model
  786. *
  787. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  788. * Side = 0x02 (0xd)
  789. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  790. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  791. */
  792. /* additional mixers to alc880_three_stack_mixer */
  793. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  794. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  795. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  796. { } /* end */
  797. };
  798. /* channel source setting (6/8 channel selection for 5-stack) */
  799. /* 6ch mode */
  800. static struct hda_verb alc880_fivestack_ch6_init[] = {
  801. /* set line-in to input, mute it */
  802. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  803. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  804. { } /* end */
  805. };
  806. /* 8ch mode */
  807. static struct hda_verb alc880_fivestack_ch8_init[] = {
  808. /* set line-in to output, unmute it */
  809. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  810. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  811. { } /* end */
  812. };
  813. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  814. { 6, alc880_fivestack_ch6_init },
  815. { 8, alc880_fivestack_ch8_init },
  816. };
  817. /*
  818. * ALC880 6-stack model
  819. *
  820. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  821. * Side = 0x05 (0x0f)
  822. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  823. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  824. */
  825. static hda_nid_t alc880_6st_dac_nids[4] = {
  826. /* front, rear, clfe, rear_surr */
  827. 0x02, 0x03, 0x04, 0x05
  828. };
  829. static struct hda_input_mux alc880_6stack_capture_source = {
  830. .num_items = 4,
  831. .items = {
  832. { "Mic", 0x0 },
  833. { "Front Mic", 0x1 },
  834. { "Line", 0x2 },
  835. { "CD", 0x4 },
  836. },
  837. };
  838. /* fixed 8-channels */
  839. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  840. { 8, NULL },
  841. };
  842. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  843. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  844. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  845. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  846. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  847. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  848. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  849. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  850. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  856. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  857. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  858. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  859. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  860. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  861. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  862. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  863. {
  864. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  865. .name = "Channel Mode",
  866. .info = alc_ch_mode_info,
  867. .get = alc_ch_mode_get,
  868. .put = alc_ch_mode_put,
  869. },
  870. { } /* end */
  871. };
  872. /*
  873. * ALC880 W810 model
  874. *
  875. * W810 has rear IO for:
  876. * Front (DAC 02)
  877. * Surround (DAC 03)
  878. * Center/LFE (DAC 04)
  879. * Digital out (06)
  880. *
  881. * The system also has a pair of internal speakers, and a headphone jack.
  882. * These are both connected to Line2 on the codec, hence to DAC 02.
  883. *
  884. * There is a variable resistor to control the speaker or headphone
  885. * volume. This is a hardware-only device without a software API.
  886. *
  887. * Plugging headphones in will disable the internal speakers. This is
  888. * implemented in hardware, not via the driver using jack sense. In
  889. * a similar fashion, plugging into the rear socket marked "front" will
  890. * disable both the speakers and headphones.
  891. *
  892. * For input, there's a microphone jack, and an "audio in" jack.
  893. * These may not do anything useful with this driver yet, because I
  894. * haven't setup any initialization verbs for these yet...
  895. */
  896. static hda_nid_t alc880_w810_dac_nids[3] = {
  897. /* front, rear/surround, clfe */
  898. 0x02, 0x03, 0x04
  899. };
  900. /* fixed 6 channels */
  901. static struct hda_channel_mode alc880_w810_modes[1] = {
  902. { 6, NULL }
  903. };
  904. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  905. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  906. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  907. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  908. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  909. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  910. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  911. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  912. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  913. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  914. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  915. { } /* end */
  916. };
  917. /*
  918. * Z710V model
  919. *
  920. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  921. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  922. * Line = 0x1a
  923. */
  924. static hda_nid_t alc880_z71v_dac_nids[1] = {
  925. 0x02
  926. };
  927. #define ALC880_Z71V_HP_DAC 0x03
  928. /* fixed 2 channels */
  929. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  930. { 2, NULL }
  931. };
  932. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  933. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  934. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  935. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  940. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  941. { } /* end */
  942. };
  943. /* FIXME! */
  944. /*
  945. * ALC880 F1734 model
  946. *
  947. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  948. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  949. */
  950. static hda_nid_t alc880_f1734_dac_nids[1] = {
  951. 0x03
  952. };
  953. #define ALC880_F1734_HP_DAC 0x02
  954. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  955. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  956. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  957. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  958. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  959. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  960. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /* FIXME! */
  966. /*
  967. * ALC880 ASUS model
  968. *
  969. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  970. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  971. * Mic = 0x18, Line = 0x1a
  972. */
  973. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  974. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  975. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  976. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  977. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  978. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  979. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  980. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  981. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  982. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  983. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  985. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  987. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  988. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  989. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  990. {
  991. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  992. .name = "Channel Mode",
  993. .info = alc_ch_mode_info,
  994. .get = alc_ch_mode_get,
  995. .put = alc_ch_mode_put,
  996. },
  997. { } /* end */
  998. };
  999. /* FIXME! */
  1000. /*
  1001. * ALC880 ASUS W1V model
  1002. *
  1003. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1004. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1005. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1006. */
  1007. /* additional mixers to alc880_asus_mixer */
  1008. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1009. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1010. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1011. { } /* end */
  1012. };
  1013. /* additional mixers to alc880_asus_mixer */
  1014. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1015. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1016. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1017. { } /* end */
  1018. };
  1019. /* TCL S700 */
  1020. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1021. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1022. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1023. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1024. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1025. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1027. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1028. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1029. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1030. {
  1031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1032. /* The multiple "Capture Source" controls confuse alsamixer
  1033. * So call somewhat different..
  1034. * FIXME: the controls appear in the "playback" view!
  1035. */
  1036. /* .name = "Capture Source", */
  1037. .name = "Input Source",
  1038. .count = 1,
  1039. .info = alc_mux_enum_info,
  1040. .get = alc_mux_enum_get,
  1041. .put = alc_mux_enum_put,
  1042. },
  1043. { } /* end */
  1044. };
  1045. /* Uniwill */
  1046. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1047. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1048. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1049. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1050. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1051. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1054. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1056. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1059. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1060. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1061. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1062. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1063. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1064. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1065. {
  1066. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1067. .name = "Channel Mode",
  1068. .info = alc_ch_mode_info,
  1069. .get = alc_ch_mode_get,
  1070. .put = alc_ch_mode_put,
  1071. },
  1072. { } /* end */
  1073. };
  1074. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1075. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1082. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1084. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1085. { } /* end */
  1086. };
  1087. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1088. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1089. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1091. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1093. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1094. { } /* end */
  1095. };
  1096. /*
  1097. * build control elements
  1098. */
  1099. static int alc_build_controls(struct hda_codec *codec)
  1100. {
  1101. struct alc_spec *spec = codec->spec;
  1102. int err;
  1103. int i;
  1104. for (i = 0; i < spec->num_mixers; i++) {
  1105. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1106. if (err < 0)
  1107. return err;
  1108. }
  1109. if (spec->multiout.dig_out_nid) {
  1110. err = snd_hda_create_spdif_out_ctls(codec,
  1111. spec->multiout.dig_out_nid);
  1112. if (err < 0)
  1113. return err;
  1114. }
  1115. if (spec->dig_in_nid) {
  1116. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1117. if (err < 0)
  1118. return err;
  1119. }
  1120. return 0;
  1121. }
  1122. /*
  1123. * initialize the codec volumes, etc
  1124. */
  1125. /*
  1126. * generic initialization of ADC, input mixers and output mixers
  1127. */
  1128. static struct hda_verb alc880_volume_init_verbs[] = {
  1129. /*
  1130. * Unmute ADC0-2 and set the default input to mic-in
  1131. */
  1132. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1134. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1135. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1136. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1137. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1138. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1139. * mixer widget
  1140. * Note: PASD motherboards uses the Line In 2 as the input for front
  1141. * panel mic (mic 2)
  1142. */
  1143. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1149. /*
  1150. * Set up output mixers (0x0c - 0x0f)
  1151. */
  1152. /* set vol=0 to output mixers */
  1153. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1154. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1155. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1156. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1157. /* set up input amps for analog loopback */
  1158. /* Amp Indices: DAC = 0, mixer = 1 */
  1159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1160. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1161. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1162. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1163. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1164. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1165. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1166. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1167. { }
  1168. };
  1169. /*
  1170. * 3-stack pin configuration:
  1171. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1172. */
  1173. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1174. /*
  1175. * preset connection lists of input pins
  1176. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1177. */
  1178. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1179. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1180. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1181. /*
  1182. * Set pin mode and muting
  1183. */
  1184. /* set front pin widgets 0x14 for output */
  1185. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1186. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1187. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1188. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1189. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1190. /* Mic2 (as headphone out) for HP output */
  1191. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1192. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. /* Line In pin widget for input */
  1194. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1195. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1196. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1197. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1198. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1199. /* CD pin widget for input */
  1200. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1201. { }
  1202. };
  1203. /*
  1204. * 5-stack pin configuration:
  1205. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1206. * line-in/side = 0x1a, f-mic = 0x1b
  1207. */
  1208. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1209. /*
  1210. * preset connection lists of input pins
  1211. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1212. */
  1213. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1214. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1215. /*
  1216. * Set pin mode and muting
  1217. */
  1218. /* set pin widgets 0x14-0x17 for output */
  1219. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1222. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1223. /* unmute pins for output (no gain on this amp) */
  1224. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1226. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1228. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1229. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1230. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1231. /* Mic2 (as headphone out) for HP output */
  1232. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1233. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1234. /* Line In pin widget for input */
  1235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1236. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1237. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1238. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1239. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1240. /* CD pin widget for input */
  1241. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1242. { }
  1243. };
  1244. /*
  1245. * W810 pin configuration:
  1246. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1247. */
  1248. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1249. /* hphone/speaker input selector: front DAC */
  1250. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1251. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1258. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. { }
  1260. };
  1261. /*
  1262. * Z71V pin configuration:
  1263. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1264. */
  1265. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  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_HP},
  1269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1270. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1271. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1273. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1274. { }
  1275. };
  1276. /*
  1277. * 6-stack pin configuration:
  1278. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1279. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1280. */
  1281. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1282. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1283. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1288. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1289. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1290. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1291. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1292. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1293. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1294. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1295. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1296. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1297. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1298. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1300. { }
  1301. };
  1302. /*
  1303. * Uniwill pin configuration:
  1304. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1305. * line = 0x1a
  1306. */
  1307. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1308. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1309. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1310. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1313. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1314. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1318. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1319. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1320. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1321. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1323. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1329. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1330. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1331. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1332. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1333. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1334. { }
  1335. };
  1336. /*
  1337. * Uniwill P53
  1338. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1339. */
  1340. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1341. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1342. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1347. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1361. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1362. { }
  1363. };
  1364. static struct hda_verb alc880_beep_init_verbs[] = {
  1365. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1366. { }
  1367. };
  1368. /* toggle speaker-output according to the hp-jack state */
  1369. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1370. {
  1371. unsigned int present;
  1372. unsigned char bits;
  1373. present = snd_hda_codec_read(codec, 0x14, 0,
  1374. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1375. bits = present ? 0x80 : 0;
  1376. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1377. 0x80, bits);
  1378. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1379. 0x80, bits);
  1380. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1381. 0x80, bits);
  1382. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1383. 0x80, bits);
  1384. }
  1385. /* auto-toggle front mic */
  1386. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1387. {
  1388. unsigned int present;
  1389. unsigned char bits;
  1390. present = snd_hda_codec_read(codec, 0x18, 0,
  1391. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1392. bits = present ? 0x80 : 0;
  1393. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1394. 0x80, bits);
  1395. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1396. 0x80, bits);
  1397. }
  1398. static void alc880_uniwill_automute(struct hda_codec *codec)
  1399. {
  1400. alc880_uniwill_hp_automute(codec);
  1401. alc880_uniwill_mic_automute(codec);
  1402. }
  1403. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1404. unsigned int res)
  1405. {
  1406. /* Looks like the unsol event is incompatible with the standard
  1407. * definition. 4bit tag is placed at 28 bit!
  1408. */
  1409. switch (res >> 28) {
  1410. case ALC880_HP_EVENT:
  1411. alc880_uniwill_hp_automute(codec);
  1412. break;
  1413. case ALC880_MIC_EVENT:
  1414. alc880_uniwill_mic_automute(codec);
  1415. break;
  1416. }
  1417. }
  1418. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1419. {
  1420. unsigned int present;
  1421. unsigned char bits;
  1422. present = snd_hda_codec_read(codec, 0x14, 0,
  1423. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1424. bits = present ? 0x80 : 0;
  1425. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1426. 0x80, bits);
  1427. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1428. 0x80, bits);
  1429. }
  1430. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1431. {
  1432. unsigned int present;
  1433. present = snd_hda_codec_read(codec, 0x21, 0,
  1434. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1435. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1436. 0x7f, present);
  1437. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1438. 0x7f, present);
  1439. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1440. 0x7f, present);
  1441. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1442. 0x7f, present);
  1443. }
  1444. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1445. unsigned int res)
  1446. {
  1447. /* Looks like the unsol event is incompatible with the standard
  1448. * definition. 4bit tag is placed at 28 bit!
  1449. */
  1450. if ((res >> 28) == ALC880_HP_EVENT)
  1451. alc880_uniwill_p53_hp_automute(codec);
  1452. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1453. alc880_uniwill_p53_dcvol_automute(codec);
  1454. }
  1455. /* FIXME! */
  1456. /*
  1457. * F1734 pin configuration:
  1458. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1459. */
  1460. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1461. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1462. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1463. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1464. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1465. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1466. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1469. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1470. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1471. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1472. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1473. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1474. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1475. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1476. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1477. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1478. { }
  1479. };
  1480. /* FIXME! */
  1481. /*
  1482. * ASUS pin configuration:
  1483. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1484. */
  1485. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1486. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1487. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1488. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1489. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1491. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1495. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1496. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1500. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1501. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1502. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1504. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1505. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1506. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1507. { }
  1508. };
  1509. /* Enable GPIO mask and set output */
  1510. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1511. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1512. /* Clevo m520g init */
  1513. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1514. /* headphone output */
  1515. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1516. /* line-out */
  1517. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1519. /* Line-in */
  1520. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1521. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. /* CD */
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. /* Mic1 (rear panel) */
  1526. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1527. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. /* Mic2 (front panel) */
  1529. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1531. /* headphone */
  1532. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1533. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* change to EAPD mode */
  1535. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1536. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1537. { }
  1538. };
  1539. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1540. /* change to EAPD mode */
  1541. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1542. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1543. /* Headphone output */
  1544. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1545. /* Front output*/
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1547. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1548. /* Line In pin widget for input */
  1549. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1550. /* CD pin widget for input */
  1551. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1552. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1553. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1554. /* change to EAPD mode */
  1555. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1556. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1557. { }
  1558. };
  1559. /*
  1560. * LG m1 express dual
  1561. *
  1562. * Pin assignment:
  1563. * Rear Line-In/Out (blue): 0x14
  1564. * Build-in Mic-In: 0x15
  1565. * Speaker-out: 0x17
  1566. * HP-Out (green): 0x1b
  1567. * Mic-In/Out (red): 0x19
  1568. * SPDIF-Out: 0x1e
  1569. */
  1570. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1571. static hda_nid_t alc880_lg_dac_nids[3] = {
  1572. 0x05, 0x02, 0x03
  1573. };
  1574. /* seems analog CD is not working */
  1575. static struct hda_input_mux alc880_lg_capture_source = {
  1576. .num_items = 3,
  1577. .items = {
  1578. { "Mic", 0x1 },
  1579. { "Line", 0x5 },
  1580. { "Internal Mic", 0x6 },
  1581. },
  1582. };
  1583. /* 2,4,6 channel modes */
  1584. static struct hda_verb alc880_lg_ch2_init[] = {
  1585. /* set line-in and mic-in to input */
  1586. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1587. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1588. { }
  1589. };
  1590. static struct hda_verb alc880_lg_ch4_init[] = {
  1591. /* set line-in to out and mic-in to input */
  1592. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1593. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1594. { }
  1595. };
  1596. static struct hda_verb alc880_lg_ch6_init[] = {
  1597. /* set line-in and mic-in to output */
  1598. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1599. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1600. { }
  1601. };
  1602. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1603. { 2, alc880_lg_ch2_init },
  1604. { 4, alc880_lg_ch4_init },
  1605. { 6, alc880_lg_ch6_init },
  1606. };
  1607. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1608. /* FIXME: it's not really "master" but front channels */
  1609. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1610. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1611. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1612. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1613. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1614. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1615. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1616. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1617. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1618. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1619. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1620. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1621. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1622. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1623. {
  1624. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1625. .name = "Channel Mode",
  1626. .info = alc_ch_mode_info,
  1627. .get = alc_ch_mode_get,
  1628. .put = alc_ch_mode_put,
  1629. },
  1630. { } /* end */
  1631. };
  1632. static struct hda_verb alc880_lg_init_verbs[] = {
  1633. /* set capture source to mic-in */
  1634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1636. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1637. /* mute all amp mixer inputs */
  1638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1640. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1641. /* line-in to input */
  1642. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1643. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1644. /* built-in mic */
  1645. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1646. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* speaker-out */
  1648. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1649. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. /* mic-in to input */
  1651. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1652. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1653. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1654. /* HP-out */
  1655. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1656. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1657. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1658. /* jack sense */
  1659. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1660. { }
  1661. };
  1662. /* toggle speaker-output according to the hp-jack state */
  1663. static void alc880_lg_automute(struct hda_codec *codec)
  1664. {
  1665. unsigned int present;
  1666. unsigned char bits;
  1667. present = snd_hda_codec_read(codec, 0x1b, 0,
  1668. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1669. bits = present ? 0x80 : 0;
  1670. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1671. 0x80, bits);
  1672. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1673. 0x80, bits);
  1674. }
  1675. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1676. {
  1677. /* Looks like the unsol event is incompatible with the standard
  1678. * definition. 4bit tag is placed at 28 bit!
  1679. */
  1680. if ((res >> 28) == 0x01)
  1681. alc880_lg_automute(codec);
  1682. }
  1683. /*
  1684. * LG LW20
  1685. *
  1686. * Pin assignment:
  1687. * Speaker-out: 0x14
  1688. * Mic-In: 0x18
  1689. * Built-in Mic-In: 0x19 (?)
  1690. * HP-Out: 0x1b
  1691. * SPDIF-Out: 0x1e
  1692. */
  1693. /* seems analog CD is not working */
  1694. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1695. .num_items = 2,
  1696. .items = {
  1697. { "Mic", 0x0 },
  1698. { "Internal Mic", 0x1 },
  1699. },
  1700. };
  1701. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1702. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1703. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1706. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1707. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1708. { } /* end */
  1709. };
  1710. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1711. /* set capture source to mic-in */
  1712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1713. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1714. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1715. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1716. /* speaker-out */
  1717. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1718. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1719. /* HP-out */
  1720. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1721. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1722. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1723. /* mic-in to input */
  1724. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1725. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1726. /* built-in mic */
  1727. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1728. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1729. /* jack sense */
  1730. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1731. { }
  1732. };
  1733. /* toggle speaker-output according to the hp-jack state */
  1734. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1735. {
  1736. unsigned int present;
  1737. unsigned char bits;
  1738. present = snd_hda_codec_read(codec, 0x1b, 0,
  1739. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1740. bits = present ? 0x80 : 0;
  1741. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1742. 0x80, bits);
  1743. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1744. 0x80, bits);
  1745. }
  1746. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1747. {
  1748. /* Looks like the unsol event is incompatible with the standard
  1749. * definition. 4bit tag is placed at 28 bit!
  1750. */
  1751. if ((res >> 28) == 0x01)
  1752. alc880_lg_lw_automute(codec);
  1753. }
  1754. /*
  1755. * Common callbacks
  1756. */
  1757. static int alc_init(struct hda_codec *codec)
  1758. {
  1759. struct alc_spec *spec = codec->spec;
  1760. unsigned int i;
  1761. for (i = 0; i < spec->num_init_verbs; i++)
  1762. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1763. if (spec->init_hook)
  1764. spec->init_hook(codec);
  1765. return 0;
  1766. }
  1767. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1768. {
  1769. struct alc_spec *spec = codec->spec;
  1770. if (spec->unsol_event)
  1771. spec->unsol_event(codec, res);
  1772. }
  1773. #ifdef CONFIG_PM
  1774. /*
  1775. * resume
  1776. */
  1777. static int alc_resume(struct hda_codec *codec)
  1778. {
  1779. struct alc_spec *spec = codec->spec;
  1780. int i;
  1781. alc_init(codec);
  1782. for (i = 0; i < spec->num_mixers; i++)
  1783. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1784. if (spec->multiout.dig_out_nid)
  1785. snd_hda_resume_spdif_out(codec);
  1786. if (spec->dig_in_nid)
  1787. snd_hda_resume_spdif_in(codec);
  1788. return 0;
  1789. }
  1790. #endif
  1791. /*
  1792. * Analog playback callbacks
  1793. */
  1794. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1795. struct hda_codec *codec,
  1796. struct snd_pcm_substream *substream)
  1797. {
  1798. struct alc_spec *spec = codec->spec;
  1799. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1800. }
  1801. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1802. struct hda_codec *codec,
  1803. unsigned int stream_tag,
  1804. unsigned int format,
  1805. struct snd_pcm_substream *substream)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1809. stream_tag, format, substream);
  1810. }
  1811. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1812. struct hda_codec *codec,
  1813. struct snd_pcm_substream *substream)
  1814. {
  1815. struct alc_spec *spec = codec->spec;
  1816. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1817. }
  1818. /*
  1819. * Digital out
  1820. */
  1821. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1822. struct hda_codec *codec,
  1823. struct snd_pcm_substream *substream)
  1824. {
  1825. struct alc_spec *spec = codec->spec;
  1826. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1827. }
  1828. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1829. struct hda_codec *codec,
  1830. unsigned int stream_tag,
  1831. unsigned int format,
  1832. struct snd_pcm_substream *substream)
  1833. {
  1834. struct alc_spec *spec = codec->spec;
  1835. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1836. stream_tag, format, substream);
  1837. }
  1838. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1839. struct hda_codec *codec,
  1840. struct snd_pcm_substream *substream)
  1841. {
  1842. struct alc_spec *spec = codec->spec;
  1843. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1844. }
  1845. /*
  1846. * Analog capture
  1847. */
  1848. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1849. struct hda_codec *codec,
  1850. unsigned int stream_tag,
  1851. unsigned int format,
  1852. struct snd_pcm_substream *substream)
  1853. {
  1854. struct alc_spec *spec = codec->spec;
  1855. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1856. stream_tag, 0, format);
  1857. return 0;
  1858. }
  1859. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1860. struct hda_codec *codec,
  1861. struct snd_pcm_substream *substream)
  1862. {
  1863. struct alc_spec *spec = codec->spec;
  1864. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1865. 0, 0, 0);
  1866. return 0;
  1867. }
  1868. /*
  1869. */
  1870. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1871. .substreams = 1,
  1872. .channels_min = 2,
  1873. .channels_max = 8,
  1874. /* NID is set in alc_build_pcms */
  1875. .ops = {
  1876. .open = alc880_playback_pcm_open,
  1877. .prepare = alc880_playback_pcm_prepare,
  1878. .cleanup = alc880_playback_pcm_cleanup
  1879. },
  1880. };
  1881. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1882. .substreams = 2,
  1883. .channels_min = 2,
  1884. .channels_max = 2,
  1885. /* NID is set in alc_build_pcms */
  1886. .ops = {
  1887. .prepare = alc880_capture_pcm_prepare,
  1888. .cleanup = alc880_capture_pcm_cleanup
  1889. },
  1890. };
  1891. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1892. .substreams = 1,
  1893. .channels_min = 2,
  1894. .channels_max = 2,
  1895. /* NID is set in alc_build_pcms */
  1896. .ops = {
  1897. .open = alc880_dig_playback_pcm_open,
  1898. .close = alc880_dig_playback_pcm_close,
  1899. .prepare = alc880_dig_playback_pcm_prepare
  1900. },
  1901. };
  1902. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1903. .substreams = 1,
  1904. .channels_min = 2,
  1905. .channels_max = 2,
  1906. /* NID is set in alc_build_pcms */
  1907. };
  1908. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1909. static struct hda_pcm_stream alc_pcm_null_playback = {
  1910. .substreams = 0,
  1911. .channels_min = 0,
  1912. .channels_max = 0,
  1913. };
  1914. static int alc_build_pcms(struct hda_codec *codec)
  1915. {
  1916. struct alc_spec *spec = codec->spec;
  1917. struct hda_pcm *info = spec->pcm_rec;
  1918. int i;
  1919. codec->num_pcms = 1;
  1920. codec->pcm_info = info;
  1921. info->name = spec->stream_name_analog;
  1922. if (spec->stream_analog_playback) {
  1923. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1924. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1925. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1926. }
  1927. if (spec->stream_analog_capture) {
  1928. snd_assert(spec->adc_nids, return -EINVAL);
  1929. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1930. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1931. }
  1932. if (spec->channel_mode) {
  1933. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1934. for (i = 0; i < spec->num_channel_mode; i++) {
  1935. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1936. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1937. }
  1938. }
  1939. }
  1940. /* SPDIF for stream index #1 */
  1941. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1942. codec->num_pcms = 2;
  1943. info = spec->pcm_rec + 1;
  1944. info->name = spec->stream_name_digital;
  1945. if (spec->multiout.dig_out_nid &&
  1946. spec->stream_digital_playback) {
  1947. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1948. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1949. }
  1950. if (spec->dig_in_nid &&
  1951. spec->stream_digital_capture) {
  1952. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1953. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1954. }
  1955. }
  1956. /* If the use of more than one ADC is requested for the current
  1957. * model, configure a second analog capture-only PCM.
  1958. */
  1959. /* Additional Analaog capture for index #2 */
  1960. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1961. spec->adc_nids) {
  1962. codec->num_pcms = 3;
  1963. info = spec->pcm_rec + 2;
  1964. info->name = spec->stream_name_analog;
  1965. /* No playback stream for second PCM */
  1966. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1967. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1968. if (spec->stream_analog_capture) {
  1969. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1970. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1971. }
  1972. }
  1973. return 0;
  1974. }
  1975. static void alc_free(struct hda_codec *codec)
  1976. {
  1977. struct alc_spec *spec = codec->spec;
  1978. unsigned int i;
  1979. if (!spec)
  1980. return;
  1981. if (spec->kctl_alloc) {
  1982. for (i = 0; i < spec->num_kctl_used; i++)
  1983. kfree(spec->kctl_alloc[i].name);
  1984. kfree(spec->kctl_alloc);
  1985. }
  1986. kfree(spec);
  1987. }
  1988. /*
  1989. */
  1990. static struct hda_codec_ops alc_patch_ops = {
  1991. .build_controls = alc_build_controls,
  1992. .build_pcms = alc_build_pcms,
  1993. .init = alc_init,
  1994. .free = alc_free,
  1995. .unsol_event = alc_unsol_event,
  1996. #ifdef CONFIG_PM
  1997. .resume = alc_resume,
  1998. #endif
  1999. };
  2000. /*
  2001. * Test configuration for debugging
  2002. *
  2003. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2004. * enum controls.
  2005. */
  2006. #ifdef CONFIG_SND_DEBUG
  2007. static hda_nid_t alc880_test_dac_nids[4] = {
  2008. 0x02, 0x03, 0x04, 0x05
  2009. };
  2010. static struct hda_input_mux alc880_test_capture_source = {
  2011. .num_items = 7,
  2012. .items = {
  2013. { "In-1", 0x0 },
  2014. { "In-2", 0x1 },
  2015. { "In-3", 0x2 },
  2016. { "In-4", 0x3 },
  2017. { "CD", 0x4 },
  2018. { "Front", 0x5 },
  2019. { "Surround", 0x6 },
  2020. },
  2021. };
  2022. static struct hda_channel_mode alc880_test_modes[4] = {
  2023. { 2, NULL },
  2024. { 4, NULL },
  2025. { 6, NULL },
  2026. { 8, NULL },
  2027. };
  2028. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2029. struct snd_ctl_elem_info *uinfo)
  2030. {
  2031. static char *texts[] = {
  2032. "N/A", "Line Out", "HP Out",
  2033. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2034. };
  2035. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2036. uinfo->count = 1;
  2037. uinfo->value.enumerated.items = 8;
  2038. if (uinfo->value.enumerated.item >= 8)
  2039. uinfo->value.enumerated.item = 7;
  2040. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2041. return 0;
  2042. }
  2043. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2044. struct snd_ctl_elem_value *ucontrol)
  2045. {
  2046. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2047. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2048. unsigned int pin_ctl, item = 0;
  2049. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2050. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2051. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2052. if (pin_ctl & AC_PINCTL_HP_EN)
  2053. item = 2;
  2054. else
  2055. item = 1;
  2056. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2057. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2058. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2059. case AC_PINCTL_VREF_50: item = 4; break;
  2060. case AC_PINCTL_VREF_GRD: item = 5; break;
  2061. case AC_PINCTL_VREF_80: item = 6; break;
  2062. case AC_PINCTL_VREF_100: item = 7; break;
  2063. }
  2064. }
  2065. ucontrol->value.enumerated.item[0] = item;
  2066. return 0;
  2067. }
  2068. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2069. struct snd_ctl_elem_value *ucontrol)
  2070. {
  2071. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2072. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2073. static unsigned int ctls[] = {
  2074. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2075. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2076. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2077. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2078. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2079. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2080. };
  2081. unsigned int old_ctl, new_ctl;
  2082. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2083. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2084. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2085. if (old_ctl != new_ctl) {
  2086. snd_hda_codec_write(codec, nid, 0,
  2087. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2088. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2089. (ucontrol->value.enumerated.item[0] >= 3 ?
  2090. 0xb080 : 0xb000));
  2091. return 1;
  2092. }
  2093. return 0;
  2094. }
  2095. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2096. struct snd_ctl_elem_info *uinfo)
  2097. {
  2098. static char *texts[] = {
  2099. "Front", "Surround", "CLFE", "Side"
  2100. };
  2101. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2102. uinfo->count = 1;
  2103. uinfo->value.enumerated.items = 4;
  2104. if (uinfo->value.enumerated.item >= 4)
  2105. uinfo->value.enumerated.item = 3;
  2106. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2107. return 0;
  2108. }
  2109. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2110. struct snd_ctl_elem_value *ucontrol)
  2111. {
  2112. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2113. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2114. unsigned int sel;
  2115. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2116. ucontrol->value.enumerated.item[0] = sel & 3;
  2117. return 0;
  2118. }
  2119. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2120. struct snd_ctl_elem_value *ucontrol)
  2121. {
  2122. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2123. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2124. unsigned int sel;
  2125. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2126. if (ucontrol->value.enumerated.item[0] != sel) {
  2127. sel = ucontrol->value.enumerated.item[0] & 3;
  2128. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2129. return 1;
  2130. }
  2131. return 0;
  2132. }
  2133. #define PIN_CTL_TEST(xname,nid) { \
  2134. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2135. .name = xname, \
  2136. .info = alc_test_pin_ctl_info, \
  2137. .get = alc_test_pin_ctl_get, \
  2138. .put = alc_test_pin_ctl_put, \
  2139. .private_value = nid \
  2140. }
  2141. #define PIN_SRC_TEST(xname,nid) { \
  2142. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2143. .name = xname, \
  2144. .info = alc_test_pin_src_info, \
  2145. .get = alc_test_pin_src_get, \
  2146. .put = alc_test_pin_src_put, \
  2147. .private_value = nid \
  2148. }
  2149. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2150. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2151. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2152. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2153. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2154. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2155. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2156. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2157. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2158. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2159. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2160. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2161. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2162. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2163. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2164. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2165. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2166. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2167. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2168. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2169. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2170. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2171. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2172. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2173. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2174. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2175. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2176. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2177. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2178. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2179. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2180. {
  2181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2182. .name = "Channel Mode",
  2183. .info = alc_ch_mode_info,
  2184. .get = alc_ch_mode_get,
  2185. .put = alc_ch_mode_put,
  2186. },
  2187. { } /* end */
  2188. };
  2189. static struct hda_verb alc880_test_init_verbs[] = {
  2190. /* Unmute inputs of 0x0c - 0x0f */
  2191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2199. /* Vol output for 0x0c-0x0f */
  2200. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2201. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2202. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2203. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2204. /* Set output pins 0x14-0x17 */
  2205. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2206. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2207. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2208. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2209. /* Unmute output pins 0x14-0x17 */
  2210. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2212. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2213. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2214. /* Set input pins 0x18-0x1c */
  2215. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2216. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2217. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2218. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2219. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2220. /* Mute input pins 0x18-0x1b */
  2221. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2223. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2224. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2225. /* ADC set up */
  2226. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2227. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2228. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2229. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2230. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2231. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2232. /* Analog input/passthru */
  2233. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2234. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2235. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2236. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2237. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2238. { }
  2239. };
  2240. #endif
  2241. /*
  2242. */
  2243. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2244. [ALC880_3ST] = "3stack",
  2245. [ALC880_TCL_S700] = "tcl",
  2246. [ALC880_3ST_DIG] = "3stack-digout",
  2247. [ALC880_CLEVO] = "clevo",
  2248. [ALC880_5ST] = "5stack",
  2249. [ALC880_5ST_DIG] = "5stack-digout",
  2250. [ALC880_W810] = "w810",
  2251. [ALC880_Z71V] = "z71v",
  2252. [ALC880_6ST] = "6stack",
  2253. [ALC880_6ST_DIG] = "6stack-digout",
  2254. [ALC880_ASUS] = "asus",
  2255. [ALC880_ASUS_W1V] = "asus-w1v",
  2256. [ALC880_ASUS_DIG] = "asus-dig",
  2257. [ALC880_ASUS_DIG2] = "asus-dig2",
  2258. [ALC880_UNIWILL_DIG] = "uniwill",
  2259. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2260. [ALC880_FUJITSU] = "fujitsu",
  2261. [ALC880_F1734] = "F1734",
  2262. [ALC880_LG] = "lg",
  2263. [ALC880_LG_LW] = "lg-lw",
  2264. #ifdef CONFIG_SND_DEBUG
  2265. [ALC880_TEST] = "test",
  2266. #endif
  2267. [ALC880_AUTO] = "auto",
  2268. };
  2269. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2270. /* Broken BIOS configuration */
  2271. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2273. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2274. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2275. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2276. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2277. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2278. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2279. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2280. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2281. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2282. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2283. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2284. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2285. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2288. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2290. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2291. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2292. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2293. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2294. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2295. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2296. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2297. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2298. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2299. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2300. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2301. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2302. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2303. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2304. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2305. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2306. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2307. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2308. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2309. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2310. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2311. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2316. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2317. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2318. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2319. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2320. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2321. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2322. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2323. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2324. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2325. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2326. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2327. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2328. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2329. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2333. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2334. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2335. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2336. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2337. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2338. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2339. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2340. {}
  2341. };
  2342. /*
  2343. * ALC880 codec presets
  2344. */
  2345. static struct alc_config_preset alc880_presets[] = {
  2346. [ALC880_3ST] = {
  2347. .mixers = { alc880_three_stack_mixer },
  2348. .init_verbs = { alc880_volume_init_verbs,
  2349. alc880_pin_3stack_init_verbs },
  2350. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2351. .dac_nids = alc880_dac_nids,
  2352. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2353. .channel_mode = alc880_threestack_modes,
  2354. .need_dac_fix = 1,
  2355. .input_mux = &alc880_capture_source,
  2356. },
  2357. [ALC880_3ST_DIG] = {
  2358. .mixers = { alc880_three_stack_mixer },
  2359. .init_verbs = { alc880_volume_init_verbs,
  2360. alc880_pin_3stack_init_verbs },
  2361. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2362. .dac_nids = alc880_dac_nids,
  2363. .dig_out_nid = ALC880_DIGOUT_NID,
  2364. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2365. .channel_mode = alc880_threestack_modes,
  2366. .need_dac_fix = 1,
  2367. .input_mux = &alc880_capture_source,
  2368. },
  2369. [ALC880_TCL_S700] = {
  2370. .mixers = { alc880_tcl_s700_mixer },
  2371. .init_verbs = { alc880_volume_init_verbs,
  2372. alc880_pin_tcl_S700_init_verbs,
  2373. alc880_gpio2_init_verbs },
  2374. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2375. .dac_nids = alc880_dac_nids,
  2376. .hp_nid = 0x03,
  2377. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2378. .channel_mode = alc880_2_jack_modes,
  2379. .input_mux = &alc880_capture_source,
  2380. },
  2381. [ALC880_5ST] = {
  2382. .mixers = { alc880_three_stack_mixer,
  2383. alc880_five_stack_mixer},
  2384. .init_verbs = { alc880_volume_init_verbs,
  2385. alc880_pin_5stack_init_verbs },
  2386. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2387. .dac_nids = alc880_dac_nids,
  2388. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2389. .channel_mode = alc880_fivestack_modes,
  2390. .input_mux = &alc880_capture_source,
  2391. },
  2392. [ALC880_5ST_DIG] = {
  2393. .mixers = { alc880_three_stack_mixer,
  2394. alc880_five_stack_mixer },
  2395. .init_verbs = { alc880_volume_init_verbs,
  2396. alc880_pin_5stack_init_verbs },
  2397. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2398. .dac_nids = alc880_dac_nids,
  2399. .dig_out_nid = ALC880_DIGOUT_NID,
  2400. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2401. .channel_mode = alc880_fivestack_modes,
  2402. .input_mux = &alc880_capture_source,
  2403. },
  2404. [ALC880_6ST] = {
  2405. .mixers = { alc880_six_stack_mixer },
  2406. .init_verbs = { alc880_volume_init_verbs,
  2407. alc880_pin_6stack_init_verbs },
  2408. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2409. .dac_nids = alc880_6st_dac_nids,
  2410. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2411. .channel_mode = alc880_sixstack_modes,
  2412. .input_mux = &alc880_6stack_capture_source,
  2413. },
  2414. [ALC880_6ST_DIG] = {
  2415. .mixers = { alc880_six_stack_mixer },
  2416. .init_verbs = { alc880_volume_init_verbs,
  2417. alc880_pin_6stack_init_verbs },
  2418. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2419. .dac_nids = alc880_6st_dac_nids,
  2420. .dig_out_nid = ALC880_DIGOUT_NID,
  2421. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2422. .channel_mode = alc880_sixstack_modes,
  2423. .input_mux = &alc880_6stack_capture_source,
  2424. },
  2425. [ALC880_W810] = {
  2426. .mixers = { alc880_w810_base_mixer },
  2427. .init_verbs = { alc880_volume_init_verbs,
  2428. alc880_pin_w810_init_verbs,
  2429. alc880_gpio2_init_verbs },
  2430. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2431. .dac_nids = alc880_w810_dac_nids,
  2432. .dig_out_nid = ALC880_DIGOUT_NID,
  2433. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2434. .channel_mode = alc880_w810_modes,
  2435. .input_mux = &alc880_capture_source,
  2436. },
  2437. [ALC880_Z71V] = {
  2438. .mixers = { alc880_z71v_mixer },
  2439. .init_verbs = { alc880_volume_init_verbs,
  2440. alc880_pin_z71v_init_verbs },
  2441. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2442. .dac_nids = alc880_z71v_dac_nids,
  2443. .dig_out_nid = ALC880_DIGOUT_NID,
  2444. .hp_nid = 0x03,
  2445. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2446. .channel_mode = alc880_2_jack_modes,
  2447. .input_mux = &alc880_capture_source,
  2448. },
  2449. [ALC880_F1734] = {
  2450. .mixers = { alc880_f1734_mixer },
  2451. .init_verbs = { alc880_volume_init_verbs,
  2452. alc880_pin_f1734_init_verbs },
  2453. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2454. .dac_nids = alc880_f1734_dac_nids,
  2455. .hp_nid = 0x02,
  2456. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2457. .channel_mode = alc880_2_jack_modes,
  2458. .input_mux = &alc880_capture_source,
  2459. },
  2460. [ALC880_ASUS] = {
  2461. .mixers = { alc880_asus_mixer },
  2462. .init_verbs = { alc880_volume_init_verbs,
  2463. alc880_pin_asus_init_verbs,
  2464. alc880_gpio1_init_verbs },
  2465. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2466. .dac_nids = alc880_asus_dac_nids,
  2467. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2468. .channel_mode = alc880_asus_modes,
  2469. .need_dac_fix = 1,
  2470. .input_mux = &alc880_capture_source,
  2471. },
  2472. [ALC880_ASUS_DIG] = {
  2473. .mixers = { alc880_asus_mixer },
  2474. .init_verbs = { alc880_volume_init_verbs,
  2475. alc880_pin_asus_init_verbs,
  2476. alc880_gpio1_init_verbs },
  2477. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2478. .dac_nids = alc880_asus_dac_nids,
  2479. .dig_out_nid = ALC880_DIGOUT_NID,
  2480. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2481. .channel_mode = alc880_asus_modes,
  2482. .need_dac_fix = 1,
  2483. .input_mux = &alc880_capture_source,
  2484. },
  2485. [ALC880_ASUS_DIG2] = {
  2486. .mixers = { alc880_asus_mixer },
  2487. .init_verbs = { alc880_volume_init_verbs,
  2488. alc880_pin_asus_init_verbs,
  2489. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2490. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2491. .dac_nids = alc880_asus_dac_nids,
  2492. .dig_out_nid = ALC880_DIGOUT_NID,
  2493. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2494. .channel_mode = alc880_asus_modes,
  2495. .need_dac_fix = 1,
  2496. .input_mux = &alc880_capture_source,
  2497. },
  2498. [ALC880_ASUS_W1V] = {
  2499. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2500. .init_verbs = { alc880_volume_init_verbs,
  2501. alc880_pin_asus_init_verbs,
  2502. alc880_gpio1_init_verbs },
  2503. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2504. .dac_nids = alc880_asus_dac_nids,
  2505. .dig_out_nid = ALC880_DIGOUT_NID,
  2506. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2507. .channel_mode = alc880_asus_modes,
  2508. .need_dac_fix = 1,
  2509. .input_mux = &alc880_capture_source,
  2510. },
  2511. [ALC880_UNIWILL_DIG] = {
  2512. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2513. .init_verbs = { alc880_volume_init_verbs,
  2514. alc880_pin_asus_init_verbs },
  2515. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2516. .dac_nids = alc880_asus_dac_nids,
  2517. .dig_out_nid = ALC880_DIGOUT_NID,
  2518. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2519. .channel_mode = alc880_asus_modes,
  2520. .need_dac_fix = 1,
  2521. .input_mux = &alc880_capture_source,
  2522. },
  2523. [ALC880_UNIWILL] = {
  2524. .mixers = { alc880_uniwill_mixer },
  2525. .init_verbs = { alc880_volume_init_verbs,
  2526. alc880_uniwill_init_verbs },
  2527. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2528. .dac_nids = alc880_asus_dac_nids,
  2529. .dig_out_nid = ALC880_DIGOUT_NID,
  2530. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2531. .channel_mode = alc880_threestack_modes,
  2532. .need_dac_fix = 1,
  2533. .input_mux = &alc880_capture_source,
  2534. .unsol_event = alc880_uniwill_unsol_event,
  2535. .init_hook = alc880_uniwill_automute,
  2536. },
  2537. [ALC880_UNIWILL_P53] = {
  2538. .mixers = { alc880_uniwill_p53_mixer },
  2539. .init_verbs = { alc880_volume_init_verbs,
  2540. alc880_uniwill_p53_init_verbs },
  2541. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2542. .dac_nids = alc880_asus_dac_nids,
  2543. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2544. .channel_mode = alc880_threestack_modes,
  2545. .input_mux = &alc880_capture_source,
  2546. .unsol_event = alc880_uniwill_p53_unsol_event,
  2547. .init_hook = alc880_uniwill_p53_hp_automute,
  2548. },
  2549. [ALC880_FUJITSU] = {
  2550. .mixers = { alc880_fujitsu_mixer,
  2551. alc880_pcbeep_mixer, },
  2552. .init_verbs = { alc880_volume_init_verbs,
  2553. alc880_uniwill_p53_init_verbs,
  2554. alc880_beep_init_verbs },
  2555. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2556. .dac_nids = alc880_dac_nids,
  2557. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2558. .channel_mode = alc880_2_jack_modes,
  2559. .input_mux = &alc880_capture_source,
  2560. .unsol_event = alc880_uniwill_p53_unsol_event,
  2561. .init_hook = alc880_uniwill_p53_hp_automute,
  2562. },
  2563. [ALC880_CLEVO] = {
  2564. .mixers = { alc880_three_stack_mixer },
  2565. .init_verbs = { alc880_volume_init_verbs,
  2566. alc880_pin_clevo_init_verbs },
  2567. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2568. .dac_nids = alc880_dac_nids,
  2569. .hp_nid = 0x03,
  2570. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2571. .channel_mode = alc880_threestack_modes,
  2572. .need_dac_fix = 1,
  2573. .input_mux = &alc880_capture_source,
  2574. },
  2575. [ALC880_LG] = {
  2576. .mixers = { alc880_lg_mixer },
  2577. .init_verbs = { alc880_volume_init_verbs,
  2578. alc880_lg_init_verbs },
  2579. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2580. .dac_nids = alc880_lg_dac_nids,
  2581. .dig_out_nid = ALC880_DIGOUT_NID,
  2582. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2583. .channel_mode = alc880_lg_ch_modes,
  2584. .need_dac_fix = 1,
  2585. .input_mux = &alc880_lg_capture_source,
  2586. .unsol_event = alc880_lg_unsol_event,
  2587. .init_hook = alc880_lg_automute,
  2588. },
  2589. [ALC880_LG_LW] = {
  2590. .mixers = { alc880_lg_lw_mixer },
  2591. .init_verbs = { alc880_volume_init_verbs,
  2592. alc880_lg_lw_init_verbs },
  2593. .num_dacs = 1,
  2594. .dac_nids = alc880_dac_nids,
  2595. .dig_out_nid = ALC880_DIGOUT_NID,
  2596. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2597. .channel_mode = alc880_2_jack_modes,
  2598. .input_mux = &alc880_lg_lw_capture_source,
  2599. .unsol_event = alc880_lg_lw_unsol_event,
  2600. .init_hook = alc880_lg_lw_automute,
  2601. },
  2602. #ifdef CONFIG_SND_DEBUG
  2603. [ALC880_TEST] = {
  2604. .mixers = { alc880_test_mixer },
  2605. .init_verbs = { alc880_test_init_verbs },
  2606. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2607. .dac_nids = alc880_test_dac_nids,
  2608. .dig_out_nid = ALC880_DIGOUT_NID,
  2609. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2610. .channel_mode = alc880_test_modes,
  2611. .input_mux = &alc880_test_capture_source,
  2612. },
  2613. #endif
  2614. };
  2615. /*
  2616. * Automatic parse of I/O pins from the BIOS configuration
  2617. */
  2618. #define NUM_CONTROL_ALLOC 32
  2619. #define NUM_VERB_ALLOC 32
  2620. enum {
  2621. ALC_CTL_WIDGET_VOL,
  2622. ALC_CTL_WIDGET_MUTE,
  2623. ALC_CTL_BIND_MUTE,
  2624. };
  2625. static struct snd_kcontrol_new alc880_control_templates[] = {
  2626. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2627. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2628. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2629. };
  2630. /* add dynamic controls */
  2631. static int add_control(struct alc_spec *spec, int type, const char *name,
  2632. unsigned long val)
  2633. {
  2634. struct snd_kcontrol_new *knew;
  2635. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2636. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2637. /* array + terminator */
  2638. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2639. if (!knew)
  2640. return -ENOMEM;
  2641. if (spec->kctl_alloc) {
  2642. memcpy(knew, spec->kctl_alloc,
  2643. sizeof(*knew) * spec->num_kctl_alloc);
  2644. kfree(spec->kctl_alloc);
  2645. }
  2646. spec->kctl_alloc = knew;
  2647. spec->num_kctl_alloc = num;
  2648. }
  2649. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2650. *knew = alc880_control_templates[type];
  2651. knew->name = kstrdup(name, GFP_KERNEL);
  2652. if (!knew->name)
  2653. return -ENOMEM;
  2654. knew->private_value = val;
  2655. spec->num_kctl_used++;
  2656. return 0;
  2657. }
  2658. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2659. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2660. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2661. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2662. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2663. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2664. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2665. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2666. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2667. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2668. #define ALC880_PIN_CD_NID 0x1c
  2669. /* fill in the dac_nids table from the parsed pin configuration */
  2670. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2671. const struct auto_pin_cfg *cfg)
  2672. {
  2673. hda_nid_t nid;
  2674. int assigned[4];
  2675. int i, j;
  2676. memset(assigned, 0, sizeof(assigned));
  2677. spec->multiout.dac_nids = spec->private_dac_nids;
  2678. /* check the pins hardwired to audio widget */
  2679. for (i = 0; i < cfg->line_outs; i++) {
  2680. nid = cfg->line_out_pins[i];
  2681. if (alc880_is_fixed_pin(nid)) {
  2682. int idx = alc880_fixed_pin_idx(nid);
  2683. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2684. assigned[idx] = 1;
  2685. }
  2686. }
  2687. /* left pins can be connect to any audio widget */
  2688. for (i = 0; i < cfg->line_outs; i++) {
  2689. nid = cfg->line_out_pins[i];
  2690. if (alc880_is_fixed_pin(nid))
  2691. continue;
  2692. /* search for an empty channel */
  2693. for (j = 0; j < cfg->line_outs; j++) {
  2694. if (!assigned[j]) {
  2695. spec->multiout.dac_nids[i] =
  2696. alc880_idx_to_dac(j);
  2697. assigned[j] = 1;
  2698. break;
  2699. }
  2700. }
  2701. }
  2702. spec->multiout.num_dacs = cfg->line_outs;
  2703. return 0;
  2704. }
  2705. /* add playback controls from the parsed DAC table */
  2706. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2707. const struct auto_pin_cfg *cfg)
  2708. {
  2709. char name[32];
  2710. static const char *chname[4] = {
  2711. "Front", "Surround", NULL /*CLFE*/, "Side"
  2712. };
  2713. hda_nid_t nid;
  2714. int i, err;
  2715. for (i = 0; i < cfg->line_outs; i++) {
  2716. if (!spec->multiout.dac_nids[i])
  2717. continue;
  2718. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2719. if (i == 2) {
  2720. /* Center/LFE */
  2721. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2722. "Center Playback Volume",
  2723. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2724. HDA_OUTPUT));
  2725. if (err < 0)
  2726. return err;
  2727. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2728. "LFE Playback Volume",
  2729. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2730. HDA_OUTPUT));
  2731. if (err < 0)
  2732. return err;
  2733. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2734. "Center Playback Switch",
  2735. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2736. HDA_INPUT));
  2737. if (err < 0)
  2738. return err;
  2739. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2740. "LFE Playback Switch",
  2741. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2742. HDA_INPUT));
  2743. if (err < 0)
  2744. return err;
  2745. } else {
  2746. sprintf(name, "%s Playback Volume", chname[i]);
  2747. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2748. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2749. HDA_OUTPUT));
  2750. if (err < 0)
  2751. return err;
  2752. sprintf(name, "%s Playback Switch", chname[i]);
  2753. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2754. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2755. HDA_INPUT));
  2756. if (err < 0)
  2757. return err;
  2758. }
  2759. }
  2760. return 0;
  2761. }
  2762. /* add playback controls for speaker and HP outputs */
  2763. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2764. const char *pfx)
  2765. {
  2766. hda_nid_t nid;
  2767. int err;
  2768. char name[32];
  2769. if (!pin)
  2770. return 0;
  2771. if (alc880_is_fixed_pin(pin)) {
  2772. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2773. /* specify the DAC as the extra output */
  2774. if (!spec->multiout.hp_nid)
  2775. spec->multiout.hp_nid = nid;
  2776. else
  2777. spec->multiout.extra_out_nid[0] = nid;
  2778. /* control HP volume/switch on the output mixer amp */
  2779. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2780. sprintf(name, "%s Playback Volume", pfx);
  2781. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2782. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2783. if (err < 0)
  2784. return err;
  2785. sprintf(name, "%s Playback Switch", pfx);
  2786. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2787. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2788. if (err < 0)
  2789. return err;
  2790. } else if (alc880_is_multi_pin(pin)) {
  2791. /* set manual connection */
  2792. /* we have only a switch on HP-out PIN */
  2793. sprintf(name, "%s Playback Switch", pfx);
  2794. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2795. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2796. if (err < 0)
  2797. return err;
  2798. }
  2799. return 0;
  2800. }
  2801. /* create input playback/capture controls for the given pin */
  2802. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2803. const char *ctlname,
  2804. int idx, hda_nid_t mix_nid)
  2805. {
  2806. char name[32];
  2807. int err;
  2808. sprintf(name, "%s Playback Volume", ctlname);
  2809. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2810. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2811. if (err < 0)
  2812. return err;
  2813. sprintf(name, "%s Playback Switch", ctlname);
  2814. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2815. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2816. if (err < 0)
  2817. return err;
  2818. return 0;
  2819. }
  2820. /* create playback/capture controls for input pins */
  2821. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2822. const struct auto_pin_cfg *cfg)
  2823. {
  2824. struct hda_input_mux *imux = &spec->private_imux;
  2825. int i, err, idx;
  2826. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2827. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2828. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2829. err = new_analog_input(spec, cfg->input_pins[i],
  2830. auto_pin_cfg_labels[i],
  2831. idx, 0x0b);
  2832. if (err < 0)
  2833. return err;
  2834. imux->items[imux->num_items].label =
  2835. auto_pin_cfg_labels[i];
  2836. imux->items[imux->num_items].index =
  2837. alc880_input_pin_idx(cfg->input_pins[i]);
  2838. imux->num_items++;
  2839. }
  2840. }
  2841. return 0;
  2842. }
  2843. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2844. hda_nid_t nid, int pin_type,
  2845. int dac_idx)
  2846. {
  2847. /* set as output */
  2848. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2849. pin_type);
  2850. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2851. AMP_OUT_UNMUTE);
  2852. /* need the manual connection? */
  2853. if (alc880_is_multi_pin(nid)) {
  2854. struct alc_spec *spec = codec->spec;
  2855. int idx = alc880_multi_pin_idx(nid);
  2856. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2857. AC_VERB_SET_CONNECT_SEL,
  2858. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2859. }
  2860. }
  2861. static int get_pin_type(int line_out_type)
  2862. {
  2863. if (line_out_type == AUTO_PIN_HP_OUT)
  2864. return PIN_HP;
  2865. else
  2866. return PIN_OUT;
  2867. }
  2868. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2869. {
  2870. struct alc_spec *spec = codec->spec;
  2871. int i;
  2872. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2873. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2874. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2875. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2876. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2877. }
  2878. }
  2879. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2880. {
  2881. struct alc_spec *spec = codec->spec;
  2882. hda_nid_t pin;
  2883. pin = spec->autocfg.speaker_pins[0];
  2884. if (pin) /* connect to front */
  2885. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2886. pin = spec->autocfg.hp_pins[0];
  2887. if (pin) /* connect to front */
  2888. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2889. }
  2890. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2891. {
  2892. struct alc_spec *spec = codec->spec;
  2893. int i;
  2894. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2895. hda_nid_t nid = spec->autocfg.input_pins[i];
  2896. if (alc880_is_input_pin(nid)) {
  2897. snd_hda_codec_write(codec, nid, 0,
  2898. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2899. i <= AUTO_PIN_FRONT_MIC ?
  2900. PIN_VREF80 : PIN_IN);
  2901. if (nid != ALC880_PIN_CD_NID)
  2902. snd_hda_codec_write(codec, nid, 0,
  2903. AC_VERB_SET_AMP_GAIN_MUTE,
  2904. AMP_OUT_MUTE);
  2905. }
  2906. }
  2907. }
  2908. /* parse the BIOS configuration and set up the alc_spec */
  2909. /* return 1 if successful, 0 if the proper config is not found,
  2910. * or a negative error code
  2911. */
  2912. static int alc880_parse_auto_config(struct hda_codec *codec)
  2913. {
  2914. struct alc_spec *spec = codec->spec;
  2915. int err;
  2916. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2917. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2918. alc880_ignore);
  2919. if (err < 0)
  2920. return err;
  2921. if (!spec->autocfg.line_outs)
  2922. return 0; /* can't find valid BIOS pin config */
  2923. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2924. if (err < 0)
  2925. return err;
  2926. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2927. if (err < 0)
  2928. return err;
  2929. err = alc880_auto_create_extra_out(spec,
  2930. spec->autocfg.speaker_pins[0],
  2931. "Speaker");
  2932. if (err < 0)
  2933. return err;
  2934. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2935. "Headphone");
  2936. if (err < 0)
  2937. return err;
  2938. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2939. if (err < 0)
  2940. return err;
  2941. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2942. if (spec->autocfg.dig_out_pin)
  2943. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2944. if (spec->autocfg.dig_in_pin)
  2945. spec->dig_in_nid = ALC880_DIGIN_NID;
  2946. if (spec->kctl_alloc)
  2947. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2948. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2949. spec->num_mux_defs = 1;
  2950. spec->input_mux = &spec->private_imux;
  2951. return 1;
  2952. }
  2953. /* additional initialization for auto-configuration model */
  2954. static void alc880_auto_init(struct hda_codec *codec)
  2955. {
  2956. alc880_auto_init_multi_out(codec);
  2957. alc880_auto_init_extra_out(codec);
  2958. alc880_auto_init_analog_input(codec);
  2959. }
  2960. /*
  2961. * OK, here we have finally the patch for ALC880
  2962. */
  2963. static int patch_alc880(struct hda_codec *codec)
  2964. {
  2965. struct alc_spec *spec;
  2966. int board_config;
  2967. int err;
  2968. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2969. if (spec == NULL)
  2970. return -ENOMEM;
  2971. codec->spec = spec;
  2972. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2973. alc880_models,
  2974. alc880_cfg_tbl);
  2975. if (board_config < 0) {
  2976. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2977. "trying auto-probe from BIOS...\n");
  2978. board_config = ALC880_AUTO;
  2979. }
  2980. if (board_config == ALC880_AUTO) {
  2981. /* automatic parse from the BIOS config */
  2982. err = alc880_parse_auto_config(codec);
  2983. if (err < 0) {
  2984. alc_free(codec);
  2985. return err;
  2986. } else if (!err) {
  2987. printk(KERN_INFO
  2988. "hda_codec: Cannot set up configuration "
  2989. "from BIOS. Using 3-stack mode...\n");
  2990. board_config = ALC880_3ST;
  2991. }
  2992. }
  2993. if (board_config != ALC880_AUTO)
  2994. setup_preset(spec, &alc880_presets[board_config]);
  2995. spec->stream_name_analog = "ALC880 Analog";
  2996. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2997. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2998. spec->stream_name_digital = "ALC880 Digital";
  2999. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3000. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3001. if (!spec->adc_nids && spec->input_mux) {
  3002. /* check whether NID 0x07 is valid */
  3003. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3004. /* get type */
  3005. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3006. if (wcap != AC_WID_AUD_IN) {
  3007. spec->adc_nids = alc880_adc_nids_alt;
  3008. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3009. spec->mixers[spec->num_mixers] =
  3010. alc880_capture_alt_mixer;
  3011. spec->num_mixers++;
  3012. } else {
  3013. spec->adc_nids = alc880_adc_nids;
  3014. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3015. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3016. spec->num_mixers++;
  3017. }
  3018. }
  3019. codec->patch_ops = alc_patch_ops;
  3020. if (board_config == ALC880_AUTO)
  3021. spec->init_hook = alc880_auto_init;
  3022. return 0;
  3023. }
  3024. /*
  3025. * ALC260 support
  3026. */
  3027. static hda_nid_t alc260_dac_nids[1] = {
  3028. /* front */
  3029. 0x02,
  3030. };
  3031. static hda_nid_t alc260_adc_nids[1] = {
  3032. /* ADC0 */
  3033. 0x04,
  3034. };
  3035. static hda_nid_t alc260_adc_nids_alt[1] = {
  3036. /* ADC1 */
  3037. 0x05,
  3038. };
  3039. static hda_nid_t alc260_hp_adc_nids[2] = {
  3040. /* ADC1, 0 */
  3041. 0x05, 0x04
  3042. };
  3043. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3044. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3045. */
  3046. static hda_nid_t alc260_dual_adc_nids[2] = {
  3047. /* ADC0, ADC1 */
  3048. 0x04, 0x05
  3049. };
  3050. #define ALC260_DIGOUT_NID 0x03
  3051. #define ALC260_DIGIN_NID 0x06
  3052. static struct hda_input_mux alc260_capture_source = {
  3053. .num_items = 4,
  3054. .items = {
  3055. { "Mic", 0x0 },
  3056. { "Front Mic", 0x1 },
  3057. { "Line", 0x2 },
  3058. { "CD", 0x4 },
  3059. },
  3060. };
  3061. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3062. * headphone jack and the internal CD lines since these are the only pins at
  3063. * which audio can appear. For flexibility, also allow the option of
  3064. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3065. * connection to the mixer output).
  3066. */
  3067. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3068. {
  3069. .num_items = 3,
  3070. .items = {
  3071. { "Mic/Line", 0x0 },
  3072. { "CD", 0x4 },
  3073. { "Headphone", 0x2 },
  3074. },
  3075. },
  3076. {
  3077. .num_items = 4,
  3078. .items = {
  3079. { "Mic/Line", 0x0 },
  3080. { "CD", 0x4 },
  3081. { "Headphone", 0x2 },
  3082. { "Mixer", 0x5 },
  3083. },
  3084. },
  3085. };
  3086. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3087. * the Fujitsu S702x, but jacks are marked differently.
  3088. */
  3089. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3090. {
  3091. .num_items = 4,
  3092. .items = {
  3093. { "Mic", 0x0 },
  3094. { "Line", 0x2 },
  3095. { "CD", 0x4 },
  3096. { "Headphone", 0x5 },
  3097. },
  3098. },
  3099. {
  3100. .num_items = 5,
  3101. .items = {
  3102. { "Mic", 0x0 },
  3103. { "Line", 0x2 },
  3104. { "CD", 0x4 },
  3105. { "Headphone", 0x6 },
  3106. { "Mixer", 0x5 },
  3107. },
  3108. },
  3109. };
  3110. /*
  3111. * This is just place-holder, so there's something for alc_build_pcms to look
  3112. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3113. * element which allows changing the channel mode, so the verb list is
  3114. * never used.
  3115. */
  3116. static struct hda_channel_mode alc260_modes[1] = {
  3117. { 2, NULL },
  3118. };
  3119. /* Mixer combinations
  3120. *
  3121. * basic: base_output + input + pc_beep + capture
  3122. * HP: base_output + input + capture_alt
  3123. * HP_3013: hp_3013 + input + capture
  3124. * fujitsu: fujitsu + capture
  3125. * acer: acer + capture
  3126. */
  3127. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3128. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3129. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3130. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3131. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3132. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3133. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3134. { } /* end */
  3135. };
  3136. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3137. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3138. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3139. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3140. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3141. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3142. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3143. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3144. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3145. { } /* end */
  3146. };
  3147. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3148. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3149. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3150. { } /* end */
  3151. };
  3152. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3153. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3154. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3155. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3156. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3157. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3158. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3159. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3160. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3161. { } /* end */
  3162. };
  3163. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3164. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3165. */
  3166. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3167. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3168. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3169. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3170. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3171. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3172. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3173. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3174. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3175. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3176. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3177. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3179. { } /* end */
  3180. };
  3181. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3182. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3183. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3184. * datasheet doesn't mention this restriction. At this stage it's not clear
  3185. * whether this behaviour is intentional or is a hardware bug in chip
  3186. * revisions available in early 2006. Therefore for now allow the
  3187. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3188. * that the lack of mic bias for this NID is intentional we could change the
  3189. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3190. *
  3191. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3192. * don't appear to make the mic bias available from the "line" jack, even
  3193. * though the NID used for this jack (0x14) can supply it. The theory is
  3194. * that perhaps Acer have included blocking capacitors between the ALC260
  3195. * and the output jack. If this turns out to be the case for all such
  3196. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3197. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3198. *
  3199. * The C20x Tablet series have a mono internal speaker which is controlled
  3200. * via the chip's Mono sum widget and pin complex, so include the necessary
  3201. * controls for such models. On models without a "mono speaker" the control
  3202. * won't do anything.
  3203. */
  3204. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3205. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3206. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3207. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3208. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3209. HDA_OUTPUT),
  3210. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3211. HDA_INPUT),
  3212. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3213. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3214. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3215. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3216. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3217. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3218. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3219. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3220. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3221. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3222. { } /* end */
  3223. };
  3224. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3225. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3226. */
  3227. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3228. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3229. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3230. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3231. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3232. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3233. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3234. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3235. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3236. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3237. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3238. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3239. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3240. { } /* end */
  3241. };
  3242. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3243. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3244. */
  3245. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3246. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3247. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, 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("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3252. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3253. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3254. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3255. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3256. { } /* end */
  3257. };
  3258. /* capture mixer elements */
  3259. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3260. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3261. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3262. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3263. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3264. {
  3265. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3266. /* The multiple "Capture Source" controls confuse alsamixer
  3267. * So call somewhat different..
  3268. * FIXME: the controls appear in the "playback" view!
  3269. */
  3270. /* .name = "Capture Source", */
  3271. .name = "Input Source",
  3272. .count = 2,
  3273. .info = alc_mux_enum_info,
  3274. .get = alc_mux_enum_get,
  3275. .put = alc_mux_enum_put,
  3276. },
  3277. { } /* end */
  3278. };
  3279. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3280. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3282. {
  3283. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3284. /* The multiple "Capture Source" controls confuse alsamixer
  3285. * So call somewhat different..
  3286. * FIXME: the controls appear in the "playback" view!
  3287. */
  3288. /* .name = "Capture Source", */
  3289. .name = "Input Source",
  3290. .count = 1,
  3291. .info = alc_mux_enum_info,
  3292. .get = alc_mux_enum_get,
  3293. .put = alc_mux_enum_put,
  3294. },
  3295. { } /* end */
  3296. };
  3297. /*
  3298. * initialization verbs
  3299. */
  3300. static struct hda_verb alc260_init_verbs[] = {
  3301. /* Line In pin widget for input */
  3302. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3303. /* CD pin widget for input */
  3304. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3305. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3306. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3307. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3308. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3309. /* LINE-2 is used for line-out in rear */
  3310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3311. /* select line-out */
  3312. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3313. /* LINE-OUT pin */
  3314. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3315. /* enable HP */
  3316. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3317. /* enable Mono */
  3318. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3319. /* mute capture amp left and right */
  3320. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3321. /* set connection select to line in (default select for this ADC) */
  3322. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3323. /* mute capture amp left and right */
  3324. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3325. /* set connection select to line in (default select for this ADC) */
  3326. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3327. /* set vol=0 Line-Out mixer amp left and right */
  3328. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3329. /* unmute pin widget amp left and right (no gain on this amp) */
  3330. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3331. /* set vol=0 HP mixer amp left and right */
  3332. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3333. /* unmute pin widget amp left and right (no gain on this amp) */
  3334. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3335. /* set vol=0 Mono mixer amp left and right */
  3336. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3337. /* unmute pin widget amp left and right (no gain on this amp) */
  3338. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3339. /* unmute LINE-2 out pin */
  3340. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3341. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3342. * Line In 2 = 0x03
  3343. */
  3344. /* mute CD */
  3345. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3346. /* mute Line In */
  3347. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3348. /* mute Mic */
  3349. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3350. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3351. /* mute Front out path */
  3352. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3353. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3354. /* mute Headphone out path */
  3355. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3356. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3357. /* mute Mono out path */
  3358. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3359. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3360. { }
  3361. };
  3362. #if 0 /* should be identical with alc260_init_verbs? */
  3363. static struct hda_verb alc260_hp_init_verbs[] = {
  3364. /* Headphone and output */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3366. /* mono output */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3368. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3369. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3370. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3371. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3372. /* Line In pin widget for input */
  3373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3374. /* Line-2 pin widget for output */
  3375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3376. /* CD pin widget for input */
  3377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3378. /* unmute amp left and right */
  3379. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3380. /* set connection select to line in (default select for this ADC) */
  3381. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3382. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3383. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3384. /* mute pin widget amp left and right (no gain on this amp) */
  3385. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3386. /* unmute HP mixer amp left and right (volume = 0) */
  3387. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3388. /* mute pin widget amp left and right (no gain on this amp) */
  3389. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* unmute CD */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3395. /* unmute Line In */
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3397. /* unmute Mic */
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* Unmute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3403. /* Unmute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3406. /* Unmute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3409. { }
  3410. };
  3411. #endif
  3412. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3413. /* Line out and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Headphone pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* unmute CD */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3444. /* unmute Line In */
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3446. /* unmute Mic */
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3461. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3462. * audio = 0x16, internal speaker = 0x10.
  3463. */
  3464. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3465. /* Disable all GPIOs */
  3466. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3467. /* Internal speaker is connected to headphone pin */
  3468. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3469. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3470. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3471. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3472. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3473. /* Ensure all other unused pins are disabled and muted. */
  3474. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3475. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3476. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3477. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3478. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3479. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3480. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3481. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3482. /* Disable digital (SPDIF) pins */
  3483. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3484. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3485. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3486. * when acting as an output.
  3487. */
  3488. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3489. /* Start with output sum widgets muted and their output gains at min */
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3492. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3495. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3498. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3499. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3500. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3501. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3502. * If the pin mode is changed by the user the pin mode control will
  3503. * take care of enabling the pin's input/output buffers as needed.
  3504. * Therefore there's no need to enable the input buffer at this
  3505. * stage.
  3506. */
  3507. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3508. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3509. * mixer ctrl)
  3510. */
  3511. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3512. /* Mute capture amp left and right */
  3513. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3514. /* Set ADC connection select to match default mixer setting - line
  3515. * in (on mic1 pin)
  3516. */
  3517. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3518. /* Do the same for the second ADC: mute capture input amp and
  3519. * set ADC connection to line in (on mic1 pin)
  3520. */
  3521. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3522. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3523. /* Mute all inputs to mixer widget (even unconnected ones) */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3531. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3532. { }
  3533. };
  3534. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3535. * similar laptops (adapted from Fujitsu init verbs).
  3536. */
  3537. static struct hda_verb alc260_acer_init_verbs[] = {
  3538. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3539. * the headphone jack. Turn this on and rely on the standard mute
  3540. * methods whenever the user wants to turn these outputs off.
  3541. */
  3542. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3543. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3544. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3545. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3546. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3547. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3548. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3549. /* Line In jack is connected to Line1 pin */
  3550. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3551. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3552. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3553. /* Ensure all other unused pins are disabled and muted. */
  3554. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3555. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3556. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3557. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3558. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3559. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3560. /* Disable digital (SPDIF) pins */
  3561. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3562. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3563. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3564. * bus when acting as outputs.
  3565. */
  3566. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3567. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3568. /* Start with output sum widgets muted and their output gains at min */
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3570. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3571. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3572. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3574. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3575. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3576. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3577. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3578. /* Unmute Line-out pin widget amp left and right
  3579. * (no equiv mixer ctrl)
  3580. */
  3581. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3582. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3583. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3584. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3585. * inputs. If the pin mode is changed by the user the pin mode control
  3586. * will take care of enabling the pin's input/output buffers as needed.
  3587. * Therefore there's no need to enable the input buffer at this
  3588. * stage.
  3589. */
  3590. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3591. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3592. /* Mute capture amp left and right */
  3593. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3594. /* Set ADC connection select to match default mixer setting - mic
  3595. * (on mic1 pin)
  3596. */
  3597. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3598. /* Do similar with the second ADC: mute capture input amp and
  3599. * set ADC connection to mic to match ALSA's default state.
  3600. */
  3601. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3602. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3603. /* Mute all inputs to mixer widget (even unconnected ones) */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3608. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3609. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3610. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3611. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3612. { }
  3613. };
  3614. static struct hda_verb alc260_will_verbs[] = {
  3615. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3616. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3617. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3618. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3619. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3620. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3621. {}
  3622. };
  3623. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3624. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3625. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3626. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3627. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3628. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3629. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3630. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3631. {}
  3632. };
  3633. /* toggle speaker-output according to the hp-jack state */
  3634. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3635. {
  3636. unsigned int present;
  3637. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3638. present = snd_hda_codec_read(codec, 0x0f, 0,
  3639. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3640. if (present) {
  3641. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3642. snd_hda_codec_write(codec, 0x0f, 0,
  3643. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3644. } else {
  3645. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3646. snd_hda_codec_write(codec, 0x0f, 0,
  3647. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3648. }
  3649. }
  3650. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3651. unsigned int res)
  3652. {
  3653. if ((res >> 26) == ALC880_HP_EVENT)
  3654. alc260_replacer_672v_automute(codec);
  3655. }
  3656. /* Test configuration for debugging, modelled after the ALC880 test
  3657. * configuration.
  3658. */
  3659. #ifdef CONFIG_SND_DEBUG
  3660. static hda_nid_t alc260_test_dac_nids[1] = {
  3661. 0x02,
  3662. };
  3663. static hda_nid_t alc260_test_adc_nids[2] = {
  3664. 0x04, 0x05,
  3665. };
  3666. /* For testing the ALC260, each input MUX needs its own definition since
  3667. * the signal assignments are different. This assumes that the first ADC
  3668. * is NID 0x04.
  3669. */
  3670. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3671. {
  3672. .num_items = 7,
  3673. .items = {
  3674. { "MIC1 pin", 0x0 },
  3675. { "MIC2 pin", 0x1 },
  3676. { "LINE1 pin", 0x2 },
  3677. { "LINE2 pin", 0x3 },
  3678. { "CD pin", 0x4 },
  3679. { "LINE-OUT pin", 0x5 },
  3680. { "HP-OUT pin", 0x6 },
  3681. },
  3682. },
  3683. {
  3684. .num_items = 8,
  3685. .items = {
  3686. { "MIC1 pin", 0x0 },
  3687. { "MIC2 pin", 0x1 },
  3688. { "LINE1 pin", 0x2 },
  3689. { "LINE2 pin", 0x3 },
  3690. { "CD pin", 0x4 },
  3691. { "Mixer", 0x5 },
  3692. { "LINE-OUT pin", 0x6 },
  3693. { "HP-OUT pin", 0x7 },
  3694. },
  3695. },
  3696. };
  3697. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3698. /* Output driver widgets */
  3699. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3700. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3701. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3702. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3703. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3704. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3705. /* Modes for retasking pin widgets
  3706. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3707. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3708. * mention this restriction. At this stage it's not clear whether
  3709. * this behaviour is intentional or is a hardware bug in chip
  3710. * revisions available at least up until early 2006. Therefore for
  3711. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3712. * choices, but if it turns out that the lack of mic bias for these
  3713. * NIDs is intentional we could change their modes from
  3714. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3715. */
  3716. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3717. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3718. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3719. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3720. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3721. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3722. /* Loopback mixer controls */
  3723. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3724. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3725. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3726. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3727. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3728. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3729. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3730. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3731. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3732. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3733. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3734. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3735. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3736. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3737. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3738. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3739. /* Controls for GPIO pins, assuming they are configured as outputs */
  3740. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3741. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3742. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3743. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3744. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3745. * is ambigious as to which NID is which; testing on laptops which
  3746. * make this output available should provide clarification.
  3747. */
  3748. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3749. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3750. { } /* end */
  3751. };
  3752. static struct hda_verb alc260_test_init_verbs[] = {
  3753. /* Enable all GPIOs as outputs with an initial value of 0 */
  3754. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3755. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3756. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3757. /* Enable retasking pins as output, initially without power amp */
  3758. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3759. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3760. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3761. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3762. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3763. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3764. /* Disable digital (SPDIF) pins initially, but users can enable
  3765. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3766. * payload also sets the generation to 0, output to be in "consumer"
  3767. * PCM format, copyright asserted, no pre-emphasis and no validity
  3768. * control.
  3769. */
  3770. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3771. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3772. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3773. * OUT1 sum bus when acting as an output.
  3774. */
  3775. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3776. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3777. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3778. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3779. /* Start with output sum widgets muted and their output gains at min */
  3780. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3781. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3782. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3783. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3784. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3785. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3786. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3787. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3788. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3789. /* Unmute retasking pin widget output buffers since the default
  3790. * state appears to be output. As the pin mode is changed by the
  3791. * user the pin mode control will take care of enabling the pin's
  3792. * input/output buffers as needed.
  3793. */
  3794. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3796. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3797. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3798. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3799. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3800. /* Also unmute the mono-out pin widget */
  3801. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3802. /* Mute capture amp left and right */
  3803. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3804. /* Set ADC connection select to match default mixer setting (mic1
  3805. * pin)
  3806. */
  3807. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3808. /* Do the same for the second ADC: mute capture input amp and
  3809. * set ADC connection to mic1 pin
  3810. */
  3811. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3812. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3813. /* Mute all inputs to mixer widget (even unconnected ones) */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3815. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3816. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3817. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3818. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3819. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3820. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3821. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3822. { }
  3823. };
  3824. #endif
  3825. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3826. .substreams = 1,
  3827. .channels_min = 2,
  3828. .channels_max = 2,
  3829. };
  3830. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3831. .substreams = 1,
  3832. .channels_min = 2,
  3833. .channels_max = 2,
  3834. };
  3835. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3836. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3837. /*
  3838. * for BIOS auto-configuration
  3839. */
  3840. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3841. const char *pfx)
  3842. {
  3843. hda_nid_t nid_vol;
  3844. unsigned long vol_val, sw_val;
  3845. char name[32];
  3846. int err;
  3847. if (nid >= 0x0f && nid < 0x11) {
  3848. nid_vol = nid - 0x7;
  3849. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3850. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3851. } else if (nid == 0x11) {
  3852. nid_vol = nid - 0x7;
  3853. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3854. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3855. } else if (nid >= 0x12 && nid <= 0x15) {
  3856. nid_vol = 0x08;
  3857. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3858. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3859. } else
  3860. return 0; /* N/A */
  3861. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3862. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3863. if (err < 0)
  3864. return err;
  3865. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3866. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3867. if (err < 0)
  3868. return err;
  3869. return 1;
  3870. }
  3871. /* add playback controls from the parsed DAC table */
  3872. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3873. const struct auto_pin_cfg *cfg)
  3874. {
  3875. hda_nid_t nid;
  3876. int err;
  3877. spec->multiout.num_dacs = 1;
  3878. spec->multiout.dac_nids = spec->private_dac_nids;
  3879. spec->multiout.dac_nids[0] = 0x02;
  3880. nid = cfg->line_out_pins[0];
  3881. if (nid) {
  3882. err = alc260_add_playback_controls(spec, nid, "Front");
  3883. if (err < 0)
  3884. return err;
  3885. }
  3886. nid = cfg->speaker_pins[0];
  3887. if (nid) {
  3888. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3889. if (err < 0)
  3890. return err;
  3891. }
  3892. nid = cfg->hp_pins[0];
  3893. if (nid) {
  3894. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3895. if (err < 0)
  3896. return err;
  3897. }
  3898. return 0;
  3899. }
  3900. /* create playback/capture controls for input pins */
  3901. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3902. const struct auto_pin_cfg *cfg)
  3903. {
  3904. struct hda_input_mux *imux = &spec->private_imux;
  3905. int i, err, idx;
  3906. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3907. if (cfg->input_pins[i] >= 0x12) {
  3908. idx = cfg->input_pins[i] - 0x12;
  3909. err = new_analog_input(spec, cfg->input_pins[i],
  3910. auto_pin_cfg_labels[i], idx,
  3911. 0x07);
  3912. if (err < 0)
  3913. return err;
  3914. imux->items[imux->num_items].label =
  3915. auto_pin_cfg_labels[i];
  3916. imux->items[imux->num_items].index = idx;
  3917. imux->num_items++;
  3918. }
  3919. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3920. idx = cfg->input_pins[i] - 0x09;
  3921. err = new_analog_input(spec, cfg->input_pins[i],
  3922. auto_pin_cfg_labels[i], idx,
  3923. 0x07);
  3924. if (err < 0)
  3925. return err;
  3926. imux->items[imux->num_items].label =
  3927. auto_pin_cfg_labels[i];
  3928. imux->items[imux->num_items].index = idx;
  3929. imux->num_items++;
  3930. }
  3931. }
  3932. return 0;
  3933. }
  3934. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3935. hda_nid_t nid, int pin_type,
  3936. int sel_idx)
  3937. {
  3938. /* set as output */
  3939. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3940. pin_type);
  3941. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3942. AMP_OUT_UNMUTE);
  3943. /* need the manual connection? */
  3944. if (nid >= 0x12) {
  3945. int idx = nid - 0x12;
  3946. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3947. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3948. }
  3949. }
  3950. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3951. {
  3952. struct alc_spec *spec = codec->spec;
  3953. hda_nid_t nid;
  3954. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3955. nid = spec->autocfg.line_out_pins[0];
  3956. if (nid) {
  3957. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3958. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3959. }
  3960. nid = spec->autocfg.speaker_pins[0];
  3961. if (nid)
  3962. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3963. nid = spec->autocfg.hp_pins[0];
  3964. if (nid)
  3965. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3966. }
  3967. #define ALC260_PIN_CD_NID 0x16
  3968. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3969. {
  3970. struct alc_spec *spec = codec->spec;
  3971. int i;
  3972. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3973. hda_nid_t nid = spec->autocfg.input_pins[i];
  3974. if (nid >= 0x12) {
  3975. snd_hda_codec_write(codec, nid, 0,
  3976. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3977. i <= AUTO_PIN_FRONT_MIC ?
  3978. PIN_VREF80 : PIN_IN);
  3979. if (nid != ALC260_PIN_CD_NID)
  3980. snd_hda_codec_write(codec, nid, 0,
  3981. AC_VERB_SET_AMP_GAIN_MUTE,
  3982. AMP_OUT_MUTE);
  3983. }
  3984. }
  3985. }
  3986. /*
  3987. * generic initialization of ADC, input mixers and output mixers
  3988. */
  3989. static struct hda_verb alc260_volume_init_verbs[] = {
  3990. /*
  3991. * Unmute ADC0-1 and set the default input to mic-in
  3992. */
  3993. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3994. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3995. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3996. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3997. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3998. * mixer widget
  3999. * Note: PASD motherboards uses the Line In 2 as the input for
  4000. * front panel mic (mic 2)
  4001. */
  4002. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4003. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4008. /*
  4009. * Set up output mixers (0x08 - 0x0a)
  4010. */
  4011. /* set vol=0 to output mixers */
  4012. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4013. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4014. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4015. /* set up input amps for analog loopback */
  4016. /* Amp Indices: DAC = 0, mixer = 1 */
  4017. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4018. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4019. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4020. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4021. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4022. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4023. { }
  4024. };
  4025. static int alc260_parse_auto_config(struct hda_codec *codec)
  4026. {
  4027. struct alc_spec *spec = codec->spec;
  4028. unsigned int wcap;
  4029. int err;
  4030. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4031. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4032. alc260_ignore);
  4033. if (err < 0)
  4034. return err;
  4035. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4036. if (err < 0)
  4037. return err;
  4038. if (!spec->kctl_alloc)
  4039. return 0; /* can't find valid BIOS pin config */
  4040. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4041. if (err < 0)
  4042. return err;
  4043. spec->multiout.max_channels = 2;
  4044. if (spec->autocfg.dig_out_pin)
  4045. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4046. if (spec->kctl_alloc)
  4047. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4048. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4049. spec->num_mux_defs = 1;
  4050. spec->input_mux = &spec->private_imux;
  4051. /* check whether NID 0x04 is valid */
  4052. wcap = get_wcaps(codec, 0x04);
  4053. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4054. if (wcap != AC_WID_AUD_IN) {
  4055. spec->adc_nids = alc260_adc_nids_alt;
  4056. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4057. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4058. } else {
  4059. spec->adc_nids = alc260_adc_nids;
  4060. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4061. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4062. }
  4063. spec->num_mixers++;
  4064. return 1;
  4065. }
  4066. /* additional initialization for auto-configuration model */
  4067. static void alc260_auto_init(struct hda_codec *codec)
  4068. {
  4069. alc260_auto_init_multi_out(codec);
  4070. alc260_auto_init_analog_input(codec);
  4071. }
  4072. /*
  4073. * ALC260 configurations
  4074. */
  4075. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4076. [ALC260_BASIC] = "basic",
  4077. [ALC260_HP] = "hp",
  4078. [ALC260_HP_3013] = "hp-3013",
  4079. [ALC260_FUJITSU_S702X] = "fujitsu",
  4080. [ALC260_ACER] = "acer",
  4081. [ALC260_WILL] = "will",
  4082. [ALC260_REPLACER_672V] = "replacer",
  4083. #ifdef CONFIG_SND_DEBUG
  4084. [ALC260_TEST] = "test",
  4085. #endif
  4086. [ALC260_AUTO] = "auto",
  4087. };
  4088. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4089. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4090. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4091. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4092. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4093. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4094. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4095. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4096. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4097. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4098. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4099. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4100. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4101. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4102. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4103. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4104. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4105. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4106. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4107. {}
  4108. };
  4109. static struct alc_config_preset alc260_presets[] = {
  4110. [ALC260_BASIC] = {
  4111. .mixers = { alc260_base_output_mixer,
  4112. alc260_input_mixer,
  4113. alc260_pc_beep_mixer,
  4114. alc260_capture_mixer },
  4115. .init_verbs = { alc260_init_verbs },
  4116. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4117. .dac_nids = alc260_dac_nids,
  4118. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4119. .adc_nids = alc260_adc_nids,
  4120. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4121. .channel_mode = alc260_modes,
  4122. .input_mux = &alc260_capture_source,
  4123. },
  4124. [ALC260_HP] = {
  4125. .mixers = { alc260_base_output_mixer,
  4126. alc260_input_mixer,
  4127. alc260_capture_alt_mixer },
  4128. .init_verbs = { alc260_init_verbs },
  4129. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4130. .dac_nids = alc260_dac_nids,
  4131. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4132. .adc_nids = alc260_hp_adc_nids,
  4133. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4134. .channel_mode = alc260_modes,
  4135. .input_mux = &alc260_capture_source,
  4136. },
  4137. [ALC260_HP_3013] = {
  4138. .mixers = { alc260_hp_3013_mixer,
  4139. alc260_input_mixer,
  4140. alc260_capture_alt_mixer },
  4141. .init_verbs = { alc260_hp_3013_init_verbs },
  4142. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4143. .dac_nids = alc260_dac_nids,
  4144. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4145. .adc_nids = alc260_hp_adc_nids,
  4146. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4147. .channel_mode = alc260_modes,
  4148. .input_mux = &alc260_capture_source,
  4149. },
  4150. [ALC260_FUJITSU_S702X] = {
  4151. .mixers = { alc260_fujitsu_mixer,
  4152. alc260_capture_mixer },
  4153. .init_verbs = { alc260_fujitsu_init_verbs },
  4154. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4155. .dac_nids = alc260_dac_nids,
  4156. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4157. .adc_nids = alc260_dual_adc_nids,
  4158. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4159. .channel_mode = alc260_modes,
  4160. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4161. .input_mux = alc260_fujitsu_capture_sources,
  4162. },
  4163. [ALC260_ACER] = {
  4164. .mixers = { alc260_acer_mixer,
  4165. alc260_capture_mixer },
  4166. .init_verbs = { alc260_acer_init_verbs },
  4167. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4168. .dac_nids = alc260_dac_nids,
  4169. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4170. .adc_nids = alc260_dual_adc_nids,
  4171. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4172. .channel_mode = alc260_modes,
  4173. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4174. .input_mux = alc260_acer_capture_sources,
  4175. },
  4176. [ALC260_WILL] = {
  4177. .mixers = { alc260_will_mixer,
  4178. alc260_capture_mixer },
  4179. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4180. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4181. .dac_nids = alc260_dac_nids,
  4182. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4183. .adc_nids = alc260_adc_nids,
  4184. .dig_out_nid = ALC260_DIGOUT_NID,
  4185. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4186. .channel_mode = alc260_modes,
  4187. .input_mux = &alc260_capture_source,
  4188. },
  4189. [ALC260_REPLACER_672V] = {
  4190. .mixers = { alc260_replacer_672v_mixer,
  4191. alc260_capture_mixer },
  4192. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4193. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4194. .dac_nids = alc260_dac_nids,
  4195. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4196. .adc_nids = alc260_adc_nids,
  4197. .dig_out_nid = ALC260_DIGOUT_NID,
  4198. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4199. .channel_mode = alc260_modes,
  4200. .input_mux = &alc260_capture_source,
  4201. .unsol_event = alc260_replacer_672v_unsol_event,
  4202. .init_hook = alc260_replacer_672v_automute,
  4203. },
  4204. #ifdef CONFIG_SND_DEBUG
  4205. [ALC260_TEST] = {
  4206. .mixers = { alc260_test_mixer,
  4207. alc260_capture_mixer },
  4208. .init_verbs = { alc260_test_init_verbs },
  4209. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4210. .dac_nids = alc260_test_dac_nids,
  4211. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4212. .adc_nids = alc260_test_adc_nids,
  4213. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4214. .channel_mode = alc260_modes,
  4215. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4216. .input_mux = alc260_test_capture_sources,
  4217. },
  4218. #endif
  4219. };
  4220. static int patch_alc260(struct hda_codec *codec)
  4221. {
  4222. struct alc_spec *spec;
  4223. int err, board_config;
  4224. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4225. if (spec == NULL)
  4226. return -ENOMEM;
  4227. codec->spec = spec;
  4228. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4229. alc260_models,
  4230. alc260_cfg_tbl);
  4231. if (board_config < 0) {
  4232. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4233. "trying auto-probe from BIOS...\n");
  4234. board_config = ALC260_AUTO;
  4235. }
  4236. if (board_config == ALC260_AUTO) {
  4237. /* automatic parse from the BIOS config */
  4238. err = alc260_parse_auto_config(codec);
  4239. if (err < 0) {
  4240. alc_free(codec);
  4241. return err;
  4242. } else if (!err) {
  4243. printk(KERN_INFO
  4244. "hda_codec: Cannot set up configuration "
  4245. "from BIOS. Using base mode...\n");
  4246. board_config = ALC260_BASIC;
  4247. }
  4248. }
  4249. if (board_config != ALC260_AUTO)
  4250. setup_preset(spec, &alc260_presets[board_config]);
  4251. spec->stream_name_analog = "ALC260 Analog";
  4252. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4253. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4254. spec->stream_name_digital = "ALC260 Digital";
  4255. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4256. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4257. codec->patch_ops = alc_patch_ops;
  4258. if (board_config == ALC260_AUTO)
  4259. spec->init_hook = alc260_auto_init;
  4260. return 0;
  4261. }
  4262. /*
  4263. * ALC882 support
  4264. *
  4265. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4266. * configuration. Each pin widget can choose any input DACs and a mixer.
  4267. * Each ADC is connected from a mixer of all inputs. This makes possible
  4268. * 6-channel independent captures.
  4269. *
  4270. * In addition, an independent DAC for the multi-playback (not used in this
  4271. * driver yet).
  4272. */
  4273. #define ALC882_DIGOUT_NID 0x06
  4274. #define ALC882_DIGIN_NID 0x0a
  4275. static struct hda_channel_mode alc882_ch_modes[1] = {
  4276. { 8, NULL }
  4277. };
  4278. static hda_nid_t alc882_dac_nids[4] = {
  4279. /* front, rear, clfe, rear_surr */
  4280. 0x02, 0x03, 0x04, 0x05
  4281. };
  4282. /* identical with ALC880 */
  4283. #define alc882_adc_nids alc880_adc_nids
  4284. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4285. /* input MUX */
  4286. /* FIXME: should be a matrix-type input source selection */
  4287. static struct hda_input_mux alc882_capture_source = {
  4288. .num_items = 4,
  4289. .items = {
  4290. { "Mic", 0x0 },
  4291. { "Front Mic", 0x1 },
  4292. { "Line", 0x2 },
  4293. { "CD", 0x4 },
  4294. },
  4295. };
  4296. #define alc882_mux_enum_info alc_mux_enum_info
  4297. #define alc882_mux_enum_get alc_mux_enum_get
  4298. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4299. struct snd_ctl_elem_value *ucontrol)
  4300. {
  4301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4302. struct alc_spec *spec = codec->spec;
  4303. const struct hda_input_mux *imux = spec->input_mux;
  4304. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4305. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4306. hda_nid_t nid = capture_mixers[adc_idx];
  4307. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4308. unsigned int i, idx;
  4309. idx = ucontrol->value.enumerated.item[0];
  4310. if (idx >= imux->num_items)
  4311. idx = imux->num_items - 1;
  4312. if (*cur_val == idx && !codec->in_resume)
  4313. return 0;
  4314. for (i = 0; i < imux->num_items; i++) {
  4315. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4316. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4317. v | (imux->items[i].index << 8));
  4318. }
  4319. *cur_val = idx;
  4320. return 1;
  4321. }
  4322. /*
  4323. * 2ch mode
  4324. */
  4325. static struct hda_verb alc882_3ST_ch2_init[] = {
  4326. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4327. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4328. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4329. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4330. { } /* end */
  4331. };
  4332. /*
  4333. * 6ch mode
  4334. */
  4335. static struct hda_verb alc882_3ST_ch6_init[] = {
  4336. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4337. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4338. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4339. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4340. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4341. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4342. { } /* end */
  4343. };
  4344. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4345. { 2, alc882_3ST_ch2_init },
  4346. { 6, alc882_3ST_ch6_init },
  4347. };
  4348. /*
  4349. * 6ch mode
  4350. */
  4351. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4352. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4353. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4354. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4355. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4356. { } /* end */
  4357. };
  4358. /*
  4359. * 8ch mode
  4360. */
  4361. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4362. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4363. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4364. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4365. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4366. { } /* end */
  4367. };
  4368. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4369. { 6, alc882_sixstack_ch6_init },
  4370. { 8, alc882_sixstack_ch8_init },
  4371. };
  4372. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4373. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4374. */
  4375. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4376. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4377. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4378. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4379. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4380. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4381. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4382. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4383. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4385. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4386. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4387. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4388. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4389. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4390. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4391. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4392. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4393. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4394. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4395. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4396. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4397. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4398. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4399. { } /* end */
  4400. };
  4401. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4402. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4403. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4404. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4405. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4406. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4407. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4408. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4409. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4410. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4411. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4412. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4413. { } /* end */
  4414. };
  4415. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4416. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4417. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4418. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4419. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4420. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4421. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4422. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4423. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4424. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4425. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4426. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4427. { } /* end */
  4428. };
  4429. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4430. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4431. */
  4432. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4433. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4434. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4435. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4444. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4445. { } /* end */
  4446. };
  4447. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4448. {
  4449. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4450. .name = "Channel Mode",
  4451. .info = alc_ch_mode_info,
  4452. .get = alc_ch_mode_get,
  4453. .put = alc_ch_mode_put,
  4454. },
  4455. { } /* end */
  4456. };
  4457. static struct hda_verb alc882_init_verbs[] = {
  4458. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4459. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4461. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4462. /* Rear mixer */
  4463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4464. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4465. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4466. /* CLFE mixer */
  4467. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4468. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4469. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4470. /* Side mixer */
  4471. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4472. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4473. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4474. /* Front Pin: output 0 (0x0c) */
  4475. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4476. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4477. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4478. /* Rear Pin: output 1 (0x0d) */
  4479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4481. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4482. /* CLFE Pin: output 2 (0x0e) */
  4483. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4484. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4485. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4486. /* Side Pin: output 3 (0x0f) */
  4487. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4488. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4489. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4490. /* Mic (rear) pin: input vref at 80% */
  4491. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4492. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4493. /* Front Mic pin: input vref at 80% */
  4494. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4495. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4496. /* Line In pin: input */
  4497. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4498. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4499. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4500. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4501. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4502. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4503. /* CD pin widget for input */
  4504. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4505. /* FIXME: use matrix-type input source selection */
  4506. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4507. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4511. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4512. /* Input mixer2 */
  4513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4517. /* Input mixer3 */
  4518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4522. /* ADC1: mute amp left and right */
  4523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4524. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4525. /* ADC2: mute amp left and right */
  4526. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4527. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4528. /* ADC3: mute amp left and right */
  4529. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4530. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4531. { }
  4532. };
  4533. static struct hda_verb alc882_eapd_verbs[] = {
  4534. /* change to EAPD mode */
  4535. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4536. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4537. { }
  4538. };
  4539. /* Mac Pro test */
  4540. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4541. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4542. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4543. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4545. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4546. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4547. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4548. { } /* end */
  4549. };
  4550. static struct hda_verb alc882_macpro_init_verbs[] = {
  4551. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4554. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4555. /* Front Pin: output 0 (0x0c) */
  4556. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4557. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4558. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4559. /* Front Mic pin: input vref at 80% */
  4560. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4561. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4562. /* Speaker: output */
  4563. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4564. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4565. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4566. /* Headphone output (output 0 - 0x0c) */
  4567. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4568. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4569. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4570. /* FIXME: use matrix-type input source selection */
  4571. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4572. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4573. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4575. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4576. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4577. /* Input mixer2 */
  4578. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4580. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4581. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4582. /* Input mixer3 */
  4583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4586. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4587. /* ADC1: mute amp left and right */
  4588. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4590. /* ADC2: mute amp left and right */
  4591. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4592. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4593. /* ADC3: mute amp left and right */
  4594. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4595. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4596. { }
  4597. };
  4598. static struct hda_verb alc882_targa_verbs[] = {
  4599. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4600. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4601. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4602. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4603. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4604. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4605. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4606. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4607. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4608. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4609. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4610. { } /* end */
  4611. };
  4612. /* toggle speaker-output according to the hp-jack state */
  4613. static void alc882_targa_automute(struct hda_codec *codec)
  4614. {
  4615. unsigned int present;
  4616. present = snd_hda_codec_read(codec, 0x14, 0,
  4617. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4618. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4619. 0x80, present ? 0x80 : 0);
  4620. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4621. 0x80, present ? 0x80 : 0);
  4622. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4623. }
  4624. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4625. {
  4626. /* Looks like the unsol event is incompatible with the standard
  4627. * definition. 4bit tag is placed at 26 bit!
  4628. */
  4629. if (((res >> 26) == ALC880_HP_EVENT)) {
  4630. alc882_targa_automute(codec);
  4631. }
  4632. }
  4633. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4635. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4636. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4637. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4638. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4639. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4640. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4641. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4642. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4643. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4644. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4645. { } /* end */
  4646. };
  4647. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4648. {
  4649. unsigned int gpiostate, gpiomask, gpiodir;
  4650. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4651. AC_VERB_GET_GPIO_DATA, 0);
  4652. if (!muted)
  4653. gpiostate |= (1 << pin);
  4654. else
  4655. gpiostate &= ~(1 << pin);
  4656. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4657. AC_VERB_GET_GPIO_MASK, 0);
  4658. gpiomask |= (1 << pin);
  4659. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4660. AC_VERB_GET_GPIO_DIRECTION, 0);
  4661. gpiodir |= (1 << pin);
  4662. snd_hda_codec_write(codec, codec->afg, 0,
  4663. AC_VERB_SET_GPIO_MASK, gpiomask);
  4664. snd_hda_codec_write(codec, codec->afg, 0,
  4665. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4666. msleep(1);
  4667. snd_hda_codec_write(codec, codec->afg, 0,
  4668. AC_VERB_SET_GPIO_DATA, gpiostate);
  4669. }
  4670. /*
  4671. * generic initialization of ADC, input mixers and output mixers
  4672. */
  4673. static struct hda_verb alc882_auto_init_verbs[] = {
  4674. /*
  4675. * Unmute ADC0-2 and set the default input to mic-in
  4676. */
  4677. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4678. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4679. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4680. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4681. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4682. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4684. * mixer widget
  4685. * Note: PASD motherboards uses the Line In 2 as the input for
  4686. * front panel mic (mic 2)
  4687. */
  4688. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4689. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4690. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4691. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4692. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4694. /*
  4695. * Set up output mixers (0x0c - 0x0f)
  4696. */
  4697. /* set vol=0 to output mixers */
  4698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4700. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4701. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4702. /* set up input amps for analog loopback */
  4703. /* Amp Indices: DAC = 0, mixer = 1 */
  4704. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4705. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4706. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4707. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4708. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4709. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4710. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4711. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4712. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4713. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4714. /* FIXME: use matrix-type input source selection */
  4715. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4716. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4718. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4719. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4720. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4721. /* Input mixer2 */
  4722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4726. /* Input mixer3 */
  4727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4730. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4731. { }
  4732. };
  4733. /* capture mixer elements */
  4734. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4737. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4738. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4739. {
  4740. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4741. /* The multiple "Capture Source" controls confuse alsamixer
  4742. * So call somewhat different..
  4743. * FIXME: the controls appear in the "playback" view!
  4744. */
  4745. /* .name = "Capture Source", */
  4746. .name = "Input Source",
  4747. .count = 2,
  4748. .info = alc882_mux_enum_info,
  4749. .get = alc882_mux_enum_get,
  4750. .put = alc882_mux_enum_put,
  4751. },
  4752. { } /* end */
  4753. };
  4754. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4755. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4756. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4757. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4758. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4759. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4760. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4761. {
  4762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4763. /* The multiple "Capture Source" controls confuse alsamixer
  4764. * So call somewhat different..
  4765. * FIXME: the controls appear in the "playback" view!
  4766. */
  4767. /* .name = "Capture Source", */
  4768. .name = "Input Source",
  4769. .count = 3,
  4770. .info = alc882_mux_enum_info,
  4771. .get = alc882_mux_enum_get,
  4772. .put = alc882_mux_enum_put,
  4773. },
  4774. { } /* end */
  4775. };
  4776. /* pcm configuration: identiacal with ALC880 */
  4777. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4778. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4779. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4780. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4781. /*
  4782. * configuration and preset
  4783. */
  4784. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4785. [ALC882_3ST_DIG] = "3stack-dig",
  4786. [ALC882_6ST_DIG] = "6stack-dig",
  4787. [ALC882_ARIMA] = "arima",
  4788. [ALC882_W2JC] = "w2jc",
  4789. [ALC885_MACPRO] = "macpro",
  4790. [ALC882_AUTO] = "auto",
  4791. };
  4792. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4793. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4794. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4795. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4796. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4797. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4798. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4799. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4800. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4801. {}
  4802. };
  4803. static struct alc_config_preset alc882_presets[] = {
  4804. [ALC882_3ST_DIG] = {
  4805. .mixers = { alc882_base_mixer },
  4806. .init_verbs = { alc882_init_verbs },
  4807. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4808. .dac_nids = alc882_dac_nids,
  4809. .dig_out_nid = ALC882_DIGOUT_NID,
  4810. .dig_in_nid = ALC882_DIGIN_NID,
  4811. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4812. .channel_mode = alc882_ch_modes,
  4813. .need_dac_fix = 1,
  4814. .input_mux = &alc882_capture_source,
  4815. },
  4816. [ALC882_6ST_DIG] = {
  4817. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4818. .init_verbs = { alc882_init_verbs },
  4819. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4820. .dac_nids = alc882_dac_nids,
  4821. .dig_out_nid = ALC882_DIGOUT_NID,
  4822. .dig_in_nid = ALC882_DIGIN_NID,
  4823. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4824. .channel_mode = alc882_sixstack_modes,
  4825. .input_mux = &alc882_capture_source,
  4826. },
  4827. [ALC882_ARIMA] = {
  4828. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4829. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4830. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4831. .dac_nids = alc882_dac_nids,
  4832. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4833. .channel_mode = alc882_sixstack_modes,
  4834. .input_mux = &alc882_capture_source,
  4835. },
  4836. [ALC882_W2JC] = {
  4837. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4838. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4839. alc880_gpio1_init_verbs },
  4840. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4841. .dac_nids = alc882_dac_nids,
  4842. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4843. .channel_mode = alc880_threestack_modes,
  4844. .need_dac_fix = 1,
  4845. .input_mux = &alc882_capture_source,
  4846. .dig_out_nid = ALC882_DIGOUT_NID,
  4847. },
  4848. [ALC885_MACPRO] = {
  4849. .mixers = { alc882_macpro_mixer },
  4850. .init_verbs = { alc882_macpro_init_verbs },
  4851. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4852. .dac_nids = alc882_dac_nids,
  4853. .dig_out_nid = ALC882_DIGOUT_NID,
  4854. .dig_in_nid = ALC882_DIGIN_NID,
  4855. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4856. .channel_mode = alc882_ch_modes,
  4857. .input_mux = &alc882_capture_source,
  4858. },
  4859. [ALC882_TARGA] = {
  4860. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4861. alc882_capture_mixer },
  4862. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4863. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4864. .dac_nids = alc882_dac_nids,
  4865. .dig_out_nid = ALC882_DIGOUT_NID,
  4866. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4867. .adc_nids = alc882_adc_nids,
  4868. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4869. .channel_mode = alc882_3ST_6ch_modes,
  4870. .need_dac_fix = 1,
  4871. .input_mux = &alc882_capture_source,
  4872. .unsol_event = alc882_targa_unsol_event,
  4873. .init_hook = alc882_targa_automute,
  4874. },
  4875. [ALC882_ASUS_A7J] = {
  4876. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4877. alc882_capture_mixer },
  4878. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4879. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4880. .dac_nids = alc882_dac_nids,
  4881. .dig_out_nid = ALC882_DIGOUT_NID,
  4882. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4883. .adc_nids = alc882_adc_nids,
  4884. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4885. .channel_mode = alc882_3ST_6ch_modes,
  4886. .need_dac_fix = 1,
  4887. .input_mux = &alc882_capture_source,
  4888. },
  4889. };
  4890. /*
  4891. * BIOS auto configuration
  4892. */
  4893. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4894. hda_nid_t nid, int pin_type,
  4895. int dac_idx)
  4896. {
  4897. /* set as output */
  4898. struct alc_spec *spec = codec->spec;
  4899. int idx;
  4900. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4901. idx = 4;
  4902. else
  4903. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4904. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4905. pin_type);
  4906. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4907. AMP_OUT_UNMUTE);
  4908. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4909. }
  4910. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4911. {
  4912. struct alc_spec *spec = codec->spec;
  4913. int i;
  4914. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4915. for (i = 0; i <= HDA_SIDE; i++) {
  4916. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4917. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4918. if (nid)
  4919. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4920. i);
  4921. }
  4922. }
  4923. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4924. {
  4925. struct alc_spec *spec = codec->spec;
  4926. hda_nid_t pin;
  4927. pin = spec->autocfg.hp_pins[0];
  4928. if (pin) /* connect to front */
  4929. /* use dac 0 */
  4930. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4931. }
  4932. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4933. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4934. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4935. {
  4936. struct alc_spec *spec = codec->spec;
  4937. int i;
  4938. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4939. hda_nid_t nid = spec->autocfg.input_pins[i];
  4940. if (alc882_is_input_pin(nid)) {
  4941. snd_hda_codec_write(codec, nid, 0,
  4942. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4943. i <= AUTO_PIN_FRONT_MIC ?
  4944. PIN_VREF80 : PIN_IN);
  4945. if (nid != ALC882_PIN_CD_NID)
  4946. snd_hda_codec_write(codec, nid, 0,
  4947. AC_VERB_SET_AMP_GAIN_MUTE,
  4948. AMP_OUT_MUTE);
  4949. }
  4950. }
  4951. }
  4952. /* almost identical with ALC880 parser... */
  4953. static int alc882_parse_auto_config(struct hda_codec *codec)
  4954. {
  4955. struct alc_spec *spec = codec->spec;
  4956. int err = alc880_parse_auto_config(codec);
  4957. if (err < 0)
  4958. return err;
  4959. else if (err > 0)
  4960. /* hack - override the init verbs */
  4961. spec->init_verbs[0] = alc882_auto_init_verbs;
  4962. return err;
  4963. }
  4964. /* additional initialization for auto-configuration model */
  4965. static void alc882_auto_init(struct hda_codec *codec)
  4966. {
  4967. alc882_auto_init_multi_out(codec);
  4968. alc882_auto_init_hp_out(codec);
  4969. alc882_auto_init_analog_input(codec);
  4970. }
  4971. static int patch_alc882(struct hda_codec *codec)
  4972. {
  4973. struct alc_spec *spec;
  4974. int err, board_config;
  4975. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4976. if (spec == NULL)
  4977. return -ENOMEM;
  4978. codec->spec = spec;
  4979. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4980. alc882_models,
  4981. alc882_cfg_tbl);
  4982. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4983. /* Pick up systems that don't supply PCI SSID */
  4984. switch (codec->subsystem_id) {
  4985. case 0x106b0c00: /* Mac Pro */
  4986. board_config = ALC885_MACPRO;
  4987. break;
  4988. default:
  4989. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4990. "trying auto-probe from BIOS...\n");
  4991. board_config = ALC882_AUTO;
  4992. }
  4993. }
  4994. if (board_config == ALC882_AUTO) {
  4995. /* automatic parse from the BIOS config */
  4996. err = alc882_parse_auto_config(codec);
  4997. if (err < 0) {
  4998. alc_free(codec);
  4999. return err;
  5000. } else if (!err) {
  5001. printk(KERN_INFO
  5002. "hda_codec: Cannot set up configuration "
  5003. "from BIOS. Using base mode...\n");
  5004. board_config = ALC882_3ST_DIG;
  5005. }
  5006. }
  5007. if (board_config != ALC882_AUTO)
  5008. setup_preset(spec, &alc882_presets[board_config]);
  5009. if (board_config == ALC885_MACPRO) {
  5010. alc882_gpio_mute(codec, 0, 0);
  5011. alc882_gpio_mute(codec, 1, 0);
  5012. }
  5013. spec->stream_name_analog = "ALC882 Analog";
  5014. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5015. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5016. spec->stream_name_digital = "ALC882 Digital";
  5017. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5018. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5019. if (!spec->adc_nids && spec->input_mux) {
  5020. /* check whether NID 0x07 is valid */
  5021. unsigned int wcap = get_wcaps(codec, 0x07);
  5022. /* get type */
  5023. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5024. if (wcap != AC_WID_AUD_IN) {
  5025. spec->adc_nids = alc882_adc_nids_alt;
  5026. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5027. spec->mixers[spec->num_mixers] =
  5028. alc882_capture_alt_mixer;
  5029. spec->num_mixers++;
  5030. } else {
  5031. spec->adc_nids = alc882_adc_nids;
  5032. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5033. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5034. spec->num_mixers++;
  5035. }
  5036. }
  5037. codec->patch_ops = alc_patch_ops;
  5038. if (board_config == ALC882_AUTO)
  5039. spec->init_hook = alc882_auto_init;
  5040. return 0;
  5041. }
  5042. /*
  5043. * ALC883 support
  5044. *
  5045. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5046. * configuration. Each pin widget can choose any input DACs and a mixer.
  5047. * Each ADC is connected from a mixer of all inputs. This makes possible
  5048. * 6-channel independent captures.
  5049. *
  5050. * In addition, an independent DAC for the multi-playback (not used in this
  5051. * driver yet).
  5052. */
  5053. #define ALC883_DIGOUT_NID 0x06
  5054. #define ALC883_DIGIN_NID 0x0a
  5055. static hda_nid_t alc883_dac_nids[4] = {
  5056. /* front, rear, clfe, rear_surr */
  5057. 0x02, 0x04, 0x03, 0x05
  5058. };
  5059. static hda_nid_t alc883_adc_nids[2] = {
  5060. /* ADC1-2 */
  5061. 0x08, 0x09,
  5062. };
  5063. /* input MUX */
  5064. /* FIXME: should be a matrix-type input source selection */
  5065. static struct hda_input_mux alc883_capture_source = {
  5066. .num_items = 4,
  5067. .items = {
  5068. { "Mic", 0x0 },
  5069. { "Front Mic", 0x1 },
  5070. { "Line", 0x2 },
  5071. { "CD", 0x4 },
  5072. },
  5073. };
  5074. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5075. .num_items = 2,
  5076. .items = {
  5077. { "Mic", 0x1 },
  5078. { "Line", 0x2 },
  5079. },
  5080. };
  5081. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5082. .num_items = 4,
  5083. .items = {
  5084. { "Mic", 0x0 },
  5085. { "iMic", 0x1 },
  5086. { "Line", 0x2 },
  5087. { "CD", 0x4 },
  5088. },
  5089. };
  5090. #define alc883_mux_enum_info alc_mux_enum_info
  5091. #define alc883_mux_enum_get alc_mux_enum_get
  5092. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5093. struct snd_ctl_elem_value *ucontrol)
  5094. {
  5095. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5096. struct alc_spec *spec = codec->spec;
  5097. const struct hda_input_mux *imux = spec->input_mux;
  5098. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5099. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5100. hda_nid_t nid = capture_mixers[adc_idx];
  5101. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5102. unsigned int i, idx;
  5103. idx = ucontrol->value.enumerated.item[0];
  5104. if (idx >= imux->num_items)
  5105. idx = imux->num_items - 1;
  5106. if (*cur_val == idx && !codec->in_resume)
  5107. return 0;
  5108. for (i = 0; i < imux->num_items; i++) {
  5109. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5110. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5111. v | (imux->items[i].index << 8));
  5112. }
  5113. *cur_val = idx;
  5114. return 1;
  5115. }
  5116. /*
  5117. * 2ch mode
  5118. */
  5119. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5120. { 2, NULL }
  5121. };
  5122. /*
  5123. * 2ch mode
  5124. */
  5125. static struct hda_verb alc883_3ST_ch2_init[] = {
  5126. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5127. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5128. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5129. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5130. { } /* end */
  5131. };
  5132. /*
  5133. * 6ch mode
  5134. */
  5135. static struct hda_verb alc883_3ST_ch6_init[] = {
  5136. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5137. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5138. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5139. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5140. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5141. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5142. { } /* end */
  5143. };
  5144. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5145. { 2, alc883_3ST_ch2_init },
  5146. { 6, alc883_3ST_ch6_init },
  5147. };
  5148. /*
  5149. * 6ch mode
  5150. */
  5151. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5152. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5153. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5154. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5155. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5156. { } /* end */
  5157. };
  5158. /*
  5159. * 8ch mode
  5160. */
  5161. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5162. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5163. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5164. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5165. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5166. { } /* end */
  5167. };
  5168. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5169. { 6, alc883_sixstack_ch6_init },
  5170. { 8, alc883_sixstack_ch8_init },
  5171. };
  5172. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5173. /* eanable EAPD on medion laptop */
  5174. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5175. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5176. { }
  5177. };
  5178. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5179. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5180. */
  5181. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5182. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5183. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5184. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5185. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5186. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5187. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5188. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5189. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5190. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5191. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5192. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5193. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5194. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5195. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5196. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5197. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5198. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5199. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5200. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5201. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5202. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5203. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5204. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5205. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5206. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5207. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5208. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5209. {
  5210. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5211. /* .name = "Capture Source", */
  5212. .name = "Input Source",
  5213. .count = 2,
  5214. .info = alc883_mux_enum_info,
  5215. .get = alc883_mux_enum_get,
  5216. .put = alc883_mux_enum_put,
  5217. },
  5218. { } /* end */
  5219. };
  5220. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5221. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5222. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5224. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5225. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5226. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5227. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5228. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5229. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5230. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5231. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5232. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5233. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5234. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5235. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5236. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5237. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5238. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5239. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5240. {
  5241. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5242. /* .name = "Capture Source", */
  5243. .name = "Input Source",
  5244. .count = 2,
  5245. .info = alc883_mux_enum_info,
  5246. .get = alc883_mux_enum_get,
  5247. .put = alc883_mux_enum_put,
  5248. },
  5249. { } /* end */
  5250. };
  5251. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5252. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5253. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5254. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5255. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5256. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5257. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5258. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5259. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5260. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5261. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5262. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5263. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5264. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5267. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5269. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5270. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5271. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5272. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5273. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5274. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5275. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5276. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5277. {
  5278. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5279. /* .name = "Capture Source", */
  5280. .name = "Input Source",
  5281. .count = 2,
  5282. .info = alc883_mux_enum_info,
  5283. .get = alc883_mux_enum_get,
  5284. .put = alc883_mux_enum_put,
  5285. },
  5286. { } /* end */
  5287. };
  5288. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5289. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5292. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5294. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5295. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5296. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5297. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5298. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5299. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5300. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5301. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5302. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5304. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5306. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5307. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5308. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5309. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5310. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5311. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5312. {
  5313. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5314. /* .name = "Capture Source", */
  5315. .name = "Input Source",
  5316. .count = 1,
  5317. .info = alc883_mux_enum_info,
  5318. .get = alc883_mux_enum_get,
  5319. .put = alc883_mux_enum_put,
  5320. },
  5321. { } /* end */
  5322. };
  5323. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5324. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5325. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5327. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5328. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5329. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5331. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5332. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5333. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5334. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5335. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5339. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5341. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5342. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5343. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5344. {
  5345. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5346. /* .name = "Capture Source", */
  5347. .name = "Input Source",
  5348. .count = 2,
  5349. .info = alc883_mux_enum_info,
  5350. .get = alc883_mux_enum_get,
  5351. .put = alc883_mux_enum_put,
  5352. },
  5353. { } /* end */
  5354. };
  5355. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5356. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5357. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5359. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5361. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5362. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5363. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5364. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5365. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5366. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5367. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5368. {
  5369. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5370. /* .name = "Capture Source", */
  5371. .name = "Input Source",
  5372. .count = 2,
  5373. .info = alc883_mux_enum_info,
  5374. .get = alc883_mux_enum_get,
  5375. .put = alc883_mux_enum_put,
  5376. },
  5377. { } /* end */
  5378. };
  5379. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5380. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5381. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5382. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5383. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5384. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5385. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5386. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5387. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5388. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5389. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5390. {
  5391. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5392. /* .name = "Capture Source", */
  5393. .name = "Input Source",
  5394. .count = 1,
  5395. .info = alc883_mux_enum_info,
  5396. .get = alc883_mux_enum_get,
  5397. .put = alc883_mux_enum_put,
  5398. },
  5399. { } /* end */
  5400. };
  5401. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5402. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5403. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5404. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5405. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5406. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5410. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5411. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5412. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5413. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5414. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5415. {
  5416. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5417. /* .name = "Capture Source", */
  5418. .name = "Input Source",
  5419. .count = 2,
  5420. .info = alc883_mux_enum_info,
  5421. .get = alc883_mux_enum_get,
  5422. .put = alc883_mux_enum_put,
  5423. },
  5424. { } /* end */
  5425. };
  5426. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5427. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5429. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5430. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5431. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5432. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5434. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5435. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5436. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5437. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5438. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5439. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5440. {
  5441. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5442. /* .name = "Capture Source", */
  5443. .name = "Input Source",
  5444. .count = 2,
  5445. .info = alc883_mux_enum_info,
  5446. .get = alc883_mux_enum_get,
  5447. .put = alc883_mux_enum_put,
  5448. },
  5449. { } /* end */
  5450. };
  5451. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5452. {
  5453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5454. .name = "Channel Mode",
  5455. .info = alc_ch_mode_info,
  5456. .get = alc_ch_mode_get,
  5457. .put = alc_ch_mode_put,
  5458. },
  5459. { } /* end */
  5460. };
  5461. static struct hda_verb alc883_init_verbs[] = {
  5462. /* ADC1: mute amp left and right */
  5463. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5464. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5465. /* ADC2: mute amp left and right */
  5466. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5467. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5468. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5469. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5470. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5471. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5472. /* Rear mixer */
  5473. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5474. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5475. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5476. /* CLFE mixer */
  5477. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5478. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5479. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5480. /* Side mixer */
  5481. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5482. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5483. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5484. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5485. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5486. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5487. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5488. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5489. /* Front Pin: output 0 (0x0c) */
  5490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5491. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5492. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5493. /* Rear Pin: output 1 (0x0d) */
  5494. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5495. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5496. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5497. /* CLFE Pin: output 2 (0x0e) */
  5498. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5499. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5500. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5501. /* Side Pin: output 3 (0x0f) */
  5502. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5503. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5504. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5505. /* Mic (rear) pin: input vref at 80% */
  5506. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5507. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5508. /* Front Mic pin: input vref at 80% */
  5509. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5510. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5511. /* Line In pin: input */
  5512. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5513. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5514. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5515. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5516. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5517. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5518. /* CD pin widget for input */
  5519. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5520. /* FIXME: use matrix-type input source selection */
  5521. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5522. /* Input mixer2 */
  5523. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5524. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5525. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5526. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5527. /* Input mixer3 */
  5528. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5529. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5530. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5531. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5532. { }
  5533. };
  5534. static struct hda_verb alc883_tagra_verbs[] = {
  5535. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5536. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5537. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5538. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5539. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5540. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5541. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5542. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5543. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5544. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5545. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5546. { } /* end */
  5547. };
  5548. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5549. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5550. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5551. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5552. { } /* end */
  5553. };
  5554. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5555. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5556. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5557. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5558. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5559. { } /* end */
  5560. };
  5561. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5562. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5563. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5564. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5565. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5566. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5567. { } /* end */
  5568. };
  5569. /* toggle front-jack and RCA according to the hp-jack state */
  5570. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5571. {
  5572. unsigned int present;
  5573. present = snd_hda_codec_read(codec, 0x1b, 0,
  5574. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5575. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5576. 0x80, present ? 0x80 : 0);
  5577. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5578. 0x80, present ? 0x80 : 0);
  5579. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5580. 0x80, present ? 0x80 : 0);
  5581. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5582. 0x80, present ? 0x80 : 0);
  5583. }
  5584. /* toggle RCA according to the front-jack state */
  5585. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5586. {
  5587. unsigned int present;
  5588. present = snd_hda_codec_read(codec, 0x14, 0,
  5589. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5590. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5591. 0x80, present ? 0x80 : 0);
  5592. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5593. 0x80, present ? 0x80 : 0);
  5594. }
  5595. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5596. unsigned int res)
  5597. {
  5598. if ((res >> 26) == ALC880_HP_EVENT)
  5599. alc888_lenovo_ms7195_front_automute(codec);
  5600. if ((res >> 26) == ALC880_FRONT_EVENT)
  5601. alc888_lenovo_ms7195_rca_automute(codec);
  5602. }
  5603. static struct hda_verb alc883_medion_md2_verbs[] = {
  5604. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5605. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5606. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5607. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5608. { } /* end */
  5609. };
  5610. /* toggle speaker-output according to the hp-jack state */
  5611. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5612. {
  5613. unsigned int present;
  5614. present = snd_hda_codec_read(codec, 0x14, 0,
  5615. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5616. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5617. 0x80, present ? 0x80 : 0);
  5618. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5619. 0x80, present ? 0x80 : 0);
  5620. }
  5621. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5622. unsigned int res)
  5623. {
  5624. if ((res >> 26) == ALC880_HP_EVENT)
  5625. alc883_medion_md2_automute(codec);
  5626. }
  5627. /* toggle speaker-output according to the hp-jack state */
  5628. static void alc883_tagra_automute(struct hda_codec *codec)
  5629. {
  5630. unsigned int present;
  5631. unsigned char bits;
  5632. present = snd_hda_codec_read(codec, 0x14, 0,
  5633. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5634. bits = present ? 0x80 : 0;
  5635. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5636. 0x80, bits);
  5637. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5638. 0x80, bits);
  5639. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5640. present ? 1 : 3);
  5641. }
  5642. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5643. {
  5644. if ((res >> 26) == ALC880_HP_EVENT)
  5645. alc883_tagra_automute(codec);
  5646. }
  5647. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5648. {
  5649. unsigned int present;
  5650. unsigned char bits;
  5651. present = snd_hda_codec_read(codec, 0x14, 0,
  5652. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5653. bits = present ? 0x80 : 0;
  5654. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5655. 0x80, bits);
  5656. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5657. 0x80, bits);
  5658. }
  5659. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5660. {
  5661. unsigned int present;
  5662. unsigned char bits;
  5663. present = snd_hda_codec_read(codec, 0x1b, 0,
  5664. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5665. bits = present ? 0x80 : 0;
  5666. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5667. 0x80, bits);
  5668. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5669. 0x80, bits);
  5670. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5671. 0x80, bits);
  5672. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5673. 0x80, bits);
  5674. }
  5675. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5676. unsigned int res)
  5677. {
  5678. if ((res >> 26) == ALC880_HP_EVENT)
  5679. alc883_lenovo_101e_all_automute(codec);
  5680. if ((res >> 26) == ALC880_FRONT_EVENT)
  5681. alc883_lenovo_101e_ispeaker_automute(codec);
  5682. }
  5683. /*
  5684. * generic initialization of ADC, input mixers and output mixers
  5685. */
  5686. static struct hda_verb alc883_auto_init_verbs[] = {
  5687. /*
  5688. * Unmute ADC0-2 and set the default input to mic-in
  5689. */
  5690. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5692. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5693. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5695. * mixer widget
  5696. * Note: PASD motherboards uses the Line In 2 as the input for
  5697. * front panel mic (mic 2)
  5698. */
  5699. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5705. /*
  5706. * Set up output mixers (0x0c - 0x0f)
  5707. */
  5708. /* set vol=0 to output mixers */
  5709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5710. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5711. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5712. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5713. /* set up input amps for analog loopback */
  5714. /* Amp Indices: DAC = 0, mixer = 1 */
  5715. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5716. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5717. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5718. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5719. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5720. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5721. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5722. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5723. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5724. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5725. /* FIXME: use matrix-type input source selection */
  5726. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5727. /* Input mixer1 */
  5728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5730. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5731. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5733. /* Input mixer2 */
  5734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5736. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5737. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5738. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5739. { }
  5740. };
  5741. /* capture mixer elements */
  5742. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5743. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5744. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5745. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5746. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5747. {
  5748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5749. /* The multiple "Capture Source" controls confuse alsamixer
  5750. * So call somewhat different..
  5751. * FIXME: the controls appear in the "playback" view!
  5752. */
  5753. /* .name = "Capture Source", */
  5754. .name = "Input Source",
  5755. .count = 2,
  5756. .info = alc882_mux_enum_info,
  5757. .get = alc882_mux_enum_get,
  5758. .put = alc882_mux_enum_put,
  5759. },
  5760. { } /* end */
  5761. };
  5762. /* pcm configuration: identiacal with ALC880 */
  5763. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5764. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5765. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5766. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5767. /*
  5768. * configuration and preset
  5769. */
  5770. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5771. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5772. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5773. [ALC883_3ST_6ch] = "3stack-6ch",
  5774. [ALC883_6ST_DIG] = "6stack-dig",
  5775. [ALC883_TARGA_DIG] = "targa-dig",
  5776. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5777. [ALC883_ACER] = "acer",
  5778. [ALC883_MEDION] = "medion",
  5779. [ALC883_MEDION_MD2] = "medion-md2",
  5780. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5781. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5782. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5783. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5784. [ALC883_AUTO] = "auto",
  5785. };
  5786. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5787. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5788. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5789. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5790. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5791. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5792. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5799. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5800. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5801. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5802. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5803. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5804. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5805. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5806. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5807. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5808. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5809. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5810. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5811. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5812. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5813. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5814. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5815. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5816. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5817. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
  5818. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5819. {}
  5820. };
  5821. static struct alc_config_preset alc883_presets[] = {
  5822. [ALC883_3ST_2ch_DIG] = {
  5823. .mixers = { alc883_3ST_2ch_mixer },
  5824. .init_verbs = { alc883_init_verbs },
  5825. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5826. .dac_nids = alc883_dac_nids,
  5827. .dig_out_nid = ALC883_DIGOUT_NID,
  5828. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5829. .adc_nids = alc883_adc_nids,
  5830. .dig_in_nid = ALC883_DIGIN_NID,
  5831. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5832. .channel_mode = alc883_3ST_2ch_modes,
  5833. .input_mux = &alc883_capture_source,
  5834. },
  5835. [ALC883_3ST_6ch_DIG] = {
  5836. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5837. .init_verbs = { alc883_init_verbs },
  5838. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5839. .dac_nids = alc883_dac_nids,
  5840. .dig_out_nid = ALC883_DIGOUT_NID,
  5841. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5842. .adc_nids = alc883_adc_nids,
  5843. .dig_in_nid = ALC883_DIGIN_NID,
  5844. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5845. .channel_mode = alc883_3ST_6ch_modes,
  5846. .need_dac_fix = 1,
  5847. .input_mux = &alc883_capture_source,
  5848. },
  5849. [ALC883_3ST_6ch] = {
  5850. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5851. .init_verbs = { alc883_init_verbs },
  5852. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5853. .dac_nids = alc883_dac_nids,
  5854. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5855. .adc_nids = alc883_adc_nids,
  5856. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5857. .channel_mode = alc883_3ST_6ch_modes,
  5858. .need_dac_fix = 1,
  5859. .input_mux = &alc883_capture_source,
  5860. },
  5861. [ALC883_6ST_DIG] = {
  5862. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5863. .init_verbs = { alc883_init_verbs },
  5864. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5865. .dac_nids = alc883_dac_nids,
  5866. .dig_out_nid = ALC883_DIGOUT_NID,
  5867. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5868. .adc_nids = alc883_adc_nids,
  5869. .dig_in_nid = ALC883_DIGIN_NID,
  5870. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5871. .channel_mode = alc883_sixstack_modes,
  5872. .input_mux = &alc883_capture_source,
  5873. },
  5874. [ALC883_TARGA_DIG] = {
  5875. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5876. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5877. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5878. .dac_nids = alc883_dac_nids,
  5879. .dig_out_nid = ALC883_DIGOUT_NID,
  5880. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5881. .adc_nids = alc883_adc_nids,
  5882. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5883. .channel_mode = alc883_3ST_6ch_modes,
  5884. .need_dac_fix = 1,
  5885. .input_mux = &alc883_capture_source,
  5886. .unsol_event = alc883_tagra_unsol_event,
  5887. .init_hook = alc883_tagra_automute,
  5888. },
  5889. [ALC883_TARGA_2ch_DIG] = {
  5890. .mixers = { alc883_tagra_2ch_mixer},
  5891. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5892. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5893. .dac_nids = alc883_dac_nids,
  5894. .dig_out_nid = ALC883_DIGOUT_NID,
  5895. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5896. .adc_nids = alc883_adc_nids,
  5897. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5898. .channel_mode = alc883_3ST_2ch_modes,
  5899. .input_mux = &alc883_capture_source,
  5900. .unsol_event = alc883_tagra_unsol_event,
  5901. .init_hook = alc883_tagra_automute,
  5902. },
  5903. [ALC883_ACER] = {
  5904. .mixers = { alc883_base_mixer,
  5905. alc883_chmode_mixer },
  5906. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5907. * and the headphone jack. Turn this on and rely on the
  5908. * standard mute methods whenever the user wants to turn
  5909. * these outputs off.
  5910. */
  5911. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5912. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5913. .dac_nids = alc883_dac_nids,
  5914. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5915. .adc_nids = alc883_adc_nids,
  5916. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5917. .channel_mode = alc883_3ST_2ch_modes,
  5918. .input_mux = &alc883_capture_source,
  5919. },
  5920. [ALC883_MEDION] = {
  5921. .mixers = { alc883_fivestack_mixer,
  5922. alc883_chmode_mixer },
  5923. .init_verbs = { alc883_init_verbs,
  5924. alc883_medion_eapd_verbs },
  5925. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5926. .dac_nids = alc883_dac_nids,
  5927. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5928. .adc_nids = alc883_adc_nids,
  5929. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5930. .channel_mode = alc883_sixstack_modes,
  5931. .input_mux = &alc883_capture_source,
  5932. },
  5933. [ALC883_MEDION_MD2] = {
  5934. .mixers = { alc883_medion_md2_mixer},
  5935. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5936. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5937. .dac_nids = alc883_dac_nids,
  5938. .dig_out_nid = ALC883_DIGOUT_NID,
  5939. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5940. .adc_nids = alc883_adc_nids,
  5941. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5942. .channel_mode = alc883_3ST_2ch_modes,
  5943. .input_mux = &alc883_capture_source,
  5944. .unsol_event = alc883_medion_md2_unsol_event,
  5945. .init_hook = alc883_medion_md2_automute,
  5946. },
  5947. [ALC883_LAPTOP_EAPD] = {
  5948. .mixers = { alc883_base_mixer,
  5949. alc883_chmode_mixer },
  5950. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5951. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5952. .dac_nids = alc883_dac_nids,
  5953. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5954. .adc_nids = alc883_adc_nids,
  5955. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5956. .channel_mode = alc883_3ST_2ch_modes,
  5957. .input_mux = &alc883_capture_source,
  5958. },
  5959. [ALC883_LENOVO_101E_2ch] = {
  5960. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5961. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5962. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5963. .dac_nids = alc883_dac_nids,
  5964. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5965. .adc_nids = alc883_adc_nids,
  5966. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5967. .channel_mode = alc883_3ST_2ch_modes,
  5968. .input_mux = &alc883_lenovo_101e_capture_source,
  5969. .unsol_event = alc883_lenovo_101e_unsol_event,
  5970. .init_hook = alc883_lenovo_101e_all_automute,
  5971. },
  5972. [ALC883_LENOVO_NB0763] = {
  5973. .mixers = { alc883_lenovo_nb0763_mixer },
  5974. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5975. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5976. .dac_nids = alc883_dac_nids,
  5977. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5978. .adc_nids = alc883_adc_nids,
  5979. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5980. .channel_mode = alc883_3ST_2ch_modes,
  5981. .need_dac_fix = 1,
  5982. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5983. .unsol_event = alc883_medion_md2_unsol_event,
  5984. .init_hook = alc883_medion_md2_automute,
  5985. },
  5986. [ALC888_LENOVO_MS7195_DIG] = {
  5987. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5988. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5989. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5990. .dac_nids = alc883_dac_nids,
  5991. .dig_out_nid = ALC883_DIGOUT_NID,
  5992. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5993. .adc_nids = alc883_adc_nids,
  5994. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5995. .channel_mode = alc883_3ST_6ch_modes,
  5996. .need_dac_fix = 1,
  5997. .input_mux = &alc883_capture_source,
  5998. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5999. .init_hook = alc888_lenovo_ms7195_front_automute,
  6000. },
  6001. };
  6002. /*
  6003. * BIOS auto configuration
  6004. */
  6005. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6006. hda_nid_t nid, int pin_type,
  6007. int dac_idx)
  6008. {
  6009. /* set as output */
  6010. struct alc_spec *spec = codec->spec;
  6011. int idx;
  6012. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6013. idx = 4;
  6014. else
  6015. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6016. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6017. pin_type);
  6018. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6019. AMP_OUT_UNMUTE);
  6020. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6021. }
  6022. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6023. {
  6024. struct alc_spec *spec = codec->spec;
  6025. int i;
  6026. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6027. for (i = 0; i <= HDA_SIDE; i++) {
  6028. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6029. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6030. if (nid)
  6031. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6032. i);
  6033. }
  6034. }
  6035. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6036. {
  6037. struct alc_spec *spec = codec->spec;
  6038. hda_nid_t pin;
  6039. pin = spec->autocfg.hp_pins[0];
  6040. if (pin) /* connect to front */
  6041. /* use dac 0 */
  6042. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6043. }
  6044. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6045. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6046. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6047. {
  6048. struct alc_spec *spec = codec->spec;
  6049. int i;
  6050. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6051. hda_nid_t nid = spec->autocfg.input_pins[i];
  6052. if (alc883_is_input_pin(nid)) {
  6053. snd_hda_codec_write(codec, nid, 0,
  6054. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6055. (i <= AUTO_PIN_FRONT_MIC ?
  6056. PIN_VREF80 : PIN_IN));
  6057. if (nid != ALC883_PIN_CD_NID)
  6058. snd_hda_codec_write(codec, nid, 0,
  6059. AC_VERB_SET_AMP_GAIN_MUTE,
  6060. AMP_OUT_MUTE);
  6061. }
  6062. }
  6063. }
  6064. /* almost identical with ALC880 parser... */
  6065. static int alc883_parse_auto_config(struct hda_codec *codec)
  6066. {
  6067. struct alc_spec *spec = codec->spec;
  6068. int err = alc880_parse_auto_config(codec);
  6069. if (err < 0)
  6070. return err;
  6071. else if (err > 0)
  6072. /* hack - override the init verbs */
  6073. spec->init_verbs[0] = alc883_auto_init_verbs;
  6074. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6075. spec->num_mixers++;
  6076. return err;
  6077. }
  6078. /* additional initialization for auto-configuration model */
  6079. static void alc883_auto_init(struct hda_codec *codec)
  6080. {
  6081. alc883_auto_init_multi_out(codec);
  6082. alc883_auto_init_hp_out(codec);
  6083. alc883_auto_init_analog_input(codec);
  6084. }
  6085. static int patch_alc883(struct hda_codec *codec)
  6086. {
  6087. struct alc_spec *spec;
  6088. int err, board_config;
  6089. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6090. if (spec == NULL)
  6091. return -ENOMEM;
  6092. codec->spec = spec;
  6093. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6094. alc883_models,
  6095. alc883_cfg_tbl);
  6096. if (board_config < 0) {
  6097. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6098. "trying auto-probe from BIOS...\n");
  6099. board_config = ALC883_AUTO;
  6100. }
  6101. if (board_config == ALC883_AUTO) {
  6102. /* automatic parse from the BIOS config */
  6103. err = alc883_parse_auto_config(codec);
  6104. if (err < 0) {
  6105. alc_free(codec);
  6106. return err;
  6107. } else if (!err) {
  6108. printk(KERN_INFO
  6109. "hda_codec: Cannot set up configuration "
  6110. "from BIOS. Using base mode...\n");
  6111. board_config = ALC883_3ST_2ch_DIG;
  6112. }
  6113. }
  6114. if (board_config != ALC883_AUTO)
  6115. setup_preset(spec, &alc883_presets[board_config]);
  6116. spec->stream_name_analog = "ALC883 Analog";
  6117. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6118. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6119. spec->stream_name_digital = "ALC883 Digital";
  6120. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6121. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6122. if (!spec->adc_nids && spec->input_mux) {
  6123. spec->adc_nids = alc883_adc_nids;
  6124. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6125. }
  6126. codec->patch_ops = alc_patch_ops;
  6127. if (board_config == ALC883_AUTO)
  6128. spec->init_hook = alc883_auto_init;
  6129. return 0;
  6130. }
  6131. /*
  6132. * ALC262 support
  6133. */
  6134. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6135. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6136. #define alc262_dac_nids alc260_dac_nids
  6137. #define alc262_adc_nids alc882_adc_nids
  6138. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6139. #define alc262_modes alc260_modes
  6140. #define alc262_capture_source alc882_capture_source
  6141. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6142. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6143. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6144. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6145. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6146. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6147. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6148. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6149. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6150. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6151. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6152. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6153. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6154. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6155. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6156. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6157. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6158. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6159. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6160. { } /* end */
  6161. };
  6162. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6163. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6164. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6165. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6166. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6167. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6168. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6169. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6170. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6171. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6172. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6173. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6174. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6175. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6176. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6177. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6178. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6179. { } /* end */
  6180. };
  6181. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6182. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6183. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6184. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6185. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6186. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6187. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6188. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6190. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6191. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6192. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6193. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6194. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6195. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6196. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6197. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6198. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6199. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6200. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6201. { } /* end */
  6202. };
  6203. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6204. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6205. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6208. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6209. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6210. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6211. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6212. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6213. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6214. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6215. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6216. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6217. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6218. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6219. { } /* end */
  6220. };
  6221. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6222. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6223. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6224. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6225. { } /* end */
  6226. };
  6227. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6228. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6229. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6230. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6231. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6232. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6233. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6234. { } /* end */
  6235. };
  6236. #define alc262_capture_mixer alc882_capture_mixer
  6237. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6238. /*
  6239. * generic initialization of ADC, input mixers and output mixers
  6240. */
  6241. static struct hda_verb alc262_init_verbs[] = {
  6242. /*
  6243. * Unmute ADC0-2 and set the default input to mic-in
  6244. */
  6245. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6246. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6247. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6248. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6249. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6250. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6251. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6252. * mixer widget
  6253. * Note: PASD motherboards uses the Line In 2 as the input for
  6254. * front panel mic (mic 2)
  6255. */
  6256. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6257. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6258. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6259. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6260. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6261. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6262. /*
  6263. * Set up output mixers (0x0c - 0x0e)
  6264. */
  6265. /* set vol=0 to output mixers */
  6266. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6267. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6268. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6269. /* set up input amps for analog loopback */
  6270. /* Amp Indices: DAC = 0, mixer = 1 */
  6271. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6272. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6273. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6274. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6275. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6276. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6277. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6278. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6279. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6280. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6281. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6282. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6285. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6286. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6287. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6288. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6289. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6290. /* FIXME: use matrix-type input source selection */
  6291. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6292. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6293. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6294. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6295. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6296. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6297. /* Input mixer2 */
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6299. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6300. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6301. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6302. /* Input mixer3 */
  6303. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6304. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6305. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6306. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6307. { }
  6308. };
  6309. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6310. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6312. {}
  6313. };
  6314. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6315. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6316. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6317. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6318. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6319. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6320. {}
  6321. };
  6322. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6323. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6324. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6326. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6327. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6328. };
  6329. /* mute/unmute internal speaker according to the hp jack and mute state */
  6330. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6331. {
  6332. struct alc_spec *spec = codec->spec;
  6333. unsigned int mute;
  6334. if (force || !spec->sense_updated) {
  6335. unsigned int present;
  6336. /* need to execute and sync at first */
  6337. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6338. present = snd_hda_codec_read(codec, 0x15, 0,
  6339. AC_VERB_GET_PIN_SENSE, 0);
  6340. spec->jack_present = (present & 0x80000000) != 0;
  6341. spec->sense_updated = 1;
  6342. }
  6343. if (spec->jack_present) {
  6344. /* mute internal speaker */
  6345. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6346. 0x80, 0x80);
  6347. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6348. 0x80, 0x80);
  6349. } else {
  6350. /* unmute internal speaker if necessary */
  6351. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6352. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6353. 0x80, mute & 0x80);
  6354. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6355. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6356. 0x80, mute & 0x80);
  6357. }
  6358. }
  6359. /* unsolicited event for HP jack sensing */
  6360. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6361. unsigned int res)
  6362. {
  6363. if ((res >> 26) != ALC880_HP_EVENT)
  6364. return;
  6365. alc262_hippo_automute(codec, 1);
  6366. }
  6367. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6368. {
  6369. struct alc_spec *spec = codec->spec;
  6370. unsigned int mute;
  6371. if (force || !spec->sense_updated) {
  6372. unsigned int present;
  6373. /* need to execute and sync at first */
  6374. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6375. present = snd_hda_codec_read(codec, 0x1b, 0,
  6376. AC_VERB_GET_PIN_SENSE, 0);
  6377. spec->jack_present = (present & 0x80000000) != 0;
  6378. spec->sense_updated = 1;
  6379. }
  6380. if (spec->jack_present) {
  6381. /* mute internal speaker */
  6382. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6383. 0x80, 0x80);
  6384. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6385. 0x80, 0x80);
  6386. } else {
  6387. /* unmute internal speaker if necessary */
  6388. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6389. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6390. 0x80, mute & 0x80);
  6391. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6392. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6393. 0x80, mute & 0x80);
  6394. }
  6395. }
  6396. /* unsolicited event for HP jack sensing */
  6397. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6398. unsigned int res)
  6399. {
  6400. if ((res >> 26) != ALC880_HP_EVENT)
  6401. return;
  6402. alc262_hippo1_automute(codec, 1);
  6403. }
  6404. /*
  6405. * fujitsu model
  6406. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6407. */
  6408. #define ALC_HP_EVENT 0x37
  6409. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6410. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6411. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6412. {}
  6413. };
  6414. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6415. .num_items = 2,
  6416. .items = {
  6417. { "Mic", 0x0 },
  6418. { "CD", 0x4 },
  6419. },
  6420. };
  6421. static struct hda_input_mux alc262_HP_capture_source = {
  6422. .num_items = 5,
  6423. .items = {
  6424. { "Mic", 0x0 },
  6425. { "Front Mic", 0x3 },
  6426. { "Line", 0x2 },
  6427. { "CD", 0x4 },
  6428. { "AUX IN", 0x6 },
  6429. },
  6430. };
  6431. /* mute/unmute internal speaker according to the hp jack and mute state */
  6432. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6433. {
  6434. struct alc_spec *spec = codec->spec;
  6435. unsigned int mute;
  6436. if (force || !spec->sense_updated) {
  6437. unsigned int present;
  6438. /* need to execute and sync at first */
  6439. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6440. present = snd_hda_codec_read(codec, 0x14, 0,
  6441. AC_VERB_GET_PIN_SENSE, 0);
  6442. spec->jack_present = (present & 0x80000000) != 0;
  6443. spec->sense_updated = 1;
  6444. }
  6445. if (spec->jack_present) {
  6446. /* mute internal speaker */
  6447. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6448. 0x80, 0x80);
  6449. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6450. 0x80, 0x80);
  6451. } else {
  6452. /* unmute internal speaker if necessary */
  6453. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6454. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6455. 0x80, mute & 0x80);
  6456. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6457. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6458. 0x80, mute & 0x80);
  6459. }
  6460. }
  6461. /* unsolicited event for HP jack sensing */
  6462. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6463. unsigned int res)
  6464. {
  6465. if ((res >> 26) != ALC_HP_EVENT)
  6466. return;
  6467. alc262_fujitsu_automute(codec, 1);
  6468. }
  6469. /* bind volumes of both NID 0x0c and 0x0d */
  6470. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6471. struct snd_ctl_elem_value *ucontrol)
  6472. {
  6473. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6474. long *valp = ucontrol->value.integer.value;
  6475. int change;
  6476. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6477. 0x7f, valp[0] & 0x7f);
  6478. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6479. 0x7f, valp[1] & 0x7f);
  6480. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6481. 0x7f, valp[0] & 0x7f);
  6482. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6483. 0x7f, valp[1] & 0x7f);
  6484. return change;
  6485. }
  6486. /* bind hp and internal speaker mute (with plug check) */
  6487. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6488. struct snd_ctl_elem_value *ucontrol)
  6489. {
  6490. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6491. long *valp = ucontrol->value.integer.value;
  6492. int change;
  6493. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6494. 0x80, valp[0] ? 0 : 0x80);
  6495. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6496. 0x80, valp[1] ? 0 : 0x80);
  6497. if (change || codec->in_resume)
  6498. alc262_fujitsu_automute(codec, codec->in_resume);
  6499. return change;
  6500. }
  6501. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6502. {
  6503. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6504. .name = "Master Playback Volume",
  6505. .info = snd_hda_mixer_amp_volume_info,
  6506. .get = snd_hda_mixer_amp_volume_get,
  6507. .put = alc262_fujitsu_master_vol_put,
  6508. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6509. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6510. },
  6511. {
  6512. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6513. .name = "Master Playback Switch",
  6514. .info = snd_hda_mixer_amp_switch_info,
  6515. .get = snd_hda_mixer_amp_switch_get,
  6516. .put = alc262_fujitsu_master_sw_put,
  6517. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6518. },
  6519. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6520. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6521. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6522. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6523. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6524. { } /* end */
  6525. };
  6526. /* additional init verbs for Benq laptops */
  6527. static struct hda_verb alc262_EAPD_verbs[] = {
  6528. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6529. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6530. {}
  6531. };
  6532. /* add playback controls from the parsed DAC table */
  6533. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6534. const struct auto_pin_cfg *cfg)
  6535. {
  6536. hda_nid_t nid;
  6537. int err;
  6538. spec->multiout.num_dacs = 1; /* only use one dac */
  6539. spec->multiout.dac_nids = spec->private_dac_nids;
  6540. spec->multiout.dac_nids[0] = 2;
  6541. nid = cfg->line_out_pins[0];
  6542. if (nid) {
  6543. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6544. "Front Playback Volume",
  6545. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6546. if (err < 0)
  6547. return err;
  6548. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6549. "Front Playback Switch",
  6550. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6551. if (err < 0)
  6552. return err;
  6553. }
  6554. nid = cfg->speaker_pins[0];
  6555. if (nid) {
  6556. if (nid == 0x16) {
  6557. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6558. "Speaker Playback Volume",
  6559. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6560. HDA_OUTPUT));
  6561. if (err < 0)
  6562. return err;
  6563. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6564. "Speaker Playback Switch",
  6565. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6566. HDA_OUTPUT));
  6567. if (err < 0)
  6568. return err;
  6569. } else {
  6570. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6571. "Speaker Playback Switch",
  6572. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6573. HDA_OUTPUT));
  6574. if (err < 0)
  6575. return err;
  6576. }
  6577. }
  6578. nid = cfg->hp_pins[0];
  6579. if (nid) {
  6580. /* spec->multiout.hp_nid = 2; */
  6581. if (nid == 0x16) {
  6582. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6583. "Headphone Playback Volume",
  6584. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6585. HDA_OUTPUT));
  6586. if (err < 0)
  6587. return err;
  6588. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6589. "Headphone Playback Switch",
  6590. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6591. HDA_OUTPUT));
  6592. if (err < 0)
  6593. return err;
  6594. } else {
  6595. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6596. "Headphone Playback Switch",
  6597. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6598. HDA_OUTPUT));
  6599. if (err < 0)
  6600. return err;
  6601. }
  6602. }
  6603. return 0;
  6604. }
  6605. /* identical with ALC880 */
  6606. #define alc262_auto_create_analog_input_ctls \
  6607. alc880_auto_create_analog_input_ctls
  6608. /*
  6609. * generic initialization of ADC, input mixers and output mixers
  6610. */
  6611. static struct hda_verb alc262_volume_init_verbs[] = {
  6612. /*
  6613. * Unmute ADC0-2 and set the default input to mic-in
  6614. */
  6615. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6616. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6617. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6619. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6620. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6621. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6622. * mixer widget
  6623. * Note: PASD motherboards uses the Line In 2 as the input for
  6624. * front panel mic (mic 2)
  6625. */
  6626. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6632. /*
  6633. * Set up output mixers (0x0c - 0x0f)
  6634. */
  6635. /* set vol=0 to output mixers */
  6636. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6637. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6638. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6639. /* set up input amps for analog loopback */
  6640. /* Amp Indices: DAC = 0, mixer = 1 */
  6641. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6642. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6643. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6644. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6645. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6646. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6647. /* FIXME: use matrix-type input source selection */
  6648. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6649. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6650. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6651. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6652. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6653. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6654. /* Input mixer2 */
  6655. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6656. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6657. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6658. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6659. /* Input mixer3 */
  6660. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6661. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6662. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6663. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6664. { }
  6665. };
  6666. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6667. /*
  6668. * Unmute ADC0-2 and set the default input to mic-in
  6669. */
  6670. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6671. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6672. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6673. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6674. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6675. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6676. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6677. * mixer widget
  6678. * Note: PASD motherboards uses the Line In 2 as the input for
  6679. * front panel mic (mic 2)
  6680. */
  6681. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6686. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6687. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6688. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6689. /*
  6690. * Set up output mixers (0x0c - 0x0e)
  6691. */
  6692. /* set vol=0 to output mixers */
  6693. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6694. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6695. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6696. /* set up input amps for analog loopback */
  6697. /* Amp Indices: DAC = 0, mixer = 1 */
  6698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6699. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6700. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6701. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6703. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6704. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6705. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6706. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6707. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6708. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6709. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6710. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6711. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6712. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6713. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6714. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6715. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6716. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6717. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6718. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6719. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6720. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6721. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6722. /* FIXME: use matrix-type input source selection */
  6723. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6724. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6725. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6726. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6727. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6728. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6729. /* Input mixer2 */
  6730. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6733. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6734. /* Input mixer3 */
  6735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6736. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6737. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6738. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6739. { }
  6740. };
  6741. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6742. /*
  6743. * Unmute ADC0-2 and set the default input to mic-in
  6744. */
  6745. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6746. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6747. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6748. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6749. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6750. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6751. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6752. * mixer widget
  6753. * Note: PASD motherboards uses the Line In 2 as the input for front
  6754. * panel mic (mic 2)
  6755. */
  6756. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6762. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6763. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6764. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6765. /*
  6766. * Set up output mixers (0x0c - 0x0e)
  6767. */
  6768. /* set vol=0 to output mixers */
  6769. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6770. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6771. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6772. /* set up input amps for analog loopback */
  6773. /* Amp Indices: DAC = 0, mixer = 1 */
  6774. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6775. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6776. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6777. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6778. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6779. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6780. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6781. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6782. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6783. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6784. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6785. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6786. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6787. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6788. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6789. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6790. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6791. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6792. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6793. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6794. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6795. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6796. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6797. /* FIXME: use matrix-type input source selection */
  6798. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6799. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6800. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6801. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6804. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6805. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6806. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6807. /* Input mixer2 */
  6808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6810. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6811. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6812. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6813. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6814. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6815. /* Input mixer3 */
  6816. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6817. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6818. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6819. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6820. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6821. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6822. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6823. { }
  6824. };
  6825. /* pcm configuration: identiacal with ALC880 */
  6826. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6827. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6828. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6829. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6830. /*
  6831. * BIOS auto configuration
  6832. */
  6833. static int alc262_parse_auto_config(struct hda_codec *codec)
  6834. {
  6835. struct alc_spec *spec = codec->spec;
  6836. int err;
  6837. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6838. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6839. alc262_ignore);
  6840. if (err < 0)
  6841. return err;
  6842. if (!spec->autocfg.line_outs)
  6843. return 0; /* can't find valid BIOS pin config */
  6844. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6845. if (err < 0)
  6846. return err;
  6847. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6848. if (err < 0)
  6849. return err;
  6850. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6851. if (spec->autocfg.dig_out_pin)
  6852. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6853. if (spec->autocfg.dig_in_pin)
  6854. spec->dig_in_nid = ALC262_DIGIN_NID;
  6855. if (spec->kctl_alloc)
  6856. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6857. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6858. spec->num_mux_defs = 1;
  6859. spec->input_mux = &spec->private_imux;
  6860. return 1;
  6861. }
  6862. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6863. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6864. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6865. /* init callback for auto-configuration model -- overriding the default init */
  6866. static void alc262_auto_init(struct hda_codec *codec)
  6867. {
  6868. alc262_auto_init_multi_out(codec);
  6869. alc262_auto_init_hp_out(codec);
  6870. alc262_auto_init_analog_input(codec);
  6871. }
  6872. /*
  6873. * configuration and preset
  6874. */
  6875. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6876. [ALC262_BASIC] = "basic",
  6877. [ALC262_HIPPO] = "hippo",
  6878. [ALC262_HIPPO_1] = "hippo_1",
  6879. [ALC262_FUJITSU] = "fujitsu",
  6880. [ALC262_HP_BPC] = "hp-bpc",
  6881. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6882. [ALC262_BENQ_ED8] = "benq",
  6883. [ALC262_BENQ_ED8] = "sony-assamd",
  6884. [ALC262_AUTO] = "auto",
  6885. };
  6886. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6887. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6888. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6889. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6890. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  6891. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  6892. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6893. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  6894. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6895. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  6896. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6897. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6898. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6899. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6900. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6901. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6902. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6903. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6904. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6905. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6906. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6907. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6908. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6909. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6910. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6911. {}
  6912. };
  6913. static struct alc_config_preset alc262_presets[] = {
  6914. [ALC262_BASIC] = {
  6915. .mixers = { alc262_base_mixer },
  6916. .init_verbs = { alc262_init_verbs },
  6917. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6918. .dac_nids = alc262_dac_nids,
  6919. .hp_nid = 0x03,
  6920. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6921. .channel_mode = alc262_modes,
  6922. .input_mux = &alc262_capture_source,
  6923. },
  6924. [ALC262_HIPPO] = {
  6925. .mixers = { alc262_base_mixer },
  6926. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6927. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6928. .dac_nids = alc262_dac_nids,
  6929. .hp_nid = 0x03,
  6930. .dig_out_nid = ALC262_DIGOUT_NID,
  6931. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6932. .channel_mode = alc262_modes,
  6933. .input_mux = &alc262_capture_source,
  6934. .unsol_event = alc262_hippo_unsol_event,
  6935. },
  6936. [ALC262_HIPPO_1] = {
  6937. .mixers = { alc262_hippo1_mixer },
  6938. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6939. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6940. .dac_nids = alc262_dac_nids,
  6941. .hp_nid = 0x02,
  6942. .dig_out_nid = ALC262_DIGOUT_NID,
  6943. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6944. .channel_mode = alc262_modes,
  6945. .input_mux = &alc262_capture_source,
  6946. .unsol_event = alc262_hippo1_unsol_event,
  6947. },
  6948. [ALC262_FUJITSU] = {
  6949. .mixers = { alc262_fujitsu_mixer },
  6950. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6951. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6952. .dac_nids = alc262_dac_nids,
  6953. .hp_nid = 0x03,
  6954. .dig_out_nid = ALC262_DIGOUT_NID,
  6955. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6956. .channel_mode = alc262_modes,
  6957. .input_mux = &alc262_fujitsu_capture_source,
  6958. .unsol_event = alc262_fujitsu_unsol_event,
  6959. },
  6960. [ALC262_HP_BPC] = {
  6961. .mixers = { alc262_HP_BPC_mixer },
  6962. .init_verbs = { alc262_HP_BPC_init_verbs },
  6963. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6964. .dac_nids = alc262_dac_nids,
  6965. .hp_nid = 0x03,
  6966. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6967. .channel_mode = alc262_modes,
  6968. .input_mux = &alc262_HP_capture_source,
  6969. },
  6970. [ALC262_HP_BPC_D7000_WF] = {
  6971. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6972. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6973. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6974. .dac_nids = alc262_dac_nids,
  6975. .hp_nid = 0x03,
  6976. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6977. .channel_mode = alc262_modes,
  6978. .input_mux = &alc262_HP_capture_source,
  6979. },
  6980. [ALC262_HP_BPC_D7000_WL] = {
  6981. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6982. alc262_HP_BPC_WildWest_option_mixer },
  6983. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6984. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6985. .dac_nids = alc262_dac_nids,
  6986. .hp_nid = 0x03,
  6987. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6988. .channel_mode = alc262_modes,
  6989. .input_mux = &alc262_HP_capture_source,
  6990. },
  6991. [ALC262_BENQ_ED8] = {
  6992. .mixers = { alc262_base_mixer },
  6993. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6994. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6995. .dac_nids = alc262_dac_nids,
  6996. .hp_nid = 0x03,
  6997. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6998. .channel_mode = alc262_modes,
  6999. .input_mux = &alc262_capture_source,
  7000. },
  7001. [ALC262_SONY_ASSAMD] = {
  7002. .mixers = { alc262_sony_mixer },
  7003. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7004. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7005. .dac_nids = alc262_dac_nids,
  7006. .hp_nid = 0x02,
  7007. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7008. .channel_mode = alc262_modes,
  7009. .input_mux = &alc262_capture_source,
  7010. .unsol_event = alc262_hippo_unsol_event,
  7011. },
  7012. };
  7013. static int patch_alc262(struct hda_codec *codec)
  7014. {
  7015. struct alc_spec *spec;
  7016. int board_config;
  7017. int err;
  7018. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7019. if (spec == NULL)
  7020. return -ENOMEM;
  7021. codec->spec = spec;
  7022. #if 0
  7023. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7024. * under-run
  7025. */
  7026. {
  7027. int tmp;
  7028. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7029. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7030. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7031. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7032. }
  7033. #endif
  7034. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7035. alc262_models,
  7036. alc262_cfg_tbl);
  7037. if (board_config < 0) {
  7038. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7039. "trying auto-probe from BIOS...\n");
  7040. board_config = ALC262_AUTO;
  7041. }
  7042. if (board_config == ALC262_AUTO) {
  7043. /* automatic parse from the BIOS config */
  7044. err = alc262_parse_auto_config(codec);
  7045. if (err < 0) {
  7046. alc_free(codec);
  7047. return err;
  7048. } else if (!err) {
  7049. printk(KERN_INFO
  7050. "hda_codec: Cannot set up configuration "
  7051. "from BIOS. Using base mode...\n");
  7052. board_config = ALC262_BASIC;
  7053. }
  7054. }
  7055. if (board_config != ALC262_AUTO)
  7056. setup_preset(spec, &alc262_presets[board_config]);
  7057. spec->stream_name_analog = "ALC262 Analog";
  7058. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7059. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7060. spec->stream_name_digital = "ALC262 Digital";
  7061. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7062. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7063. if (!spec->adc_nids && spec->input_mux) {
  7064. /* check whether NID 0x07 is valid */
  7065. unsigned int wcap = get_wcaps(codec, 0x07);
  7066. /* get type */
  7067. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7068. if (wcap != AC_WID_AUD_IN) {
  7069. spec->adc_nids = alc262_adc_nids_alt;
  7070. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7071. spec->mixers[spec->num_mixers] =
  7072. alc262_capture_alt_mixer;
  7073. spec->num_mixers++;
  7074. } else {
  7075. spec->adc_nids = alc262_adc_nids;
  7076. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7077. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7078. spec->num_mixers++;
  7079. }
  7080. }
  7081. codec->patch_ops = alc_patch_ops;
  7082. if (board_config == ALC262_AUTO)
  7083. spec->init_hook = alc262_auto_init;
  7084. return 0;
  7085. }
  7086. /*
  7087. * ALC268 channel source setting (2 channel)
  7088. */
  7089. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7090. #define alc268_modes alc260_modes
  7091. static hda_nid_t alc268_dac_nids[2] = {
  7092. /* front, hp */
  7093. 0x02, 0x03
  7094. };
  7095. static hda_nid_t alc268_adc_nids[2] = {
  7096. /* ADC0-1 */
  7097. 0x08, 0x07
  7098. };
  7099. static hda_nid_t alc268_adc_nids_alt[1] = {
  7100. /* ADC0 */
  7101. 0x08
  7102. };
  7103. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7104. /* output mixer control */
  7105. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7106. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7107. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7108. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7109. { }
  7110. };
  7111. /*
  7112. * generic initialization of ADC, input mixers and output mixers
  7113. */
  7114. static struct hda_verb alc268_base_init_verbs[] = {
  7115. /* Unmute DAC0-1 and set vol = 0 */
  7116. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7117. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7118. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7119. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7120. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7121. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7122. /*
  7123. * Set up output mixers (0x0c - 0x0e)
  7124. */
  7125. /* set vol=0 to output mixers */
  7126. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7128. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7129. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7130. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7131. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7132. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7133. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7134. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7135. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7136. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7137. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7138. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7139. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7140. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7141. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7142. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7143. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7144. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7145. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7146. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7147. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7148. /* FIXME: use matrix-type input source selection */
  7149. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7150. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7151. /* Input mixer2 */
  7152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7155. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7156. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7157. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7159. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7160. { }
  7161. };
  7162. /*
  7163. * generic initialization of ADC, input mixers and output mixers
  7164. */
  7165. static struct hda_verb alc268_volume_init_verbs[] = {
  7166. /* set output DAC */
  7167. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7168. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7169. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7170. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7171. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7172. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7173. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7174. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7175. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7176. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7177. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7178. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7179. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7180. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7181. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7182. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7183. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7184. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7185. /* set PCBEEP vol = 0 */
  7186. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7187. { }
  7188. };
  7189. #define alc268_mux_enum_info alc_mux_enum_info
  7190. #define alc268_mux_enum_get alc_mux_enum_get
  7191. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7192. struct snd_ctl_elem_value *ucontrol)
  7193. {
  7194. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7195. struct alc_spec *spec = codec->spec;
  7196. const struct hda_input_mux *imux = spec->input_mux;
  7197. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7198. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7199. hda_nid_t nid = capture_mixers[adc_idx];
  7200. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7201. unsigned int i, idx;
  7202. idx = ucontrol->value.enumerated.item[0];
  7203. if (idx >= imux->num_items)
  7204. idx = imux->num_items - 1;
  7205. if (*cur_val == idx && !codec->in_resume)
  7206. return 0;
  7207. for (i = 0; i < imux->num_items; i++) {
  7208. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7209. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7210. v | (imux->items[i].index << 8));
  7211. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7212. idx );
  7213. }
  7214. *cur_val = idx;
  7215. return 1;
  7216. }
  7217. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7218. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7219. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7220. {
  7221. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7222. /* The multiple "Capture Source" controls confuse alsamixer
  7223. * So call somewhat different..
  7224. * FIXME: the controls appear in the "playback" view!
  7225. */
  7226. /* .name = "Capture Source", */
  7227. .name = "Input Source",
  7228. .count = 1,
  7229. .info = alc268_mux_enum_info,
  7230. .get = alc268_mux_enum_get,
  7231. .put = alc268_mux_enum_put,
  7232. },
  7233. { } /* end */
  7234. };
  7235. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7236. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7237. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7238. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7239. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7240. {
  7241. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7242. /* The multiple "Capture Source" controls confuse alsamixer
  7243. * So call somewhat different..
  7244. * FIXME: the controls appear in the "playback" view!
  7245. */
  7246. /* .name = "Capture Source", */
  7247. .name = "Input Source",
  7248. .count = 2,
  7249. .info = alc268_mux_enum_info,
  7250. .get = alc268_mux_enum_get,
  7251. .put = alc268_mux_enum_put,
  7252. },
  7253. { } /* end */
  7254. };
  7255. static struct hda_input_mux alc268_capture_source = {
  7256. .num_items = 4,
  7257. .items = {
  7258. { "Mic", 0x0 },
  7259. { "Front Mic", 0x1 },
  7260. { "Line", 0x2 },
  7261. { "CD", 0x3 },
  7262. },
  7263. };
  7264. /* create input playback/capture controls for the given pin */
  7265. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7266. const char *ctlname, int idx)
  7267. {
  7268. char name[32];
  7269. int err;
  7270. sprintf(name, "%s Playback Volume", ctlname);
  7271. if (nid == 0x14) {
  7272. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7273. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7274. HDA_OUTPUT));
  7275. if (err < 0)
  7276. return err;
  7277. } else if (nid == 0x15) {
  7278. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7279. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7280. HDA_OUTPUT));
  7281. if (err < 0)
  7282. return err;
  7283. } else
  7284. return -1;
  7285. sprintf(name, "%s Playback Switch", ctlname);
  7286. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7287. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7288. if (err < 0)
  7289. return err;
  7290. return 0;
  7291. }
  7292. /* add playback controls from the parsed DAC table */
  7293. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7294. const struct auto_pin_cfg *cfg)
  7295. {
  7296. hda_nid_t nid;
  7297. int err;
  7298. spec->multiout.num_dacs = 2; /* only use one dac */
  7299. spec->multiout.dac_nids = spec->private_dac_nids;
  7300. spec->multiout.dac_nids[0] = 2;
  7301. spec->multiout.dac_nids[1] = 3;
  7302. nid = cfg->line_out_pins[0];
  7303. if (nid)
  7304. alc268_new_analog_output(spec, nid, "Front", 0);
  7305. nid = cfg->speaker_pins[0];
  7306. if (nid == 0x1d) {
  7307. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7308. "Speaker Playback Volume",
  7309. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7310. if (err < 0)
  7311. return err;
  7312. }
  7313. nid = cfg->hp_pins[0];
  7314. if (nid)
  7315. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7316. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7317. if (nid == 0x16) {
  7318. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7319. "Mono Playback Switch",
  7320. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7321. if (err < 0)
  7322. return err;
  7323. }
  7324. return 0;
  7325. }
  7326. /* create playback/capture controls for input pins */
  7327. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7328. const struct auto_pin_cfg *cfg)
  7329. {
  7330. struct hda_input_mux *imux = &spec->private_imux;
  7331. int i, idx1;
  7332. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7333. switch(cfg->input_pins[i]) {
  7334. case 0x18:
  7335. idx1 = 0; /* Mic 1 */
  7336. break;
  7337. case 0x19:
  7338. idx1 = 1; /* Mic 2 */
  7339. break;
  7340. case 0x1a:
  7341. idx1 = 2; /* Line In */
  7342. break;
  7343. case 0x1c:
  7344. idx1 = 3; /* CD */
  7345. break;
  7346. default:
  7347. continue;
  7348. }
  7349. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7350. imux->items[imux->num_items].index = idx1;
  7351. imux->num_items++;
  7352. }
  7353. return 0;
  7354. }
  7355. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7356. {
  7357. struct alc_spec *spec = codec->spec;
  7358. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7359. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7360. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7361. unsigned int dac_vol1, dac_vol2;
  7362. if (speaker_nid) {
  7363. snd_hda_codec_write(codec, speaker_nid, 0,
  7364. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7365. snd_hda_codec_write(codec, 0x0f, 0,
  7366. AC_VERB_SET_AMP_GAIN_MUTE,
  7367. AMP_IN_UNMUTE(1));
  7368. snd_hda_codec_write(codec, 0x10, 0,
  7369. AC_VERB_SET_AMP_GAIN_MUTE,
  7370. AMP_IN_UNMUTE(1));
  7371. } else {
  7372. snd_hda_codec_write(codec, 0x0f, 0,
  7373. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7374. snd_hda_codec_write(codec, 0x10, 0,
  7375. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7376. }
  7377. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7378. if (line_nid == 0x14)
  7379. dac_vol2 = AMP_OUT_ZERO;
  7380. else if (line_nid == 0x15)
  7381. dac_vol1 = AMP_OUT_ZERO;
  7382. if (hp_nid == 0x14)
  7383. dac_vol2 = AMP_OUT_ZERO;
  7384. else if (hp_nid == 0x15)
  7385. dac_vol1 = AMP_OUT_ZERO;
  7386. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7387. spec->autocfg.line_out_pins[1] != 0x16 ||
  7388. spec->autocfg.line_out_pins[2] != 0x16)
  7389. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7390. snd_hda_codec_write(codec, 0x02, 0,
  7391. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7392. snd_hda_codec_write(codec, 0x03, 0,
  7393. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7394. }
  7395. /* pcm configuration: identiacal with ALC880 */
  7396. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7397. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7398. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7399. /*
  7400. * BIOS auto configuration
  7401. */
  7402. static int alc268_parse_auto_config(struct hda_codec *codec)
  7403. {
  7404. struct alc_spec *spec = codec->spec;
  7405. int err;
  7406. static hda_nid_t alc268_ignore[] = { 0 };
  7407. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7408. alc268_ignore);
  7409. if (err < 0)
  7410. return err;
  7411. if (!spec->autocfg.line_outs)
  7412. return 0; /* can't find valid BIOS pin config */
  7413. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7414. if (err < 0)
  7415. return err;
  7416. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7417. if (err < 0)
  7418. return err;
  7419. spec->multiout.max_channels = 2;
  7420. /* digital only support output */
  7421. if (spec->autocfg.dig_out_pin)
  7422. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7423. if (spec->kctl_alloc)
  7424. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7425. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7426. spec->num_mux_defs = 1;
  7427. spec->input_mux = &spec->private_imux;
  7428. return 1;
  7429. }
  7430. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7431. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7432. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7433. /* init callback for auto-configuration model -- overriding the default init */
  7434. static void alc268_auto_init(struct hda_codec *codec)
  7435. {
  7436. alc268_auto_init_multi_out(codec);
  7437. alc268_auto_init_hp_out(codec);
  7438. alc268_auto_init_mono_speaker_out(codec);
  7439. alc268_auto_init_analog_input(codec);
  7440. }
  7441. /*
  7442. * configuration and preset
  7443. */
  7444. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7445. [ALC268_3ST] = "3stack",
  7446. [ALC268_AUTO] = "auto",
  7447. };
  7448. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7449. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7450. {}
  7451. };
  7452. static struct alc_config_preset alc268_presets[] = {
  7453. [ALC268_3ST] = {
  7454. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7455. .init_verbs = { alc268_base_init_verbs },
  7456. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7457. .dac_nids = alc268_dac_nids,
  7458. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7459. .adc_nids = alc268_adc_nids_alt,
  7460. .hp_nid = 0x03,
  7461. .dig_out_nid = ALC268_DIGOUT_NID,
  7462. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7463. .channel_mode = alc268_modes,
  7464. .input_mux = &alc268_capture_source,
  7465. },
  7466. };
  7467. static int patch_alc268(struct hda_codec *codec)
  7468. {
  7469. struct alc_spec *spec;
  7470. int board_config;
  7471. int err;
  7472. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7473. if (spec == NULL)
  7474. return -ENOMEM;
  7475. codec->spec = spec;
  7476. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7477. alc268_models,
  7478. alc268_cfg_tbl);
  7479. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7480. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7481. "trying auto-probe from BIOS...\n");
  7482. board_config = ALC268_AUTO;
  7483. }
  7484. if (board_config == ALC268_AUTO) {
  7485. /* automatic parse from the BIOS config */
  7486. err = alc268_parse_auto_config(codec);
  7487. if (err < 0) {
  7488. alc_free(codec);
  7489. return err;
  7490. } else if (!err) {
  7491. printk(KERN_INFO
  7492. "hda_codec: Cannot set up configuration "
  7493. "from BIOS. Using base mode...\n");
  7494. board_config = ALC268_3ST;
  7495. }
  7496. }
  7497. if (board_config != ALC268_AUTO)
  7498. setup_preset(spec, &alc268_presets[board_config]);
  7499. spec->stream_name_analog = "ALC268 Analog";
  7500. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7501. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7502. spec->stream_name_digital = "ALC268 Digital";
  7503. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7504. if (board_config == ALC268_AUTO) {
  7505. if (!spec->adc_nids && spec->input_mux) {
  7506. /* check whether NID 0x07 is valid */
  7507. unsigned int wcap = get_wcaps(codec, 0x07);
  7508. /* get type */
  7509. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7510. if (wcap != AC_WID_AUD_IN) {
  7511. spec->adc_nids = alc268_adc_nids_alt;
  7512. spec->num_adc_nids =
  7513. ARRAY_SIZE(alc268_adc_nids_alt);
  7514. spec->mixers[spec->num_mixers] =
  7515. alc268_capture_alt_mixer;
  7516. spec->num_mixers++;
  7517. } else {
  7518. spec->adc_nids = alc268_adc_nids;
  7519. spec->num_adc_nids =
  7520. ARRAY_SIZE(alc268_adc_nids);
  7521. spec->mixers[spec->num_mixers] =
  7522. alc268_capture_mixer;
  7523. spec->num_mixers++;
  7524. }
  7525. }
  7526. }
  7527. codec->patch_ops = alc_patch_ops;
  7528. if (board_config == ALC268_AUTO)
  7529. spec->init_hook = alc268_auto_init;
  7530. return 0;
  7531. }
  7532. /*
  7533. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7534. */
  7535. /*
  7536. * set the path ways for 2 channel output
  7537. * need to set the codec line out and mic 1 pin widgets to inputs
  7538. */
  7539. static struct hda_verb alc861_threestack_ch2_init[] = {
  7540. /* set pin widget 1Ah (line in) for input */
  7541. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7542. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7543. * the vref
  7544. */
  7545. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7546. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7547. #if 0
  7548. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7549. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7550. #endif
  7551. { } /* end */
  7552. };
  7553. /*
  7554. * 6ch mode
  7555. * need to set the codec line out and mic 1 pin widgets to outputs
  7556. */
  7557. static struct hda_verb alc861_threestack_ch6_init[] = {
  7558. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7559. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7560. /* set pin widget 18h (mic1) for output (CLFE)*/
  7561. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7562. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7563. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7564. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7565. #if 0
  7566. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7567. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7568. #endif
  7569. { } /* end */
  7570. };
  7571. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7572. { 2, alc861_threestack_ch2_init },
  7573. { 6, alc861_threestack_ch6_init },
  7574. };
  7575. /* Set mic1 as input and unmute the mixer */
  7576. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7577. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7578. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7579. { } /* end */
  7580. };
  7581. /* Set mic1 as output and mute mixer */
  7582. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7583. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7584. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7585. { } /* end */
  7586. };
  7587. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7588. { 2, alc861_uniwill_m31_ch2_init },
  7589. { 4, alc861_uniwill_m31_ch4_init },
  7590. };
  7591. /* Set mic1 and line-in as input and unmute the mixer */
  7592. static struct hda_verb alc861_asus_ch2_init[] = {
  7593. /* set pin widget 1Ah (line in) for input */
  7594. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7595. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7596. * the vref
  7597. */
  7598. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7599. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7600. #if 0
  7601. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7602. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7603. #endif
  7604. { } /* end */
  7605. };
  7606. /* Set mic1 nad line-in as output and mute mixer */
  7607. static struct hda_verb alc861_asus_ch6_init[] = {
  7608. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7609. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7610. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7611. /* set pin widget 18h (mic1) for output (CLFE)*/
  7612. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7613. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7614. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7615. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7616. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7617. #if 0
  7618. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7619. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7620. #endif
  7621. { } /* end */
  7622. };
  7623. static struct hda_channel_mode alc861_asus_modes[2] = {
  7624. { 2, alc861_asus_ch2_init },
  7625. { 6, alc861_asus_ch6_init },
  7626. };
  7627. /* patch-ALC861 */
  7628. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7629. /* output mixer control */
  7630. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7631. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7632. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7633. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7634. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7635. /*Input mixer control */
  7636. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7637. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7638. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7639. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7640. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7641. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7642. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7643. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7644. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7645. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7646. /* Capture mixer control */
  7647. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7648. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7649. {
  7650. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7651. .name = "Capture Source",
  7652. .count = 1,
  7653. .info = alc_mux_enum_info,
  7654. .get = alc_mux_enum_get,
  7655. .put = alc_mux_enum_put,
  7656. },
  7657. { } /* end */
  7658. };
  7659. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7660. /* output mixer control */
  7661. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7662. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7663. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7664. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7665. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7666. /* Input mixer control */
  7667. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7668. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7669. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7670. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7671. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7672. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7673. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7674. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7675. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7676. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7677. /* Capture mixer control */
  7678. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7679. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7680. {
  7681. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7682. .name = "Capture Source",
  7683. .count = 1,
  7684. .info = alc_mux_enum_info,
  7685. .get = alc_mux_enum_get,
  7686. .put = alc_mux_enum_put,
  7687. },
  7688. {
  7689. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7690. .name = "Channel Mode",
  7691. .info = alc_ch_mode_info,
  7692. .get = alc_ch_mode_get,
  7693. .put = alc_ch_mode_put,
  7694. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7695. },
  7696. { } /* end */
  7697. };
  7698. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7699. /* output mixer control */
  7700. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7701. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7702. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7703. /*Capture mixer control */
  7704. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7705. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7706. {
  7707. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7708. .name = "Capture Source",
  7709. .count = 1,
  7710. .info = alc_mux_enum_info,
  7711. .get = alc_mux_enum_get,
  7712. .put = alc_mux_enum_put,
  7713. },
  7714. { } /* end */
  7715. };
  7716. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7717. /* output mixer control */
  7718. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7719. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7720. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7721. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7722. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7723. /* Input mixer control */
  7724. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7725. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7726. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7727. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7728. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7729. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7731. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7732. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7733. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7734. /* Capture mixer control */
  7735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7737. {
  7738. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7739. .name = "Capture Source",
  7740. .count = 1,
  7741. .info = alc_mux_enum_info,
  7742. .get = alc_mux_enum_get,
  7743. .put = alc_mux_enum_put,
  7744. },
  7745. {
  7746. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7747. .name = "Channel Mode",
  7748. .info = alc_ch_mode_info,
  7749. .get = alc_ch_mode_get,
  7750. .put = alc_ch_mode_put,
  7751. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7752. },
  7753. { } /* end */
  7754. };
  7755. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7756. /* output mixer control */
  7757. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7758. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7759. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7760. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7761. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7762. /* Input mixer control */
  7763. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7764. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7765. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7766. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7767. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7768. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7769. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7770. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7771. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7772. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7773. /* Capture mixer control */
  7774. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7775. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7776. {
  7777. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7778. .name = "Capture Source",
  7779. .count = 1,
  7780. .info = alc_mux_enum_info,
  7781. .get = alc_mux_enum_get,
  7782. .put = alc_mux_enum_put,
  7783. },
  7784. {
  7785. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7786. .name = "Channel Mode",
  7787. .info = alc_ch_mode_info,
  7788. .get = alc_ch_mode_get,
  7789. .put = alc_ch_mode_put,
  7790. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7791. },
  7792. { }
  7793. };
  7794. /* additional mixer */
  7795. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7796. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7797. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7798. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7799. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7800. { }
  7801. };
  7802. /*
  7803. * generic initialization of ADC, input mixers and output mixers
  7804. */
  7805. static struct hda_verb alc861_base_init_verbs[] = {
  7806. /*
  7807. * Unmute ADC0 and set the default input to mic-in
  7808. */
  7809. /* port-A for surround (rear panel) */
  7810. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7811. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7812. /* port-B for mic-in (rear panel) with vref */
  7813. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7814. /* port-C for line-in (rear panel) */
  7815. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7816. /* port-D for Front */
  7817. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7818. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7819. /* port-E for HP out (front panel) */
  7820. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7821. /* route front PCM to HP */
  7822. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7823. /* port-F for mic-in (front panel) with vref */
  7824. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7825. /* port-G for CLFE (rear panel) */
  7826. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7827. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7828. /* port-H for side (rear panel) */
  7829. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7830. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7831. /* CD-in */
  7832. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7833. /* route front mic to ADC1*/
  7834. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7836. /* Unmute DAC0~3 & spdif out*/
  7837. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7838. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7839. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7840. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7841. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7842. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7843. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7844. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7845. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7846. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7847. /* Unmute Stereo Mixer 15 */
  7848. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7849. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7850. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7851. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7852. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7853. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7854. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7855. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7856. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7857. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7858. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7859. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7860. /* hp used DAC 3 (Front) */
  7861. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7862. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7863. { }
  7864. };
  7865. static struct hda_verb alc861_threestack_init_verbs[] = {
  7866. /*
  7867. * Unmute ADC0 and set the default input to mic-in
  7868. */
  7869. /* port-A for surround (rear panel) */
  7870. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7871. /* port-B for mic-in (rear panel) with vref */
  7872. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7873. /* port-C for line-in (rear panel) */
  7874. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7875. /* port-D for Front */
  7876. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7877. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7878. /* port-E for HP out (front panel) */
  7879. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7880. /* route front PCM to HP */
  7881. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7882. /* port-F for mic-in (front panel) with vref */
  7883. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7884. /* port-G for CLFE (rear panel) */
  7885. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7886. /* port-H for side (rear panel) */
  7887. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7888. /* CD-in */
  7889. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7890. /* route front mic to ADC1*/
  7891. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7892. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7893. /* Unmute DAC0~3 & spdif out*/
  7894. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7895. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7896. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7897. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7898. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7899. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7900. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7901. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7902. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7903. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7904. /* Unmute Stereo Mixer 15 */
  7905. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7906. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7908. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7909. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7910. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7911. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7912. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7913. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7914. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7915. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7916. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7917. /* hp used DAC 3 (Front) */
  7918. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7919. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7920. { }
  7921. };
  7922. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7923. /*
  7924. * Unmute ADC0 and set the default input to mic-in
  7925. */
  7926. /* port-A for surround (rear panel) */
  7927. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7928. /* port-B for mic-in (rear panel) with vref */
  7929. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7930. /* port-C for line-in (rear panel) */
  7931. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7932. /* port-D for Front */
  7933. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7934. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7935. /* port-E for HP out (front panel) */
  7936. /* this has to be set to VREF80 */
  7937. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7938. /* route front PCM to HP */
  7939. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7940. /* port-F for mic-in (front panel) with vref */
  7941. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7942. /* port-G for CLFE (rear panel) */
  7943. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7944. /* port-H for side (rear panel) */
  7945. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7946. /* CD-in */
  7947. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7948. /* route front mic to ADC1*/
  7949. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7950. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7951. /* Unmute DAC0~3 & spdif out*/
  7952. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7953. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7954. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7955. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7956. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7957. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7958. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7959. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7960. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7961. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7962. /* Unmute Stereo Mixer 15 */
  7963. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7964. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7965. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7966. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7967. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7968. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7969. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7970. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7971. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7972. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7973. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7974. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7975. /* hp used DAC 3 (Front) */
  7976. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7977. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7978. { }
  7979. };
  7980. static struct hda_verb alc861_asus_init_verbs[] = {
  7981. /*
  7982. * Unmute ADC0 and set the default input to mic-in
  7983. */
  7984. /* port-A for surround (rear panel)
  7985. * according to codec#0 this is the HP jack
  7986. */
  7987. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7988. /* route front PCM to HP */
  7989. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7990. /* port-B for mic-in (rear panel) with vref */
  7991. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7992. /* port-C for line-in (rear panel) */
  7993. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7994. /* port-D for Front */
  7995. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7996. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7997. /* port-E for HP out (front panel) */
  7998. /* this has to be set to VREF80 */
  7999. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8000. /* route front PCM to HP */
  8001. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8002. /* port-F for mic-in (front panel) with vref */
  8003. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8004. /* port-G for CLFE (rear panel) */
  8005. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8006. /* port-H for side (rear panel) */
  8007. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8008. /* CD-in */
  8009. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8010. /* route front mic to ADC1*/
  8011. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8012. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8013. /* Unmute DAC0~3 & spdif out*/
  8014. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8015. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8016. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8017. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8018. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8019. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8020. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8021. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8022. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8023. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8024. /* Unmute Stereo Mixer 15 */
  8025. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8026. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8027. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8028. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8029. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8030. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8031. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8032. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8033. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8034. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8035. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8036. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8037. /* hp used DAC 3 (Front) */
  8038. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8039. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8040. { }
  8041. };
  8042. /* additional init verbs for ASUS laptops */
  8043. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8044. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8045. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8046. { }
  8047. };
  8048. /*
  8049. * generic initialization of ADC, input mixers and output mixers
  8050. */
  8051. static struct hda_verb alc861_auto_init_verbs[] = {
  8052. /*
  8053. * Unmute ADC0 and set the default input to mic-in
  8054. */
  8055. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8056. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8057. /* Unmute DAC0~3 & spdif out*/
  8058. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8059. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8060. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8061. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8063. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8064. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8065. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8066. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8067. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8068. /* Unmute Stereo Mixer 15 */
  8069. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8070. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8071. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8072. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8073. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8074. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8075. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8076. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8077. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8078. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8079. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8080. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8081. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8082. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8083. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8084. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8085. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8086. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8087. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8088. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8089. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8090. { }
  8091. };
  8092. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8093. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8094. { }
  8095. };
  8096. /* toggle speaker-output according to the hp-jack state */
  8097. static void alc861_toshiba_automute(struct hda_codec *codec)
  8098. {
  8099. unsigned int present;
  8100. present = snd_hda_codec_read(codec, 0x0f, 0,
  8101. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8102. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8103. 0x80, present ? 0x80 : 0);
  8104. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8105. 0x80, present ? 0x80 : 0);
  8106. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8107. 0x80, present ? 0 : 0x80);
  8108. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8109. 0x80, present ? 0 : 0x80);
  8110. }
  8111. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8112. unsigned int res)
  8113. {
  8114. if ((res >> 26) == ALC880_HP_EVENT)
  8115. alc861_toshiba_automute(codec);
  8116. }
  8117. /* pcm configuration: identiacal with ALC880 */
  8118. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8119. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8120. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8121. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8122. #define ALC861_DIGOUT_NID 0x07
  8123. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8124. { 8, NULL }
  8125. };
  8126. static hda_nid_t alc861_dac_nids[4] = {
  8127. /* front, surround, clfe, side */
  8128. 0x03, 0x06, 0x05, 0x04
  8129. };
  8130. static hda_nid_t alc660_dac_nids[3] = {
  8131. /* front, clfe, surround */
  8132. 0x03, 0x05, 0x06
  8133. };
  8134. static hda_nid_t alc861_adc_nids[1] = {
  8135. /* ADC0-2 */
  8136. 0x08,
  8137. };
  8138. static struct hda_input_mux alc861_capture_source = {
  8139. .num_items = 5,
  8140. .items = {
  8141. { "Mic", 0x0 },
  8142. { "Front Mic", 0x3 },
  8143. { "Line", 0x1 },
  8144. { "CD", 0x4 },
  8145. { "Mixer", 0x5 },
  8146. },
  8147. };
  8148. /* fill in the dac_nids table from the parsed pin configuration */
  8149. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8150. const struct auto_pin_cfg *cfg)
  8151. {
  8152. int i;
  8153. hda_nid_t nid;
  8154. spec->multiout.dac_nids = spec->private_dac_nids;
  8155. for (i = 0; i < cfg->line_outs; i++) {
  8156. nid = cfg->line_out_pins[i];
  8157. if (nid) {
  8158. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8159. continue;
  8160. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8161. }
  8162. }
  8163. spec->multiout.num_dacs = cfg->line_outs;
  8164. return 0;
  8165. }
  8166. /* add playback controls from the parsed DAC table */
  8167. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8168. const struct auto_pin_cfg *cfg)
  8169. {
  8170. char name[32];
  8171. static const char *chname[4] = {
  8172. "Front", "Surround", NULL /*CLFE*/, "Side"
  8173. };
  8174. hda_nid_t nid;
  8175. int i, idx, err;
  8176. for (i = 0; i < cfg->line_outs; i++) {
  8177. nid = spec->multiout.dac_nids[i];
  8178. if (!nid)
  8179. continue;
  8180. if (nid == 0x05) {
  8181. /* Center/LFE */
  8182. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8183. "Center Playback Switch",
  8184. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8185. HDA_OUTPUT));
  8186. if (err < 0)
  8187. return err;
  8188. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8189. "LFE Playback Switch",
  8190. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8191. HDA_OUTPUT));
  8192. if (err < 0)
  8193. return err;
  8194. } else {
  8195. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8196. idx++)
  8197. if (nid == alc861_dac_nids[idx])
  8198. break;
  8199. sprintf(name, "%s Playback Switch", chname[idx]);
  8200. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8201. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8202. HDA_OUTPUT));
  8203. if (err < 0)
  8204. return err;
  8205. }
  8206. }
  8207. return 0;
  8208. }
  8209. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8210. {
  8211. int err;
  8212. hda_nid_t nid;
  8213. if (!pin)
  8214. return 0;
  8215. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8216. nid = 0x03;
  8217. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8218. "Headphone Playback Switch",
  8219. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8220. if (err < 0)
  8221. return err;
  8222. spec->multiout.hp_nid = nid;
  8223. }
  8224. return 0;
  8225. }
  8226. /* create playback/capture controls for input pins */
  8227. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8228. const struct auto_pin_cfg *cfg)
  8229. {
  8230. struct hda_input_mux *imux = &spec->private_imux;
  8231. int i, err, idx, idx1;
  8232. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8233. switch (cfg->input_pins[i]) {
  8234. case 0x0c:
  8235. idx1 = 1;
  8236. idx = 2; /* Line In */
  8237. break;
  8238. case 0x0f:
  8239. idx1 = 2;
  8240. idx = 2; /* Line In */
  8241. break;
  8242. case 0x0d:
  8243. idx1 = 0;
  8244. idx = 1; /* Mic In */
  8245. break;
  8246. case 0x10:
  8247. idx1 = 3;
  8248. idx = 1; /* Mic In */
  8249. break;
  8250. case 0x11:
  8251. idx1 = 4;
  8252. idx = 0; /* CD */
  8253. break;
  8254. default:
  8255. continue;
  8256. }
  8257. err = new_analog_input(spec, cfg->input_pins[i],
  8258. auto_pin_cfg_labels[i], idx, 0x15);
  8259. if (err < 0)
  8260. return err;
  8261. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8262. imux->items[imux->num_items].index = idx1;
  8263. imux->num_items++;
  8264. }
  8265. return 0;
  8266. }
  8267. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8268. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8269. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8270. {
  8271. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8272. /* The multiple "Capture Source" controls confuse alsamixer
  8273. * So call somewhat different..
  8274. *FIXME: the controls appear in the "playback" view!
  8275. */
  8276. /* .name = "Capture Source", */
  8277. .name = "Input Source",
  8278. .count = 1,
  8279. .info = alc_mux_enum_info,
  8280. .get = alc_mux_enum_get,
  8281. .put = alc_mux_enum_put,
  8282. },
  8283. { } /* end */
  8284. };
  8285. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8286. hda_nid_t nid,
  8287. int pin_type, int dac_idx)
  8288. {
  8289. /* set as output */
  8290. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8291. pin_type);
  8292. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8293. AMP_OUT_UNMUTE);
  8294. }
  8295. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8296. {
  8297. struct alc_spec *spec = codec->spec;
  8298. int i;
  8299. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8300. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8301. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8302. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8303. if (nid)
  8304. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8305. spec->multiout.dac_nids[i]);
  8306. }
  8307. }
  8308. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8309. {
  8310. struct alc_spec *spec = codec->spec;
  8311. hda_nid_t pin;
  8312. pin = spec->autocfg.hp_pins[0];
  8313. if (pin) /* connect to front */
  8314. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8315. spec->multiout.dac_nids[0]);
  8316. }
  8317. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8318. {
  8319. struct alc_spec *spec = codec->spec;
  8320. int i;
  8321. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8322. hda_nid_t nid = spec->autocfg.input_pins[i];
  8323. if (nid >= 0x0c && nid <= 0x11) {
  8324. snd_hda_codec_write(codec, nid, 0,
  8325. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8326. i <= AUTO_PIN_FRONT_MIC ?
  8327. PIN_VREF80 : PIN_IN);
  8328. }
  8329. }
  8330. }
  8331. /* parse the BIOS configuration and set up the alc_spec */
  8332. /* return 1 if successful, 0 if the proper config is not found,
  8333. * or a negative error code
  8334. */
  8335. static int alc861_parse_auto_config(struct hda_codec *codec)
  8336. {
  8337. struct alc_spec *spec = codec->spec;
  8338. int err;
  8339. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8340. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8341. alc861_ignore);
  8342. if (err < 0)
  8343. return err;
  8344. if (!spec->autocfg.line_outs)
  8345. return 0; /* can't find valid BIOS pin config */
  8346. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8347. if (err < 0)
  8348. return err;
  8349. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8350. if (err < 0)
  8351. return err;
  8352. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8353. if (err < 0)
  8354. return err;
  8355. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8356. if (err < 0)
  8357. return err;
  8358. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8359. if (spec->autocfg.dig_out_pin)
  8360. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8361. if (spec->kctl_alloc)
  8362. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8363. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8364. spec->num_mux_defs = 1;
  8365. spec->input_mux = &spec->private_imux;
  8366. spec->adc_nids = alc861_adc_nids;
  8367. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8368. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8369. spec->num_mixers++;
  8370. return 1;
  8371. }
  8372. /* additional initialization for auto-configuration model */
  8373. static void alc861_auto_init(struct hda_codec *codec)
  8374. {
  8375. alc861_auto_init_multi_out(codec);
  8376. alc861_auto_init_hp_out(codec);
  8377. alc861_auto_init_analog_input(codec);
  8378. }
  8379. /*
  8380. * configuration and preset
  8381. */
  8382. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8383. [ALC861_3ST] = "3stack",
  8384. [ALC660_3ST] = "3stack-660",
  8385. [ALC861_3ST_DIG] = "3stack-dig",
  8386. [ALC861_6ST_DIG] = "6stack-dig",
  8387. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8388. [ALC861_TOSHIBA] = "toshiba",
  8389. [ALC861_ASUS] = "asus",
  8390. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8391. [ALC861_AUTO] = "auto",
  8392. };
  8393. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8394. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8395. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8396. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8397. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8398. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8399. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8400. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  8401. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8402. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8403. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8404. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8405. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8406. {}
  8407. };
  8408. static struct alc_config_preset alc861_presets[] = {
  8409. [ALC861_3ST] = {
  8410. .mixers = { alc861_3ST_mixer },
  8411. .init_verbs = { alc861_threestack_init_verbs },
  8412. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8413. .dac_nids = alc861_dac_nids,
  8414. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8415. .channel_mode = alc861_threestack_modes,
  8416. .need_dac_fix = 1,
  8417. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8418. .adc_nids = alc861_adc_nids,
  8419. .input_mux = &alc861_capture_source,
  8420. },
  8421. [ALC861_3ST_DIG] = {
  8422. .mixers = { alc861_base_mixer },
  8423. .init_verbs = { alc861_threestack_init_verbs },
  8424. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8425. .dac_nids = alc861_dac_nids,
  8426. .dig_out_nid = ALC861_DIGOUT_NID,
  8427. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8428. .channel_mode = alc861_threestack_modes,
  8429. .need_dac_fix = 1,
  8430. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8431. .adc_nids = alc861_adc_nids,
  8432. .input_mux = &alc861_capture_source,
  8433. },
  8434. [ALC861_6ST_DIG] = {
  8435. .mixers = { alc861_base_mixer },
  8436. .init_verbs = { alc861_base_init_verbs },
  8437. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8438. .dac_nids = alc861_dac_nids,
  8439. .dig_out_nid = ALC861_DIGOUT_NID,
  8440. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8441. .channel_mode = alc861_8ch_modes,
  8442. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8443. .adc_nids = alc861_adc_nids,
  8444. .input_mux = &alc861_capture_source,
  8445. },
  8446. [ALC660_3ST] = {
  8447. .mixers = { alc861_3ST_mixer },
  8448. .init_verbs = { alc861_threestack_init_verbs },
  8449. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8450. .dac_nids = alc660_dac_nids,
  8451. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8452. .channel_mode = alc861_threestack_modes,
  8453. .need_dac_fix = 1,
  8454. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8455. .adc_nids = alc861_adc_nids,
  8456. .input_mux = &alc861_capture_source,
  8457. },
  8458. [ALC861_UNIWILL_M31] = {
  8459. .mixers = { alc861_uniwill_m31_mixer },
  8460. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8461. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8462. .dac_nids = alc861_dac_nids,
  8463. .dig_out_nid = ALC861_DIGOUT_NID,
  8464. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8465. .channel_mode = alc861_uniwill_m31_modes,
  8466. .need_dac_fix = 1,
  8467. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8468. .adc_nids = alc861_adc_nids,
  8469. .input_mux = &alc861_capture_source,
  8470. },
  8471. [ALC861_TOSHIBA] = {
  8472. .mixers = { alc861_toshiba_mixer },
  8473. .init_verbs = { alc861_base_init_verbs,
  8474. alc861_toshiba_init_verbs },
  8475. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8476. .dac_nids = alc861_dac_nids,
  8477. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8478. .channel_mode = alc883_3ST_2ch_modes,
  8479. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8480. .adc_nids = alc861_adc_nids,
  8481. .input_mux = &alc861_capture_source,
  8482. .unsol_event = alc861_toshiba_unsol_event,
  8483. .init_hook = alc861_toshiba_automute,
  8484. },
  8485. [ALC861_ASUS] = {
  8486. .mixers = { alc861_asus_mixer },
  8487. .init_verbs = { alc861_asus_init_verbs },
  8488. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8489. .dac_nids = alc861_dac_nids,
  8490. .dig_out_nid = ALC861_DIGOUT_NID,
  8491. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8492. .channel_mode = alc861_asus_modes,
  8493. .need_dac_fix = 1,
  8494. .hp_nid = 0x06,
  8495. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8496. .adc_nids = alc861_adc_nids,
  8497. .input_mux = &alc861_capture_source,
  8498. },
  8499. [ALC861_ASUS_LAPTOP] = {
  8500. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8501. .init_verbs = { alc861_asus_init_verbs,
  8502. alc861_asus_laptop_init_verbs },
  8503. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8504. .dac_nids = alc861_dac_nids,
  8505. .dig_out_nid = ALC861_DIGOUT_NID,
  8506. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8507. .channel_mode = alc883_3ST_2ch_modes,
  8508. .need_dac_fix = 1,
  8509. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8510. .adc_nids = alc861_adc_nids,
  8511. .input_mux = &alc861_capture_source,
  8512. },
  8513. };
  8514. static int patch_alc861(struct hda_codec *codec)
  8515. {
  8516. struct alc_spec *spec;
  8517. int board_config;
  8518. int err;
  8519. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8520. if (spec == NULL)
  8521. return -ENOMEM;
  8522. codec->spec = spec;
  8523. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8524. alc861_models,
  8525. alc861_cfg_tbl);
  8526. if (board_config < 0) {
  8527. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8528. "trying auto-probe from BIOS...\n");
  8529. board_config = ALC861_AUTO;
  8530. }
  8531. if (board_config == ALC861_AUTO) {
  8532. /* automatic parse from the BIOS config */
  8533. err = alc861_parse_auto_config(codec);
  8534. if (err < 0) {
  8535. alc_free(codec);
  8536. return err;
  8537. } else if (!err) {
  8538. printk(KERN_INFO
  8539. "hda_codec: Cannot set up configuration "
  8540. "from BIOS. Using base mode...\n");
  8541. board_config = ALC861_3ST_DIG;
  8542. }
  8543. }
  8544. if (board_config != ALC861_AUTO)
  8545. setup_preset(spec, &alc861_presets[board_config]);
  8546. spec->stream_name_analog = "ALC861 Analog";
  8547. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8548. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8549. spec->stream_name_digital = "ALC861 Digital";
  8550. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8551. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8552. codec->patch_ops = alc_patch_ops;
  8553. if (board_config == ALC861_AUTO)
  8554. spec->init_hook = alc861_auto_init;
  8555. return 0;
  8556. }
  8557. /*
  8558. * ALC861-VD support
  8559. *
  8560. * Based on ALC882
  8561. *
  8562. * In addition, an independent DAC
  8563. */
  8564. #define ALC861VD_DIGOUT_NID 0x06
  8565. static hda_nid_t alc861vd_dac_nids[4] = {
  8566. /* front, surr, clfe, side surr */
  8567. 0x02, 0x03, 0x04, 0x05
  8568. };
  8569. /* dac_nids for ALC660vd are in a different order - according to
  8570. * Realtek's driver.
  8571. * This should probably tesult in a different mixer for 6stack models
  8572. * of ALC660vd codecs, but for now there is only 3stack mixer
  8573. * - and it is the same as in 861vd.
  8574. * adc_nids in ALC660vd are (is) the same as in 861vd
  8575. */
  8576. static hda_nid_t alc660vd_dac_nids[3] = {
  8577. /* front, rear, clfe, rear_surr */
  8578. 0x02, 0x04, 0x03
  8579. };
  8580. static hda_nid_t alc861vd_adc_nids[1] = {
  8581. /* ADC0 */
  8582. 0x09,
  8583. };
  8584. /* input MUX */
  8585. /* FIXME: should be a matrix-type input source selection */
  8586. static struct hda_input_mux alc861vd_capture_source = {
  8587. .num_items = 4,
  8588. .items = {
  8589. { "Mic", 0x0 },
  8590. { "Front Mic", 0x1 },
  8591. { "Line", 0x2 },
  8592. { "CD", 0x4 },
  8593. },
  8594. };
  8595. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8596. .num_items = 3,
  8597. .items = {
  8598. { "Front Mic", 0x0 },
  8599. { "ATAPI Mic", 0x1 },
  8600. { "Line In", 0x5 },
  8601. },
  8602. };
  8603. #define alc861vd_mux_enum_info alc_mux_enum_info
  8604. #define alc861vd_mux_enum_get alc_mux_enum_get
  8605. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8606. struct snd_ctl_elem_value *ucontrol)
  8607. {
  8608. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8609. struct alc_spec *spec = codec->spec;
  8610. const struct hda_input_mux *imux = spec->input_mux;
  8611. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8612. static hda_nid_t capture_mixers[1] = { 0x22 };
  8613. hda_nid_t nid = capture_mixers[adc_idx];
  8614. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8615. unsigned int i, idx;
  8616. idx = ucontrol->value.enumerated.item[0];
  8617. if (idx >= imux->num_items)
  8618. idx = imux->num_items - 1;
  8619. if (*cur_val == idx && !codec->in_resume)
  8620. return 0;
  8621. for (i = 0; i < imux->num_items; i++) {
  8622. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8623. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8624. v | (imux->items[i].index << 8));
  8625. }
  8626. *cur_val = idx;
  8627. return 1;
  8628. }
  8629. /*
  8630. * 2ch mode
  8631. */
  8632. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8633. { 2, NULL }
  8634. };
  8635. /*
  8636. * 6ch mode
  8637. */
  8638. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8639. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8640. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8641. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8642. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8643. { } /* end */
  8644. };
  8645. /*
  8646. * 8ch mode
  8647. */
  8648. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8649. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8650. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8651. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8652. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8653. { } /* end */
  8654. };
  8655. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8656. { 6, alc861vd_6stack_ch6_init },
  8657. { 8, alc861vd_6stack_ch8_init },
  8658. };
  8659. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8660. {
  8661. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8662. .name = "Channel Mode",
  8663. .info = alc_ch_mode_info,
  8664. .get = alc_ch_mode_get,
  8665. .put = alc_ch_mode_put,
  8666. },
  8667. { } /* end */
  8668. };
  8669. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8670. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8671. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8672. {
  8673. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8674. /* The multiple "Capture Source" controls confuse alsamixer
  8675. * So call somewhat different..
  8676. *FIXME: the controls appear in the "playback" view!
  8677. */
  8678. /* .name = "Capture Source", */
  8679. .name = "Input Source",
  8680. .count = 1,
  8681. .info = alc861vd_mux_enum_info,
  8682. .get = alc861vd_mux_enum_get,
  8683. .put = alc861vd_mux_enum_put,
  8684. },
  8685. { } /* end */
  8686. };
  8687. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8688. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8689. */
  8690. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8691. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8692. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8693. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8694. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8695. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8696. HDA_OUTPUT),
  8697. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8698. HDA_OUTPUT),
  8699. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8700. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8701. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8702. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8703. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8704. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8705. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8706. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8707. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8708. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8709. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8710. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8711. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8712. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8713. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8714. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8715. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8716. { } /* end */
  8717. };
  8718. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8719. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8720. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8721. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8722. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8724. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8725. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8728. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8729. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8730. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8731. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8732. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8733. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8734. { } /* end */
  8735. };
  8736. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8737. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8738. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8739. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8740. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8741. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8742. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8743. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8744. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8745. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8746. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8747. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8748. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8749. { } /* end */
  8750. };
  8751. /* Pin assignment: Front=0x14, HP = 0x15,
  8752. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8753. */
  8754. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8755. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8756. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8757. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8758. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8759. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8760. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8761. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8762. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8763. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8764. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8765. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8766. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8767. {
  8768. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8769. /* .name = "Capture Source", */
  8770. .name = "Input Source",
  8771. .count = 1,
  8772. .info = alc882_mux_enum_info,
  8773. .get = alc882_mux_enum_get,
  8774. .put = alc882_mux_enum_put,
  8775. },
  8776. { } /* end */
  8777. };
  8778. /*
  8779. * generic initialization of ADC, input mixers and output mixers
  8780. */
  8781. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8782. /*
  8783. * Unmute ADC0 and set the default input to mic-in
  8784. */
  8785. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8786. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8787. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8788. * the analog-loopback mixer widget
  8789. */
  8790. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8791. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8793. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8795. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8796. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8797. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8798. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8799. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8800. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8801. /*
  8802. * Set up output mixers (0x02 - 0x05)
  8803. */
  8804. /* set vol=0 to output mixers */
  8805. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8806. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8807. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8808. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8809. /* set up input amps for analog loopback */
  8810. /* Amp Indices: DAC = 0, mixer = 1 */
  8811. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8812. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8813. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8814. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8815. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8816. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8817. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8818. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8819. { }
  8820. };
  8821. /*
  8822. * 3-stack pin configuration:
  8823. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8824. */
  8825. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8826. /*
  8827. * Set pin mode and muting
  8828. */
  8829. /* set front pin widgets 0x14 for output */
  8830. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8831. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8832. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8833. /* Mic (rear) pin: input vref at 80% */
  8834. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8835. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8836. /* Front Mic pin: input vref at 80% */
  8837. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8838. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8839. /* Line In pin: input */
  8840. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8841. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8842. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8843. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8844. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8845. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8846. /* CD pin widget for input */
  8847. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8848. { }
  8849. };
  8850. /*
  8851. * 6-stack pin configuration:
  8852. */
  8853. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8854. /*
  8855. * Set pin mode and muting
  8856. */
  8857. /* set front pin widgets 0x14 for output */
  8858. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8859. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8860. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8861. /* Rear Pin: output 1 (0x0d) */
  8862. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8863. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8864. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8865. /* CLFE Pin: output 2 (0x0e) */
  8866. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8867. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8868. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8869. /* Side Pin: output 3 (0x0f) */
  8870. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8871. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8872. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8873. /* Mic (rear) pin: input vref at 80% */
  8874. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8875. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8876. /* Front Mic pin: input vref at 80% */
  8877. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8878. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8879. /* Line In pin: input */
  8880. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8881. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8882. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8883. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8884. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8885. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8886. /* CD pin widget for input */
  8887. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8888. { }
  8889. };
  8890. static struct hda_verb alc861vd_eapd_verbs[] = {
  8891. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8892. { }
  8893. };
  8894. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8896. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8897. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8898. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8899. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8900. {}
  8901. };
  8902. /* toggle speaker-output according to the hp-jack state */
  8903. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8904. {
  8905. unsigned int present;
  8906. unsigned char bits;
  8907. present = snd_hda_codec_read(codec, 0x1b, 0,
  8908. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8909. bits = present ? 0x80 : 0;
  8910. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8911. 0x80, bits);
  8912. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8913. 0x80, bits);
  8914. }
  8915. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8916. {
  8917. unsigned int present;
  8918. unsigned char bits;
  8919. present = snd_hda_codec_read(codec, 0x18, 0,
  8920. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8921. bits = present ? 0x80 : 0;
  8922. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8923. 0x80, bits);
  8924. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8925. 0x80, bits);
  8926. }
  8927. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8928. {
  8929. alc861vd_lenovo_hp_automute(codec);
  8930. alc861vd_lenovo_mic_automute(codec);
  8931. }
  8932. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8933. unsigned int res)
  8934. {
  8935. switch (res >> 26) {
  8936. case ALC880_HP_EVENT:
  8937. alc861vd_lenovo_hp_automute(codec);
  8938. break;
  8939. case ALC880_MIC_EVENT:
  8940. alc861vd_lenovo_mic_automute(codec);
  8941. break;
  8942. }
  8943. }
  8944. static struct hda_verb alc861vd_dallas_verbs[] = {
  8945. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8946. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8947. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8948. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8949. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8950. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8951. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8952. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8953. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8954. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8955. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8956. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8957. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8958. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8959. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8960. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8961. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8962. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8963. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8964. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8965. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8966. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8967. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8968. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8969. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8970. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8971. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8972. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8973. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8974. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8975. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8976. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8977. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8978. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8979. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8980. { } /* end */
  8981. };
  8982. /* toggle speaker-output according to the hp-jack state */
  8983. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8984. {
  8985. unsigned int present;
  8986. present = snd_hda_codec_read(codec, 0x15, 0,
  8987. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8988. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8989. 0x80, present ? 0x80 : 0);
  8990. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8991. 0x80, present ? 0x80 : 0);
  8992. }
  8993. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8994. {
  8995. if ((res >> 26) == ALC880_HP_EVENT)
  8996. alc861vd_dallas_automute(codec);
  8997. }
  8998. /* pcm configuration: identiacal with ALC880 */
  8999. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9000. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9001. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9002. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9003. /*
  9004. * configuration and preset
  9005. */
  9006. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9007. [ALC660VD_3ST] = "3stack-660",
  9008. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9009. [ALC861VD_3ST] = "3stack",
  9010. [ALC861VD_3ST_DIG] = "3stack-digout",
  9011. [ALC861VD_6ST_DIG] = "6stack-digout",
  9012. [ALC861VD_LENOVO] = "lenovo",
  9013. [ALC861VD_DALLAS] = "dallas",
  9014. [ALC861VD_AUTO] = "auto",
  9015. };
  9016. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9017. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9018. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9019. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9020. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9021. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9022. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9023. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9024. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9025. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9026. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9027. {}
  9028. };
  9029. static struct alc_config_preset alc861vd_presets[] = {
  9030. [ALC660VD_3ST] = {
  9031. .mixers = { alc861vd_3st_mixer },
  9032. .init_verbs = { alc861vd_volume_init_verbs,
  9033. alc861vd_3stack_init_verbs },
  9034. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9035. .dac_nids = alc660vd_dac_nids,
  9036. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9037. .adc_nids = alc861vd_adc_nids,
  9038. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9039. .channel_mode = alc861vd_3stack_2ch_modes,
  9040. .input_mux = &alc861vd_capture_source,
  9041. },
  9042. [ALC660VD_3ST_DIG] = {
  9043. .mixers = { alc861vd_3st_mixer },
  9044. .init_verbs = { alc861vd_volume_init_verbs,
  9045. alc861vd_3stack_init_verbs },
  9046. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9047. .dac_nids = alc660vd_dac_nids,
  9048. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9049. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9050. .adc_nids = alc861vd_adc_nids,
  9051. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9052. .channel_mode = alc861vd_3stack_2ch_modes,
  9053. .input_mux = &alc861vd_capture_source,
  9054. },
  9055. [ALC861VD_3ST] = {
  9056. .mixers = { alc861vd_3st_mixer },
  9057. .init_verbs = { alc861vd_volume_init_verbs,
  9058. alc861vd_3stack_init_verbs },
  9059. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9060. .dac_nids = alc861vd_dac_nids,
  9061. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9062. .channel_mode = alc861vd_3stack_2ch_modes,
  9063. .input_mux = &alc861vd_capture_source,
  9064. },
  9065. [ALC861VD_3ST_DIG] = {
  9066. .mixers = { alc861vd_3st_mixer },
  9067. .init_verbs = { alc861vd_volume_init_verbs,
  9068. alc861vd_3stack_init_verbs },
  9069. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9070. .dac_nids = alc861vd_dac_nids,
  9071. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9072. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9073. .channel_mode = alc861vd_3stack_2ch_modes,
  9074. .input_mux = &alc861vd_capture_source,
  9075. },
  9076. [ALC861VD_6ST_DIG] = {
  9077. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9078. .init_verbs = { alc861vd_volume_init_verbs,
  9079. alc861vd_6stack_init_verbs },
  9080. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9081. .dac_nids = alc861vd_dac_nids,
  9082. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9083. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9084. .channel_mode = alc861vd_6stack_modes,
  9085. .input_mux = &alc861vd_capture_source,
  9086. },
  9087. [ALC861VD_LENOVO] = {
  9088. .mixers = { alc861vd_lenovo_mixer },
  9089. .init_verbs = { alc861vd_volume_init_verbs,
  9090. alc861vd_3stack_init_verbs,
  9091. alc861vd_eapd_verbs,
  9092. alc861vd_lenovo_unsol_verbs },
  9093. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9094. .dac_nids = alc660vd_dac_nids,
  9095. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9096. .adc_nids = alc861vd_adc_nids,
  9097. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9098. .channel_mode = alc861vd_3stack_2ch_modes,
  9099. .input_mux = &alc861vd_capture_source,
  9100. .unsol_event = alc861vd_lenovo_unsol_event,
  9101. .init_hook = alc861vd_lenovo_automute,
  9102. },
  9103. [ALC861VD_DALLAS] = {
  9104. .mixers = { alc861vd_dallas_mixer },
  9105. .init_verbs = { alc861vd_dallas_verbs },
  9106. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9107. .dac_nids = alc861vd_dac_nids,
  9108. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9109. .adc_nids = alc861vd_adc_nids,
  9110. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9111. .channel_mode = alc861vd_3stack_2ch_modes,
  9112. .input_mux = &alc861vd_dallas_capture_source,
  9113. .unsol_event = alc861vd_dallas_unsol_event,
  9114. .init_hook = alc861vd_dallas_automute,
  9115. },
  9116. };
  9117. /*
  9118. * BIOS auto configuration
  9119. */
  9120. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9121. hda_nid_t nid, int pin_type, int dac_idx)
  9122. {
  9123. /* set as output */
  9124. snd_hda_codec_write(codec, nid, 0,
  9125. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9126. snd_hda_codec_write(codec, nid, 0,
  9127. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9128. }
  9129. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9130. {
  9131. struct alc_spec *spec = codec->spec;
  9132. int i;
  9133. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9134. for (i = 0; i <= HDA_SIDE; i++) {
  9135. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9136. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9137. if (nid)
  9138. alc861vd_auto_set_output_and_unmute(codec, nid,
  9139. pin_type, i);
  9140. }
  9141. }
  9142. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9143. {
  9144. struct alc_spec *spec = codec->spec;
  9145. hda_nid_t pin;
  9146. pin = spec->autocfg.hp_pins[0];
  9147. if (pin) /* connect to front and use dac 0 */
  9148. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9149. }
  9150. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9151. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9152. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9153. {
  9154. struct alc_spec *spec = codec->spec;
  9155. int i;
  9156. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9157. hda_nid_t nid = spec->autocfg.input_pins[i];
  9158. if (alc861vd_is_input_pin(nid)) {
  9159. snd_hda_codec_write(codec, nid, 0,
  9160. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9161. i <= AUTO_PIN_FRONT_MIC ?
  9162. PIN_VREF80 : PIN_IN);
  9163. if (nid != ALC861VD_PIN_CD_NID)
  9164. snd_hda_codec_write(codec, nid, 0,
  9165. AC_VERB_SET_AMP_GAIN_MUTE,
  9166. AMP_OUT_MUTE);
  9167. }
  9168. }
  9169. }
  9170. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9171. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9172. /* add playback controls from the parsed DAC table */
  9173. /* Based on ALC880 version. But ALC861VD has separate,
  9174. * different NIDs for mute/unmute switch and volume control */
  9175. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9176. const struct auto_pin_cfg *cfg)
  9177. {
  9178. char name[32];
  9179. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9180. hda_nid_t nid_v, nid_s;
  9181. int i, err;
  9182. for (i = 0; i < cfg->line_outs; i++) {
  9183. if (!spec->multiout.dac_nids[i])
  9184. continue;
  9185. nid_v = alc861vd_idx_to_mixer_vol(
  9186. alc880_dac_to_idx(
  9187. spec->multiout.dac_nids[i]));
  9188. nid_s = alc861vd_idx_to_mixer_switch(
  9189. alc880_dac_to_idx(
  9190. spec->multiout.dac_nids[i]));
  9191. if (i == 2) {
  9192. /* Center/LFE */
  9193. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9194. "Center Playback Volume",
  9195. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9196. HDA_OUTPUT));
  9197. if (err < 0)
  9198. return err;
  9199. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9200. "LFE Playback Volume",
  9201. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9202. HDA_OUTPUT));
  9203. if (err < 0)
  9204. return err;
  9205. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9206. "Center Playback Switch",
  9207. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9208. HDA_INPUT));
  9209. if (err < 0)
  9210. return err;
  9211. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9212. "LFE Playback Switch",
  9213. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9214. HDA_INPUT));
  9215. if (err < 0)
  9216. return err;
  9217. } else {
  9218. sprintf(name, "%s Playback Volume", chname[i]);
  9219. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9220. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9221. HDA_OUTPUT));
  9222. if (err < 0)
  9223. return err;
  9224. sprintf(name, "%s Playback Switch", chname[i]);
  9225. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9226. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9227. HDA_INPUT));
  9228. if (err < 0)
  9229. return err;
  9230. }
  9231. }
  9232. return 0;
  9233. }
  9234. /* add playback controls for speaker and HP outputs */
  9235. /* Based on ALC880 version. But ALC861VD has separate,
  9236. * different NIDs for mute/unmute switch and volume control */
  9237. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9238. hda_nid_t pin, const char *pfx)
  9239. {
  9240. hda_nid_t nid_v, nid_s;
  9241. int err;
  9242. char name[32];
  9243. if (!pin)
  9244. return 0;
  9245. if (alc880_is_fixed_pin(pin)) {
  9246. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9247. /* specify the DAC as the extra output */
  9248. if (!spec->multiout.hp_nid)
  9249. spec->multiout.hp_nid = nid_v;
  9250. else
  9251. spec->multiout.extra_out_nid[0] = nid_v;
  9252. /* control HP volume/switch on the output mixer amp */
  9253. nid_v = alc861vd_idx_to_mixer_vol(
  9254. alc880_fixed_pin_idx(pin));
  9255. nid_s = alc861vd_idx_to_mixer_switch(
  9256. alc880_fixed_pin_idx(pin));
  9257. sprintf(name, "%s Playback Volume", pfx);
  9258. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9259. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9260. if (err < 0)
  9261. return err;
  9262. sprintf(name, "%s Playback Switch", pfx);
  9263. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9264. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9265. if (err < 0)
  9266. return err;
  9267. } else if (alc880_is_multi_pin(pin)) {
  9268. /* set manual connection */
  9269. /* we have only a switch on HP-out PIN */
  9270. sprintf(name, "%s Playback Switch", pfx);
  9271. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9272. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9273. if (err < 0)
  9274. return err;
  9275. }
  9276. return 0;
  9277. }
  9278. /* parse the BIOS configuration and set up the alc_spec
  9279. * return 1 if successful, 0 if the proper config is not found,
  9280. * or a negative error code
  9281. * Based on ALC880 version - had to change it to override
  9282. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9283. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9284. {
  9285. struct alc_spec *spec = codec->spec;
  9286. int err;
  9287. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9288. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9289. alc861vd_ignore);
  9290. if (err < 0)
  9291. return err;
  9292. if (!spec->autocfg.line_outs)
  9293. return 0; /* can't find valid BIOS pin config */
  9294. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9295. if (err < 0)
  9296. return err;
  9297. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9298. if (err < 0)
  9299. return err;
  9300. err = alc861vd_auto_create_extra_out(spec,
  9301. spec->autocfg.speaker_pins[0],
  9302. "Speaker");
  9303. if (err < 0)
  9304. return err;
  9305. err = alc861vd_auto_create_extra_out(spec,
  9306. spec->autocfg.hp_pins[0],
  9307. "Headphone");
  9308. if (err < 0)
  9309. return err;
  9310. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9311. if (err < 0)
  9312. return err;
  9313. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9314. if (spec->autocfg.dig_out_pin)
  9315. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9316. if (spec->kctl_alloc)
  9317. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9318. spec->init_verbs[spec->num_init_verbs++]
  9319. = alc861vd_volume_init_verbs;
  9320. spec->num_mux_defs = 1;
  9321. spec->input_mux = &spec->private_imux;
  9322. return 1;
  9323. }
  9324. /* additional initialization for auto-configuration model */
  9325. static void alc861vd_auto_init(struct hda_codec *codec)
  9326. {
  9327. alc861vd_auto_init_multi_out(codec);
  9328. alc861vd_auto_init_hp_out(codec);
  9329. alc861vd_auto_init_analog_input(codec);
  9330. }
  9331. static int patch_alc861vd(struct hda_codec *codec)
  9332. {
  9333. struct alc_spec *spec;
  9334. int err, board_config;
  9335. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9336. if (spec == NULL)
  9337. return -ENOMEM;
  9338. codec->spec = spec;
  9339. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9340. alc861vd_models,
  9341. alc861vd_cfg_tbl);
  9342. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9343. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9344. "ALC861VD, trying auto-probe from BIOS...\n");
  9345. board_config = ALC861VD_AUTO;
  9346. }
  9347. if (board_config == ALC861VD_AUTO) {
  9348. /* automatic parse from the BIOS config */
  9349. err = alc861vd_parse_auto_config(codec);
  9350. if (err < 0) {
  9351. alc_free(codec);
  9352. return err;
  9353. } else if (!err) {
  9354. printk(KERN_INFO
  9355. "hda_codec: Cannot set up configuration "
  9356. "from BIOS. Using base mode...\n");
  9357. board_config = ALC861VD_3ST;
  9358. }
  9359. }
  9360. if (board_config != ALC861VD_AUTO)
  9361. setup_preset(spec, &alc861vd_presets[board_config]);
  9362. spec->stream_name_analog = "ALC861VD Analog";
  9363. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9364. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9365. spec->stream_name_digital = "ALC861VD Digital";
  9366. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9367. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9368. spec->adc_nids = alc861vd_adc_nids;
  9369. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9370. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9371. spec->num_mixers++;
  9372. codec->patch_ops = alc_patch_ops;
  9373. if (board_config == ALC861VD_AUTO)
  9374. spec->init_hook = alc861vd_auto_init;
  9375. return 0;
  9376. }
  9377. /*
  9378. * ALC662 support
  9379. *
  9380. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9381. * configuration. Each pin widget can choose any input DACs and a mixer.
  9382. * Each ADC is connected from a mixer of all inputs. This makes possible
  9383. * 6-channel independent captures.
  9384. *
  9385. * In addition, an independent DAC for the multi-playback (not used in this
  9386. * driver yet).
  9387. */
  9388. #define ALC662_DIGOUT_NID 0x06
  9389. #define ALC662_DIGIN_NID 0x0a
  9390. static hda_nid_t alc662_dac_nids[4] = {
  9391. /* front, rear, clfe, rear_surr */
  9392. 0x02, 0x03, 0x04
  9393. };
  9394. static hda_nid_t alc662_adc_nids[1] = {
  9395. /* ADC1-2 */
  9396. 0x09,
  9397. };
  9398. /* input MUX */
  9399. /* FIXME: should be a matrix-type input source selection */
  9400. static struct hda_input_mux alc662_capture_source = {
  9401. .num_items = 4,
  9402. .items = {
  9403. { "Mic", 0x0 },
  9404. { "Front Mic", 0x1 },
  9405. { "Line", 0x2 },
  9406. { "CD", 0x4 },
  9407. },
  9408. };
  9409. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9410. .num_items = 2,
  9411. .items = {
  9412. { "Mic", 0x1 },
  9413. { "Line", 0x2 },
  9414. },
  9415. };
  9416. #define alc662_mux_enum_info alc_mux_enum_info
  9417. #define alc662_mux_enum_get alc_mux_enum_get
  9418. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9419. struct snd_ctl_elem_value *ucontrol)
  9420. {
  9421. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9422. struct alc_spec *spec = codec->spec;
  9423. const struct hda_input_mux *imux = spec->input_mux;
  9424. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9425. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9426. hda_nid_t nid = capture_mixers[adc_idx];
  9427. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9428. unsigned int i, idx;
  9429. idx = ucontrol->value.enumerated.item[0];
  9430. if (idx >= imux->num_items)
  9431. idx = imux->num_items - 1;
  9432. if (*cur_val == idx && !codec->in_resume)
  9433. return 0;
  9434. for (i = 0; i < imux->num_items; i++) {
  9435. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9436. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9437. v | (imux->items[i].index << 8));
  9438. }
  9439. *cur_val = idx;
  9440. return 1;
  9441. }
  9442. /*
  9443. * 2ch mode
  9444. */
  9445. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9446. { 2, NULL }
  9447. };
  9448. /*
  9449. * 2ch mode
  9450. */
  9451. static struct hda_verb alc662_3ST_ch2_init[] = {
  9452. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9453. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9454. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9455. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9456. { } /* end */
  9457. };
  9458. /*
  9459. * 6ch mode
  9460. */
  9461. static struct hda_verb alc662_3ST_ch6_init[] = {
  9462. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9463. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9464. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9465. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9466. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9467. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9468. { } /* end */
  9469. };
  9470. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9471. { 2, alc662_3ST_ch2_init },
  9472. { 6, alc662_3ST_ch6_init },
  9473. };
  9474. /*
  9475. * 2ch mode
  9476. */
  9477. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9478. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9479. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9480. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9481. { } /* end */
  9482. };
  9483. /*
  9484. * 6ch mode
  9485. */
  9486. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9487. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9488. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9489. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9490. { } /* end */
  9491. };
  9492. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9493. { 2, alc662_sixstack_ch6_init },
  9494. { 6, alc662_sixstack_ch8_init },
  9495. };
  9496. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9497. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9498. */
  9499. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9500. /* output mixer control */
  9501. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9502. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9503. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9504. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9505. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9506. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9507. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9508. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9509. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9510. /*Input mixer control */
  9511. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9512. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9513. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9514. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9515. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9516. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9517. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9518. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9519. /* Capture mixer control */
  9520. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9521. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9522. {
  9523. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9524. .name = "Capture Source",
  9525. .count = 1,
  9526. .info = alc_mux_enum_info,
  9527. .get = alc_mux_enum_get,
  9528. .put = alc_mux_enum_put,
  9529. },
  9530. { } /* end */
  9531. };
  9532. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9533. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9534. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9535. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9536. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9537. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9538. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9539. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9540. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9541. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9542. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9543. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9544. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9545. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9546. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9547. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9548. {
  9549. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9550. /* .name = "Capture Source", */
  9551. .name = "Input Source",
  9552. .count = 1,
  9553. .info = alc662_mux_enum_info,
  9554. .get = alc662_mux_enum_get,
  9555. .put = alc662_mux_enum_put,
  9556. },
  9557. { } /* end */
  9558. };
  9559. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9560. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9561. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9562. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9563. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9564. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9565. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9566. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9567. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9568. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9569. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9570. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9571. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9572. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9573. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9574. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9575. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9576. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9577. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9578. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9579. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9580. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9581. {
  9582. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9583. /* .name = "Capture Source", */
  9584. .name = "Input Source",
  9585. .count = 1,
  9586. .info = alc662_mux_enum_info,
  9587. .get = alc662_mux_enum_get,
  9588. .put = alc662_mux_enum_put,
  9589. },
  9590. { } /* end */
  9591. };
  9592. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9593. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9594. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9595. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9596. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9597. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9598. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9599. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9600. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9601. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9602. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9603. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9604. {
  9605. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9606. /* .name = "Capture Source", */
  9607. .name = "Input Source",
  9608. .count = 1,
  9609. .info = alc662_mux_enum_info,
  9610. .get = alc662_mux_enum_get,
  9611. .put = alc662_mux_enum_put,
  9612. },
  9613. { } /* end */
  9614. };
  9615. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9616. {
  9617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9618. .name = "Channel Mode",
  9619. .info = alc_ch_mode_info,
  9620. .get = alc_ch_mode_get,
  9621. .put = alc_ch_mode_put,
  9622. },
  9623. { } /* end */
  9624. };
  9625. static struct hda_verb alc662_init_verbs[] = {
  9626. /* ADC: mute amp left and right */
  9627. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9628. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9629. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9634. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9635. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9636. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9637. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9638. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9639. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9640. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9641. /* Front Pin: output 0 (0x0c) */
  9642. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9643. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9644. /* Rear Pin: output 1 (0x0d) */
  9645. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9646. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9647. /* CLFE Pin: output 2 (0x0e) */
  9648. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9649. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9650. /* Mic (rear) pin: input vref at 80% */
  9651. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9652. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9653. /* Front Mic pin: input vref at 80% */
  9654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9655. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9656. /* Line In pin: input */
  9657. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9658. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9659. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9660. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9661. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9662. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9663. /* CD pin widget for input */
  9664. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9665. /* FIXME: use matrix-type input source selection */
  9666. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9667. /* Input mixer */
  9668. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9669. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9670. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9671. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9672. { }
  9673. };
  9674. static struct hda_verb alc662_sue_init_verbs[] = {
  9675. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9676. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9677. {}
  9678. };
  9679. /*
  9680. * generic initialization of ADC, input mixers and output mixers
  9681. */
  9682. static struct hda_verb alc662_auto_init_verbs[] = {
  9683. /*
  9684. * Unmute ADC and set the default input to mic-in
  9685. */
  9686. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9687. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9688. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9689. * mixer widget
  9690. * Note: PASD motherboards uses the Line In 2 as the input for front
  9691. * panel mic (mic 2)
  9692. */
  9693. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9698. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9699. /*
  9700. * Set up output mixers (0x0c - 0x0f)
  9701. */
  9702. /* set vol=0 to output mixers */
  9703. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9704. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9705. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9706. /* set up input amps for analog loopback */
  9707. /* Amp Indices: DAC = 0, mixer = 1 */
  9708. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9709. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9710. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9711. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9712. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9713. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9714. /* FIXME: use matrix-type input source selection */
  9715. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9716. /* Input mixer */
  9717. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9718. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9719. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9720. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9722. { }
  9723. };
  9724. /* capture mixer elements */
  9725. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9726. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9727. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9728. {
  9729. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9730. /* The multiple "Capture Source" controls confuse alsamixer
  9731. * So call somewhat different..
  9732. * FIXME: the controls appear in the "playback" view!
  9733. */
  9734. /* .name = "Capture Source", */
  9735. .name = "Input Source",
  9736. .count = 1,
  9737. .info = alc882_mux_enum_info,
  9738. .get = alc882_mux_enum_get,
  9739. .put = alc882_mux_enum_put,
  9740. },
  9741. { } /* end */
  9742. };
  9743. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9744. {
  9745. unsigned int present;
  9746. unsigned char bits;
  9747. present = snd_hda_codec_read(codec, 0x14, 0,
  9748. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9749. bits = present ? 0x80 : 0;
  9750. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9751. 0x80, bits);
  9752. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9753. 0x80, bits);
  9754. }
  9755. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9756. {
  9757. unsigned int present;
  9758. unsigned char bits;
  9759. present = snd_hda_codec_read(codec, 0x1b, 0,
  9760. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9761. bits = present ? 0x80 : 0;
  9762. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9763. 0x80, bits);
  9764. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9765. 0x80, bits);
  9766. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9767. 0x80, bits);
  9768. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9769. 0x80, bits);
  9770. }
  9771. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9772. unsigned int res)
  9773. {
  9774. if ((res >> 26) == ALC880_HP_EVENT)
  9775. alc662_lenovo_101e_all_automute(codec);
  9776. if ((res >> 26) == ALC880_FRONT_EVENT)
  9777. alc662_lenovo_101e_ispeaker_automute(codec);
  9778. }
  9779. /* pcm configuration: identiacal with ALC880 */
  9780. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9781. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9782. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9783. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9784. /*
  9785. * configuration and preset
  9786. */
  9787. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9788. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9789. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9790. [ALC662_3ST_6ch] = "3stack-6ch",
  9791. [ALC662_5ST_DIG] = "6stack-dig",
  9792. [ALC662_LENOVO_101E] = "lenovo-101e",
  9793. [ALC662_AUTO] = "auto",
  9794. };
  9795. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9796. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9797. {}
  9798. };
  9799. static struct alc_config_preset alc662_presets[] = {
  9800. [ALC662_3ST_2ch_DIG] = {
  9801. .mixers = { alc662_3ST_2ch_mixer },
  9802. .init_verbs = { alc662_init_verbs },
  9803. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9804. .dac_nids = alc662_dac_nids,
  9805. .dig_out_nid = ALC662_DIGOUT_NID,
  9806. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9807. .adc_nids = alc662_adc_nids,
  9808. .dig_in_nid = ALC662_DIGIN_NID,
  9809. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9810. .channel_mode = alc662_3ST_2ch_modes,
  9811. .input_mux = &alc662_capture_source,
  9812. },
  9813. [ALC662_3ST_6ch_DIG] = {
  9814. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9815. .init_verbs = { alc662_init_verbs },
  9816. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9817. .dac_nids = alc662_dac_nids,
  9818. .dig_out_nid = ALC662_DIGOUT_NID,
  9819. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9820. .adc_nids = alc662_adc_nids,
  9821. .dig_in_nid = ALC662_DIGIN_NID,
  9822. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9823. .channel_mode = alc662_3ST_6ch_modes,
  9824. .need_dac_fix = 1,
  9825. .input_mux = &alc662_capture_source,
  9826. },
  9827. [ALC662_3ST_6ch] = {
  9828. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9829. .init_verbs = { alc662_init_verbs },
  9830. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9831. .dac_nids = alc662_dac_nids,
  9832. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9833. .adc_nids = alc662_adc_nids,
  9834. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9835. .channel_mode = alc662_3ST_6ch_modes,
  9836. .need_dac_fix = 1,
  9837. .input_mux = &alc662_capture_source,
  9838. },
  9839. [ALC662_5ST_DIG] = {
  9840. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9841. .init_verbs = { alc662_init_verbs },
  9842. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9843. .dac_nids = alc662_dac_nids,
  9844. .dig_out_nid = ALC662_DIGOUT_NID,
  9845. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9846. .adc_nids = alc662_adc_nids,
  9847. .dig_in_nid = ALC662_DIGIN_NID,
  9848. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9849. .channel_mode = alc662_5stack_modes,
  9850. .input_mux = &alc662_capture_source,
  9851. },
  9852. [ALC662_LENOVO_101E] = {
  9853. .mixers = { alc662_lenovo_101e_mixer },
  9854. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9855. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9856. .dac_nids = alc662_dac_nids,
  9857. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9858. .adc_nids = alc662_adc_nids,
  9859. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9860. .channel_mode = alc662_3ST_2ch_modes,
  9861. .input_mux = &alc662_lenovo_101e_capture_source,
  9862. .unsol_event = alc662_lenovo_101e_unsol_event,
  9863. .init_hook = alc662_lenovo_101e_all_automute,
  9864. },
  9865. };
  9866. /*
  9867. * BIOS auto configuration
  9868. */
  9869. /* add playback controls from the parsed DAC table */
  9870. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9871. const struct auto_pin_cfg *cfg)
  9872. {
  9873. char name[32];
  9874. static const char *chname[4] = {
  9875. "Front", "Surround", NULL /*CLFE*/, "Side"
  9876. };
  9877. hda_nid_t nid;
  9878. int i, err;
  9879. for (i = 0; i < cfg->line_outs; i++) {
  9880. if (!spec->multiout.dac_nids[i])
  9881. continue;
  9882. nid = alc880_idx_to_dac(i);
  9883. if (i == 2) {
  9884. /* Center/LFE */
  9885. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9886. "Center Playback Volume",
  9887. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9888. HDA_OUTPUT));
  9889. if (err < 0)
  9890. return err;
  9891. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9892. "LFE Playback Volume",
  9893. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9894. HDA_OUTPUT));
  9895. if (err < 0)
  9896. return err;
  9897. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9898. "Center Playback Switch",
  9899. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9900. HDA_INPUT));
  9901. if (err < 0)
  9902. return err;
  9903. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9904. "LFE Playback Switch",
  9905. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9906. HDA_INPUT));
  9907. if (err < 0)
  9908. return err;
  9909. } else {
  9910. sprintf(name, "%s Playback Volume", chname[i]);
  9911. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9912. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9913. HDA_OUTPUT));
  9914. if (err < 0)
  9915. return err;
  9916. sprintf(name, "%s Playback Switch", chname[i]);
  9917. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9918. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9919. HDA_INPUT));
  9920. if (err < 0)
  9921. return err;
  9922. }
  9923. }
  9924. return 0;
  9925. }
  9926. /* add playback controls for speaker and HP outputs */
  9927. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9928. const char *pfx)
  9929. {
  9930. hda_nid_t nid;
  9931. int err;
  9932. char name[32];
  9933. if (!pin)
  9934. return 0;
  9935. if (alc880_is_fixed_pin(pin)) {
  9936. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9937. /* printk("DAC nid=%x\n",nid); */
  9938. /* specify the DAC as the extra output */
  9939. if (!spec->multiout.hp_nid)
  9940. spec->multiout.hp_nid = nid;
  9941. else
  9942. spec->multiout.extra_out_nid[0] = nid;
  9943. /* control HP volume/switch on the output mixer amp */
  9944. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9945. sprintf(name, "%s Playback Volume", pfx);
  9946. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9947. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9948. if (err < 0)
  9949. return err;
  9950. sprintf(name, "%s Playback Switch", pfx);
  9951. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9952. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9953. if (err < 0)
  9954. return err;
  9955. } else if (alc880_is_multi_pin(pin)) {
  9956. /* set manual connection */
  9957. /* we have only a switch on HP-out PIN */
  9958. sprintf(name, "%s Playback Switch", pfx);
  9959. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9960. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9961. if (err < 0)
  9962. return err;
  9963. }
  9964. return 0;
  9965. }
  9966. /* create playback/capture controls for input pins */
  9967. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9968. const struct auto_pin_cfg *cfg)
  9969. {
  9970. struct hda_input_mux *imux = &spec->private_imux;
  9971. int i, err, idx;
  9972. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9973. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9974. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9975. err = new_analog_input(spec, cfg->input_pins[i],
  9976. auto_pin_cfg_labels[i],
  9977. idx, 0x0b);
  9978. if (err < 0)
  9979. return err;
  9980. imux->items[imux->num_items].label =
  9981. auto_pin_cfg_labels[i];
  9982. imux->items[imux->num_items].index =
  9983. alc880_input_pin_idx(cfg->input_pins[i]);
  9984. imux->num_items++;
  9985. }
  9986. }
  9987. return 0;
  9988. }
  9989. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9990. hda_nid_t nid, int pin_type,
  9991. int dac_idx)
  9992. {
  9993. /* set as output */
  9994. snd_hda_codec_write(codec, nid, 0,
  9995. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9996. snd_hda_codec_write(codec, nid, 0,
  9997. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9998. /* need the manual connection? */
  9999. if (alc880_is_multi_pin(nid)) {
  10000. struct alc_spec *spec = codec->spec;
  10001. int idx = alc880_multi_pin_idx(nid);
  10002. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10003. AC_VERB_SET_CONNECT_SEL,
  10004. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10005. }
  10006. }
  10007. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10008. {
  10009. struct alc_spec *spec = codec->spec;
  10010. int i;
  10011. for (i = 0; i <= HDA_SIDE; i++) {
  10012. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10013. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10014. if (nid)
  10015. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10016. i);
  10017. }
  10018. }
  10019. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10020. {
  10021. struct alc_spec *spec = codec->spec;
  10022. hda_nid_t pin;
  10023. pin = spec->autocfg.hp_pins[0];
  10024. if (pin) /* connect to front */
  10025. /* use dac 0 */
  10026. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10027. }
  10028. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10029. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10030. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10031. {
  10032. struct alc_spec *spec = codec->spec;
  10033. int i;
  10034. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10035. hda_nid_t nid = spec->autocfg.input_pins[i];
  10036. if (alc662_is_input_pin(nid)) {
  10037. snd_hda_codec_write(codec, nid, 0,
  10038. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10039. (i <= AUTO_PIN_FRONT_MIC ?
  10040. PIN_VREF80 : PIN_IN));
  10041. if (nid != ALC662_PIN_CD_NID)
  10042. snd_hda_codec_write(codec, nid, 0,
  10043. AC_VERB_SET_AMP_GAIN_MUTE,
  10044. AMP_OUT_MUTE);
  10045. }
  10046. }
  10047. }
  10048. static int alc662_parse_auto_config(struct hda_codec *codec)
  10049. {
  10050. struct alc_spec *spec = codec->spec;
  10051. int err;
  10052. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10053. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10054. alc662_ignore);
  10055. if (err < 0)
  10056. return err;
  10057. if (!spec->autocfg.line_outs)
  10058. return 0; /* can't find valid BIOS pin config */
  10059. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10060. if (err < 0)
  10061. return err;
  10062. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10063. if (err < 0)
  10064. return err;
  10065. err = alc662_auto_create_extra_out(spec,
  10066. spec->autocfg.speaker_pins[0],
  10067. "Speaker");
  10068. if (err < 0)
  10069. return err;
  10070. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10071. "Headphone");
  10072. if (err < 0)
  10073. return err;
  10074. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10075. if (err < 0)
  10076. return err;
  10077. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10078. if (spec->autocfg.dig_out_pin)
  10079. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10080. if (spec->kctl_alloc)
  10081. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10082. spec->num_mux_defs = 1;
  10083. spec->input_mux = &spec->private_imux;
  10084. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10085. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10086. spec->num_mixers++;
  10087. return 1;
  10088. }
  10089. /* additional initialization for auto-configuration model */
  10090. static void alc662_auto_init(struct hda_codec *codec)
  10091. {
  10092. alc662_auto_init_multi_out(codec);
  10093. alc662_auto_init_hp_out(codec);
  10094. alc662_auto_init_analog_input(codec);
  10095. }
  10096. static int patch_alc662(struct hda_codec *codec)
  10097. {
  10098. struct alc_spec *spec;
  10099. int err, board_config;
  10100. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10101. if (!spec)
  10102. return -ENOMEM;
  10103. codec->spec = spec;
  10104. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10105. alc662_models,
  10106. alc662_cfg_tbl);
  10107. if (board_config < 0) {
  10108. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10109. "trying auto-probe from BIOS...\n");
  10110. board_config = ALC662_AUTO;
  10111. }
  10112. if (board_config == ALC662_AUTO) {
  10113. /* automatic parse from the BIOS config */
  10114. err = alc662_parse_auto_config(codec);
  10115. if (err < 0) {
  10116. alc_free(codec);
  10117. return err;
  10118. } else if (!err) {
  10119. printk(KERN_INFO
  10120. "hda_codec: Cannot set up configuration "
  10121. "from BIOS. Using base mode...\n");
  10122. board_config = ALC662_3ST_2ch_DIG;
  10123. }
  10124. }
  10125. if (board_config != ALC662_AUTO)
  10126. setup_preset(spec, &alc662_presets[board_config]);
  10127. spec->stream_name_analog = "ALC662 Analog";
  10128. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10129. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10130. spec->stream_name_digital = "ALC662 Digital";
  10131. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10132. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10133. if (!spec->adc_nids && spec->input_mux) {
  10134. spec->adc_nids = alc662_adc_nids;
  10135. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10136. }
  10137. codec->patch_ops = alc_patch_ops;
  10138. if (board_config == ALC662_AUTO)
  10139. spec->init_hook = alc662_auto_init;
  10140. return 0;
  10141. }
  10142. /*
  10143. * patch entries
  10144. */
  10145. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10146. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10147. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10148. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10149. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10150. .patch = patch_alc861 },
  10151. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10152. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10153. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10154. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10155. .patch = patch_alc883 },
  10156. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10157. .patch = patch_alc662 },
  10158. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10159. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10160. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10161. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10162. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10163. {} /* terminator */
  10164. };