patch_realtek.c 332 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049
  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_AUTO,
  92. ALC262_MODEL_LAST /* last tag */
  93. };
  94. /* ALC861 models */
  95. enum {
  96. ALC861_3ST,
  97. ALC660_3ST,
  98. ALC861_3ST_DIG,
  99. ALC861_6ST_DIG,
  100. ALC861_UNIWILL_M31,
  101. ALC861_TOSHIBA,
  102. ALC861_ASUS,
  103. ALC861_ASUS_LAPTOP,
  104. ALC861_AUTO,
  105. ALC861_MODEL_LAST,
  106. };
  107. /* ALC861-VD models */
  108. enum {
  109. ALC660VD_3ST,
  110. ALC861VD_3ST,
  111. ALC861VD_3ST_DIG,
  112. ALC861VD_6ST_DIG,
  113. ALC861VD_AUTO,
  114. ALC861VD_MODEL_LAST,
  115. };
  116. /* ALC662 models */
  117. enum {
  118. ALC662_3ST_2ch_DIG,
  119. ALC662_3ST_6ch_DIG,
  120. ALC662_3ST_6ch,
  121. ALC662_5ST_DIG,
  122. ALC662_LENOVO_101E,
  123. ALC662_AUTO,
  124. ALC662_MODEL_LAST,
  125. };
  126. /* ALC882 models */
  127. enum {
  128. ALC882_3ST_DIG,
  129. ALC882_6ST_DIG,
  130. ALC882_ARIMA,
  131. ALC882_AUTO,
  132. ALC885_MACPRO,
  133. ALC882_MODEL_LAST,
  134. };
  135. /* ALC883 models */
  136. enum {
  137. ALC883_3ST_2ch_DIG,
  138. ALC883_3ST_6ch_DIG,
  139. ALC883_3ST_6ch,
  140. ALC883_6ST_DIG,
  141. ALC883_TARGA_DIG,
  142. ALC883_TARGA_2ch_DIG,
  143. ALC888_DEMO_BOARD,
  144. ALC883_ACER,
  145. ALC883_MEDION,
  146. ALC883_LAPTOP_EAPD,
  147. ALC883_LENOVO_101E_2ch,
  148. ALC883_AUTO,
  149. ALC883_MODEL_LAST,
  150. };
  151. /* for GPIO Poll */
  152. #define GPIO_MASK 0x03
  153. struct alc_spec {
  154. /* codec parameterization */
  155. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  156. unsigned int num_mixers;
  157. const struct hda_verb *init_verbs[5]; /* initialization verbs
  158. * don't forget NULL
  159. * termination!
  160. */
  161. unsigned int num_init_verbs;
  162. char *stream_name_analog; /* analog PCM stream */
  163. struct hda_pcm_stream *stream_analog_playback;
  164. struct hda_pcm_stream *stream_analog_capture;
  165. char *stream_name_digital; /* digital PCM stream */
  166. struct hda_pcm_stream *stream_digital_playback;
  167. struct hda_pcm_stream *stream_digital_capture;
  168. /* playback */
  169. struct hda_multi_out multiout; /* playback set-up
  170. * max_channels, dacs must be set
  171. * dig_out_nid and hp_nid are optional
  172. */
  173. /* capture */
  174. unsigned int num_adc_nids;
  175. hda_nid_t *adc_nids;
  176. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  177. /* capture source */
  178. unsigned int num_mux_defs;
  179. const struct hda_input_mux *input_mux;
  180. unsigned int cur_mux[3];
  181. /* channel model */
  182. const struct hda_channel_mode *channel_mode;
  183. int num_channel_mode;
  184. int need_dac_fix;
  185. /* PCM information */
  186. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  187. /* dynamic controls, init_verbs and input_mux */
  188. struct auto_pin_cfg autocfg;
  189. unsigned int num_kctl_alloc, num_kctl_used;
  190. struct snd_kcontrol_new *kctl_alloc;
  191. struct hda_input_mux private_imux;
  192. hda_nid_t private_dac_nids[5];
  193. /* hooks */
  194. void (*init_hook)(struct hda_codec *codec);
  195. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  196. /* for pin sensing */
  197. unsigned int sense_updated: 1;
  198. unsigned int jack_present: 1;
  199. };
  200. /*
  201. * configuration template - to be copied to the spec instance
  202. */
  203. struct alc_config_preset {
  204. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  205. * with spec
  206. */
  207. const struct hda_verb *init_verbs[5];
  208. unsigned int num_dacs;
  209. hda_nid_t *dac_nids;
  210. hda_nid_t dig_out_nid; /* optional */
  211. hda_nid_t hp_nid; /* optional */
  212. unsigned int num_adc_nids;
  213. hda_nid_t *adc_nids;
  214. hda_nid_t dig_in_nid;
  215. unsigned int num_channel_mode;
  216. const struct hda_channel_mode *channel_mode;
  217. int need_dac_fix;
  218. unsigned int num_mux_defs;
  219. const struct hda_input_mux *input_mux;
  220. void (*unsol_event)(struct hda_codec *, unsigned int);
  221. void (*init_hook)(struct hda_codec *);
  222. };
  223. /*
  224. * input MUX handling
  225. */
  226. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  227. struct snd_ctl_elem_info *uinfo)
  228. {
  229. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  230. struct alc_spec *spec = codec->spec;
  231. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  232. if (mux_idx >= spec->num_mux_defs)
  233. mux_idx = 0;
  234. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  235. }
  236. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  237. struct snd_ctl_elem_value *ucontrol)
  238. {
  239. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  240. struct alc_spec *spec = codec->spec;
  241. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  242. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  243. return 0;
  244. }
  245. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  246. struct snd_ctl_elem_value *ucontrol)
  247. {
  248. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  249. struct alc_spec *spec = codec->spec;
  250. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  251. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  252. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  253. spec->adc_nids[adc_idx],
  254. &spec->cur_mux[adc_idx]);
  255. }
  256. /*
  257. * channel mode setting
  258. */
  259. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  265. spec->num_channel_mode);
  266. }
  267. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_value *ucontrol)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  273. spec->num_channel_mode,
  274. spec->multiout.max_channels);
  275. }
  276. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_value *ucontrol)
  278. {
  279. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  280. struct alc_spec *spec = codec->spec;
  281. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  282. spec->num_channel_mode,
  283. &spec->multiout.max_channels);
  284. if (err >= 0 && spec->need_dac_fix)
  285. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  286. return err;
  287. }
  288. /*
  289. * Control the mode of pin widget settings via the mixer. "pc" is used
  290. * instead of "%" to avoid consequences of accidently treating the % as
  291. * being part of a format specifier. Maximum allowed length of a value is
  292. * 63 characters plus NULL terminator.
  293. *
  294. * Note: some retasking pin complexes seem to ignore requests for input
  295. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  296. * are requested. Therefore order this list so that this behaviour will not
  297. * cause problems when mixer clients move through the enum sequentially.
  298. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  299. * March 2006.
  300. */
  301. static char *alc_pin_mode_names[] = {
  302. "Mic 50pc bias", "Mic 80pc bias",
  303. "Line in", "Line out", "Headphone out",
  304. };
  305. static unsigned char alc_pin_mode_values[] = {
  306. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  307. };
  308. /* The control can present all 5 options, or it can limit the options based
  309. * in the pin being assumed to be exclusively an input or an output pin. In
  310. * addition, "input" pins may or may not process the mic bias option
  311. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  312. * accept requests for bias as of chip versions up to March 2006) and/or
  313. * wiring in the computer.
  314. */
  315. #define ALC_PIN_DIR_IN 0x00
  316. #define ALC_PIN_DIR_OUT 0x01
  317. #define ALC_PIN_DIR_INOUT 0x02
  318. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  319. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  320. /* Info about the pin modes supported by the different pin direction modes.
  321. * For each direction the minimum and maximum values are given.
  322. */
  323. static signed char alc_pin_mode_dir_info[5][2] = {
  324. { 0, 2 }, /* ALC_PIN_DIR_IN */
  325. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  326. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  327. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  328. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  329. };
  330. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  331. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  332. #define alc_pin_mode_n_items(_dir) \
  333. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  334. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  335. struct snd_ctl_elem_info *uinfo)
  336. {
  337. unsigned int item_num = uinfo->value.enumerated.item;
  338. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  339. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  340. uinfo->count = 1;
  341. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  342. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  343. item_num = alc_pin_mode_min(dir);
  344. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  345. return 0;
  346. }
  347. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  348. struct snd_ctl_elem_value *ucontrol)
  349. {
  350. unsigned int i;
  351. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  352. hda_nid_t nid = kcontrol->private_value & 0xffff;
  353. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  354. long *valp = ucontrol->value.integer.value;
  355. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  356. AC_VERB_GET_PIN_WIDGET_CONTROL,
  357. 0x00);
  358. /* Find enumerated value for current pinctl setting */
  359. i = alc_pin_mode_min(dir);
  360. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  361. i++;
  362. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  363. return 0;
  364. }
  365. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_value *ucontrol)
  367. {
  368. signed int change;
  369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  370. hda_nid_t nid = kcontrol->private_value & 0xffff;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. long val = *ucontrol->value.integer.value;
  373. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  374. AC_VERB_GET_PIN_WIDGET_CONTROL,
  375. 0x00);
  376. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  377. val = alc_pin_mode_min(dir);
  378. change = pinctl != alc_pin_mode_values[val];
  379. if (change) {
  380. /* Set pin mode to that requested */
  381. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  382. alc_pin_mode_values[val]);
  383. /* Also enable the retasking pin's input/output as required
  384. * for the requested pin mode. Enum values of 2 or less are
  385. * input modes.
  386. *
  387. * Dynamically switching the input/output buffers probably
  388. * reduces noise slightly (particularly on input) so we'll
  389. * do it. However, having both input and output buffers
  390. * enabled simultaneously doesn't seem to be problematic if
  391. * this turns out to be necessary in the future.
  392. */
  393. if (val <= 2) {
  394. snd_hda_codec_write(codec, nid, 0,
  395. AC_VERB_SET_AMP_GAIN_MUTE,
  396. AMP_OUT_MUTE);
  397. snd_hda_codec_write(codec, nid, 0,
  398. AC_VERB_SET_AMP_GAIN_MUTE,
  399. AMP_IN_UNMUTE(0));
  400. } else {
  401. snd_hda_codec_write(codec, nid, 0,
  402. AC_VERB_SET_AMP_GAIN_MUTE,
  403. AMP_IN_MUTE(0));
  404. snd_hda_codec_write(codec, nid, 0,
  405. AC_VERB_SET_AMP_GAIN_MUTE,
  406. AMP_OUT_UNMUTE);
  407. }
  408. }
  409. return change;
  410. }
  411. #define ALC_PIN_MODE(xname, nid, dir) \
  412. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  413. .info = alc_pin_mode_info, \
  414. .get = alc_pin_mode_get, \
  415. .put = alc_pin_mode_put, \
  416. .private_value = nid | (dir<<16) }
  417. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  418. * together using a mask with more than one bit set. This control is
  419. * currently used only by the ALC260 test model. At this stage they are not
  420. * needed for any "production" models.
  421. */
  422. #ifdef CONFIG_SND_DEBUG
  423. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  424. struct snd_ctl_elem_info *uinfo)
  425. {
  426. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  427. uinfo->count = 1;
  428. uinfo->value.integer.min = 0;
  429. uinfo->value.integer.max = 1;
  430. return 0;
  431. }
  432. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  433. struct snd_ctl_elem_value *ucontrol)
  434. {
  435. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  436. hda_nid_t nid = kcontrol->private_value & 0xffff;
  437. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  438. long *valp = ucontrol->value.integer.value;
  439. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  440. AC_VERB_GET_GPIO_DATA, 0x00);
  441. *valp = (val & mask) != 0;
  442. return 0;
  443. }
  444. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  445. struct snd_ctl_elem_value *ucontrol)
  446. {
  447. signed int change;
  448. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  449. hda_nid_t nid = kcontrol->private_value & 0xffff;
  450. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  451. long val = *ucontrol->value.integer.value;
  452. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  453. AC_VERB_GET_GPIO_DATA,
  454. 0x00);
  455. /* Set/unset the masked GPIO bit(s) as needed */
  456. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  457. if (val == 0)
  458. gpio_data &= ~mask;
  459. else
  460. gpio_data |= mask;
  461. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  462. return change;
  463. }
  464. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  465. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  466. .info = alc_gpio_data_info, \
  467. .get = alc_gpio_data_get, \
  468. .put = alc_gpio_data_put, \
  469. .private_value = nid | (mask<<16) }
  470. #endif /* CONFIG_SND_DEBUG */
  471. /* A switch control to allow the enabling of the digital IO pins on the
  472. * ALC260. This is incredibly simplistic; the intention of this control is
  473. * to provide something in the test model allowing digital outputs to be
  474. * identified if present. If models are found which can utilise these
  475. * outputs a more complete mixer control can be devised for those models if
  476. * necessary.
  477. */
  478. #ifdef CONFIG_SND_DEBUG
  479. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  480. struct snd_ctl_elem_info *uinfo)
  481. {
  482. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  483. uinfo->count = 1;
  484. uinfo->value.integer.min = 0;
  485. uinfo->value.integer.max = 1;
  486. return 0;
  487. }
  488. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  489. struct snd_ctl_elem_value *ucontrol)
  490. {
  491. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  492. hda_nid_t nid = kcontrol->private_value & 0xffff;
  493. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  494. long *valp = ucontrol->value.integer.value;
  495. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  496. AC_VERB_GET_DIGI_CONVERT, 0x00);
  497. *valp = (val & mask) != 0;
  498. return 0;
  499. }
  500. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  501. struct snd_ctl_elem_value *ucontrol)
  502. {
  503. signed int change;
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. hda_nid_t nid = kcontrol->private_value & 0xffff;
  506. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  507. long val = *ucontrol->value.integer.value;
  508. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  509. AC_VERB_GET_DIGI_CONVERT,
  510. 0x00);
  511. /* Set/unset the masked control bit(s) as needed */
  512. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  513. if (val==0)
  514. ctrl_data &= ~mask;
  515. else
  516. ctrl_data |= mask;
  517. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  518. ctrl_data);
  519. return change;
  520. }
  521. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  522. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  523. .info = alc_spdif_ctrl_info, \
  524. .get = alc_spdif_ctrl_get, \
  525. .put = alc_spdif_ctrl_put, \
  526. .private_value = nid | (mask<<16) }
  527. #endif /* CONFIG_SND_DEBUG */
  528. /*
  529. * set up from the preset table
  530. */
  531. static void setup_preset(struct alc_spec *spec,
  532. const struct alc_config_preset *preset)
  533. {
  534. int i;
  535. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  536. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  537. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  538. i++)
  539. spec->init_verbs[spec->num_init_verbs++] =
  540. preset->init_verbs[i];
  541. spec->channel_mode = preset->channel_mode;
  542. spec->num_channel_mode = preset->num_channel_mode;
  543. spec->need_dac_fix = preset->need_dac_fix;
  544. spec->multiout.max_channels = spec->channel_mode[0].channels;
  545. spec->multiout.num_dacs = preset->num_dacs;
  546. spec->multiout.dac_nids = preset->dac_nids;
  547. spec->multiout.dig_out_nid = preset->dig_out_nid;
  548. spec->multiout.hp_nid = preset->hp_nid;
  549. spec->num_mux_defs = preset->num_mux_defs;
  550. if (!spec->num_mux_defs)
  551. spec->num_mux_defs = 1;
  552. spec->input_mux = preset->input_mux;
  553. spec->num_adc_nids = preset->num_adc_nids;
  554. spec->adc_nids = preset->adc_nids;
  555. spec->dig_in_nid = preset->dig_in_nid;
  556. spec->unsol_event = preset->unsol_event;
  557. spec->init_hook = preset->init_hook;
  558. }
  559. /* Enable GPIO mask and set output */
  560. static struct hda_verb alc_gpio1_init_verbs[] = {
  561. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  562. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  563. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  564. { }
  565. };
  566. static struct hda_verb alc_gpio2_init_verbs[] = {
  567. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  568. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  569. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  570. { }
  571. };
  572. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  573. * 31 ~ 16 : Manufacture ID
  574. * 15 ~ 8 : SKU ID
  575. * 7 ~ 0 : Assembly ID
  576. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  577. */
  578. static void alc_subsystem_id(struct hda_codec *codec,
  579. unsigned int porta, unsigned int porte,
  580. unsigned int portd)
  581. {
  582. unsigned int ass, tmp;
  583. ass = codec->subsystem_id;
  584. if (!(ass & 1))
  585. return;
  586. /* Override */
  587. tmp = (ass & 0x38) >> 3; /* external Amp control */
  588. switch (tmp) {
  589. case 1:
  590. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  591. break;
  592. case 3:
  593. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  594. break;
  595. case 5:
  596. case 6:
  597. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  598. hda_nid_t port = 0;
  599. tmp = (ass & 0x1800) >> 11;
  600. switch (tmp) {
  601. case 0: port = porta; break;
  602. case 1: port = porte; break;
  603. case 2: port = portd; break;
  604. }
  605. if (port)
  606. snd_hda_codec_write(codec, port, 0,
  607. AC_VERB_SET_EAPD_BTLENABLE,
  608. 2);
  609. }
  610. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  611. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  612. (tmp == 5 ? 0x3040 : 0x3050));
  613. break;
  614. }
  615. }
  616. /*
  617. * ALC880 3-stack model
  618. *
  619. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  620. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  621. * F-Mic = 0x1b, HP = 0x19
  622. */
  623. static hda_nid_t alc880_dac_nids[4] = {
  624. /* front, rear, clfe, rear_surr */
  625. 0x02, 0x05, 0x04, 0x03
  626. };
  627. static hda_nid_t alc880_adc_nids[3] = {
  628. /* ADC0-2 */
  629. 0x07, 0x08, 0x09,
  630. };
  631. /* The datasheet says the node 0x07 is connected from inputs,
  632. * but it shows zero connection in the real implementation on some devices.
  633. * Note: this is a 915GAV bug, fixed on 915GLV
  634. */
  635. static hda_nid_t alc880_adc_nids_alt[2] = {
  636. /* ADC1-2 */
  637. 0x08, 0x09,
  638. };
  639. #define ALC880_DIGOUT_NID 0x06
  640. #define ALC880_DIGIN_NID 0x0a
  641. static struct hda_input_mux alc880_capture_source = {
  642. .num_items = 4,
  643. .items = {
  644. { "Mic", 0x0 },
  645. { "Front Mic", 0x3 },
  646. { "Line", 0x2 },
  647. { "CD", 0x4 },
  648. },
  649. };
  650. /* channel source setting (2/6 channel selection for 3-stack) */
  651. /* 2ch mode */
  652. static struct hda_verb alc880_threestack_ch2_init[] = {
  653. /* set line-in to input, mute it */
  654. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  655. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  656. /* set mic-in to input vref 80%, mute it */
  657. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  658. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  659. { } /* end */
  660. };
  661. /* 6ch mode */
  662. static struct hda_verb alc880_threestack_ch6_init[] = {
  663. /* set line-in to output, unmute it */
  664. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  665. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  666. /* set mic-in to output, unmute it */
  667. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  668. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  669. { } /* end */
  670. };
  671. static struct hda_channel_mode alc880_threestack_modes[2] = {
  672. { 2, alc880_threestack_ch2_init },
  673. { 6, alc880_threestack_ch6_init },
  674. };
  675. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  676. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  677. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  678. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  679. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  680. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  681. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  682. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  683. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  684. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  685. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  686. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  687. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  688. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  689. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  690. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  691. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  692. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  693. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  694. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  695. {
  696. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  697. .name = "Channel Mode",
  698. .info = alc_ch_mode_info,
  699. .get = alc_ch_mode_get,
  700. .put = alc_ch_mode_put,
  701. },
  702. { } /* end */
  703. };
  704. /* capture mixer elements */
  705. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  706. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  707. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  708. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  709. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  710. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  711. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  712. {
  713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  714. /* The multiple "Capture Source" controls confuse alsamixer
  715. * So call somewhat different..
  716. * FIXME: the controls appear in the "playback" view!
  717. */
  718. /* .name = "Capture Source", */
  719. .name = "Input Source",
  720. .count = 3,
  721. .info = alc_mux_enum_info,
  722. .get = alc_mux_enum_get,
  723. .put = alc_mux_enum_put,
  724. },
  725. { } /* end */
  726. };
  727. /* capture mixer elements (in case NID 0x07 not available) */
  728. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  729. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  730. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  731. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  732. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  733. {
  734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  735. /* The multiple "Capture Source" controls confuse alsamixer
  736. * So call somewhat different..
  737. * FIXME: the controls appear in the "playback" view!
  738. */
  739. /* .name = "Capture Source", */
  740. .name = "Input Source",
  741. .count = 2,
  742. .info = alc_mux_enum_info,
  743. .get = alc_mux_enum_get,
  744. .put = alc_mux_enum_put,
  745. },
  746. { } /* end */
  747. };
  748. /*
  749. * ALC880 5-stack model
  750. *
  751. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  752. * Side = 0x02 (0xd)
  753. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  754. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  755. */
  756. /* additional mixers to alc880_three_stack_mixer */
  757. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  758. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  759. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  760. { } /* end */
  761. };
  762. /* channel source setting (6/8 channel selection for 5-stack) */
  763. /* 6ch mode */
  764. static struct hda_verb alc880_fivestack_ch6_init[] = {
  765. /* set line-in to input, mute it */
  766. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  767. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  768. { } /* end */
  769. };
  770. /* 8ch mode */
  771. static struct hda_verb alc880_fivestack_ch8_init[] = {
  772. /* set line-in to output, unmute it */
  773. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  774. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  775. { } /* end */
  776. };
  777. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  778. { 6, alc880_fivestack_ch6_init },
  779. { 8, alc880_fivestack_ch8_init },
  780. };
  781. /*
  782. * ALC880 6-stack model
  783. *
  784. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  785. * Side = 0x05 (0x0f)
  786. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  787. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  788. */
  789. static hda_nid_t alc880_6st_dac_nids[4] = {
  790. /* front, rear, clfe, rear_surr */
  791. 0x02, 0x03, 0x04, 0x05
  792. };
  793. static struct hda_input_mux alc880_6stack_capture_source = {
  794. .num_items = 4,
  795. .items = {
  796. { "Mic", 0x0 },
  797. { "Front Mic", 0x1 },
  798. { "Line", 0x2 },
  799. { "CD", 0x4 },
  800. },
  801. };
  802. /* fixed 8-channels */
  803. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  804. { 8, NULL },
  805. };
  806. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  807. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  808. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  809. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  810. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  811. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  812. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  813. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  814. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  815. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  816. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  817. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  818. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  819. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  820. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  823. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  824. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  825. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  826. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  827. {
  828. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  829. .name = "Channel Mode",
  830. .info = alc_ch_mode_info,
  831. .get = alc_ch_mode_get,
  832. .put = alc_ch_mode_put,
  833. },
  834. { } /* end */
  835. };
  836. /*
  837. * ALC880 W810 model
  838. *
  839. * W810 has rear IO for:
  840. * Front (DAC 02)
  841. * Surround (DAC 03)
  842. * Center/LFE (DAC 04)
  843. * Digital out (06)
  844. *
  845. * The system also has a pair of internal speakers, and a headphone jack.
  846. * These are both connected to Line2 on the codec, hence to DAC 02.
  847. *
  848. * There is a variable resistor to control the speaker or headphone
  849. * volume. This is a hardware-only device without a software API.
  850. *
  851. * Plugging headphones in will disable the internal speakers. This is
  852. * implemented in hardware, not via the driver using jack sense. In
  853. * a similar fashion, plugging into the rear socket marked "front" will
  854. * disable both the speakers and headphones.
  855. *
  856. * For input, there's a microphone jack, and an "audio in" jack.
  857. * These may not do anything useful with this driver yet, because I
  858. * haven't setup any initialization verbs for these yet...
  859. */
  860. static hda_nid_t alc880_w810_dac_nids[3] = {
  861. /* front, rear/surround, clfe */
  862. 0x02, 0x03, 0x04
  863. };
  864. /* fixed 6 channels */
  865. static struct hda_channel_mode alc880_w810_modes[1] = {
  866. { 6, NULL }
  867. };
  868. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  869. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  870. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  871. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  878. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  879. { } /* end */
  880. };
  881. /*
  882. * Z710V model
  883. *
  884. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  885. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  886. * Line = 0x1a
  887. */
  888. static hda_nid_t alc880_z71v_dac_nids[1] = {
  889. 0x02
  890. };
  891. #define ALC880_Z71V_HP_DAC 0x03
  892. /* fixed 2 channels */
  893. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  894. { 2, NULL }
  895. };
  896. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  897. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  898. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  899. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  900. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  901. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  902. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  903. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  904. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  905. { } /* end */
  906. };
  907. /* FIXME! */
  908. /*
  909. * ALC880 F1734 model
  910. *
  911. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  912. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  913. */
  914. static hda_nid_t alc880_f1734_dac_nids[1] = {
  915. 0x03
  916. };
  917. #define ALC880_F1734_HP_DAC 0x02
  918. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  919. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  920. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  921. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  922. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  923. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  924. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  925. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  926. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  927. { } /* end */
  928. };
  929. /* FIXME! */
  930. /*
  931. * ALC880 ASUS model
  932. *
  933. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  934. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  935. * Mic = 0x18, Line = 0x1a
  936. */
  937. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  938. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  939. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  940. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  941. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  942. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  943. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  944. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  945. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  946. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  947. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  948. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  949. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  950. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  951. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  952. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  953. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  954. {
  955. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  956. .name = "Channel Mode",
  957. .info = alc_ch_mode_info,
  958. .get = alc_ch_mode_get,
  959. .put = alc_ch_mode_put,
  960. },
  961. { } /* end */
  962. };
  963. /* FIXME! */
  964. /*
  965. * ALC880 ASUS W1V model
  966. *
  967. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  968. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  969. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  970. */
  971. /* additional mixers to alc880_asus_mixer */
  972. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  973. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  974. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  975. { } /* end */
  976. };
  977. /* additional mixers to alc880_asus_mixer */
  978. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  979. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  980. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  981. { } /* end */
  982. };
  983. /* TCL S700 */
  984. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  985. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  986. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  987. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  988. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  989. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  990. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  991. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  992. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  993. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  994. {
  995. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  996. /* The multiple "Capture Source" controls confuse alsamixer
  997. * So call somewhat different..
  998. * FIXME: the controls appear in the "playback" view!
  999. */
  1000. /* .name = "Capture Source", */
  1001. .name = "Input Source",
  1002. .count = 1,
  1003. .info = alc_mux_enum_info,
  1004. .get = alc_mux_enum_get,
  1005. .put = alc_mux_enum_put,
  1006. },
  1007. { } /* end */
  1008. };
  1009. /* Uniwill */
  1010. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1011. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1013. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1014. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1015. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1016. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1017. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1018. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1020. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1023. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1024. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1025. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1027. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1028. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1029. {
  1030. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1031. .name = "Channel Mode",
  1032. .info = alc_ch_mode_info,
  1033. .get = alc_ch_mode_get,
  1034. .put = alc_ch_mode_put,
  1035. },
  1036. { } /* end */
  1037. };
  1038. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1039. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1040. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1041. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1042. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1043. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1044. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1045. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1046. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1047. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1048. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1049. { } /* end */
  1050. };
  1051. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1052. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1055. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1058. { } /* end */
  1059. };
  1060. /*
  1061. * build control elements
  1062. */
  1063. static int alc_build_controls(struct hda_codec *codec)
  1064. {
  1065. struct alc_spec *spec = codec->spec;
  1066. int err;
  1067. int i;
  1068. for (i = 0; i < spec->num_mixers; i++) {
  1069. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1070. if (err < 0)
  1071. return err;
  1072. }
  1073. if (spec->multiout.dig_out_nid) {
  1074. err = snd_hda_create_spdif_out_ctls(codec,
  1075. spec->multiout.dig_out_nid);
  1076. if (err < 0)
  1077. return err;
  1078. }
  1079. if (spec->dig_in_nid) {
  1080. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1081. if (err < 0)
  1082. return err;
  1083. }
  1084. return 0;
  1085. }
  1086. /*
  1087. * initialize the codec volumes, etc
  1088. */
  1089. /*
  1090. * generic initialization of ADC, input mixers and output mixers
  1091. */
  1092. static struct hda_verb alc880_volume_init_verbs[] = {
  1093. /*
  1094. * Unmute ADC0-2 and set the default input to mic-in
  1095. */
  1096. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1097. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1098. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1099. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1100. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1101. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1102. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1103. * mixer widget
  1104. * Note: PASD motherboards uses the Line In 2 as the input for front
  1105. * panel mic (mic 2)
  1106. */
  1107. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1108. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1109. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1110. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1111. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1112. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1113. /*
  1114. * Set up output mixers (0x0c - 0x0f)
  1115. */
  1116. /* set vol=0 to output mixers */
  1117. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1118. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1119. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1120. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1121. /* set up input amps for analog loopback */
  1122. /* Amp Indices: DAC = 0, mixer = 1 */
  1123. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1124. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1125. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1126. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1128. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1129. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1130. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1131. { }
  1132. };
  1133. /*
  1134. * 3-stack pin configuration:
  1135. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1136. */
  1137. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1138. /*
  1139. * preset connection lists of input pins
  1140. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1141. */
  1142. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1143. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1144. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1145. /*
  1146. * Set pin mode and muting
  1147. */
  1148. /* set front pin widgets 0x14 for output */
  1149. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1150. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1151. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1152. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1153. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1154. /* Mic2 (as headphone out) for HP output */
  1155. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1156. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1157. /* Line In pin widget for input */
  1158. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1159. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1160. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1161. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1162. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1163. /* CD pin widget for input */
  1164. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1165. { }
  1166. };
  1167. /*
  1168. * 5-stack pin configuration:
  1169. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1170. * line-in/side = 0x1a, f-mic = 0x1b
  1171. */
  1172. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1173. /*
  1174. * preset connection lists of input pins
  1175. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1176. */
  1177. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1178. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1179. /*
  1180. * Set pin mode and muting
  1181. */
  1182. /* set pin widgets 0x14-0x17 for output */
  1183. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1184. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1186. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1187. /* unmute pins for output (no gain on this amp) */
  1188. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1189. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1190. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1191. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1192. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1193. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1194. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1195. /* Mic2 (as headphone out) for HP output */
  1196. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1197. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1198. /* Line In pin widget for input */
  1199. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1200. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1201. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1202. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1203. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1204. /* CD pin widget for input */
  1205. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1206. { }
  1207. };
  1208. /*
  1209. * W810 pin configuration:
  1210. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1211. */
  1212. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1213. /* hphone/speaker input selector: front DAC */
  1214. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1218. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1219. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1221. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1223. { }
  1224. };
  1225. /*
  1226. * Z71V pin configuration:
  1227. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1228. */
  1229. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1230. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1231. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1232. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1233. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1234. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1236. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1237. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1238. { }
  1239. };
  1240. /*
  1241. * 6-stack pin configuration:
  1242. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1243. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1244. */
  1245. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1246. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1248. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1249. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1256. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1258. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1260. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1262. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1263. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1264. { }
  1265. };
  1266. /*
  1267. * Uniwill pin configuration:
  1268. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1269. * line = 0x1a
  1270. */
  1271. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1272. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1273. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1274. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1275. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1276. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1277. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1278. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1279. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1280. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1281. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1282. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1283. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1284. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1285. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1286. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1287. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1288. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1290. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1291. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1292. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1293. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1294. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1295. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1296. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1297. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1298. { }
  1299. };
  1300. /*
  1301. * Uniwill P53
  1302. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1303. */
  1304. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1305. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1306. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1307. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1308. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1309. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1311. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1312. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1313. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1314. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1315. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1316. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1317. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1318. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1320. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1321. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1323. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1325. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1326. { }
  1327. };
  1328. static struct hda_verb alc880_beep_init_verbs[] = {
  1329. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1330. { }
  1331. };
  1332. /* toggle speaker-output according to the hp-jack state */
  1333. static void alc880_uniwill_automute(struct hda_codec *codec)
  1334. {
  1335. unsigned int present;
  1336. unsigned char bits;
  1337. present = snd_hda_codec_read(codec, 0x14, 0,
  1338. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1339. bits = present ? 0x80 : 0;
  1340. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1341. 0x80, bits);
  1342. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1343. 0x80, bits);
  1344. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1345. 0x80, bits);
  1346. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1347. 0x80, bits);
  1348. present = snd_hda_codec_read(codec, 0x18, 0,
  1349. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1350. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1351. 0x7000 | (0x01 << 8) | bits);
  1352. }
  1353. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1354. unsigned int res)
  1355. {
  1356. /* Looks like the unsol event is incompatible with the standard
  1357. * definition. 4bit tag is placed at 28 bit!
  1358. */
  1359. if ((res >> 28) == ALC880_HP_EVENT ||
  1360. (res >> 28) == ALC880_MIC_EVENT)
  1361. alc880_uniwill_automute(codec);
  1362. }
  1363. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1364. {
  1365. unsigned int present;
  1366. unsigned char bits;
  1367. present = snd_hda_codec_read(codec, 0x14, 0,
  1368. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1369. bits = present ? 0x80 : 0;
  1370. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1371. 0x80, bits);
  1372. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1373. 0x80, bits);
  1374. }
  1375. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1376. {
  1377. unsigned int present;
  1378. present = snd_hda_codec_read(codec, 0x21, 0,
  1379. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1380. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1381. 0x7f, present);
  1382. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1383. 0x7f, present);
  1384. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1385. 0x7f, present);
  1386. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1387. 0x7f, present);
  1388. }
  1389. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1390. unsigned int res)
  1391. {
  1392. /* Looks like the unsol event is incompatible with the standard
  1393. * definition. 4bit tag is placed at 28 bit!
  1394. */
  1395. if ((res >> 28) == ALC880_HP_EVENT)
  1396. alc880_uniwill_p53_hp_automute(codec);
  1397. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1398. alc880_uniwill_p53_dcvol_automute(codec);
  1399. }
  1400. /* FIXME! */
  1401. /*
  1402. * F1734 pin configuration:
  1403. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1404. */
  1405. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1406. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1407. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1408. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1409. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1410. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1411. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1412. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1413. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1414. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1415. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1416. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1417. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1418. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1419. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1420. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1421. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1422. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1423. { }
  1424. };
  1425. /* FIXME! */
  1426. /*
  1427. * ASUS pin configuration:
  1428. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1429. */
  1430. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1431. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1432. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1433. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1434. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1436. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1438. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1439. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1440. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1441. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1442. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1443. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1444. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1445. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1446. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1447. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1448. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1449. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1450. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1451. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1452. { }
  1453. };
  1454. /* Enable GPIO mask and set output */
  1455. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1456. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1457. /* Clevo m520g init */
  1458. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1459. /* headphone output */
  1460. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1461. /* line-out */
  1462. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1463. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1464. /* Line-in */
  1465. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1466. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. /* CD */
  1468. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1469. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1470. /* Mic1 (rear panel) */
  1471. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1472. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1473. /* Mic2 (front panel) */
  1474. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1475. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1476. /* headphone */
  1477. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1478. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1479. /* change to EAPD mode */
  1480. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1481. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1482. { }
  1483. };
  1484. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1485. /* change to EAPD mode */
  1486. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1487. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1488. /* Headphone output */
  1489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1490. /* Front output*/
  1491. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1493. /* Line In pin widget for input */
  1494. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. /* CD pin widget for input */
  1496. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1497. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. /* change to EAPD mode */
  1500. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1501. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1502. { }
  1503. };
  1504. /*
  1505. * LG m1 express dual
  1506. *
  1507. * Pin assignment:
  1508. * Rear Line-In/Out (blue): 0x14
  1509. * Build-in Mic-In: 0x15
  1510. * Speaker-out: 0x17
  1511. * HP-Out (green): 0x1b
  1512. * Mic-In/Out (red): 0x19
  1513. * SPDIF-Out: 0x1e
  1514. */
  1515. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1516. static hda_nid_t alc880_lg_dac_nids[3] = {
  1517. 0x05, 0x02, 0x03
  1518. };
  1519. /* seems analog CD is not working */
  1520. static struct hda_input_mux alc880_lg_capture_source = {
  1521. .num_items = 3,
  1522. .items = {
  1523. { "Mic", 0x1 },
  1524. { "Line", 0x5 },
  1525. { "Internal Mic", 0x6 },
  1526. },
  1527. };
  1528. /* 2,4,6 channel modes */
  1529. static struct hda_verb alc880_lg_ch2_init[] = {
  1530. /* set line-in and mic-in to input */
  1531. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1532. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1533. { }
  1534. };
  1535. static struct hda_verb alc880_lg_ch4_init[] = {
  1536. /* set line-in to out and mic-in to input */
  1537. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1538. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1539. { }
  1540. };
  1541. static struct hda_verb alc880_lg_ch6_init[] = {
  1542. /* set line-in and mic-in to output */
  1543. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1544. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1545. { }
  1546. };
  1547. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1548. { 2, alc880_lg_ch2_init },
  1549. { 4, alc880_lg_ch4_init },
  1550. { 6, alc880_lg_ch6_init },
  1551. };
  1552. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1553. /* FIXME: it's not really "master" but front channels */
  1554. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1555. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1556. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1557. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1558. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1559. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1560. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1561. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1562. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1563. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1564. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1565. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1566. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1567. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1568. {
  1569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1570. .name = "Channel Mode",
  1571. .info = alc_ch_mode_info,
  1572. .get = alc_ch_mode_get,
  1573. .put = alc_ch_mode_put,
  1574. },
  1575. { } /* end */
  1576. };
  1577. static struct hda_verb alc880_lg_init_verbs[] = {
  1578. /* set capture source to mic-in */
  1579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1580. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1581. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1582. /* mute all amp mixer inputs */
  1583. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1584. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1586. /* line-in to input */
  1587. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1588. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1589. /* built-in mic */
  1590. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1591. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1592. /* speaker-out */
  1593. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1594. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1595. /* mic-in to input */
  1596. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1597. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1598. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1599. /* HP-out */
  1600. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1602. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1603. /* jack sense */
  1604. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1605. { }
  1606. };
  1607. /* toggle speaker-output according to the hp-jack state */
  1608. static void alc880_lg_automute(struct hda_codec *codec)
  1609. {
  1610. unsigned int present;
  1611. unsigned char bits;
  1612. present = snd_hda_codec_read(codec, 0x1b, 0,
  1613. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1614. bits = present ? 0x80 : 0;
  1615. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1616. 0x80, bits);
  1617. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1618. 0x80, bits);
  1619. }
  1620. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1621. {
  1622. /* Looks like the unsol event is incompatible with the standard
  1623. * definition. 4bit tag is placed at 28 bit!
  1624. */
  1625. if ((res >> 28) == 0x01)
  1626. alc880_lg_automute(codec);
  1627. }
  1628. /*
  1629. * LG LW20
  1630. *
  1631. * Pin assignment:
  1632. * Speaker-out: 0x14
  1633. * Mic-In: 0x18
  1634. * Built-in Mic-In: 0x19 (?)
  1635. * HP-Out: 0x1b
  1636. * SPDIF-Out: 0x1e
  1637. */
  1638. /* seems analog CD is not working */
  1639. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1640. .num_items = 2,
  1641. .items = {
  1642. { "Mic", 0x0 },
  1643. { "Internal Mic", 0x1 },
  1644. },
  1645. };
  1646. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1647. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1648. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1649. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1650. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1651. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1652. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1653. { } /* end */
  1654. };
  1655. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1656. /* set capture source to mic-in */
  1657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1658. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1659. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1660. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1661. /* speaker-out */
  1662. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1663. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1664. /* HP-out */
  1665. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1666. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1667. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1668. /* mic-in to input */
  1669. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1670. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1671. /* built-in mic */
  1672. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1673. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* jack sense */
  1675. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1676. { }
  1677. };
  1678. /* toggle speaker-output according to the hp-jack state */
  1679. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1680. {
  1681. unsigned int present;
  1682. unsigned char bits;
  1683. present = snd_hda_codec_read(codec, 0x1b, 0,
  1684. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1685. bits = present ? 0x80 : 0;
  1686. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1687. 0x80, bits);
  1688. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1689. 0x80, bits);
  1690. }
  1691. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1692. {
  1693. /* Looks like the unsol event is incompatible with the standard
  1694. * definition. 4bit tag is placed at 28 bit!
  1695. */
  1696. if ((res >> 28) == 0x01)
  1697. alc880_lg_lw_automute(codec);
  1698. }
  1699. /*
  1700. * Common callbacks
  1701. */
  1702. static int alc_init(struct hda_codec *codec)
  1703. {
  1704. struct alc_spec *spec = codec->spec;
  1705. unsigned int i;
  1706. for (i = 0; i < spec->num_init_verbs; i++)
  1707. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1708. if (spec->init_hook)
  1709. spec->init_hook(codec);
  1710. return 0;
  1711. }
  1712. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1713. {
  1714. struct alc_spec *spec = codec->spec;
  1715. if (spec->unsol_event)
  1716. spec->unsol_event(codec, res);
  1717. }
  1718. #ifdef CONFIG_PM
  1719. /*
  1720. * resume
  1721. */
  1722. static int alc_resume(struct hda_codec *codec)
  1723. {
  1724. struct alc_spec *spec = codec->spec;
  1725. int i;
  1726. alc_init(codec);
  1727. for (i = 0; i < spec->num_mixers; i++)
  1728. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1729. if (spec->multiout.dig_out_nid)
  1730. snd_hda_resume_spdif_out(codec);
  1731. if (spec->dig_in_nid)
  1732. snd_hda_resume_spdif_in(codec);
  1733. return 0;
  1734. }
  1735. #endif
  1736. /*
  1737. * Analog playback callbacks
  1738. */
  1739. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1740. struct hda_codec *codec,
  1741. struct snd_pcm_substream *substream)
  1742. {
  1743. struct alc_spec *spec = codec->spec;
  1744. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1745. }
  1746. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1747. struct hda_codec *codec,
  1748. unsigned int stream_tag,
  1749. unsigned int format,
  1750. struct snd_pcm_substream *substream)
  1751. {
  1752. struct alc_spec *spec = codec->spec;
  1753. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1754. stream_tag, format, substream);
  1755. }
  1756. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1757. struct hda_codec *codec,
  1758. struct snd_pcm_substream *substream)
  1759. {
  1760. struct alc_spec *spec = codec->spec;
  1761. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1762. }
  1763. /*
  1764. * Digital out
  1765. */
  1766. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1767. struct hda_codec *codec,
  1768. struct snd_pcm_substream *substream)
  1769. {
  1770. struct alc_spec *spec = codec->spec;
  1771. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1772. }
  1773. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1774. struct hda_codec *codec,
  1775. unsigned int stream_tag,
  1776. unsigned int format,
  1777. struct snd_pcm_substream *substream)
  1778. {
  1779. struct alc_spec *spec = codec->spec;
  1780. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1781. stream_tag, format, substream);
  1782. }
  1783. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1784. struct hda_codec *codec,
  1785. struct snd_pcm_substream *substream)
  1786. {
  1787. struct alc_spec *spec = codec->spec;
  1788. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1789. }
  1790. /*
  1791. * Analog capture
  1792. */
  1793. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1794. struct hda_codec *codec,
  1795. unsigned int stream_tag,
  1796. unsigned int format,
  1797. struct snd_pcm_substream *substream)
  1798. {
  1799. struct alc_spec *spec = codec->spec;
  1800. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1801. stream_tag, 0, format);
  1802. return 0;
  1803. }
  1804. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1805. struct hda_codec *codec,
  1806. struct snd_pcm_substream *substream)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1810. 0, 0, 0);
  1811. return 0;
  1812. }
  1813. /*
  1814. */
  1815. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1816. .substreams = 1,
  1817. .channels_min = 2,
  1818. .channels_max = 8,
  1819. /* NID is set in alc_build_pcms */
  1820. .ops = {
  1821. .open = alc880_playback_pcm_open,
  1822. .prepare = alc880_playback_pcm_prepare,
  1823. .cleanup = alc880_playback_pcm_cleanup
  1824. },
  1825. };
  1826. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1827. .substreams = 2,
  1828. .channels_min = 2,
  1829. .channels_max = 2,
  1830. /* NID is set in alc_build_pcms */
  1831. .ops = {
  1832. .prepare = alc880_capture_pcm_prepare,
  1833. .cleanup = alc880_capture_pcm_cleanup
  1834. },
  1835. };
  1836. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1837. .substreams = 1,
  1838. .channels_min = 2,
  1839. .channels_max = 2,
  1840. /* NID is set in alc_build_pcms */
  1841. .ops = {
  1842. .open = alc880_dig_playback_pcm_open,
  1843. .close = alc880_dig_playback_pcm_close,
  1844. .prepare = alc880_dig_playback_pcm_prepare
  1845. },
  1846. };
  1847. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1848. .substreams = 1,
  1849. .channels_min = 2,
  1850. .channels_max = 2,
  1851. /* NID is set in alc_build_pcms */
  1852. };
  1853. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1854. static struct hda_pcm_stream alc_pcm_null_playback = {
  1855. .substreams = 0,
  1856. .channels_min = 0,
  1857. .channels_max = 0,
  1858. };
  1859. static int alc_build_pcms(struct hda_codec *codec)
  1860. {
  1861. struct alc_spec *spec = codec->spec;
  1862. struct hda_pcm *info = spec->pcm_rec;
  1863. int i;
  1864. codec->num_pcms = 1;
  1865. codec->pcm_info = info;
  1866. info->name = spec->stream_name_analog;
  1867. if (spec->stream_analog_playback) {
  1868. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1869. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1870. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1871. }
  1872. if (spec->stream_analog_capture) {
  1873. snd_assert(spec->adc_nids, return -EINVAL);
  1874. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1875. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1876. }
  1877. if (spec->channel_mode) {
  1878. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1879. for (i = 0; i < spec->num_channel_mode; i++) {
  1880. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1881. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1882. }
  1883. }
  1884. }
  1885. /* SPDIF for stream index #1 */
  1886. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1887. codec->num_pcms = 2;
  1888. info = spec->pcm_rec + 1;
  1889. info->name = spec->stream_name_digital;
  1890. if (spec->multiout.dig_out_nid &&
  1891. spec->stream_digital_playback) {
  1892. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1893. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1894. }
  1895. if (spec->dig_in_nid &&
  1896. spec->stream_digital_capture) {
  1897. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1898. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1899. }
  1900. }
  1901. /* If the use of more than one ADC is requested for the current
  1902. * model, configure a second analog capture-only PCM.
  1903. */
  1904. /* Additional Analaog capture for index #2 */
  1905. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1906. spec->adc_nids) {
  1907. codec->num_pcms = 3;
  1908. info = spec->pcm_rec + 2;
  1909. info->name = spec->stream_name_analog;
  1910. /* No playback stream for second PCM */
  1911. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1912. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1913. if (spec->stream_analog_capture) {
  1914. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1915. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1916. }
  1917. }
  1918. return 0;
  1919. }
  1920. static void alc_free(struct hda_codec *codec)
  1921. {
  1922. struct alc_spec *spec = codec->spec;
  1923. unsigned int i;
  1924. if (!spec)
  1925. return;
  1926. if (spec->kctl_alloc) {
  1927. for (i = 0; i < spec->num_kctl_used; i++)
  1928. kfree(spec->kctl_alloc[i].name);
  1929. kfree(spec->kctl_alloc);
  1930. }
  1931. kfree(spec);
  1932. }
  1933. /*
  1934. */
  1935. static struct hda_codec_ops alc_patch_ops = {
  1936. .build_controls = alc_build_controls,
  1937. .build_pcms = alc_build_pcms,
  1938. .init = alc_init,
  1939. .free = alc_free,
  1940. .unsol_event = alc_unsol_event,
  1941. #ifdef CONFIG_PM
  1942. .resume = alc_resume,
  1943. #endif
  1944. };
  1945. /*
  1946. * Test configuration for debugging
  1947. *
  1948. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1949. * enum controls.
  1950. */
  1951. #ifdef CONFIG_SND_DEBUG
  1952. static hda_nid_t alc880_test_dac_nids[4] = {
  1953. 0x02, 0x03, 0x04, 0x05
  1954. };
  1955. static struct hda_input_mux alc880_test_capture_source = {
  1956. .num_items = 7,
  1957. .items = {
  1958. { "In-1", 0x0 },
  1959. { "In-2", 0x1 },
  1960. { "In-3", 0x2 },
  1961. { "In-4", 0x3 },
  1962. { "CD", 0x4 },
  1963. { "Front", 0x5 },
  1964. { "Surround", 0x6 },
  1965. },
  1966. };
  1967. static struct hda_channel_mode alc880_test_modes[4] = {
  1968. { 2, NULL },
  1969. { 4, NULL },
  1970. { 6, NULL },
  1971. { 8, NULL },
  1972. };
  1973. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1974. struct snd_ctl_elem_info *uinfo)
  1975. {
  1976. static char *texts[] = {
  1977. "N/A", "Line Out", "HP Out",
  1978. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1979. };
  1980. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1981. uinfo->count = 1;
  1982. uinfo->value.enumerated.items = 8;
  1983. if (uinfo->value.enumerated.item >= 8)
  1984. uinfo->value.enumerated.item = 7;
  1985. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1986. return 0;
  1987. }
  1988. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1989. struct snd_ctl_elem_value *ucontrol)
  1990. {
  1991. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1992. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1993. unsigned int pin_ctl, item = 0;
  1994. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1995. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1996. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1997. if (pin_ctl & AC_PINCTL_HP_EN)
  1998. item = 2;
  1999. else
  2000. item = 1;
  2001. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2002. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2003. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2004. case AC_PINCTL_VREF_50: item = 4; break;
  2005. case AC_PINCTL_VREF_GRD: item = 5; break;
  2006. case AC_PINCTL_VREF_80: item = 6; break;
  2007. case AC_PINCTL_VREF_100: item = 7; break;
  2008. }
  2009. }
  2010. ucontrol->value.enumerated.item[0] = item;
  2011. return 0;
  2012. }
  2013. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2014. struct snd_ctl_elem_value *ucontrol)
  2015. {
  2016. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2017. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2018. static unsigned int ctls[] = {
  2019. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2020. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2021. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2022. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2023. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2024. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2025. };
  2026. unsigned int old_ctl, new_ctl;
  2027. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2028. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2029. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2030. if (old_ctl != new_ctl) {
  2031. snd_hda_codec_write(codec, nid, 0,
  2032. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2033. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2034. (ucontrol->value.enumerated.item[0] >= 3 ?
  2035. 0xb080 : 0xb000));
  2036. return 1;
  2037. }
  2038. return 0;
  2039. }
  2040. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2041. struct snd_ctl_elem_info *uinfo)
  2042. {
  2043. static char *texts[] = {
  2044. "Front", "Surround", "CLFE", "Side"
  2045. };
  2046. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2047. uinfo->count = 1;
  2048. uinfo->value.enumerated.items = 4;
  2049. if (uinfo->value.enumerated.item >= 4)
  2050. uinfo->value.enumerated.item = 3;
  2051. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2052. return 0;
  2053. }
  2054. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2055. struct snd_ctl_elem_value *ucontrol)
  2056. {
  2057. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2058. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2059. unsigned int sel;
  2060. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2061. ucontrol->value.enumerated.item[0] = sel & 3;
  2062. return 0;
  2063. }
  2064. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2065. struct snd_ctl_elem_value *ucontrol)
  2066. {
  2067. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2068. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2069. unsigned int sel;
  2070. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2071. if (ucontrol->value.enumerated.item[0] != sel) {
  2072. sel = ucontrol->value.enumerated.item[0] & 3;
  2073. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2074. return 1;
  2075. }
  2076. return 0;
  2077. }
  2078. #define PIN_CTL_TEST(xname,nid) { \
  2079. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2080. .name = xname, \
  2081. .info = alc_test_pin_ctl_info, \
  2082. .get = alc_test_pin_ctl_get, \
  2083. .put = alc_test_pin_ctl_put, \
  2084. .private_value = nid \
  2085. }
  2086. #define PIN_SRC_TEST(xname,nid) { \
  2087. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2088. .name = xname, \
  2089. .info = alc_test_pin_src_info, \
  2090. .get = alc_test_pin_src_get, \
  2091. .put = alc_test_pin_src_put, \
  2092. .private_value = nid \
  2093. }
  2094. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2095. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2096. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2097. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2098. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2099. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2100. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2101. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2102. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2103. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2104. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2105. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2106. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2107. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2108. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2109. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2110. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2111. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2112. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2113. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2114. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2115. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2116. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2117. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2118. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2119. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2120. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2121. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2122. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2123. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2124. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2125. {
  2126. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2127. .name = "Channel Mode",
  2128. .info = alc_ch_mode_info,
  2129. .get = alc_ch_mode_get,
  2130. .put = alc_ch_mode_put,
  2131. },
  2132. { } /* end */
  2133. };
  2134. static struct hda_verb alc880_test_init_verbs[] = {
  2135. /* Unmute inputs of 0x0c - 0x0f */
  2136. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2137. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2138. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2139. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2140. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2141. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2142. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2143. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2144. /* Vol output for 0x0c-0x0f */
  2145. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2146. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2147. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2148. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2149. /* Set output pins 0x14-0x17 */
  2150. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2151. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2152. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2153. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2154. /* Unmute output pins 0x14-0x17 */
  2155. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2156. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2157. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2158. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2159. /* Set input pins 0x18-0x1c */
  2160. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2161. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2162. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2163. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2164. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2165. /* Mute input pins 0x18-0x1b */
  2166. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2167. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2168. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2169. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2170. /* ADC set up */
  2171. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2172. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2173. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2174. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2175. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2176. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2177. /* Analog input/passthru */
  2178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2181. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2182. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2183. { }
  2184. };
  2185. #endif
  2186. /*
  2187. */
  2188. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2189. [ALC880_3ST] = "3stack",
  2190. [ALC880_TCL_S700] = "tcl",
  2191. [ALC880_3ST_DIG] = "3stack-digout",
  2192. [ALC880_CLEVO] = "clevo",
  2193. [ALC880_5ST] = "5stack",
  2194. [ALC880_5ST_DIG] = "5stack-digout",
  2195. [ALC880_W810] = "w810",
  2196. [ALC880_Z71V] = "z71v",
  2197. [ALC880_6ST] = "6stack",
  2198. [ALC880_6ST_DIG] = "6stack-digout",
  2199. [ALC880_ASUS] = "asus",
  2200. [ALC880_ASUS_W1V] = "asus-w1v",
  2201. [ALC880_ASUS_DIG] = "asus-dig",
  2202. [ALC880_ASUS_DIG2] = "asus-dig2",
  2203. [ALC880_UNIWILL_DIG] = "uniwill",
  2204. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2205. [ALC880_FUJITSU] = "fujitsu",
  2206. [ALC880_F1734] = "F1734",
  2207. [ALC880_LG] = "lg",
  2208. [ALC880_LG_LW] = "lg-lw",
  2209. #ifdef CONFIG_SND_DEBUG
  2210. [ALC880_TEST] = "test",
  2211. #endif
  2212. [ALC880_AUTO] = "auto",
  2213. };
  2214. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2215. /* Broken BIOS configuration */
  2216. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2217. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2218. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2219. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2220. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2221. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2222. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2223. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2224. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2225. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2226. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2227. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2228. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2229. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2230. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2231. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2232. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2233. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2234. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2235. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2236. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2237. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2238. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2239. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2240. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2241. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2242. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2243. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2244. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2245. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2246. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2247. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2248. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2249. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2250. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2251. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2252. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2253. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2254. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2255. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2256. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2257. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2258. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2259. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2260. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2261. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2262. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2263. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2264. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2265. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2266. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2267. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2268. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2269. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2270. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2271. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2272. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2273. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2274. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2275. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2276. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2277. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2278. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2279. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2280. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2281. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2282. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2283. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2284. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2285. {}
  2286. };
  2287. /*
  2288. * ALC880 codec presets
  2289. */
  2290. static struct alc_config_preset alc880_presets[] = {
  2291. [ALC880_3ST] = {
  2292. .mixers = { alc880_three_stack_mixer },
  2293. .init_verbs = { alc880_volume_init_verbs,
  2294. alc880_pin_3stack_init_verbs },
  2295. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2296. .dac_nids = alc880_dac_nids,
  2297. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2298. .channel_mode = alc880_threestack_modes,
  2299. .need_dac_fix = 1,
  2300. .input_mux = &alc880_capture_source,
  2301. },
  2302. [ALC880_3ST_DIG] = {
  2303. .mixers = { alc880_three_stack_mixer },
  2304. .init_verbs = { alc880_volume_init_verbs,
  2305. alc880_pin_3stack_init_verbs },
  2306. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2307. .dac_nids = alc880_dac_nids,
  2308. .dig_out_nid = ALC880_DIGOUT_NID,
  2309. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2310. .channel_mode = alc880_threestack_modes,
  2311. .need_dac_fix = 1,
  2312. .input_mux = &alc880_capture_source,
  2313. },
  2314. [ALC880_TCL_S700] = {
  2315. .mixers = { alc880_tcl_s700_mixer },
  2316. .init_verbs = { alc880_volume_init_verbs,
  2317. alc880_pin_tcl_S700_init_verbs,
  2318. alc880_gpio2_init_verbs },
  2319. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2320. .dac_nids = alc880_dac_nids,
  2321. .hp_nid = 0x03,
  2322. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2323. .channel_mode = alc880_2_jack_modes,
  2324. .input_mux = &alc880_capture_source,
  2325. },
  2326. [ALC880_5ST] = {
  2327. .mixers = { alc880_three_stack_mixer,
  2328. alc880_five_stack_mixer},
  2329. .init_verbs = { alc880_volume_init_verbs,
  2330. alc880_pin_5stack_init_verbs },
  2331. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2332. .dac_nids = alc880_dac_nids,
  2333. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2334. .channel_mode = alc880_fivestack_modes,
  2335. .input_mux = &alc880_capture_source,
  2336. },
  2337. [ALC880_5ST_DIG] = {
  2338. .mixers = { alc880_three_stack_mixer,
  2339. alc880_five_stack_mixer },
  2340. .init_verbs = { alc880_volume_init_verbs,
  2341. alc880_pin_5stack_init_verbs },
  2342. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2343. .dac_nids = alc880_dac_nids,
  2344. .dig_out_nid = ALC880_DIGOUT_NID,
  2345. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2346. .channel_mode = alc880_fivestack_modes,
  2347. .input_mux = &alc880_capture_source,
  2348. },
  2349. [ALC880_6ST] = {
  2350. .mixers = { alc880_six_stack_mixer },
  2351. .init_verbs = { alc880_volume_init_verbs,
  2352. alc880_pin_6stack_init_verbs },
  2353. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2354. .dac_nids = alc880_6st_dac_nids,
  2355. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2356. .channel_mode = alc880_sixstack_modes,
  2357. .input_mux = &alc880_6stack_capture_source,
  2358. },
  2359. [ALC880_6ST_DIG] = {
  2360. .mixers = { alc880_six_stack_mixer },
  2361. .init_verbs = { alc880_volume_init_verbs,
  2362. alc880_pin_6stack_init_verbs },
  2363. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2364. .dac_nids = alc880_6st_dac_nids,
  2365. .dig_out_nid = ALC880_DIGOUT_NID,
  2366. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2367. .channel_mode = alc880_sixstack_modes,
  2368. .input_mux = &alc880_6stack_capture_source,
  2369. },
  2370. [ALC880_W810] = {
  2371. .mixers = { alc880_w810_base_mixer },
  2372. .init_verbs = { alc880_volume_init_verbs,
  2373. alc880_pin_w810_init_verbs,
  2374. alc880_gpio2_init_verbs },
  2375. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2376. .dac_nids = alc880_w810_dac_nids,
  2377. .dig_out_nid = ALC880_DIGOUT_NID,
  2378. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2379. .channel_mode = alc880_w810_modes,
  2380. .input_mux = &alc880_capture_source,
  2381. },
  2382. [ALC880_Z71V] = {
  2383. .mixers = { alc880_z71v_mixer },
  2384. .init_verbs = { alc880_volume_init_verbs,
  2385. alc880_pin_z71v_init_verbs },
  2386. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2387. .dac_nids = alc880_z71v_dac_nids,
  2388. .dig_out_nid = ALC880_DIGOUT_NID,
  2389. .hp_nid = 0x03,
  2390. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2391. .channel_mode = alc880_2_jack_modes,
  2392. .input_mux = &alc880_capture_source,
  2393. },
  2394. [ALC880_F1734] = {
  2395. .mixers = { alc880_f1734_mixer },
  2396. .init_verbs = { alc880_volume_init_verbs,
  2397. alc880_pin_f1734_init_verbs },
  2398. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2399. .dac_nids = alc880_f1734_dac_nids,
  2400. .hp_nid = 0x02,
  2401. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2402. .channel_mode = alc880_2_jack_modes,
  2403. .input_mux = &alc880_capture_source,
  2404. },
  2405. [ALC880_ASUS] = {
  2406. .mixers = { alc880_asus_mixer },
  2407. .init_verbs = { alc880_volume_init_verbs,
  2408. alc880_pin_asus_init_verbs,
  2409. alc880_gpio1_init_verbs },
  2410. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2411. .dac_nids = alc880_asus_dac_nids,
  2412. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2413. .channel_mode = alc880_asus_modes,
  2414. .need_dac_fix = 1,
  2415. .input_mux = &alc880_capture_source,
  2416. },
  2417. [ALC880_ASUS_DIG] = {
  2418. .mixers = { alc880_asus_mixer },
  2419. .init_verbs = { alc880_volume_init_verbs,
  2420. alc880_pin_asus_init_verbs,
  2421. alc880_gpio1_init_verbs },
  2422. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2423. .dac_nids = alc880_asus_dac_nids,
  2424. .dig_out_nid = ALC880_DIGOUT_NID,
  2425. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2426. .channel_mode = alc880_asus_modes,
  2427. .need_dac_fix = 1,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_ASUS_DIG2] = {
  2431. .mixers = { alc880_asus_mixer },
  2432. .init_verbs = { alc880_volume_init_verbs,
  2433. alc880_pin_asus_init_verbs,
  2434. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2435. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2436. .dac_nids = alc880_asus_dac_nids,
  2437. .dig_out_nid = ALC880_DIGOUT_NID,
  2438. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2439. .channel_mode = alc880_asus_modes,
  2440. .need_dac_fix = 1,
  2441. .input_mux = &alc880_capture_source,
  2442. },
  2443. [ALC880_ASUS_W1V] = {
  2444. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2445. .init_verbs = { alc880_volume_init_verbs,
  2446. alc880_pin_asus_init_verbs,
  2447. alc880_gpio1_init_verbs },
  2448. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2449. .dac_nids = alc880_asus_dac_nids,
  2450. .dig_out_nid = ALC880_DIGOUT_NID,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2452. .channel_mode = alc880_asus_modes,
  2453. .need_dac_fix = 1,
  2454. .input_mux = &alc880_capture_source,
  2455. },
  2456. [ALC880_UNIWILL_DIG] = {
  2457. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2458. .init_verbs = { alc880_volume_init_verbs,
  2459. alc880_pin_asus_init_verbs },
  2460. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2461. .dac_nids = alc880_asus_dac_nids,
  2462. .dig_out_nid = ALC880_DIGOUT_NID,
  2463. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2464. .channel_mode = alc880_asus_modes,
  2465. .need_dac_fix = 1,
  2466. .input_mux = &alc880_capture_source,
  2467. },
  2468. [ALC880_UNIWILL] = {
  2469. .mixers = { alc880_uniwill_mixer },
  2470. .init_verbs = { alc880_volume_init_verbs,
  2471. alc880_uniwill_init_verbs },
  2472. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2473. .dac_nids = alc880_asus_dac_nids,
  2474. .dig_out_nid = ALC880_DIGOUT_NID,
  2475. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2476. .channel_mode = alc880_threestack_modes,
  2477. .need_dac_fix = 1,
  2478. .input_mux = &alc880_capture_source,
  2479. .unsol_event = alc880_uniwill_unsol_event,
  2480. .init_hook = alc880_uniwill_automute,
  2481. },
  2482. [ALC880_UNIWILL_P53] = {
  2483. .mixers = { alc880_uniwill_p53_mixer },
  2484. .init_verbs = { alc880_volume_init_verbs,
  2485. alc880_uniwill_p53_init_verbs },
  2486. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2487. .dac_nids = alc880_asus_dac_nids,
  2488. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2489. .channel_mode = alc880_threestack_modes,
  2490. .input_mux = &alc880_capture_source,
  2491. .unsol_event = alc880_uniwill_p53_unsol_event,
  2492. .init_hook = alc880_uniwill_p53_hp_automute,
  2493. },
  2494. [ALC880_FUJITSU] = {
  2495. .mixers = { alc880_fujitsu_mixer,
  2496. alc880_pcbeep_mixer, },
  2497. .init_verbs = { alc880_volume_init_verbs,
  2498. alc880_uniwill_p53_init_verbs,
  2499. alc880_beep_init_verbs },
  2500. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2501. .dac_nids = alc880_dac_nids,
  2502. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2503. .channel_mode = alc880_2_jack_modes,
  2504. .input_mux = &alc880_capture_source,
  2505. .unsol_event = alc880_uniwill_p53_unsol_event,
  2506. .init_hook = alc880_uniwill_p53_hp_automute,
  2507. },
  2508. [ALC880_CLEVO] = {
  2509. .mixers = { alc880_three_stack_mixer },
  2510. .init_verbs = { alc880_volume_init_verbs,
  2511. alc880_pin_clevo_init_verbs },
  2512. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2513. .dac_nids = alc880_dac_nids,
  2514. .hp_nid = 0x03,
  2515. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2516. .channel_mode = alc880_threestack_modes,
  2517. .need_dac_fix = 1,
  2518. .input_mux = &alc880_capture_source,
  2519. },
  2520. [ALC880_LG] = {
  2521. .mixers = { alc880_lg_mixer },
  2522. .init_verbs = { alc880_volume_init_verbs,
  2523. alc880_lg_init_verbs },
  2524. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2525. .dac_nids = alc880_lg_dac_nids,
  2526. .dig_out_nid = ALC880_DIGOUT_NID,
  2527. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2528. .channel_mode = alc880_lg_ch_modes,
  2529. .need_dac_fix = 1,
  2530. .input_mux = &alc880_lg_capture_source,
  2531. .unsol_event = alc880_lg_unsol_event,
  2532. .init_hook = alc880_lg_automute,
  2533. },
  2534. [ALC880_LG_LW] = {
  2535. .mixers = { alc880_lg_lw_mixer },
  2536. .init_verbs = { alc880_volume_init_verbs,
  2537. alc880_lg_lw_init_verbs },
  2538. .num_dacs = 1,
  2539. .dac_nids = alc880_dac_nids,
  2540. .dig_out_nid = ALC880_DIGOUT_NID,
  2541. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2542. .channel_mode = alc880_2_jack_modes,
  2543. .input_mux = &alc880_lg_lw_capture_source,
  2544. .unsol_event = alc880_lg_lw_unsol_event,
  2545. .init_hook = alc880_lg_lw_automute,
  2546. },
  2547. #ifdef CONFIG_SND_DEBUG
  2548. [ALC880_TEST] = {
  2549. .mixers = { alc880_test_mixer },
  2550. .init_verbs = { alc880_test_init_verbs },
  2551. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2552. .dac_nids = alc880_test_dac_nids,
  2553. .dig_out_nid = ALC880_DIGOUT_NID,
  2554. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2555. .channel_mode = alc880_test_modes,
  2556. .input_mux = &alc880_test_capture_source,
  2557. },
  2558. #endif
  2559. };
  2560. /*
  2561. * Automatic parse of I/O pins from the BIOS configuration
  2562. */
  2563. #define NUM_CONTROL_ALLOC 32
  2564. #define NUM_VERB_ALLOC 32
  2565. enum {
  2566. ALC_CTL_WIDGET_VOL,
  2567. ALC_CTL_WIDGET_MUTE,
  2568. ALC_CTL_BIND_MUTE,
  2569. };
  2570. static struct snd_kcontrol_new alc880_control_templates[] = {
  2571. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2572. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2573. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2574. };
  2575. /* add dynamic controls */
  2576. static int add_control(struct alc_spec *spec, int type, const char *name,
  2577. unsigned long val)
  2578. {
  2579. struct snd_kcontrol_new *knew;
  2580. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2581. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2582. /* array + terminator */
  2583. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2584. if (!knew)
  2585. return -ENOMEM;
  2586. if (spec->kctl_alloc) {
  2587. memcpy(knew, spec->kctl_alloc,
  2588. sizeof(*knew) * spec->num_kctl_alloc);
  2589. kfree(spec->kctl_alloc);
  2590. }
  2591. spec->kctl_alloc = knew;
  2592. spec->num_kctl_alloc = num;
  2593. }
  2594. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2595. *knew = alc880_control_templates[type];
  2596. knew->name = kstrdup(name, GFP_KERNEL);
  2597. if (!knew->name)
  2598. return -ENOMEM;
  2599. knew->private_value = val;
  2600. spec->num_kctl_used++;
  2601. return 0;
  2602. }
  2603. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2604. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2605. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2606. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2607. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2608. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2609. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2610. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2611. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2612. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2613. #define ALC880_PIN_CD_NID 0x1c
  2614. /* fill in the dac_nids table from the parsed pin configuration */
  2615. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2616. const struct auto_pin_cfg *cfg)
  2617. {
  2618. hda_nid_t nid;
  2619. int assigned[4];
  2620. int i, j;
  2621. memset(assigned, 0, sizeof(assigned));
  2622. spec->multiout.dac_nids = spec->private_dac_nids;
  2623. /* check the pins hardwired to audio widget */
  2624. for (i = 0; i < cfg->line_outs; i++) {
  2625. nid = cfg->line_out_pins[i];
  2626. if (alc880_is_fixed_pin(nid)) {
  2627. int idx = alc880_fixed_pin_idx(nid);
  2628. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2629. assigned[idx] = 1;
  2630. }
  2631. }
  2632. /* left pins can be connect to any audio widget */
  2633. for (i = 0; i < cfg->line_outs; i++) {
  2634. nid = cfg->line_out_pins[i];
  2635. if (alc880_is_fixed_pin(nid))
  2636. continue;
  2637. /* search for an empty channel */
  2638. for (j = 0; j < cfg->line_outs; j++) {
  2639. if (!assigned[j]) {
  2640. spec->multiout.dac_nids[i] =
  2641. alc880_idx_to_dac(j);
  2642. assigned[j] = 1;
  2643. break;
  2644. }
  2645. }
  2646. }
  2647. spec->multiout.num_dacs = cfg->line_outs;
  2648. return 0;
  2649. }
  2650. /* add playback controls from the parsed DAC table */
  2651. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2652. const struct auto_pin_cfg *cfg)
  2653. {
  2654. char name[32];
  2655. static const char *chname[4] = {
  2656. "Front", "Surround", NULL /*CLFE*/, "Side"
  2657. };
  2658. hda_nid_t nid;
  2659. int i, err;
  2660. for (i = 0; i < cfg->line_outs; i++) {
  2661. if (!spec->multiout.dac_nids[i])
  2662. continue;
  2663. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2664. if (i == 2) {
  2665. /* Center/LFE */
  2666. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2667. "Center Playback Volume",
  2668. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2669. HDA_OUTPUT));
  2670. if (err < 0)
  2671. return err;
  2672. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2673. "LFE Playback Volume",
  2674. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2675. HDA_OUTPUT));
  2676. if (err < 0)
  2677. return err;
  2678. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2679. "Center Playback Switch",
  2680. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2681. HDA_INPUT));
  2682. if (err < 0)
  2683. return err;
  2684. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2685. "LFE Playback Switch",
  2686. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2687. HDA_INPUT));
  2688. if (err < 0)
  2689. return err;
  2690. } else {
  2691. sprintf(name, "%s Playback Volume", chname[i]);
  2692. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2693. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2694. HDA_OUTPUT));
  2695. if (err < 0)
  2696. return err;
  2697. sprintf(name, "%s Playback Switch", chname[i]);
  2698. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2699. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2700. HDA_INPUT));
  2701. if (err < 0)
  2702. return err;
  2703. }
  2704. }
  2705. return 0;
  2706. }
  2707. /* add playback controls for speaker and HP outputs */
  2708. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2709. const char *pfx)
  2710. {
  2711. hda_nid_t nid;
  2712. int err;
  2713. char name[32];
  2714. if (!pin)
  2715. return 0;
  2716. if (alc880_is_fixed_pin(pin)) {
  2717. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2718. /* specify the DAC as the extra output */
  2719. if (!spec->multiout.hp_nid)
  2720. spec->multiout.hp_nid = nid;
  2721. else
  2722. spec->multiout.extra_out_nid[0] = nid;
  2723. /* control HP volume/switch on the output mixer amp */
  2724. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2725. sprintf(name, "%s Playback Volume", pfx);
  2726. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2727. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2728. if (err < 0)
  2729. return err;
  2730. sprintf(name, "%s Playback Switch", pfx);
  2731. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2732. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2733. if (err < 0)
  2734. return err;
  2735. } else if (alc880_is_multi_pin(pin)) {
  2736. /* set manual connection */
  2737. /* we have only a switch on HP-out PIN */
  2738. sprintf(name, "%s Playback Switch", pfx);
  2739. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2740. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2741. if (err < 0)
  2742. return err;
  2743. }
  2744. return 0;
  2745. }
  2746. /* create input playback/capture controls for the given pin */
  2747. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2748. const char *ctlname,
  2749. int idx, hda_nid_t mix_nid)
  2750. {
  2751. char name[32];
  2752. int err;
  2753. sprintf(name, "%s Playback Volume", ctlname);
  2754. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2755. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2756. if (err < 0)
  2757. return err;
  2758. sprintf(name, "%s Playback Switch", ctlname);
  2759. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2760. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2761. if (err < 0)
  2762. return err;
  2763. return 0;
  2764. }
  2765. /* create playback/capture controls for input pins */
  2766. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2767. const struct auto_pin_cfg *cfg)
  2768. {
  2769. struct hda_input_mux *imux = &spec->private_imux;
  2770. int i, err, idx;
  2771. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2772. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2773. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2774. err = new_analog_input(spec, cfg->input_pins[i],
  2775. auto_pin_cfg_labels[i],
  2776. idx, 0x0b);
  2777. if (err < 0)
  2778. return err;
  2779. imux->items[imux->num_items].label =
  2780. auto_pin_cfg_labels[i];
  2781. imux->items[imux->num_items].index =
  2782. alc880_input_pin_idx(cfg->input_pins[i]);
  2783. imux->num_items++;
  2784. }
  2785. }
  2786. return 0;
  2787. }
  2788. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2789. hda_nid_t nid, int pin_type,
  2790. int dac_idx)
  2791. {
  2792. /* set as output */
  2793. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2794. pin_type);
  2795. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2796. AMP_OUT_UNMUTE);
  2797. /* need the manual connection? */
  2798. if (alc880_is_multi_pin(nid)) {
  2799. struct alc_spec *spec = codec->spec;
  2800. int idx = alc880_multi_pin_idx(nid);
  2801. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2802. AC_VERB_SET_CONNECT_SEL,
  2803. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2804. }
  2805. }
  2806. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2807. {
  2808. struct alc_spec *spec = codec->spec;
  2809. int i;
  2810. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2811. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2812. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2813. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2814. }
  2815. }
  2816. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2817. {
  2818. struct alc_spec *spec = codec->spec;
  2819. hda_nid_t pin;
  2820. pin = spec->autocfg.speaker_pins[0];
  2821. if (pin) /* connect to front */
  2822. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2823. pin = spec->autocfg.hp_pins[0];
  2824. if (pin) /* connect to front */
  2825. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2826. }
  2827. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2828. {
  2829. struct alc_spec *spec = codec->spec;
  2830. int i;
  2831. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2832. hda_nid_t nid = spec->autocfg.input_pins[i];
  2833. if (alc880_is_input_pin(nid)) {
  2834. snd_hda_codec_write(codec, nid, 0,
  2835. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2836. i <= AUTO_PIN_FRONT_MIC ?
  2837. PIN_VREF80 : PIN_IN);
  2838. if (nid != ALC880_PIN_CD_NID)
  2839. snd_hda_codec_write(codec, nid, 0,
  2840. AC_VERB_SET_AMP_GAIN_MUTE,
  2841. AMP_OUT_MUTE);
  2842. }
  2843. }
  2844. }
  2845. /* parse the BIOS configuration and set up the alc_spec */
  2846. /* return 1 if successful, 0 if the proper config is not found,
  2847. * or a negative error code
  2848. */
  2849. static int alc880_parse_auto_config(struct hda_codec *codec)
  2850. {
  2851. struct alc_spec *spec = codec->spec;
  2852. int err;
  2853. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2854. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2855. alc880_ignore);
  2856. if (err < 0)
  2857. return err;
  2858. if (!spec->autocfg.line_outs)
  2859. return 0; /* can't find valid BIOS pin config */
  2860. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2861. if (err < 0)
  2862. return err;
  2863. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2864. if (err < 0)
  2865. return err;
  2866. err = alc880_auto_create_extra_out(spec,
  2867. spec->autocfg.speaker_pins[0],
  2868. "Speaker");
  2869. if (err < 0)
  2870. return err;
  2871. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2872. "Headphone");
  2873. if (err < 0)
  2874. return err;
  2875. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2876. if (err < 0)
  2877. return err;
  2878. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2879. if (spec->autocfg.dig_out_pin)
  2880. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2881. if (spec->autocfg.dig_in_pin)
  2882. spec->dig_in_nid = ALC880_DIGIN_NID;
  2883. if (spec->kctl_alloc)
  2884. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2885. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2886. spec->num_mux_defs = 1;
  2887. spec->input_mux = &spec->private_imux;
  2888. return 1;
  2889. }
  2890. /* additional initialization for auto-configuration model */
  2891. static void alc880_auto_init(struct hda_codec *codec)
  2892. {
  2893. alc880_auto_init_multi_out(codec);
  2894. alc880_auto_init_extra_out(codec);
  2895. alc880_auto_init_analog_input(codec);
  2896. }
  2897. /*
  2898. * OK, here we have finally the patch for ALC880
  2899. */
  2900. static int patch_alc880(struct hda_codec *codec)
  2901. {
  2902. struct alc_spec *spec;
  2903. int board_config;
  2904. int err;
  2905. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2906. if (spec == NULL)
  2907. return -ENOMEM;
  2908. codec->spec = spec;
  2909. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2910. alc880_models,
  2911. alc880_cfg_tbl);
  2912. if (board_config < 0) {
  2913. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2914. "trying auto-probe from BIOS...\n");
  2915. board_config = ALC880_AUTO;
  2916. }
  2917. if (board_config == ALC880_AUTO) {
  2918. /* automatic parse from the BIOS config */
  2919. err = alc880_parse_auto_config(codec);
  2920. if (err < 0) {
  2921. alc_free(codec);
  2922. return err;
  2923. } else if (!err) {
  2924. printk(KERN_INFO
  2925. "hda_codec: Cannot set up configuration "
  2926. "from BIOS. Using 3-stack mode...\n");
  2927. board_config = ALC880_3ST;
  2928. }
  2929. }
  2930. if (board_config != ALC880_AUTO)
  2931. setup_preset(spec, &alc880_presets[board_config]);
  2932. spec->stream_name_analog = "ALC880 Analog";
  2933. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2934. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2935. spec->stream_name_digital = "ALC880 Digital";
  2936. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2937. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2938. if (!spec->adc_nids && spec->input_mux) {
  2939. /* check whether NID 0x07 is valid */
  2940. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2941. /* get type */
  2942. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  2943. if (wcap != AC_WID_AUD_IN) {
  2944. spec->adc_nids = alc880_adc_nids_alt;
  2945. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2946. spec->mixers[spec->num_mixers] =
  2947. alc880_capture_alt_mixer;
  2948. spec->num_mixers++;
  2949. } else {
  2950. spec->adc_nids = alc880_adc_nids;
  2951. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2952. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2953. spec->num_mixers++;
  2954. }
  2955. }
  2956. codec->patch_ops = alc_patch_ops;
  2957. if (board_config == ALC880_AUTO)
  2958. spec->init_hook = alc880_auto_init;
  2959. return 0;
  2960. }
  2961. /*
  2962. * ALC260 support
  2963. */
  2964. static hda_nid_t alc260_dac_nids[1] = {
  2965. /* front */
  2966. 0x02,
  2967. };
  2968. static hda_nid_t alc260_adc_nids[1] = {
  2969. /* ADC0 */
  2970. 0x04,
  2971. };
  2972. static hda_nid_t alc260_adc_nids_alt[1] = {
  2973. /* ADC1 */
  2974. 0x05,
  2975. };
  2976. static hda_nid_t alc260_hp_adc_nids[2] = {
  2977. /* ADC1, 0 */
  2978. 0x05, 0x04
  2979. };
  2980. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2981. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2982. */
  2983. static hda_nid_t alc260_dual_adc_nids[2] = {
  2984. /* ADC0, ADC1 */
  2985. 0x04, 0x05
  2986. };
  2987. #define ALC260_DIGOUT_NID 0x03
  2988. #define ALC260_DIGIN_NID 0x06
  2989. static struct hda_input_mux alc260_capture_source = {
  2990. .num_items = 4,
  2991. .items = {
  2992. { "Mic", 0x0 },
  2993. { "Front Mic", 0x1 },
  2994. { "Line", 0x2 },
  2995. { "CD", 0x4 },
  2996. },
  2997. };
  2998. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2999. * headphone jack and the internal CD lines since these are the only pins at
  3000. * which audio can appear. For flexibility, also allow the option of
  3001. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3002. * connection to the mixer output).
  3003. */
  3004. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3005. {
  3006. .num_items = 3,
  3007. .items = {
  3008. { "Mic/Line", 0x0 },
  3009. { "CD", 0x4 },
  3010. { "Headphone", 0x2 },
  3011. },
  3012. },
  3013. {
  3014. .num_items = 4,
  3015. .items = {
  3016. { "Mic/Line", 0x0 },
  3017. { "CD", 0x4 },
  3018. { "Headphone", 0x2 },
  3019. { "Mixer", 0x5 },
  3020. },
  3021. },
  3022. };
  3023. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3024. * the Fujitsu S702x, but jacks are marked differently.
  3025. */
  3026. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3027. {
  3028. .num_items = 4,
  3029. .items = {
  3030. { "Mic", 0x0 },
  3031. { "Line", 0x2 },
  3032. { "CD", 0x4 },
  3033. { "Headphone", 0x5 },
  3034. },
  3035. },
  3036. {
  3037. .num_items = 5,
  3038. .items = {
  3039. { "Mic", 0x0 },
  3040. { "Line", 0x2 },
  3041. { "CD", 0x4 },
  3042. { "Headphone", 0x6 },
  3043. { "Mixer", 0x5 },
  3044. },
  3045. },
  3046. };
  3047. /*
  3048. * This is just place-holder, so there's something for alc_build_pcms to look
  3049. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3050. * element which allows changing the channel mode, so the verb list is
  3051. * never used.
  3052. */
  3053. static struct hda_channel_mode alc260_modes[1] = {
  3054. { 2, NULL },
  3055. };
  3056. /* Mixer combinations
  3057. *
  3058. * basic: base_output + input + pc_beep + capture
  3059. * HP: base_output + input + capture_alt
  3060. * HP_3013: hp_3013 + input + capture
  3061. * fujitsu: fujitsu + capture
  3062. * acer: acer + capture
  3063. */
  3064. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3065. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3066. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3067. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3068. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3069. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3070. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3071. { } /* end */
  3072. };
  3073. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3074. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3075. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3076. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3077. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3078. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3079. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3080. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3081. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3082. { } /* end */
  3083. };
  3084. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3085. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3086. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3087. { } /* end */
  3088. };
  3089. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3090. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3091. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3092. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3093. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3094. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3095. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3096. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3097. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3098. { } /* end */
  3099. };
  3100. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3101. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3102. */
  3103. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3104. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3105. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3106. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3107. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3108. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3109. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3110. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3111. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3112. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3113. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3114. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3115. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3116. { } /* end */
  3117. };
  3118. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3119. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3120. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3121. * datasheet doesn't mention this restriction. At this stage it's not clear
  3122. * whether this behaviour is intentional or is a hardware bug in chip
  3123. * revisions available in early 2006. Therefore for now allow the
  3124. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3125. * that the lack of mic bias for this NID is intentional we could change the
  3126. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3127. *
  3128. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3129. * don't appear to make the mic bias available from the "line" jack, even
  3130. * though the NID used for this jack (0x14) can supply it. The theory is
  3131. * that perhaps Acer have included blocking capacitors between the ALC260
  3132. * and the output jack. If this turns out to be the case for all such
  3133. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3134. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3135. *
  3136. * The C20x Tablet series have a mono internal speaker which is controlled
  3137. * via the chip's Mono sum widget and pin complex, so include the necessary
  3138. * controls for such models. On models without a "mono speaker" the control
  3139. * won't do anything.
  3140. */
  3141. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3142. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3143. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3144. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3145. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3146. HDA_OUTPUT),
  3147. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3148. HDA_INPUT),
  3149. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3150. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3151. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3152. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3153. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3154. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3155. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3156. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3157. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3158. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3159. { } /* end */
  3160. };
  3161. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3162. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3163. */
  3164. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3165. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3166. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3167. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3168. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3169. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3170. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3171. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3172. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3173. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3174. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3175. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3176. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3177. { } /* end */
  3178. };
  3179. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3180. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3181. */
  3182. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3183. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3184. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3185. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3186. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3187. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3188. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3189. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3192. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3193. { } /* end */
  3194. };
  3195. /* capture mixer elements */
  3196. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3197. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3198. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3199. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3200. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3201. {
  3202. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3203. /* The multiple "Capture Source" controls confuse alsamixer
  3204. * So call somewhat different..
  3205. * FIXME: the controls appear in the "playback" view!
  3206. */
  3207. /* .name = "Capture Source", */
  3208. .name = "Input Source",
  3209. .count = 2,
  3210. .info = alc_mux_enum_info,
  3211. .get = alc_mux_enum_get,
  3212. .put = alc_mux_enum_put,
  3213. },
  3214. { } /* end */
  3215. };
  3216. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3217. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3218. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3219. {
  3220. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3221. /* The multiple "Capture Source" controls confuse alsamixer
  3222. * So call somewhat different..
  3223. * FIXME: the controls appear in the "playback" view!
  3224. */
  3225. /* .name = "Capture Source", */
  3226. .name = "Input Source",
  3227. .count = 1,
  3228. .info = alc_mux_enum_info,
  3229. .get = alc_mux_enum_get,
  3230. .put = alc_mux_enum_put,
  3231. },
  3232. { } /* end */
  3233. };
  3234. /*
  3235. * initialization verbs
  3236. */
  3237. static struct hda_verb alc260_init_verbs[] = {
  3238. /* Line In pin widget for input */
  3239. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3240. /* CD pin widget for input */
  3241. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3242. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3243. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3244. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3245. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3246. /* LINE-2 is used for line-out in rear */
  3247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3248. /* select line-out */
  3249. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3250. /* LINE-OUT pin */
  3251. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3252. /* enable HP */
  3253. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3254. /* enable Mono */
  3255. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3256. /* mute capture amp left and right */
  3257. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3258. /* set connection select to line in (default select for this ADC) */
  3259. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3260. /* mute capture amp left and right */
  3261. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3262. /* set connection select to line in (default select for this ADC) */
  3263. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3264. /* set vol=0 Line-Out mixer amp left and right */
  3265. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3266. /* unmute pin widget amp left and right (no gain on this amp) */
  3267. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3268. /* set vol=0 HP mixer amp left and right */
  3269. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3270. /* unmute pin widget amp left and right (no gain on this amp) */
  3271. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3272. /* set vol=0 Mono mixer amp left and right */
  3273. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3274. /* unmute pin widget amp left and right (no gain on this amp) */
  3275. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3276. /* unmute LINE-2 out pin */
  3277. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3278. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3279. * Line In 2 = 0x03
  3280. */
  3281. /* mute CD */
  3282. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3283. /* mute Line In */
  3284. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3285. /* mute Mic */
  3286. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3287. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3288. /* mute Front out path */
  3289. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3290. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3291. /* mute Headphone out path */
  3292. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3293. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3294. /* mute Mono out path */
  3295. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3296. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3297. { }
  3298. };
  3299. #if 0 /* should be identical with alc260_init_verbs? */
  3300. static struct hda_verb alc260_hp_init_verbs[] = {
  3301. /* Headphone and output */
  3302. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3303. /* mono output */
  3304. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3305. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3306. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3307. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3308. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3309. /* Line In pin widget for input */
  3310. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3311. /* Line-2 pin widget for output */
  3312. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3313. /* CD pin widget for input */
  3314. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3315. /* unmute amp left and right */
  3316. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3317. /* set connection select to line in (default select for this ADC) */
  3318. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3319. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3320. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3321. /* mute pin widget amp left and right (no gain on this amp) */
  3322. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3323. /* unmute HP mixer amp left and right (volume = 0) */
  3324. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3325. /* mute pin widget amp left and right (no gain on this amp) */
  3326. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3327. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3328. * Line In 2 = 0x03
  3329. */
  3330. /* unmute CD */
  3331. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3332. /* unmute Line In */
  3333. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3334. /* unmute Mic */
  3335. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3336. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3337. /* Unmute Front out path */
  3338. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3339. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3340. /* Unmute Headphone out path */
  3341. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3342. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3343. /* Unmute Mono out path */
  3344. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3345. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3346. { }
  3347. };
  3348. #endif
  3349. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3350. /* Line out and output */
  3351. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3352. /* mono output */
  3353. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3358. /* Line In pin widget for input */
  3359. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3360. /* Headphone pin widget for output */
  3361. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3362. /* CD pin widget for input */
  3363. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3364. /* unmute amp left and right */
  3365. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3366. /* set connection select to line in (default select for this ADC) */
  3367. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3368. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3369. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3370. /* mute pin widget amp left and right (no gain on this amp) */
  3371. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3372. /* unmute HP mixer amp left and right (volume = 0) */
  3373. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3374. /* mute pin widget amp left and right (no gain on this amp) */
  3375. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3376. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3377. * Line In 2 = 0x03
  3378. */
  3379. /* unmute CD */
  3380. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3381. /* unmute Line In */
  3382. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3383. /* unmute Mic */
  3384. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3385. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3386. /* Unmute Front out path */
  3387. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3388. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3389. /* Unmute Headphone out path */
  3390. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3391. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3392. /* Unmute Mono out path */
  3393. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3394. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3395. { }
  3396. };
  3397. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3398. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3399. * audio = 0x16, internal speaker = 0x10.
  3400. */
  3401. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3402. /* Disable all GPIOs */
  3403. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3404. /* Internal speaker is connected to headphone pin */
  3405. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3406. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3407. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3408. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3409. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3410. /* Ensure all other unused pins are disabled and muted. */
  3411. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3412. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3413. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3414. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3415. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3416. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3417. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3418. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3419. /* Disable digital (SPDIF) pins */
  3420. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3421. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3422. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3423. * when acting as an output.
  3424. */
  3425. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3426. /* Start with output sum widgets muted and their output gains at min */
  3427. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3428. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3429. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3430. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3431. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3432. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3433. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3434. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3435. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3436. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3437. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3438. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3439. * If the pin mode is changed by the user the pin mode control will
  3440. * take care of enabling the pin's input/output buffers as needed.
  3441. * Therefore there's no need to enable the input buffer at this
  3442. * stage.
  3443. */
  3444. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3445. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3446. * mixer ctrl)
  3447. */
  3448. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3449. /* Mute capture amp left and right */
  3450. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3451. /* Set ADC connection select to match default mixer setting - line
  3452. * in (on mic1 pin)
  3453. */
  3454. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3455. /* Do the same for the second ADC: mute capture input amp and
  3456. * set ADC connection to line in (on mic1 pin)
  3457. */
  3458. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3459. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3460. /* Mute all inputs to mixer widget (even unconnected ones) */
  3461. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3462. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3463. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3464. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3465. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3466. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3467. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3468. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3469. { }
  3470. };
  3471. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3472. * similar laptops (adapted from Fujitsu init verbs).
  3473. */
  3474. static struct hda_verb alc260_acer_init_verbs[] = {
  3475. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3476. * the headphone jack. Turn this on and rely on the standard mute
  3477. * methods whenever the user wants to turn these outputs off.
  3478. */
  3479. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3480. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3481. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3482. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3483. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3484. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3485. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3486. /* Line In jack is connected to Line1 pin */
  3487. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3488. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3489. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3490. /* Ensure all other unused pins are disabled and muted. */
  3491. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3492. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3494. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3495. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3496. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3497. /* Disable digital (SPDIF) pins */
  3498. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3499. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3500. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3501. * bus when acting as outputs.
  3502. */
  3503. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3504. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3505. /* Start with output sum widgets muted and their output gains at min */
  3506. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3507. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3508. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3509. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3510. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3511. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3512. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3514. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3515. /* Unmute Line-out pin widget amp left and right
  3516. * (no equiv mixer ctrl)
  3517. */
  3518. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3519. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3520. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3521. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3522. * inputs. If the pin mode is changed by the user the pin mode control
  3523. * will take care of enabling the pin's input/output buffers as needed.
  3524. * Therefore there's no need to enable the input buffer at this
  3525. * stage.
  3526. */
  3527. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3528. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3529. /* Mute capture amp left and right */
  3530. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Set ADC connection select to match default mixer setting - mic
  3532. * (on mic1 pin)
  3533. */
  3534. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3535. /* Do similar with the second ADC: mute capture input amp and
  3536. * set ADC connection to mic to match ALSA's default state.
  3537. */
  3538. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3539. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3540. /* Mute all inputs to mixer widget (even unconnected ones) */
  3541. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3542. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3543. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3544. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3545. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3546. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3547. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3548. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3549. { }
  3550. };
  3551. static struct hda_verb alc260_will_verbs[] = {
  3552. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3553. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3554. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3555. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3556. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3557. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3558. {}
  3559. };
  3560. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3561. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3562. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3563. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3564. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3565. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3566. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3567. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3568. {}
  3569. };
  3570. /* toggle speaker-output according to the hp-jack state */
  3571. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3572. {
  3573. unsigned int present;
  3574. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3575. present = snd_hda_codec_read(codec, 0x0f, 0,
  3576. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3577. if (present) {
  3578. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3579. snd_hda_codec_write(codec, 0x0f, 0,
  3580. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3581. } else {
  3582. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3583. snd_hda_codec_write(codec, 0x0f, 0,
  3584. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3585. }
  3586. }
  3587. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3588. unsigned int res)
  3589. {
  3590. if ((res >> 26) == ALC880_HP_EVENT)
  3591. alc260_replacer_672v_automute(codec);
  3592. }
  3593. /* Test configuration for debugging, modelled after the ALC880 test
  3594. * configuration.
  3595. */
  3596. #ifdef CONFIG_SND_DEBUG
  3597. static hda_nid_t alc260_test_dac_nids[1] = {
  3598. 0x02,
  3599. };
  3600. static hda_nid_t alc260_test_adc_nids[2] = {
  3601. 0x04, 0x05,
  3602. };
  3603. /* For testing the ALC260, each input MUX needs its own definition since
  3604. * the signal assignments are different. This assumes that the first ADC
  3605. * is NID 0x04.
  3606. */
  3607. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3608. {
  3609. .num_items = 7,
  3610. .items = {
  3611. { "MIC1 pin", 0x0 },
  3612. { "MIC2 pin", 0x1 },
  3613. { "LINE1 pin", 0x2 },
  3614. { "LINE2 pin", 0x3 },
  3615. { "CD pin", 0x4 },
  3616. { "LINE-OUT pin", 0x5 },
  3617. { "HP-OUT pin", 0x6 },
  3618. },
  3619. },
  3620. {
  3621. .num_items = 8,
  3622. .items = {
  3623. { "MIC1 pin", 0x0 },
  3624. { "MIC2 pin", 0x1 },
  3625. { "LINE1 pin", 0x2 },
  3626. { "LINE2 pin", 0x3 },
  3627. { "CD pin", 0x4 },
  3628. { "Mixer", 0x5 },
  3629. { "LINE-OUT pin", 0x6 },
  3630. { "HP-OUT pin", 0x7 },
  3631. },
  3632. },
  3633. };
  3634. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3635. /* Output driver widgets */
  3636. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3637. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3638. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3639. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3640. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3641. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3642. /* Modes for retasking pin widgets
  3643. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3644. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3645. * mention this restriction. At this stage it's not clear whether
  3646. * this behaviour is intentional or is a hardware bug in chip
  3647. * revisions available at least up until early 2006. Therefore for
  3648. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3649. * choices, but if it turns out that the lack of mic bias for these
  3650. * NIDs is intentional we could change their modes from
  3651. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3652. */
  3653. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3654. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3655. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3656. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3657. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3658. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3659. /* Loopback mixer controls */
  3660. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3661. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3662. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3663. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3664. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3665. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3666. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3667. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3668. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3669. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3670. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3671. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3672. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3673. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3674. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3675. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3676. /* Controls for GPIO pins, assuming they are configured as outputs */
  3677. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3678. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3679. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3680. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3681. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3682. * is ambigious as to which NID is which; testing on laptops which
  3683. * make this output available should provide clarification.
  3684. */
  3685. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3686. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3687. { } /* end */
  3688. };
  3689. static struct hda_verb alc260_test_init_verbs[] = {
  3690. /* Enable all GPIOs as outputs with an initial value of 0 */
  3691. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3692. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3693. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3694. /* Enable retasking pins as output, initially without power amp */
  3695. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3696. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3697. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3698. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3699. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3700. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3701. /* Disable digital (SPDIF) pins initially, but users can enable
  3702. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3703. * payload also sets the generation to 0, output to be in "consumer"
  3704. * PCM format, copyright asserted, no pre-emphasis and no validity
  3705. * control.
  3706. */
  3707. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3708. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3709. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3710. * OUT1 sum bus when acting as an output.
  3711. */
  3712. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3713. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3714. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3715. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3716. /* Start with output sum widgets muted and their output gains at min */
  3717. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3718. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3719. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3720. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3721. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3722. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3723. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3724. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3725. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3726. /* Unmute retasking pin widget output buffers since the default
  3727. * state appears to be output. As the pin mode is changed by the
  3728. * user the pin mode control will take care of enabling the pin's
  3729. * input/output buffers as needed.
  3730. */
  3731. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3732. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3733. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3734. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3735. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3736. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3737. /* Also unmute the mono-out pin widget */
  3738. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3739. /* Mute capture amp left and right */
  3740. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3741. /* Set ADC connection select to match default mixer setting (mic1
  3742. * pin)
  3743. */
  3744. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3745. /* Do the same for the second ADC: mute capture input amp and
  3746. * set ADC connection to mic1 pin
  3747. */
  3748. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3749. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3750. /* Mute all inputs to mixer widget (even unconnected ones) */
  3751. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3752. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3753. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3754. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3755. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3756. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3757. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3758. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3759. { }
  3760. };
  3761. #endif
  3762. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3763. .substreams = 1,
  3764. .channels_min = 2,
  3765. .channels_max = 2,
  3766. };
  3767. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3768. .substreams = 1,
  3769. .channels_min = 2,
  3770. .channels_max = 2,
  3771. };
  3772. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3773. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3774. /*
  3775. * for BIOS auto-configuration
  3776. */
  3777. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3778. const char *pfx)
  3779. {
  3780. hda_nid_t nid_vol;
  3781. unsigned long vol_val, sw_val;
  3782. char name[32];
  3783. int err;
  3784. if (nid >= 0x0f && nid < 0x11) {
  3785. nid_vol = nid - 0x7;
  3786. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3787. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3788. } else if (nid == 0x11) {
  3789. nid_vol = nid - 0x7;
  3790. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3791. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3792. } else if (nid >= 0x12 && nid <= 0x15) {
  3793. nid_vol = 0x08;
  3794. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3795. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3796. } else
  3797. return 0; /* N/A */
  3798. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3799. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3800. if (err < 0)
  3801. return err;
  3802. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3803. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3804. if (err < 0)
  3805. return err;
  3806. return 1;
  3807. }
  3808. /* add playback controls from the parsed DAC table */
  3809. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3810. const struct auto_pin_cfg *cfg)
  3811. {
  3812. hda_nid_t nid;
  3813. int err;
  3814. spec->multiout.num_dacs = 1;
  3815. spec->multiout.dac_nids = spec->private_dac_nids;
  3816. spec->multiout.dac_nids[0] = 0x02;
  3817. nid = cfg->line_out_pins[0];
  3818. if (nid) {
  3819. err = alc260_add_playback_controls(spec, nid, "Front");
  3820. if (err < 0)
  3821. return err;
  3822. }
  3823. nid = cfg->speaker_pins[0];
  3824. if (nid) {
  3825. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3826. if (err < 0)
  3827. return err;
  3828. }
  3829. nid = cfg->hp_pins[0];
  3830. if (nid) {
  3831. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3832. if (err < 0)
  3833. return err;
  3834. }
  3835. return 0;
  3836. }
  3837. /* create playback/capture controls for input pins */
  3838. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3839. const struct auto_pin_cfg *cfg)
  3840. {
  3841. struct hda_input_mux *imux = &spec->private_imux;
  3842. int i, err, idx;
  3843. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3844. if (cfg->input_pins[i] >= 0x12) {
  3845. idx = cfg->input_pins[i] - 0x12;
  3846. err = new_analog_input(spec, cfg->input_pins[i],
  3847. auto_pin_cfg_labels[i], idx,
  3848. 0x07);
  3849. if (err < 0)
  3850. return err;
  3851. imux->items[imux->num_items].label =
  3852. auto_pin_cfg_labels[i];
  3853. imux->items[imux->num_items].index = idx;
  3854. imux->num_items++;
  3855. }
  3856. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3857. idx = cfg->input_pins[i] - 0x09;
  3858. err = new_analog_input(spec, cfg->input_pins[i],
  3859. auto_pin_cfg_labels[i], idx,
  3860. 0x07);
  3861. if (err < 0)
  3862. return err;
  3863. imux->items[imux->num_items].label =
  3864. auto_pin_cfg_labels[i];
  3865. imux->items[imux->num_items].index = idx;
  3866. imux->num_items++;
  3867. }
  3868. }
  3869. return 0;
  3870. }
  3871. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3872. hda_nid_t nid, int pin_type,
  3873. int sel_idx)
  3874. {
  3875. /* set as output */
  3876. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3877. pin_type);
  3878. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3879. AMP_OUT_UNMUTE);
  3880. /* need the manual connection? */
  3881. if (nid >= 0x12) {
  3882. int idx = nid - 0x12;
  3883. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3884. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3885. }
  3886. }
  3887. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3888. {
  3889. struct alc_spec *spec = codec->spec;
  3890. hda_nid_t nid;
  3891. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3892. nid = spec->autocfg.line_out_pins[0];
  3893. if (nid)
  3894. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3895. nid = spec->autocfg.speaker_pins[0];
  3896. if (nid)
  3897. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3898. nid = spec->autocfg.hp_pins[0];
  3899. if (nid)
  3900. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3901. }
  3902. #define ALC260_PIN_CD_NID 0x16
  3903. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3904. {
  3905. struct alc_spec *spec = codec->spec;
  3906. int i;
  3907. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3908. hda_nid_t nid = spec->autocfg.input_pins[i];
  3909. if (nid >= 0x12) {
  3910. snd_hda_codec_write(codec, nid, 0,
  3911. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3912. i <= AUTO_PIN_FRONT_MIC ?
  3913. PIN_VREF80 : PIN_IN);
  3914. if (nid != ALC260_PIN_CD_NID)
  3915. snd_hda_codec_write(codec, nid, 0,
  3916. AC_VERB_SET_AMP_GAIN_MUTE,
  3917. AMP_OUT_MUTE);
  3918. }
  3919. }
  3920. }
  3921. /*
  3922. * generic initialization of ADC, input mixers and output mixers
  3923. */
  3924. static struct hda_verb alc260_volume_init_verbs[] = {
  3925. /*
  3926. * Unmute ADC0-1 and set the default input to mic-in
  3927. */
  3928. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3929. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3930. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3931. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3932. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3933. * mixer widget
  3934. * Note: PASD motherboards uses the Line In 2 as the input for
  3935. * front panel mic (mic 2)
  3936. */
  3937. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3938. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3939. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3940. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3941. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3942. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3943. /*
  3944. * Set up output mixers (0x08 - 0x0a)
  3945. */
  3946. /* set vol=0 to output mixers */
  3947. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3948. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3949. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3950. /* set up input amps for analog loopback */
  3951. /* Amp Indices: DAC = 0, mixer = 1 */
  3952. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3953. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3954. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3955. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3956. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3957. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3958. { }
  3959. };
  3960. static int alc260_parse_auto_config(struct hda_codec *codec)
  3961. {
  3962. struct alc_spec *spec = codec->spec;
  3963. unsigned int wcap;
  3964. int err;
  3965. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3966. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3967. alc260_ignore);
  3968. if (err < 0)
  3969. return err;
  3970. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3971. if (err < 0)
  3972. return err;
  3973. if (!spec->kctl_alloc)
  3974. return 0; /* can't find valid BIOS pin config */
  3975. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3976. if (err < 0)
  3977. return err;
  3978. spec->multiout.max_channels = 2;
  3979. if (spec->autocfg.dig_out_pin)
  3980. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3981. if (spec->kctl_alloc)
  3982. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3983. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3984. spec->num_mux_defs = 1;
  3985. spec->input_mux = &spec->private_imux;
  3986. /* check whether NID 0x04 is valid */
  3987. wcap = get_wcaps(codec, 0x04);
  3988. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3989. if (wcap != AC_WID_AUD_IN) {
  3990. spec->adc_nids = alc260_adc_nids_alt;
  3991. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3992. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3993. } else {
  3994. spec->adc_nids = alc260_adc_nids;
  3995. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3996. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3997. }
  3998. spec->num_mixers++;
  3999. return 1;
  4000. }
  4001. /* additional initialization for auto-configuration model */
  4002. static void alc260_auto_init(struct hda_codec *codec)
  4003. {
  4004. alc260_auto_init_multi_out(codec);
  4005. alc260_auto_init_analog_input(codec);
  4006. }
  4007. /*
  4008. * ALC260 configurations
  4009. */
  4010. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4011. [ALC260_BASIC] = "basic",
  4012. [ALC260_HP] = "hp",
  4013. [ALC260_HP_3013] = "hp-3013",
  4014. [ALC260_FUJITSU_S702X] = "fujitsu",
  4015. [ALC260_ACER] = "acer",
  4016. [ALC260_WILL] = "will",
  4017. [ALC260_REPLACER_672V] = "replacer",
  4018. #ifdef CONFIG_SND_DEBUG
  4019. [ALC260_TEST] = "test",
  4020. #endif
  4021. [ALC260_AUTO] = "auto",
  4022. };
  4023. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4024. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4025. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4026. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4027. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4028. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4029. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4030. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4031. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4032. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4033. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4034. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4035. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4036. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4037. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4038. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4039. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4040. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4041. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4042. {}
  4043. };
  4044. static struct alc_config_preset alc260_presets[] = {
  4045. [ALC260_BASIC] = {
  4046. .mixers = { alc260_base_output_mixer,
  4047. alc260_input_mixer,
  4048. alc260_pc_beep_mixer,
  4049. alc260_capture_mixer },
  4050. .init_verbs = { alc260_init_verbs },
  4051. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4052. .dac_nids = alc260_dac_nids,
  4053. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4054. .adc_nids = alc260_adc_nids,
  4055. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4056. .channel_mode = alc260_modes,
  4057. .input_mux = &alc260_capture_source,
  4058. },
  4059. [ALC260_HP] = {
  4060. .mixers = { alc260_base_output_mixer,
  4061. alc260_input_mixer,
  4062. alc260_capture_alt_mixer },
  4063. .init_verbs = { alc260_init_verbs },
  4064. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4065. .dac_nids = alc260_dac_nids,
  4066. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4067. .adc_nids = alc260_hp_adc_nids,
  4068. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4069. .channel_mode = alc260_modes,
  4070. .input_mux = &alc260_capture_source,
  4071. },
  4072. [ALC260_HP_3013] = {
  4073. .mixers = { alc260_hp_3013_mixer,
  4074. alc260_input_mixer,
  4075. alc260_capture_alt_mixer },
  4076. .init_verbs = { alc260_hp_3013_init_verbs },
  4077. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4078. .dac_nids = alc260_dac_nids,
  4079. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4080. .adc_nids = alc260_hp_adc_nids,
  4081. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4082. .channel_mode = alc260_modes,
  4083. .input_mux = &alc260_capture_source,
  4084. },
  4085. [ALC260_FUJITSU_S702X] = {
  4086. .mixers = { alc260_fujitsu_mixer,
  4087. alc260_capture_mixer },
  4088. .init_verbs = { alc260_fujitsu_init_verbs },
  4089. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4090. .dac_nids = alc260_dac_nids,
  4091. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4092. .adc_nids = alc260_dual_adc_nids,
  4093. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4094. .channel_mode = alc260_modes,
  4095. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4096. .input_mux = alc260_fujitsu_capture_sources,
  4097. },
  4098. [ALC260_ACER] = {
  4099. .mixers = { alc260_acer_mixer,
  4100. alc260_capture_mixer },
  4101. .init_verbs = { alc260_acer_init_verbs },
  4102. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4103. .dac_nids = alc260_dac_nids,
  4104. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4105. .adc_nids = alc260_dual_adc_nids,
  4106. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4107. .channel_mode = alc260_modes,
  4108. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4109. .input_mux = alc260_acer_capture_sources,
  4110. },
  4111. [ALC260_WILL] = {
  4112. .mixers = { alc260_will_mixer,
  4113. alc260_capture_mixer },
  4114. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4115. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4116. .dac_nids = alc260_dac_nids,
  4117. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4118. .adc_nids = alc260_adc_nids,
  4119. .dig_out_nid = ALC260_DIGOUT_NID,
  4120. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4121. .channel_mode = alc260_modes,
  4122. .input_mux = &alc260_capture_source,
  4123. },
  4124. [ALC260_REPLACER_672V] = {
  4125. .mixers = { alc260_replacer_672v_mixer,
  4126. alc260_capture_mixer },
  4127. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4128. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4129. .dac_nids = alc260_dac_nids,
  4130. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4131. .adc_nids = alc260_adc_nids,
  4132. .dig_out_nid = ALC260_DIGOUT_NID,
  4133. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4134. .channel_mode = alc260_modes,
  4135. .input_mux = &alc260_capture_source,
  4136. .unsol_event = alc260_replacer_672v_unsol_event,
  4137. .init_hook = alc260_replacer_672v_automute,
  4138. },
  4139. #ifdef CONFIG_SND_DEBUG
  4140. [ALC260_TEST] = {
  4141. .mixers = { alc260_test_mixer,
  4142. alc260_capture_mixer },
  4143. .init_verbs = { alc260_test_init_verbs },
  4144. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4145. .dac_nids = alc260_test_dac_nids,
  4146. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4147. .adc_nids = alc260_test_adc_nids,
  4148. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4149. .channel_mode = alc260_modes,
  4150. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4151. .input_mux = alc260_test_capture_sources,
  4152. },
  4153. #endif
  4154. };
  4155. static int patch_alc260(struct hda_codec *codec)
  4156. {
  4157. struct alc_spec *spec;
  4158. int err, board_config;
  4159. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4160. if (spec == NULL)
  4161. return -ENOMEM;
  4162. codec->spec = spec;
  4163. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4164. alc260_models,
  4165. alc260_cfg_tbl);
  4166. if (board_config < 0) {
  4167. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4168. "trying auto-probe from BIOS...\n");
  4169. board_config = ALC260_AUTO;
  4170. }
  4171. if (board_config == ALC260_AUTO) {
  4172. /* automatic parse from the BIOS config */
  4173. err = alc260_parse_auto_config(codec);
  4174. if (err < 0) {
  4175. alc_free(codec);
  4176. return err;
  4177. } else if (!err) {
  4178. printk(KERN_INFO
  4179. "hda_codec: Cannot set up configuration "
  4180. "from BIOS. Using base mode...\n");
  4181. board_config = ALC260_BASIC;
  4182. }
  4183. }
  4184. if (board_config != ALC260_AUTO)
  4185. setup_preset(spec, &alc260_presets[board_config]);
  4186. spec->stream_name_analog = "ALC260 Analog";
  4187. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4188. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4189. spec->stream_name_digital = "ALC260 Digital";
  4190. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4191. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4192. codec->patch_ops = alc_patch_ops;
  4193. if (board_config == ALC260_AUTO)
  4194. spec->init_hook = alc260_auto_init;
  4195. return 0;
  4196. }
  4197. /*
  4198. * ALC882 support
  4199. *
  4200. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4201. * configuration. Each pin widget can choose any input DACs and a mixer.
  4202. * Each ADC is connected from a mixer of all inputs. This makes possible
  4203. * 6-channel independent captures.
  4204. *
  4205. * In addition, an independent DAC for the multi-playback (not used in this
  4206. * driver yet).
  4207. */
  4208. #define ALC882_DIGOUT_NID 0x06
  4209. #define ALC882_DIGIN_NID 0x0a
  4210. static struct hda_channel_mode alc882_ch_modes[1] = {
  4211. { 8, NULL }
  4212. };
  4213. static hda_nid_t alc882_dac_nids[4] = {
  4214. /* front, rear, clfe, rear_surr */
  4215. 0x02, 0x03, 0x04, 0x05
  4216. };
  4217. /* identical with ALC880 */
  4218. #define alc882_adc_nids alc880_adc_nids
  4219. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4220. /* input MUX */
  4221. /* FIXME: should be a matrix-type input source selection */
  4222. static struct hda_input_mux alc882_capture_source = {
  4223. .num_items = 4,
  4224. .items = {
  4225. { "Mic", 0x0 },
  4226. { "Front Mic", 0x1 },
  4227. { "Line", 0x2 },
  4228. { "CD", 0x4 },
  4229. },
  4230. };
  4231. #define alc882_mux_enum_info alc_mux_enum_info
  4232. #define alc882_mux_enum_get alc_mux_enum_get
  4233. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4234. struct snd_ctl_elem_value *ucontrol)
  4235. {
  4236. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4237. struct alc_spec *spec = codec->spec;
  4238. const struct hda_input_mux *imux = spec->input_mux;
  4239. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4240. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4241. hda_nid_t nid = capture_mixers[adc_idx];
  4242. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4243. unsigned int i, idx;
  4244. idx = ucontrol->value.enumerated.item[0];
  4245. if (idx >= imux->num_items)
  4246. idx = imux->num_items - 1;
  4247. if (*cur_val == idx && !codec->in_resume)
  4248. return 0;
  4249. for (i = 0; i < imux->num_items; i++) {
  4250. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4251. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4252. v | (imux->items[i].index << 8));
  4253. }
  4254. *cur_val = idx;
  4255. return 1;
  4256. }
  4257. /*
  4258. * 6ch mode
  4259. */
  4260. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4261. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4262. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4263. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4264. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4265. { } /* end */
  4266. };
  4267. /*
  4268. * 8ch mode
  4269. */
  4270. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4271. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4272. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4273. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4274. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4275. { } /* end */
  4276. };
  4277. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4278. { 6, alc882_sixstack_ch6_init },
  4279. { 8, alc882_sixstack_ch8_init },
  4280. };
  4281. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4282. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4283. */
  4284. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4285. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4286. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4287. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4288. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4289. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4290. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4291. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4292. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4293. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4294. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4295. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4296. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4297. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4298. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4299. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4300. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4301. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4302. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4303. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4304. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4305. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4306. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4307. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4308. { } /* end */
  4309. };
  4310. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4311. {
  4312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4313. .name = "Channel Mode",
  4314. .info = alc_ch_mode_info,
  4315. .get = alc_ch_mode_get,
  4316. .put = alc_ch_mode_put,
  4317. },
  4318. { } /* end */
  4319. };
  4320. static struct hda_verb alc882_init_verbs[] = {
  4321. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4322. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4323. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4324. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4325. /* Rear mixer */
  4326. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4327. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4328. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4329. /* CLFE mixer */
  4330. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4331. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4332. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4333. /* Side mixer */
  4334. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4335. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4336. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4337. /* Front Pin: output 0 (0x0c) */
  4338. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4339. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4340. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4341. /* Rear Pin: output 1 (0x0d) */
  4342. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4343. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4344. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4345. /* CLFE Pin: output 2 (0x0e) */
  4346. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4347. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4348. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4349. /* Side Pin: output 3 (0x0f) */
  4350. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4351. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4352. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4353. /* Mic (rear) pin: input vref at 80% */
  4354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4356. /* Front Mic pin: input vref at 80% */
  4357. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4358. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4359. /* Line In pin: input */
  4360. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4361. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4362. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4363. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4364. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4365. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4366. /* CD pin widget for input */
  4367. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4368. /* FIXME: use matrix-type input source selection */
  4369. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4370. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4371. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4372. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4373. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4374. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4375. /* Input mixer2 */
  4376. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4377. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4378. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4379. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4380. /* Input mixer3 */
  4381. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4382. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4383. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4384. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4385. /* ADC1: mute amp left and right */
  4386. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4387. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4388. /* ADC2: mute amp left and right */
  4389. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4390. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4391. /* ADC3: mute amp left and right */
  4392. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4393. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4394. { }
  4395. };
  4396. static struct hda_verb alc882_eapd_verbs[] = {
  4397. /* change to EAPD mode */
  4398. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4399. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4400. { }
  4401. };
  4402. /* Mac Pro test */
  4403. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4404. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4405. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4406. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4407. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4408. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4409. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4410. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4411. { } /* end */
  4412. };
  4413. static struct hda_verb alc882_macpro_init_verbs[] = {
  4414. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4415. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4416. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4417. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4418. /* Front Pin: output 0 (0x0c) */
  4419. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4421. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4422. /* Front Mic pin: input vref at 80% */
  4423. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4424. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4425. /* Speaker: output */
  4426. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4427. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4428. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4429. /* Headphone output (output 0 - 0x0c) */
  4430. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4431. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4432. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4433. /* FIXME: use matrix-type input source selection */
  4434. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4435. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4436. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4437. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4438. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4439. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4440. /* Input mixer2 */
  4441. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4442. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4443. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4444. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4445. /* Input mixer3 */
  4446. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4447. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4448. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4449. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4450. /* ADC1: mute amp left and right */
  4451. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4452. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4453. /* ADC2: mute amp left and right */
  4454. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4455. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4456. /* ADC3: mute amp left and right */
  4457. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4458. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4459. { }
  4460. };
  4461. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4462. {
  4463. unsigned int gpiostate, gpiomask, gpiodir;
  4464. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4465. AC_VERB_GET_GPIO_DATA, 0);
  4466. if (!muted)
  4467. gpiostate |= (1 << pin);
  4468. else
  4469. gpiostate &= ~(1 << pin);
  4470. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4471. AC_VERB_GET_GPIO_MASK, 0);
  4472. gpiomask |= (1 << pin);
  4473. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4474. AC_VERB_GET_GPIO_DIRECTION, 0);
  4475. gpiodir |= (1 << pin);
  4476. snd_hda_codec_write(codec, codec->afg, 0,
  4477. AC_VERB_SET_GPIO_MASK, gpiomask);
  4478. snd_hda_codec_write(codec, codec->afg, 0,
  4479. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4480. msleep(1);
  4481. snd_hda_codec_write(codec, codec->afg, 0,
  4482. AC_VERB_SET_GPIO_DATA, gpiostate);
  4483. }
  4484. /*
  4485. * generic initialization of ADC, input mixers and output mixers
  4486. */
  4487. static struct hda_verb alc882_auto_init_verbs[] = {
  4488. /*
  4489. * Unmute ADC0-2 and set the default input to mic-in
  4490. */
  4491. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4493. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4494. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4495. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4496. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4497. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4498. * mixer widget
  4499. * Note: PASD motherboards uses the Line In 2 as the input for
  4500. * front panel mic (mic 2)
  4501. */
  4502. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4503. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4504. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4505. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4506. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4507. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4508. /*
  4509. * Set up output mixers (0x0c - 0x0f)
  4510. */
  4511. /* set vol=0 to output mixers */
  4512. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4514. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4515. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4516. /* set up input amps for analog loopback */
  4517. /* Amp Indices: DAC = 0, mixer = 1 */
  4518. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4519. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4520. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4521. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4522. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4523. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4526. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4527. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4528. /* FIXME: use matrix-type input source selection */
  4529. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4530. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4531. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4532. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4533. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4534. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4535. /* Input mixer2 */
  4536. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4537. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4538. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4539. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4540. /* Input mixer3 */
  4541. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4542. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4543. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4544. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4545. { }
  4546. };
  4547. /* capture mixer elements */
  4548. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4549. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4550. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4551. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4552. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4553. {
  4554. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4555. /* The multiple "Capture Source" controls confuse alsamixer
  4556. * So call somewhat different..
  4557. * FIXME: the controls appear in the "playback" view!
  4558. */
  4559. /* .name = "Capture Source", */
  4560. .name = "Input Source",
  4561. .count = 2,
  4562. .info = alc882_mux_enum_info,
  4563. .get = alc882_mux_enum_get,
  4564. .put = alc882_mux_enum_put,
  4565. },
  4566. { } /* end */
  4567. };
  4568. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4569. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4570. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4571. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4572. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4573. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4574. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4575. {
  4576. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4577. /* The multiple "Capture Source" controls confuse alsamixer
  4578. * So call somewhat different..
  4579. * FIXME: the controls appear in the "playback" view!
  4580. */
  4581. /* .name = "Capture Source", */
  4582. .name = "Input Source",
  4583. .count = 3,
  4584. .info = alc882_mux_enum_info,
  4585. .get = alc882_mux_enum_get,
  4586. .put = alc882_mux_enum_put,
  4587. },
  4588. { } /* end */
  4589. };
  4590. /* pcm configuration: identiacal with ALC880 */
  4591. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4592. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4593. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4594. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4595. /*
  4596. * configuration and preset
  4597. */
  4598. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4599. [ALC882_3ST_DIG] = "3stack-dig",
  4600. [ALC882_6ST_DIG] = "6stack-dig",
  4601. [ALC882_ARIMA] = "arima",
  4602. [ALC885_MACPRO] = "macpro",
  4603. [ALC882_AUTO] = "auto",
  4604. };
  4605. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4606. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4607. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4608. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4609. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4610. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4611. {}
  4612. };
  4613. static struct alc_config_preset alc882_presets[] = {
  4614. [ALC882_3ST_DIG] = {
  4615. .mixers = { alc882_base_mixer },
  4616. .init_verbs = { alc882_init_verbs },
  4617. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4618. .dac_nids = alc882_dac_nids,
  4619. .dig_out_nid = ALC882_DIGOUT_NID,
  4620. .dig_in_nid = ALC882_DIGIN_NID,
  4621. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4622. .channel_mode = alc882_ch_modes,
  4623. .need_dac_fix = 1,
  4624. .input_mux = &alc882_capture_source,
  4625. },
  4626. [ALC882_6ST_DIG] = {
  4627. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4628. .init_verbs = { alc882_init_verbs },
  4629. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4630. .dac_nids = alc882_dac_nids,
  4631. .dig_out_nid = ALC882_DIGOUT_NID,
  4632. .dig_in_nid = ALC882_DIGIN_NID,
  4633. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4634. .channel_mode = alc882_sixstack_modes,
  4635. .input_mux = &alc882_capture_source,
  4636. },
  4637. [ALC882_ARIMA] = {
  4638. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4639. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4640. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4641. .dac_nids = alc882_dac_nids,
  4642. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4643. .channel_mode = alc882_sixstack_modes,
  4644. .input_mux = &alc882_capture_source,
  4645. },
  4646. [ALC885_MACPRO] = {
  4647. .mixers = { alc882_macpro_mixer },
  4648. .init_verbs = { alc882_macpro_init_verbs },
  4649. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4650. .dac_nids = alc882_dac_nids,
  4651. .dig_out_nid = ALC882_DIGOUT_NID,
  4652. .dig_in_nid = ALC882_DIGIN_NID,
  4653. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4654. .channel_mode = alc882_ch_modes,
  4655. .input_mux = &alc882_capture_source,
  4656. },
  4657. };
  4658. /*
  4659. * BIOS auto configuration
  4660. */
  4661. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4662. hda_nid_t nid, int pin_type,
  4663. int dac_idx)
  4664. {
  4665. /* set as output */
  4666. struct alc_spec *spec = codec->spec;
  4667. int idx;
  4668. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4669. idx = 4;
  4670. else
  4671. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4672. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4673. pin_type);
  4674. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4675. AMP_OUT_UNMUTE);
  4676. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4677. }
  4678. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4679. {
  4680. struct alc_spec *spec = codec->spec;
  4681. int i;
  4682. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4683. for (i = 0; i <= HDA_SIDE; i++) {
  4684. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4685. if (nid)
  4686. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT,
  4687. i);
  4688. }
  4689. }
  4690. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4691. {
  4692. struct alc_spec *spec = codec->spec;
  4693. hda_nid_t pin;
  4694. pin = spec->autocfg.hp_pins[0];
  4695. if (pin) /* connect to front */
  4696. /* use dac 0 */
  4697. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4698. }
  4699. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4700. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4701. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4702. {
  4703. struct alc_spec *spec = codec->spec;
  4704. int i;
  4705. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4706. hda_nid_t nid = spec->autocfg.input_pins[i];
  4707. if (alc882_is_input_pin(nid)) {
  4708. snd_hda_codec_write(codec, nid, 0,
  4709. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4710. i <= AUTO_PIN_FRONT_MIC ?
  4711. PIN_VREF80 : PIN_IN);
  4712. if (nid != ALC882_PIN_CD_NID)
  4713. snd_hda_codec_write(codec, nid, 0,
  4714. AC_VERB_SET_AMP_GAIN_MUTE,
  4715. AMP_OUT_MUTE);
  4716. }
  4717. }
  4718. }
  4719. /* almost identical with ALC880 parser... */
  4720. static int alc882_parse_auto_config(struct hda_codec *codec)
  4721. {
  4722. struct alc_spec *spec = codec->spec;
  4723. int err = alc880_parse_auto_config(codec);
  4724. if (err < 0)
  4725. return err;
  4726. else if (err > 0)
  4727. /* hack - override the init verbs */
  4728. spec->init_verbs[0] = alc882_auto_init_verbs;
  4729. return err;
  4730. }
  4731. /* additional initialization for auto-configuration model */
  4732. static void alc882_auto_init(struct hda_codec *codec)
  4733. {
  4734. alc882_auto_init_multi_out(codec);
  4735. alc882_auto_init_hp_out(codec);
  4736. alc882_auto_init_analog_input(codec);
  4737. }
  4738. static int patch_alc882(struct hda_codec *codec)
  4739. {
  4740. struct alc_spec *spec;
  4741. int err, board_config;
  4742. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4743. if (spec == NULL)
  4744. return -ENOMEM;
  4745. codec->spec = spec;
  4746. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4747. alc882_models,
  4748. alc882_cfg_tbl);
  4749. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4750. /* Pick up systems that don't supply PCI SSID */
  4751. switch (codec->subsystem_id) {
  4752. case 0x106b0c00: /* Mac Pro */
  4753. board_config = ALC885_MACPRO;
  4754. break;
  4755. default:
  4756. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4757. "trying auto-probe from BIOS...\n");
  4758. board_config = ALC882_AUTO;
  4759. }
  4760. }
  4761. if (board_config == ALC882_AUTO) {
  4762. /* automatic parse from the BIOS config */
  4763. err = alc882_parse_auto_config(codec);
  4764. if (err < 0) {
  4765. alc_free(codec);
  4766. return err;
  4767. } else if (!err) {
  4768. printk(KERN_INFO
  4769. "hda_codec: Cannot set up configuration "
  4770. "from BIOS. Using base mode...\n");
  4771. board_config = ALC882_3ST_DIG;
  4772. }
  4773. }
  4774. if (board_config != ALC882_AUTO)
  4775. setup_preset(spec, &alc882_presets[board_config]);
  4776. if (board_config == ALC885_MACPRO) {
  4777. alc882_gpio_mute(codec, 0, 0);
  4778. alc882_gpio_mute(codec, 1, 0);
  4779. }
  4780. spec->stream_name_analog = "ALC882 Analog";
  4781. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4782. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4783. spec->stream_name_digital = "ALC882 Digital";
  4784. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4785. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4786. if (!spec->adc_nids && spec->input_mux) {
  4787. /* check whether NID 0x07 is valid */
  4788. unsigned int wcap = get_wcaps(codec, 0x07);
  4789. /* get type */
  4790. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  4791. if (wcap != AC_WID_AUD_IN) {
  4792. spec->adc_nids = alc882_adc_nids_alt;
  4793. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4794. spec->mixers[spec->num_mixers] =
  4795. alc882_capture_alt_mixer;
  4796. spec->num_mixers++;
  4797. } else {
  4798. spec->adc_nids = alc882_adc_nids;
  4799. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4800. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4801. spec->num_mixers++;
  4802. }
  4803. }
  4804. codec->patch_ops = alc_patch_ops;
  4805. if (board_config == ALC882_AUTO)
  4806. spec->init_hook = alc882_auto_init;
  4807. return 0;
  4808. }
  4809. /*
  4810. * ALC883 support
  4811. *
  4812. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4813. * configuration. Each pin widget can choose any input DACs and a mixer.
  4814. * Each ADC is connected from a mixer of all inputs. This makes possible
  4815. * 6-channel independent captures.
  4816. *
  4817. * In addition, an independent DAC for the multi-playback (not used in this
  4818. * driver yet).
  4819. */
  4820. #define ALC883_DIGOUT_NID 0x06
  4821. #define ALC883_DIGIN_NID 0x0a
  4822. static hda_nid_t alc883_dac_nids[4] = {
  4823. /* front, rear, clfe, rear_surr */
  4824. 0x02, 0x04, 0x03, 0x05
  4825. };
  4826. static hda_nid_t alc883_adc_nids[2] = {
  4827. /* ADC1-2 */
  4828. 0x08, 0x09,
  4829. };
  4830. /* input MUX */
  4831. /* FIXME: should be a matrix-type input source selection */
  4832. static struct hda_input_mux alc883_capture_source = {
  4833. .num_items = 4,
  4834. .items = {
  4835. { "Mic", 0x0 },
  4836. { "Front Mic", 0x1 },
  4837. { "Line", 0x2 },
  4838. { "CD", 0x4 },
  4839. },
  4840. };
  4841. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  4842. .num_items = 2,
  4843. .items = {
  4844. { "Mic", 0x1 },
  4845. { "Line", 0x2 },
  4846. },
  4847. };
  4848. #define alc883_mux_enum_info alc_mux_enum_info
  4849. #define alc883_mux_enum_get alc_mux_enum_get
  4850. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4851. struct snd_ctl_elem_value *ucontrol)
  4852. {
  4853. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4854. struct alc_spec *spec = codec->spec;
  4855. const struct hda_input_mux *imux = spec->input_mux;
  4856. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4857. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4858. hda_nid_t nid = capture_mixers[adc_idx];
  4859. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4860. unsigned int i, idx;
  4861. idx = ucontrol->value.enumerated.item[0];
  4862. if (idx >= imux->num_items)
  4863. idx = imux->num_items - 1;
  4864. if (*cur_val == idx && !codec->in_resume)
  4865. return 0;
  4866. for (i = 0; i < imux->num_items; i++) {
  4867. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4868. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4869. v | (imux->items[i].index << 8));
  4870. }
  4871. *cur_val = idx;
  4872. return 1;
  4873. }
  4874. /*
  4875. * 2ch mode
  4876. */
  4877. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4878. { 2, NULL }
  4879. };
  4880. /*
  4881. * 2ch mode
  4882. */
  4883. static struct hda_verb alc883_3ST_ch2_init[] = {
  4884. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4885. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4886. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4887. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4888. { } /* end */
  4889. };
  4890. /*
  4891. * 6ch mode
  4892. */
  4893. static struct hda_verb alc883_3ST_ch6_init[] = {
  4894. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4895. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4896. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4897. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4898. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4899. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4900. { } /* end */
  4901. };
  4902. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4903. { 2, alc883_3ST_ch2_init },
  4904. { 6, alc883_3ST_ch6_init },
  4905. };
  4906. /*
  4907. * 6ch mode
  4908. */
  4909. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4910. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4911. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4912. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4913. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4914. { } /* end */
  4915. };
  4916. /*
  4917. * 8ch mode
  4918. */
  4919. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4920. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4921. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4922. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4923. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4924. { } /* end */
  4925. };
  4926. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4927. { 6, alc883_sixstack_ch6_init },
  4928. { 8, alc883_sixstack_ch8_init },
  4929. };
  4930. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4931. /* eanable EAPD on medion laptop */
  4932. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4933. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4934. { }
  4935. };
  4936. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4937. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4938. */
  4939. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4940. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4941. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4942. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4943. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4944. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4945. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4946. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4947. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4948. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4949. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4950. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4951. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4952. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4953. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4954. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4955. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4956. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4957. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4958. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4959. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4960. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4961. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4962. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4963. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4964. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4965. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4966. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4967. {
  4968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4969. /* .name = "Capture Source", */
  4970. .name = "Input Source",
  4971. .count = 2,
  4972. .info = alc883_mux_enum_info,
  4973. .get = alc883_mux_enum_get,
  4974. .put = alc883_mux_enum_put,
  4975. },
  4976. { } /* end */
  4977. };
  4978. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4979. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4980. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4981. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4982. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4983. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4984. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4985. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4986. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4987. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4988. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4989. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4990. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4991. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4992. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4993. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4994. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4995. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4996. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4997. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4998. {
  4999. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5000. /* .name = "Capture Source", */
  5001. .name = "Input Source",
  5002. .count = 2,
  5003. .info = alc883_mux_enum_info,
  5004. .get = alc883_mux_enum_get,
  5005. .put = alc883_mux_enum_put,
  5006. },
  5007. { } /* end */
  5008. };
  5009. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5010. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5011. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5012. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5013. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5014. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5015. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5016. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5017. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5018. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5019. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5020. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5023. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5024. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5025. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5026. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5027. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5028. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5029. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5030. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5031. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5032. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5033. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5034. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5035. {
  5036. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5037. /* .name = "Capture Source", */
  5038. .name = "Input Source",
  5039. .count = 2,
  5040. .info = alc883_mux_enum_info,
  5041. .get = alc883_mux_enum_get,
  5042. .put = alc883_mux_enum_put,
  5043. },
  5044. { } /* end */
  5045. };
  5046. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5047. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5048. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5049. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5050. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5051. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5052. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5053. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5054. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5055. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5056. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5057. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5058. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5059. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5060. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5061. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5062. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5063. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5064. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5065. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5066. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5067. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5068. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5069. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5070. {
  5071. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5072. /* .name = "Capture Source", */
  5073. .name = "Input Source",
  5074. .count = 1,
  5075. .info = alc883_mux_enum_info,
  5076. .get = alc883_mux_enum_get,
  5077. .put = alc883_mux_enum_put,
  5078. },
  5079. { } /* end */
  5080. };
  5081. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5082. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5083. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5084. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5085. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5086. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5087. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5088. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5089. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5090. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5091. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5092. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5093. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5094. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5095. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5096. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5097. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5098. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5099. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5100. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5101. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5102. {
  5103. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5104. /* .name = "Capture Source", */
  5105. .name = "Input Source",
  5106. .count = 2,
  5107. .info = alc883_mux_enum_info,
  5108. .get = alc883_mux_enum_get,
  5109. .put = alc883_mux_enum_put,
  5110. },
  5111. { } /* end */
  5112. };
  5113. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5114. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5115. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5116. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5117. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5118. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5119. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5120. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5122. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5123. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5124. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5125. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5126. {
  5127. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5128. /* .name = "Capture Source", */
  5129. .name = "Input Source",
  5130. .count = 2,
  5131. .info = alc883_mux_enum_info,
  5132. .get = alc883_mux_enum_get,
  5133. .put = alc883_mux_enum_put,
  5134. },
  5135. { } /* end */
  5136. };
  5137. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5138. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5139. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5140. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5141. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5142. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5143. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5144. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5145. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5146. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5147. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5148. {
  5149. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5150. /* .name = "Capture Source", */
  5151. .name = "Input Source",
  5152. .count = 1,
  5153. .info = alc883_mux_enum_info,
  5154. .get = alc883_mux_enum_get,
  5155. .put = alc883_mux_enum_put,
  5156. },
  5157. { } /* end */
  5158. };
  5159. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5160. {
  5161. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5162. .name = "Channel Mode",
  5163. .info = alc_ch_mode_info,
  5164. .get = alc_ch_mode_get,
  5165. .put = alc_ch_mode_put,
  5166. },
  5167. { } /* end */
  5168. };
  5169. static struct hda_verb alc883_init_verbs[] = {
  5170. /* ADC1: mute amp left and right */
  5171. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5172. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5173. /* ADC2: mute amp left and right */
  5174. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5175. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5176. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5177. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5178. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5179. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5180. /* Rear mixer */
  5181. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5182. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5183. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5184. /* CLFE mixer */
  5185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5186. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5187. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5188. /* Side mixer */
  5189. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5190. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5191. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5192. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5193. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5194. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5195. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5196. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5197. /* Front Pin: output 0 (0x0c) */
  5198. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5199. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5200. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5201. /* Rear Pin: output 1 (0x0d) */
  5202. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5203. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5204. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5205. /* CLFE Pin: output 2 (0x0e) */
  5206. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5207. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5208. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5209. /* Side Pin: output 3 (0x0f) */
  5210. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5211. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5212. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5213. /* Mic (rear) pin: input vref at 80% */
  5214. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5215. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5216. /* Front Mic pin: input vref at 80% */
  5217. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5218. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5219. /* Line In pin: input */
  5220. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5221. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5222. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5223. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5224. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5225. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5226. /* CD pin widget for input */
  5227. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5228. /* FIXME: use matrix-type input source selection */
  5229. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5230. /* Input mixer2 */
  5231. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5233. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5234. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5235. /* Input mixer3 */
  5236. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5237. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5238. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5239. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5240. { }
  5241. };
  5242. static struct hda_verb alc883_tagra_verbs[] = {
  5243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5244. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5245. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5246. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5247. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5248. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5249. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5250. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5251. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5252. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5253. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5254. { } /* end */
  5255. };
  5256. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5257. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5258. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5259. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5260. { } /* end */
  5261. };
  5262. /* toggle speaker-output according to the hp-jack state */
  5263. static void alc883_tagra_automute(struct hda_codec *codec)
  5264. {
  5265. unsigned int present;
  5266. unsigned char bits;
  5267. present = snd_hda_codec_read(codec, 0x14, 0,
  5268. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5269. bits = present ? 0x80 : 0;
  5270. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5271. 0x80, bits);
  5272. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5273. 0x80, bits);
  5274. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5275. present ? 1 : 3);
  5276. }
  5277. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5278. {
  5279. if ((res >> 26) == ALC880_HP_EVENT)
  5280. alc883_tagra_automute(codec);
  5281. }
  5282. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5283. {
  5284. unsigned int present;
  5285. unsigned char bits;
  5286. present = snd_hda_codec_read(codec, 0x14, 0,
  5287. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5288. bits = present ? 0x80 : 0;
  5289. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5290. 0x80, bits);
  5291. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5292. 0x80, bits);
  5293. }
  5294. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5295. {
  5296. unsigned int present;
  5297. unsigned char bits;
  5298. present = snd_hda_codec_read(codec, 0x1b, 0,
  5299. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5300. bits = present ? 0x80 : 0;
  5301. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5302. 0x80, bits);
  5303. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5304. 0x80, bits);
  5305. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5306. 0x80, bits);
  5307. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5308. 0x80, bits);
  5309. }
  5310. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5311. unsigned int res)
  5312. {
  5313. if ((res >> 26) == ALC880_HP_EVENT)
  5314. alc883_lenovo_101e_all_automute(codec);
  5315. if ((res >> 26) == ALC880_FRONT_EVENT)
  5316. alc883_lenovo_101e_ispeaker_automute(codec);
  5317. }
  5318. /*
  5319. * generic initialization of ADC, input mixers and output mixers
  5320. */
  5321. static struct hda_verb alc883_auto_init_verbs[] = {
  5322. /*
  5323. * Unmute ADC0-2 and set the default input to mic-in
  5324. */
  5325. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5326. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5327. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5328. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5329. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5330. * mixer widget
  5331. * Note: PASD motherboards uses the Line In 2 as the input for
  5332. * front panel mic (mic 2)
  5333. */
  5334. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5335. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5336. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5337. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5338. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5339. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5340. /*
  5341. * Set up output mixers (0x0c - 0x0f)
  5342. */
  5343. /* set vol=0 to output mixers */
  5344. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5345. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5346. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5347. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5348. /* set up input amps for analog loopback */
  5349. /* Amp Indices: DAC = 0, mixer = 1 */
  5350. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5351. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5352. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5353. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5354. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5355. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5356. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5357. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5358. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5359. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5360. /* FIXME: use matrix-type input source selection */
  5361. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5362. /* Input mixer1 */
  5363. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5364. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5365. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5366. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5367. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5368. /* Input mixer2 */
  5369. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5370. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5371. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5372. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5373. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5374. { }
  5375. };
  5376. /* capture mixer elements */
  5377. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5378. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5379. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5380. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5381. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5382. {
  5383. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5384. /* The multiple "Capture Source" controls confuse alsamixer
  5385. * So call somewhat different..
  5386. * FIXME: the controls appear in the "playback" view!
  5387. */
  5388. /* .name = "Capture Source", */
  5389. .name = "Input Source",
  5390. .count = 2,
  5391. .info = alc882_mux_enum_info,
  5392. .get = alc882_mux_enum_get,
  5393. .put = alc882_mux_enum_put,
  5394. },
  5395. { } /* end */
  5396. };
  5397. /* pcm configuration: identiacal with ALC880 */
  5398. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5399. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5400. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5401. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5402. /*
  5403. * configuration and preset
  5404. */
  5405. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5406. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5407. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5408. [ALC883_3ST_6ch] = "3stack-6ch",
  5409. [ALC883_6ST_DIG] = "6stack-dig",
  5410. [ALC883_TARGA_DIG] = "targa-dig",
  5411. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5412. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  5413. [ALC883_ACER] = "acer",
  5414. [ALC883_MEDION] = "medion",
  5415. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5416. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5417. [ALC883_AUTO] = "auto",
  5418. };
  5419. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5420. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5421. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5422. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5423. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5424. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5425. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5426. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5427. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5428. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5429. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5430. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5431. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5432. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5433. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5434. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5435. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5436. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5437. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5438. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5439. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5440. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5441. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5442. SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch),
  5443. {}
  5444. };
  5445. static struct alc_config_preset alc883_presets[] = {
  5446. [ALC883_3ST_2ch_DIG] = {
  5447. .mixers = { alc883_3ST_2ch_mixer },
  5448. .init_verbs = { alc883_init_verbs },
  5449. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5450. .dac_nids = alc883_dac_nids,
  5451. .dig_out_nid = ALC883_DIGOUT_NID,
  5452. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5453. .adc_nids = alc883_adc_nids,
  5454. .dig_in_nid = ALC883_DIGIN_NID,
  5455. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5456. .channel_mode = alc883_3ST_2ch_modes,
  5457. .input_mux = &alc883_capture_source,
  5458. },
  5459. [ALC883_3ST_6ch_DIG] = {
  5460. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5461. .init_verbs = { alc883_init_verbs },
  5462. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5463. .dac_nids = alc883_dac_nids,
  5464. .dig_out_nid = ALC883_DIGOUT_NID,
  5465. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5466. .adc_nids = alc883_adc_nids,
  5467. .dig_in_nid = ALC883_DIGIN_NID,
  5468. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5469. .channel_mode = alc883_3ST_6ch_modes,
  5470. .need_dac_fix = 1,
  5471. .input_mux = &alc883_capture_source,
  5472. },
  5473. [ALC883_3ST_6ch] = {
  5474. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5475. .init_verbs = { alc883_init_verbs },
  5476. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5477. .dac_nids = alc883_dac_nids,
  5478. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5479. .adc_nids = alc883_adc_nids,
  5480. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5481. .channel_mode = alc883_3ST_6ch_modes,
  5482. .need_dac_fix = 1,
  5483. .input_mux = &alc883_capture_source,
  5484. },
  5485. [ALC883_6ST_DIG] = {
  5486. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5487. .init_verbs = { alc883_init_verbs },
  5488. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5489. .dac_nids = alc883_dac_nids,
  5490. .dig_out_nid = ALC883_DIGOUT_NID,
  5491. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5492. .adc_nids = alc883_adc_nids,
  5493. .dig_in_nid = ALC883_DIGIN_NID,
  5494. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5495. .channel_mode = alc883_sixstack_modes,
  5496. .input_mux = &alc883_capture_source,
  5497. },
  5498. [ALC883_TARGA_DIG] = {
  5499. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5500. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5501. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5502. .dac_nids = alc883_dac_nids,
  5503. .dig_out_nid = ALC883_DIGOUT_NID,
  5504. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5505. .adc_nids = alc883_adc_nids,
  5506. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5507. .channel_mode = alc883_3ST_6ch_modes,
  5508. .need_dac_fix = 1,
  5509. .input_mux = &alc883_capture_source,
  5510. .unsol_event = alc883_tagra_unsol_event,
  5511. .init_hook = alc883_tagra_automute,
  5512. },
  5513. [ALC883_TARGA_2ch_DIG] = {
  5514. .mixers = { alc883_tagra_2ch_mixer},
  5515. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5516. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5517. .dac_nids = alc883_dac_nids,
  5518. .dig_out_nid = ALC883_DIGOUT_NID,
  5519. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5520. .adc_nids = alc883_adc_nids,
  5521. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5522. .channel_mode = alc883_3ST_2ch_modes,
  5523. .input_mux = &alc883_capture_source,
  5524. .unsol_event = alc883_tagra_unsol_event,
  5525. .init_hook = alc883_tagra_automute,
  5526. },
  5527. [ALC888_DEMO_BOARD] = {
  5528. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5529. .init_verbs = { alc883_init_verbs },
  5530. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5531. .dac_nids = alc883_dac_nids,
  5532. .dig_out_nid = ALC883_DIGOUT_NID,
  5533. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5534. .adc_nids = alc883_adc_nids,
  5535. .dig_in_nid = ALC883_DIGIN_NID,
  5536. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5537. .channel_mode = alc883_sixstack_modes,
  5538. .input_mux = &alc883_capture_source,
  5539. },
  5540. [ALC883_ACER] = {
  5541. .mixers = { alc883_base_mixer,
  5542. alc883_chmode_mixer },
  5543. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5544. * and the headphone jack. Turn this on and rely on the
  5545. * standard mute methods whenever the user wants to turn
  5546. * these outputs off.
  5547. */
  5548. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5549. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5550. .dac_nids = alc883_dac_nids,
  5551. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5552. .adc_nids = alc883_adc_nids,
  5553. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5554. .channel_mode = alc883_3ST_2ch_modes,
  5555. .input_mux = &alc883_capture_source,
  5556. },
  5557. [ALC883_MEDION] = {
  5558. .mixers = { alc883_fivestack_mixer,
  5559. alc883_chmode_mixer },
  5560. .init_verbs = { alc883_init_verbs,
  5561. alc883_medion_eapd_verbs },
  5562. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5563. .dac_nids = alc883_dac_nids,
  5564. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5565. .adc_nids = alc883_adc_nids,
  5566. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5567. .channel_mode = alc883_sixstack_modes,
  5568. .input_mux = &alc883_capture_source,
  5569. },
  5570. [ALC883_LAPTOP_EAPD] = {
  5571. .mixers = { alc883_base_mixer,
  5572. alc883_chmode_mixer },
  5573. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5574. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5575. .dac_nids = alc883_dac_nids,
  5576. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5577. .adc_nids = alc883_adc_nids,
  5578. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5579. .channel_mode = alc883_3ST_2ch_modes,
  5580. .input_mux = &alc883_capture_source,
  5581. },
  5582. [ALC883_LENOVO_101E_2ch] = {
  5583. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5584. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5585. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5586. .dac_nids = alc883_dac_nids,
  5587. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5588. .adc_nids = alc883_adc_nids,
  5589. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5590. .channel_mode = alc883_3ST_2ch_modes,
  5591. .input_mux = &alc883_lenovo_101e_capture_source,
  5592. .unsol_event = alc883_lenovo_101e_unsol_event,
  5593. .init_hook = alc883_lenovo_101e_all_automute,
  5594. },
  5595. };
  5596. /*
  5597. * BIOS auto configuration
  5598. */
  5599. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5600. hda_nid_t nid, int pin_type,
  5601. int dac_idx)
  5602. {
  5603. /* set as output */
  5604. struct alc_spec *spec = codec->spec;
  5605. int idx;
  5606. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5607. idx = 4;
  5608. else
  5609. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5610. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5611. pin_type);
  5612. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5613. AMP_OUT_UNMUTE);
  5614. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5615. }
  5616. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5617. {
  5618. struct alc_spec *spec = codec->spec;
  5619. int i;
  5620. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5621. for (i = 0; i <= HDA_SIDE; i++) {
  5622. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5623. if (nid)
  5624. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT,
  5625. i);
  5626. }
  5627. }
  5628. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5629. {
  5630. struct alc_spec *spec = codec->spec;
  5631. hda_nid_t pin;
  5632. pin = spec->autocfg.hp_pins[0];
  5633. if (pin) /* connect to front */
  5634. /* use dac 0 */
  5635. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5636. }
  5637. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5638. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5639. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5640. {
  5641. struct alc_spec *spec = codec->spec;
  5642. int i;
  5643. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5644. hda_nid_t nid = spec->autocfg.input_pins[i];
  5645. if (alc883_is_input_pin(nid)) {
  5646. snd_hda_codec_write(codec, nid, 0,
  5647. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5648. (i <= AUTO_PIN_FRONT_MIC ?
  5649. PIN_VREF80 : PIN_IN));
  5650. if (nid != ALC883_PIN_CD_NID)
  5651. snd_hda_codec_write(codec, nid, 0,
  5652. AC_VERB_SET_AMP_GAIN_MUTE,
  5653. AMP_OUT_MUTE);
  5654. }
  5655. }
  5656. }
  5657. /* almost identical with ALC880 parser... */
  5658. static int alc883_parse_auto_config(struct hda_codec *codec)
  5659. {
  5660. struct alc_spec *spec = codec->spec;
  5661. int err = alc880_parse_auto_config(codec);
  5662. if (err < 0)
  5663. return err;
  5664. else if (err > 0)
  5665. /* hack - override the init verbs */
  5666. spec->init_verbs[0] = alc883_auto_init_verbs;
  5667. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5668. spec->num_mixers++;
  5669. return err;
  5670. }
  5671. /* additional initialization for auto-configuration model */
  5672. static void alc883_auto_init(struct hda_codec *codec)
  5673. {
  5674. alc883_auto_init_multi_out(codec);
  5675. alc883_auto_init_hp_out(codec);
  5676. alc883_auto_init_analog_input(codec);
  5677. }
  5678. static int patch_alc883(struct hda_codec *codec)
  5679. {
  5680. struct alc_spec *spec;
  5681. int err, board_config;
  5682. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5683. if (spec == NULL)
  5684. return -ENOMEM;
  5685. codec->spec = spec;
  5686. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5687. alc883_models,
  5688. alc883_cfg_tbl);
  5689. if (board_config < 0) {
  5690. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5691. "trying auto-probe from BIOS...\n");
  5692. board_config = ALC883_AUTO;
  5693. }
  5694. if (board_config == ALC883_AUTO) {
  5695. /* automatic parse from the BIOS config */
  5696. err = alc883_parse_auto_config(codec);
  5697. if (err < 0) {
  5698. alc_free(codec);
  5699. return err;
  5700. } else if (!err) {
  5701. printk(KERN_INFO
  5702. "hda_codec: Cannot set up configuration "
  5703. "from BIOS. Using base mode...\n");
  5704. board_config = ALC883_3ST_2ch_DIG;
  5705. }
  5706. }
  5707. if (board_config != ALC883_AUTO)
  5708. setup_preset(spec, &alc883_presets[board_config]);
  5709. spec->stream_name_analog = "ALC883 Analog";
  5710. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5711. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5712. spec->stream_name_digital = "ALC883 Digital";
  5713. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5714. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5715. if (!spec->adc_nids && spec->input_mux) {
  5716. spec->adc_nids = alc883_adc_nids;
  5717. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5718. }
  5719. codec->patch_ops = alc_patch_ops;
  5720. if (board_config == ALC883_AUTO)
  5721. spec->init_hook = alc883_auto_init;
  5722. return 0;
  5723. }
  5724. /*
  5725. * ALC262 support
  5726. */
  5727. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5728. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5729. #define alc262_dac_nids alc260_dac_nids
  5730. #define alc262_adc_nids alc882_adc_nids
  5731. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5732. #define alc262_modes alc260_modes
  5733. #define alc262_capture_source alc882_capture_source
  5734. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5735. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5736. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5737. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5738. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5739. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5740. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5741. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5742. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5743. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5744. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5745. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5746. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5747. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5748. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5749. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5750. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5751. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5752. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5753. { } /* end */
  5754. };
  5755. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5756. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5757. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5758. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5759. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5761. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5762. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5763. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5764. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5765. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5766. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5767. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5768. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5769. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5770. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5771. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5772. { } /* end */
  5773. };
  5774. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5775. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5776. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5777. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5778. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5779. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5780. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5781. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5782. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5783. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5784. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5785. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5786. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5787. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5788. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5789. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5790. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5791. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5792. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5793. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5794. { } /* end */
  5795. };
  5796. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  5797. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5798. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5799. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5800. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5801. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5802. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5803. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5804. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5805. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  5806. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5807. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5808. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5809. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5810. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5811. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5812. { } /* end */
  5813. };
  5814. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  5815. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5816. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5817. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  5818. { } /* end */
  5819. };
  5820. #define alc262_capture_mixer alc882_capture_mixer
  5821. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5822. /*
  5823. * generic initialization of ADC, input mixers and output mixers
  5824. */
  5825. static struct hda_verb alc262_init_verbs[] = {
  5826. /*
  5827. * Unmute ADC0-2 and set the default input to mic-in
  5828. */
  5829. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5830. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5831. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5832. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5833. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5835. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5836. * mixer widget
  5837. * Note: PASD motherboards uses the Line In 2 as the input for
  5838. * front panel mic (mic 2)
  5839. */
  5840. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5841. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5842. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5843. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5844. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5845. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5846. /*
  5847. * Set up output mixers (0x0c - 0x0e)
  5848. */
  5849. /* set vol=0 to output mixers */
  5850. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5851. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5852. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5853. /* set up input amps for analog loopback */
  5854. /* Amp Indices: DAC = 0, mixer = 1 */
  5855. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5856. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5857. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5858. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5859. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5860. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5861. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5862. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5863. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5864. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5865. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5866. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5867. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5868. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5869. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5870. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5871. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5872. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5873. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5874. /* FIXME: use matrix-type input source selection */
  5875. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5876. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5877. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5878. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5879. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5880. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5881. /* Input mixer2 */
  5882. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5883. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5884. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5885. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5886. /* Input mixer3 */
  5887. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5888. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5889. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5890. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5891. { }
  5892. };
  5893. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5894. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5895. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5896. {}
  5897. };
  5898. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5899. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5900. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5901. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5902. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5903. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5904. {}
  5905. };
  5906. /* mute/unmute internal speaker according to the hp jack and mute state */
  5907. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5908. {
  5909. struct alc_spec *spec = codec->spec;
  5910. unsigned int mute;
  5911. if (force || !spec->sense_updated) {
  5912. unsigned int present;
  5913. /* need to execute and sync at first */
  5914. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5915. present = snd_hda_codec_read(codec, 0x15, 0,
  5916. AC_VERB_GET_PIN_SENSE, 0);
  5917. spec->jack_present = (present & 0x80000000) != 0;
  5918. spec->sense_updated = 1;
  5919. }
  5920. if (spec->jack_present) {
  5921. /* mute internal speaker */
  5922. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5923. 0x80, 0x80);
  5924. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5925. 0x80, 0x80);
  5926. } else {
  5927. /* unmute internal speaker if necessary */
  5928. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5929. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5930. 0x80, mute & 0x80);
  5931. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5932. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5933. 0x80, mute & 0x80);
  5934. }
  5935. }
  5936. /* unsolicited event for HP jack sensing */
  5937. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5938. unsigned int res)
  5939. {
  5940. if ((res >> 26) != ALC880_HP_EVENT)
  5941. return;
  5942. alc262_hippo_automute(codec, 1);
  5943. }
  5944. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5945. {
  5946. struct alc_spec *spec = codec->spec;
  5947. unsigned int mute;
  5948. if (force || !spec->sense_updated) {
  5949. unsigned int present;
  5950. /* need to execute and sync at first */
  5951. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5952. present = snd_hda_codec_read(codec, 0x1b, 0,
  5953. AC_VERB_GET_PIN_SENSE, 0);
  5954. spec->jack_present = (present & 0x80000000) != 0;
  5955. spec->sense_updated = 1;
  5956. }
  5957. if (spec->jack_present) {
  5958. /* mute internal speaker */
  5959. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5960. 0x80, 0x80);
  5961. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5962. 0x80, 0x80);
  5963. } else {
  5964. /* unmute internal speaker if necessary */
  5965. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5966. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5967. 0x80, mute & 0x80);
  5968. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5969. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5970. 0x80, mute & 0x80);
  5971. }
  5972. }
  5973. /* unsolicited event for HP jack sensing */
  5974. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5975. unsigned int res)
  5976. {
  5977. if ((res >> 26) != ALC880_HP_EVENT)
  5978. return;
  5979. alc262_hippo1_automute(codec, 1);
  5980. }
  5981. /*
  5982. * fujitsu model
  5983. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5984. */
  5985. #define ALC_HP_EVENT 0x37
  5986. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5987. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5988. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5989. {}
  5990. };
  5991. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5992. .num_items = 2,
  5993. .items = {
  5994. { "Mic", 0x0 },
  5995. { "CD", 0x4 },
  5996. },
  5997. };
  5998. static struct hda_input_mux alc262_HP_capture_source = {
  5999. .num_items = 5,
  6000. .items = {
  6001. { "Mic", 0x0 },
  6002. { "Front Mic", 0x3 },
  6003. { "Line", 0x2 },
  6004. { "CD", 0x4 },
  6005. { "AUX IN", 0x6 },
  6006. },
  6007. };
  6008. /* mute/unmute internal speaker according to the hp jack and mute state */
  6009. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6010. {
  6011. struct alc_spec *spec = codec->spec;
  6012. unsigned int mute;
  6013. if (force || !spec->sense_updated) {
  6014. unsigned int present;
  6015. /* need to execute and sync at first */
  6016. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6017. present = snd_hda_codec_read(codec, 0x14, 0,
  6018. AC_VERB_GET_PIN_SENSE, 0);
  6019. spec->jack_present = (present & 0x80000000) != 0;
  6020. spec->sense_updated = 1;
  6021. }
  6022. if (spec->jack_present) {
  6023. /* mute internal speaker */
  6024. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6025. 0x80, 0x80);
  6026. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6027. 0x80, 0x80);
  6028. } else {
  6029. /* unmute internal speaker if necessary */
  6030. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6031. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6032. 0x80, mute & 0x80);
  6033. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6034. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6035. 0x80, mute & 0x80);
  6036. }
  6037. }
  6038. /* unsolicited event for HP jack sensing */
  6039. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6040. unsigned int res)
  6041. {
  6042. if ((res >> 26) != ALC_HP_EVENT)
  6043. return;
  6044. alc262_fujitsu_automute(codec, 1);
  6045. }
  6046. /* bind volumes of both NID 0x0c and 0x0d */
  6047. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6048. struct snd_ctl_elem_value *ucontrol)
  6049. {
  6050. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6051. long *valp = ucontrol->value.integer.value;
  6052. int change;
  6053. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6054. 0x7f, valp[0] & 0x7f);
  6055. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6056. 0x7f, valp[1] & 0x7f);
  6057. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6058. 0x7f, valp[0] & 0x7f);
  6059. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6060. 0x7f, valp[1] & 0x7f);
  6061. return change;
  6062. }
  6063. /* bind hp and internal speaker mute (with plug check) */
  6064. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6065. struct snd_ctl_elem_value *ucontrol)
  6066. {
  6067. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6068. long *valp = ucontrol->value.integer.value;
  6069. int change;
  6070. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6071. 0x80, valp[0] ? 0 : 0x80);
  6072. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6073. 0x80, valp[1] ? 0 : 0x80);
  6074. if (change || codec->in_resume)
  6075. alc262_fujitsu_automute(codec, codec->in_resume);
  6076. return change;
  6077. }
  6078. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6079. {
  6080. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6081. .name = "Master Playback Volume",
  6082. .info = snd_hda_mixer_amp_volume_info,
  6083. .get = snd_hda_mixer_amp_volume_get,
  6084. .put = alc262_fujitsu_master_vol_put,
  6085. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6086. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6087. },
  6088. {
  6089. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6090. .name = "Master Playback Switch",
  6091. .info = snd_hda_mixer_amp_switch_info,
  6092. .get = snd_hda_mixer_amp_switch_get,
  6093. .put = alc262_fujitsu_master_sw_put,
  6094. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6095. },
  6096. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6097. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6098. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6099. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6100. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6101. { } /* end */
  6102. };
  6103. /* additional init verbs for Benq laptops */
  6104. static struct hda_verb alc262_EAPD_verbs[] = {
  6105. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6106. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6107. {}
  6108. };
  6109. /* add playback controls from the parsed DAC table */
  6110. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6111. const struct auto_pin_cfg *cfg)
  6112. {
  6113. hda_nid_t nid;
  6114. int err;
  6115. spec->multiout.num_dacs = 1; /* only use one dac */
  6116. spec->multiout.dac_nids = spec->private_dac_nids;
  6117. spec->multiout.dac_nids[0] = 2;
  6118. nid = cfg->line_out_pins[0];
  6119. if (nid) {
  6120. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6121. "Front Playback Volume",
  6122. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6123. if (err < 0)
  6124. return err;
  6125. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6126. "Front Playback Switch",
  6127. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6128. if (err < 0)
  6129. return err;
  6130. }
  6131. nid = cfg->speaker_pins[0];
  6132. if (nid) {
  6133. if (nid == 0x16) {
  6134. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6135. "Speaker Playback Volume",
  6136. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6137. HDA_OUTPUT));
  6138. if (err < 0)
  6139. return err;
  6140. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6141. "Speaker Playback Switch",
  6142. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6143. HDA_OUTPUT));
  6144. if (err < 0)
  6145. return err;
  6146. } else {
  6147. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6148. "Speaker Playback Switch",
  6149. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6150. HDA_OUTPUT));
  6151. if (err < 0)
  6152. return err;
  6153. }
  6154. }
  6155. nid = cfg->hp_pins[0];
  6156. if (nid) {
  6157. /* spec->multiout.hp_nid = 2; */
  6158. if (nid == 0x16) {
  6159. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6160. "Headphone Playback Volume",
  6161. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6162. HDA_OUTPUT));
  6163. if (err < 0)
  6164. return err;
  6165. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6166. "Headphone Playback Switch",
  6167. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6168. HDA_OUTPUT));
  6169. if (err < 0)
  6170. return err;
  6171. } else {
  6172. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6173. "Headphone Playback Switch",
  6174. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6175. HDA_OUTPUT));
  6176. if (err < 0)
  6177. return err;
  6178. }
  6179. }
  6180. return 0;
  6181. }
  6182. /* identical with ALC880 */
  6183. #define alc262_auto_create_analog_input_ctls \
  6184. alc880_auto_create_analog_input_ctls
  6185. /*
  6186. * generic initialization of ADC, input mixers and output mixers
  6187. */
  6188. static struct hda_verb alc262_volume_init_verbs[] = {
  6189. /*
  6190. * Unmute ADC0-2 and set the default input to mic-in
  6191. */
  6192. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6193. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6194. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6195. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6196. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6197. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6198. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6199. * mixer widget
  6200. * Note: PASD motherboards uses the Line In 2 as the input for
  6201. * front panel mic (mic 2)
  6202. */
  6203. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6204. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6205. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6206. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6207. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6208. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6209. /*
  6210. * Set up output mixers (0x0c - 0x0f)
  6211. */
  6212. /* set vol=0 to output mixers */
  6213. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6215. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6216. /* set up input amps for analog loopback */
  6217. /* Amp Indices: DAC = 0, mixer = 1 */
  6218. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6219. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6220. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6221. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6222. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6223. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6224. /* FIXME: use matrix-type input source selection */
  6225. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6226. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6227. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6228. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6229. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6230. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6231. /* Input mixer2 */
  6232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6233. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6234. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6235. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6236. /* Input mixer3 */
  6237. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6238. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6239. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6240. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6241. { }
  6242. };
  6243. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6244. /*
  6245. * Unmute ADC0-2 and set the default input to mic-in
  6246. */
  6247. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6248. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6249. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6250. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6251. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6252. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6253. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6254. * mixer widget
  6255. * Note: PASD motherboards uses the Line In 2 as the input for
  6256. * front panel mic (mic 2)
  6257. */
  6258. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6259. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6260. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6261. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6262. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6263. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6264. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6265. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6266. /*
  6267. * Set up output mixers (0x0c - 0x0e)
  6268. */
  6269. /* set vol=0 to output mixers */
  6270. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6271. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6272. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6273. /* set up input amps for analog loopback */
  6274. /* Amp Indices: DAC = 0, mixer = 1 */
  6275. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6276. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6277. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6278. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6279. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6280. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6281. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6282. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6283. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6284. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6286. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6287. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6288. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6289. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6290. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6291. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6292. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6293. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6294. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6295. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6296. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6297. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6298. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6299. /* FIXME: use matrix-type input source selection */
  6300. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6301. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6302. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6303. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6304. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6305. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6306. /* Input mixer2 */
  6307. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6308. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6309. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6310. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6311. /* Input mixer3 */
  6312. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6313. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6314. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6315. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6316. { }
  6317. };
  6318. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6319. /*
  6320. * Unmute ADC0-2 and set the default input to mic-in
  6321. */
  6322. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6323. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6324. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6325. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6326. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6327. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6328. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6329. * mixer widget
  6330. * Note: PASD motherboards uses the Line In 2 as the input for front
  6331. * panel mic (mic 2)
  6332. */
  6333. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6334. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6335. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6336. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6337. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6338. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6339. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6340. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6341. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6342. /*
  6343. * Set up output mixers (0x0c - 0x0e)
  6344. */
  6345. /* set vol=0 to output mixers */
  6346. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6347. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6348. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6349. /* set up input amps for analog loopback */
  6350. /* Amp Indices: DAC = 0, mixer = 1 */
  6351. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6352. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6353. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6354. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6355. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6356. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6357. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6358. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6359. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6360. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6361. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6362. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6363. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6364. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6365. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6366. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6367. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6368. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6369. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6370. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6371. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6372. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6373. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6374. /* FIXME: use matrix-type input source selection */
  6375. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6376. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6377. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6378. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6379. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6380. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6381. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6382. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6383. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6384. /* Input mixer2 */
  6385. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6386. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6387. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6388. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6389. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6390. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6391. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6392. /* Input mixer3 */
  6393. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6394. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6395. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6396. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6397. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6398. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6399. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6400. { }
  6401. };
  6402. /* pcm configuration: identiacal with ALC880 */
  6403. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6404. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6405. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6406. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6407. /*
  6408. * BIOS auto configuration
  6409. */
  6410. static int alc262_parse_auto_config(struct hda_codec *codec)
  6411. {
  6412. struct alc_spec *spec = codec->spec;
  6413. int err;
  6414. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6415. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6416. alc262_ignore);
  6417. if (err < 0)
  6418. return err;
  6419. if (!spec->autocfg.line_outs)
  6420. return 0; /* can't find valid BIOS pin config */
  6421. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6422. if (err < 0)
  6423. return err;
  6424. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6425. if (err < 0)
  6426. return err;
  6427. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6428. if (spec->autocfg.dig_out_pin)
  6429. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6430. if (spec->autocfg.dig_in_pin)
  6431. spec->dig_in_nid = ALC262_DIGIN_NID;
  6432. if (spec->kctl_alloc)
  6433. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6434. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6435. spec->num_mux_defs = 1;
  6436. spec->input_mux = &spec->private_imux;
  6437. return 1;
  6438. }
  6439. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6440. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6441. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6442. /* init callback for auto-configuration model -- overriding the default init */
  6443. static void alc262_auto_init(struct hda_codec *codec)
  6444. {
  6445. alc262_auto_init_multi_out(codec);
  6446. alc262_auto_init_hp_out(codec);
  6447. alc262_auto_init_analog_input(codec);
  6448. }
  6449. /*
  6450. * configuration and preset
  6451. */
  6452. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6453. [ALC262_BASIC] = "basic",
  6454. [ALC262_HIPPO] = "hippo",
  6455. [ALC262_HIPPO_1] = "hippo_1",
  6456. [ALC262_FUJITSU] = "fujitsu",
  6457. [ALC262_HP_BPC] = "hp-bpc",
  6458. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6459. [ALC262_BENQ_ED8] = "benq",
  6460. [ALC262_AUTO] = "auto",
  6461. };
  6462. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6463. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6464. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6465. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6466. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6467. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6468. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6469. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6470. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6471. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6472. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6473. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6474. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6475. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6476. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6477. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6478. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6479. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6480. {}
  6481. };
  6482. static struct alc_config_preset alc262_presets[] = {
  6483. [ALC262_BASIC] = {
  6484. .mixers = { alc262_base_mixer },
  6485. .init_verbs = { alc262_init_verbs },
  6486. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6487. .dac_nids = alc262_dac_nids,
  6488. .hp_nid = 0x03,
  6489. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6490. .channel_mode = alc262_modes,
  6491. .input_mux = &alc262_capture_source,
  6492. },
  6493. [ALC262_HIPPO] = {
  6494. .mixers = { alc262_base_mixer },
  6495. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6496. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6497. .dac_nids = alc262_dac_nids,
  6498. .hp_nid = 0x03,
  6499. .dig_out_nid = ALC262_DIGOUT_NID,
  6500. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6501. .channel_mode = alc262_modes,
  6502. .input_mux = &alc262_capture_source,
  6503. .unsol_event = alc262_hippo_unsol_event,
  6504. },
  6505. [ALC262_HIPPO_1] = {
  6506. .mixers = { alc262_hippo1_mixer },
  6507. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6508. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6509. .dac_nids = alc262_dac_nids,
  6510. .hp_nid = 0x02,
  6511. .dig_out_nid = ALC262_DIGOUT_NID,
  6512. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6513. .channel_mode = alc262_modes,
  6514. .input_mux = &alc262_capture_source,
  6515. .unsol_event = alc262_hippo1_unsol_event,
  6516. },
  6517. [ALC262_FUJITSU] = {
  6518. .mixers = { alc262_fujitsu_mixer },
  6519. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6520. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6521. .dac_nids = alc262_dac_nids,
  6522. .hp_nid = 0x03,
  6523. .dig_out_nid = ALC262_DIGOUT_NID,
  6524. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6525. .channel_mode = alc262_modes,
  6526. .input_mux = &alc262_fujitsu_capture_source,
  6527. .unsol_event = alc262_fujitsu_unsol_event,
  6528. },
  6529. [ALC262_HP_BPC] = {
  6530. .mixers = { alc262_HP_BPC_mixer },
  6531. .init_verbs = { alc262_HP_BPC_init_verbs },
  6532. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6533. .dac_nids = alc262_dac_nids,
  6534. .hp_nid = 0x03,
  6535. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6536. .channel_mode = alc262_modes,
  6537. .input_mux = &alc262_HP_capture_source,
  6538. },
  6539. [ALC262_HP_BPC_D7000_WF] = {
  6540. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6541. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6542. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6543. .dac_nids = alc262_dac_nids,
  6544. .hp_nid = 0x03,
  6545. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6546. .channel_mode = alc262_modes,
  6547. .input_mux = &alc262_HP_capture_source,
  6548. },
  6549. [ALC262_HP_BPC_D7000_WL] = {
  6550. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6551. alc262_HP_BPC_WildWest_option_mixer },
  6552. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6553. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6554. .dac_nids = alc262_dac_nids,
  6555. .hp_nid = 0x03,
  6556. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6557. .channel_mode = alc262_modes,
  6558. .input_mux = &alc262_HP_capture_source,
  6559. },
  6560. [ALC262_BENQ_ED8] = {
  6561. .mixers = { alc262_base_mixer },
  6562. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6563. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6564. .dac_nids = alc262_dac_nids,
  6565. .hp_nid = 0x03,
  6566. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6567. .channel_mode = alc262_modes,
  6568. .input_mux = &alc262_capture_source,
  6569. },
  6570. };
  6571. static int patch_alc262(struct hda_codec *codec)
  6572. {
  6573. struct alc_spec *spec;
  6574. int board_config;
  6575. int err;
  6576. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6577. if (spec == NULL)
  6578. return -ENOMEM;
  6579. codec->spec = spec;
  6580. #if 0
  6581. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  6582. * under-run
  6583. */
  6584. {
  6585. int tmp;
  6586. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6587. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  6588. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6589. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  6590. }
  6591. #endif
  6592. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  6593. alc262_models,
  6594. alc262_cfg_tbl);
  6595. if (board_config < 0) {
  6596. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  6597. "trying auto-probe from BIOS...\n");
  6598. board_config = ALC262_AUTO;
  6599. }
  6600. if (board_config == ALC262_AUTO) {
  6601. /* automatic parse from the BIOS config */
  6602. err = alc262_parse_auto_config(codec);
  6603. if (err < 0) {
  6604. alc_free(codec);
  6605. return err;
  6606. } else if (!err) {
  6607. printk(KERN_INFO
  6608. "hda_codec: Cannot set up configuration "
  6609. "from BIOS. Using base mode...\n");
  6610. board_config = ALC262_BASIC;
  6611. }
  6612. }
  6613. if (board_config != ALC262_AUTO)
  6614. setup_preset(spec, &alc262_presets[board_config]);
  6615. spec->stream_name_analog = "ALC262 Analog";
  6616. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  6617. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  6618. spec->stream_name_digital = "ALC262 Digital";
  6619. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6620. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6621. if (!spec->adc_nids && spec->input_mux) {
  6622. /* check whether NID 0x07 is valid */
  6623. unsigned int wcap = get_wcaps(codec, 0x07);
  6624. /* get type */
  6625. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  6626. if (wcap != AC_WID_AUD_IN) {
  6627. spec->adc_nids = alc262_adc_nids_alt;
  6628. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6629. spec->mixers[spec->num_mixers] =
  6630. alc262_capture_alt_mixer;
  6631. spec->num_mixers++;
  6632. } else {
  6633. spec->adc_nids = alc262_adc_nids;
  6634. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6635. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6636. spec->num_mixers++;
  6637. }
  6638. }
  6639. codec->patch_ops = alc_patch_ops;
  6640. if (board_config == ALC262_AUTO)
  6641. spec->init_hook = alc262_auto_init;
  6642. return 0;
  6643. }
  6644. /*
  6645. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6646. */
  6647. /*
  6648. * set the path ways for 2 channel output
  6649. * need to set the codec line out and mic 1 pin widgets to inputs
  6650. */
  6651. static struct hda_verb alc861_threestack_ch2_init[] = {
  6652. /* set pin widget 1Ah (line in) for input */
  6653. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6654. /* set pin widget 18h (mic1/2) for input, for mic also enable
  6655. * the vref
  6656. */
  6657. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6658. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6659. #if 0
  6660. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6661. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6662. #endif
  6663. { } /* end */
  6664. };
  6665. /*
  6666. * 6ch mode
  6667. * need to set the codec line out and mic 1 pin widgets to outputs
  6668. */
  6669. static struct hda_verb alc861_threestack_ch6_init[] = {
  6670. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6671. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6672. /* set pin widget 18h (mic1) for output (CLFE)*/
  6673. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6674. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6675. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6676. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6677. #if 0
  6678. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6679. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6680. #endif
  6681. { } /* end */
  6682. };
  6683. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6684. { 2, alc861_threestack_ch2_init },
  6685. { 6, alc861_threestack_ch6_init },
  6686. };
  6687. /* Set mic1 as input and unmute the mixer */
  6688. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6689. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6690. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6691. { } /* end */
  6692. };
  6693. /* Set mic1 as output and mute mixer */
  6694. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6695. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6696. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6697. { } /* end */
  6698. };
  6699. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6700. { 2, alc861_uniwill_m31_ch2_init },
  6701. { 4, alc861_uniwill_m31_ch4_init },
  6702. };
  6703. /* Set mic1 and line-in as input and unmute the mixer */
  6704. static struct hda_verb alc861_asus_ch2_init[] = {
  6705. /* set pin widget 1Ah (line in) for input */
  6706. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6707. /* set pin widget 18h (mic1/2) for input, for mic also enable
  6708. * the vref
  6709. */
  6710. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6711. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6712. #if 0
  6713. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6714. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6715. #endif
  6716. { } /* end */
  6717. };
  6718. /* Set mic1 nad line-in as output and mute mixer */
  6719. static struct hda_verb alc861_asus_ch6_init[] = {
  6720. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6721. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6722. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6723. /* set pin widget 18h (mic1) for output (CLFE)*/
  6724. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6725. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6726. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6727. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6728. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6729. #if 0
  6730. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6731. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6732. #endif
  6733. { } /* end */
  6734. };
  6735. static struct hda_channel_mode alc861_asus_modes[2] = {
  6736. { 2, alc861_asus_ch2_init },
  6737. { 6, alc861_asus_ch6_init },
  6738. };
  6739. /* patch-ALC861 */
  6740. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6741. /* output mixer control */
  6742. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6743. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6744. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6745. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6746. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6747. /*Input mixer control */
  6748. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6749. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6750. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6751. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6752. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6753. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6754. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6755. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6756. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6757. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6758. /* Capture mixer control */
  6759. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6760. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6761. {
  6762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6763. .name = "Capture Source",
  6764. .count = 1,
  6765. .info = alc_mux_enum_info,
  6766. .get = alc_mux_enum_get,
  6767. .put = alc_mux_enum_put,
  6768. },
  6769. { } /* end */
  6770. };
  6771. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6772. /* output mixer control */
  6773. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6774. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6775. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6776. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6777. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6778. /* Input mixer control */
  6779. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6780. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6781. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6782. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6783. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6784. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6785. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6786. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6787. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6788. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6789. /* Capture mixer control */
  6790. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6791. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6792. {
  6793. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6794. .name = "Capture Source",
  6795. .count = 1,
  6796. .info = alc_mux_enum_info,
  6797. .get = alc_mux_enum_get,
  6798. .put = alc_mux_enum_put,
  6799. },
  6800. {
  6801. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6802. .name = "Channel Mode",
  6803. .info = alc_ch_mode_info,
  6804. .get = alc_ch_mode_get,
  6805. .put = alc_ch_mode_put,
  6806. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6807. },
  6808. { } /* end */
  6809. };
  6810. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6811. /* output mixer control */
  6812. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6813. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6814. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6815. /*Capture mixer control */
  6816. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6817. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6818. {
  6819. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6820. .name = "Capture Source",
  6821. .count = 1,
  6822. .info = alc_mux_enum_info,
  6823. .get = alc_mux_enum_get,
  6824. .put = alc_mux_enum_put,
  6825. },
  6826. { } /* end */
  6827. };
  6828. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6829. /* output mixer control */
  6830. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6831. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6832. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6833. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6834. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6835. /* Input mixer control */
  6836. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6837. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6838. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6839. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6840. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6841. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6842. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6843. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6844. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6845. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6846. /* Capture mixer control */
  6847. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6848. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6849. {
  6850. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6851. .name = "Capture Source",
  6852. .count = 1,
  6853. .info = alc_mux_enum_info,
  6854. .get = alc_mux_enum_get,
  6855. .put = alc_mux_enum_put,
  6856. },
  6857. {
  6858. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6859. .name = "Channel Mode",
  6860. .info = alc_ch_mode_info,
  6861. .get = alc_ch_mode_get,
  6862. .put = alc_ch_mode_put,
  6863. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6864. },
  6865. { } /* end */
  6866. };
  6867. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6868. /* output mixer control */
  6869. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6870. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6871. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6872. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6873. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6874. /* Input mixer control */
  6875. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6876. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6877. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6878. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6879. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6880. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6881. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6882. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6883. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6884. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  6885. /* Capture mixer control */
  6886. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6887. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6888. {
  6889. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6890. .name = "Capture Source",
  6891. .count = 1,
  6892. .info = alc_mux_enum_info,
  6893. .get = alc_mux_enum_get,
  6894. .put = alc_mux_enum_put,
  6895. },
  6896. {
  6897. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6898. .name = "Channel Mode",
  6899. .info = alc_ch_mode_info,
  6900. .get = alc_ch_mode_get,
  6901. .put = alc_ch_mode_put,
  6902. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6903. },
  6904. { }
  6905. };
  6906. /* additional mixer */
  6907. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6908. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6909. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6910. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6911. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6912. { }
  6913. };
  6914. /*
  6915. * generic initialization of ADC, input mixers and output mixers
  6916. */
  6917. static struct hda_verb alc861_base_init_verbs[] = {
  6918. /*
  6919. * Unmute ADC0 and set the default input to mic-in
  6920. */
  6921. /* port-A for surround (rear panel) */
  6922. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6923. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6924. /* port-B for mic-in (rear panel) with vref */
  6925. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6926. /* port-C for line-in (rear panel) */
  6927. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6928. /* port-D for Front */
  6929. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6930. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6931. /* port-E for HP out (front panel) */
  6932. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6933. /* route front PCM to HP */
  6934. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6935. /* port-F for mic-in (front panel) with vref */
  6936. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6937. /* port-G for CLFE (rear panel) */
  6938. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6939. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6940. /* port-H for side (rear panel) */
  6941. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6942. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6943. /* CD-in */
  6944. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6945. /* route front mic to ADC1*/
  6946. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6947. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6948. /* Unmute DAC0~3 & spdif out*/
  6949. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6950. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6951. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6952. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6953. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6954. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6955. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6956. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6957. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6958. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6959. /* Unmute Stereo Mixer 15 */
  6960. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6961. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6963. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  6964. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6965. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6966. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6967. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6968. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6969. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6970. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6971. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6972. /* hp used DAC 3 (Front) */
  6973. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6974. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6975. { }
  6976. };
  6977. static struct hda_verb alc861_threestack_init_verbs[] = {
  6978. /*
  6979. * Unmute ADC0 and set the default input to mic-in
  6980. */
  6981. /* port-A for surround (rear panel) */
  6982. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6983. /* port-B for mic-in (rear panel) with vref */
  6984. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6985. /* port-C for line-in (rear panel) */
  6986. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6987. /* port-D for Front */
  6988. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6989. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6990. /* port-E for HP out (front panel) */
  6991. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6992. /* route front PCM to HP */
  6993. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6994. /* port-F for mic-in (front panel) with vref */
  6995. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6996. /* port-G for CLFE (rear panel) */
  6997. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6998. /* port-H for side (rear panel) */
  6999. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7000. /* CD-in */
  7001. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7002. /* route front mic to ADC1*/
  7003. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7004. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7005. /* Unmute DAC0~3 & spdif out*/
  7006. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7007. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7008. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7009. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7010. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7011. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7012. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7013. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7014. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7015. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7016. /* Unmute Stereo Mixer 15 */
  7017. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7018. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7019. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7020. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7021. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7022. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7023. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7024. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7025. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7026. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7027. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7028. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7029. /* hp used DAC 3 (Front) */
  7030. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7031. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7032. { }
  7033. };
  7034. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7035. /*
  7036. * Unmute ADC0 and set the default input to mic-in
  7037. */
  7038. /* port-A for surround (rear panel) */
  7039. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7040. /* port-B for mic-in (rear panel) with vref */
  7041. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7042. /* port-C for line-in (rear panel) */
  7043. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7044. /* port-D for Front */
  7045. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7046. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7047. /* port-E for HP out (front panel) */
  7048. /* this has to be set to VREF80 */
  7049. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7050. /* route front PCM to HP */
  7051. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7052. /* port-F for mic-in (front panel) with vref */
  7053. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7054. /* port-G for CLFE (rear panel) */
  7055. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7056. /* port-H for side (rear panel) */
  7057. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7058. /* CD-in */
  7059. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7060. /* route front mic to ADC1*/
  7061. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7062. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7063. /* Unmute DAC0~3 & spdif out*/
  7064. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7065. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7066. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7067. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7068. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7069. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7070. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7071. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7072. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7073. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7074. /* Unmute Stereo Mixer 15 */
  7075. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7076. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7077. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7078. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7079. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7080. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7081. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7082. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7083. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7084. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7085. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7086. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7087. /* hp used DAC 3 (Front) */
  7088. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7089. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7090. { }
  7091. };
  7092. static struct hda_verb alc861_asus_init_verbs[] = {
  7093. /*
  7094. * Unmute ADC0 and set the default input to mic-in
  7095. */
  7096. /* port-A for surround (rear panel)
  7097. * according to codec#0 this is the HP jack
  7098. */
  7099. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7100. /* route front PCM to HP */
  7101. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7102. /* port-B for mic-in (rear panel) with vref */
  7103. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7104. /* port-C for line-in (rear panel) */
  7105. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7106. /* port-D for Front */
  7107. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7108. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7109. /* port-E for HP out (front panel) */
  7110. /* this has to be set to VREF80 */
  7111. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7112. /* route front PCM to HP */
  7113. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7114. /* port-F for mic-in (front panel) with vref */
  7115. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7116. /* port-G for CLFE (rear panel) */
  7117. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7118. /* port-H for side (rear panel) */
  7119. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7120. /* CD-in */
  7121. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7122. /* route front mic to ADC1*/
  7123. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7124. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7125. /* Unmute DAC0~3 & spdif out*/
  7126. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7127. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7128. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7129. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7130. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7131. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7132. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7133. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7134. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7135. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7136. /* Unmute Stereo Mixer 15 */
  7137. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7138. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7139. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7140. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7141. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7142. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7143. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7144. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7145. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7146. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7147. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7148. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7149. /* hp used DAC 3 (Front) */
  7150. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7151. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7152. { }
  7153. };
  7154. /* additional init verbs for ASUS laptops */
  7155. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  7156. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  7157. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  7158. { }
  7159. };
  7160. /*
  7161. * generic initialization of ADC, input mixers and output mixers
  7162. */
  7163. static struct hda_verb alc861_auto_init_verbs[] = {
  7164. /*
  7165. * Unmute ADC0 and set the default input to mic-in
  7166. */
  7167. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  7168. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7169. /* Unmute DAC0~3 & spdif out*/
  7170. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7171. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7172. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7173. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7174. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7175. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7176. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7177. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7178. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7179. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7180. /* Unmute Stereo Mixer 15 */
  7181. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7182. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7183. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7184. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  7185. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7186. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7187. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7188. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7189. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7190. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7191. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7192. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7193. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7194. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7195. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7196. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7197. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7198. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7199. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7200. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7201. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  7202. { }
  7203. };
  7204. static struct hda_verb alc861_toshiba_init_verbs[] = {
  7205. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7206. { }
  7207. };
  7208. /* toggle speaker-output according to the hp-jack state */
  7209. static void alc861_toshiba_automute(struct hda_codec *codec)
  7210. {
  7211. unsigned int present;
  7212. present = snd_hda_codec_read(codec, 0x0f, 0,
  7213. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  7214. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  7215. 0x80, present ? 0x80 : 0);
  7216. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  7217. 0x80, present ? 0x80 : 0);
  7218. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  7219. 0x80, present ? 0 : 0x80);
  7220. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  7221. 0x80, present ? 0 : 0x80);
  7222. }
  7223. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  7224. unsigned int res)
  7225. {
  7226. if ((res >> 26) == ALC880_HP_EVENT)
  7227. alc861_toshiba_automute(codec);
  7228. }
  7229. /* pcm configuration: identiacal with ALC880 */
  7230. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  7231. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  7232. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  7233. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  7234. #define ALC861_DIGOUT_NID 0x07
  7235. static struct hda_channel_mode alc861_8ch_modes[1] = {
  7236. { 8, NULL }
  7237. };
  7238. static hda_nid_t alc861_dac_nids[4] = {
  7239. /* front, surround, clfe, side */
  7240. 0x03, 0x06, 0x05, 0x04
  7241. };
  7242. static hda_nid_t alc660_dac_nids[3] = {
  7243. /* front, clfe, surround */
  7244. 0x03, 0x05, 0x06
  7245. };
  7246. static hda_nid_t alc861_adc_nids[1] = {
  7247. /* ADC0-2 */
  7248. 0x08,
  7249. };
  7250. static struct hda_input_mux alc861_capture_source = {
  7251. .num_items = 5,
  7252. .items = {
  7253. { "Mic", 0x0 },
  7254. { "Front Mic", 0x3 },
  7255. { "Line", 0x1 },
  7256. { "CD", 0x4 },
  7257. { "Mixer", 0x5 },
  7258. },
  7259. };
  7260. /* fill in the dac_nids table from the parsed pin configuration */
  7261. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  7262. const struct auto_pin_cfg *cfg)
  7263. {
  7264. int i;
  7265. hda_nid_t nid;
  7266. spec->multiout.dac_nids = spec->private_dac_nids;
  7267. for (i = 0; i < cfg->line_outs; i++) {
  7268. nid = cfg->line_out_pins[i];
  7269. if (nid) {
  7270. if (i >= ARRAY_SIZE(alc861_dac_nids))
  7271. continue;
  7272. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  7273. }
  7274. }
  7275. spec->multiout.num_dacs = cfg->line_outs;
  7276. return 0;
  7277. }
  7278. /* add playback controls from the parsed DAC table */
  7279. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  7280. const struct auto_pin_cfg *cfg)
  7281. {
  7282. char name[32];
  7283. static const char *chname[4] = {
  7284. "Front", "Surround", NULL /*CLFE*/, "Side"
  7285. };
  7286. hda_nid_t nid;
  7287. int i, idx, err;
  7288. for (i = 0; i < cfg->line_outs; i++) {
  7289. nid = spec->multiout.dac_nids[i];
  7290. if (!nid)
  7291. continue;
  7292. if (nid == 0x05) {
  7293. /* Center/LFE */
  7294. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7295. "Center Playback Switch",
  7296. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  7297. HDA_OUTPUT));
  7298. if (err < 0)
  7299. return err;
  7300. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7301. "LFE Playback Switch",
  7302. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7303. HDA_OUTPUT));
  7304. if (err < 0)
  7305. return err;
  7306. } else {
  7307. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  7308. idx++)
  7309. if (nid == alc861_dac_nids[idx])
  7310. break;
  7311. sprintf(name, "%s Playback Switch", chname[idx]);
  7312. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7313. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7314. HDA_OUTPUT));
  7315. if (err < 0)
  7316. return err;
  7317. }
  7318. }
  7319. return 0;
  7320. }
  7321. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  7322. {
  7323. int err;
  7324. hda_nid_t nid;
  7325. if (!pin)
  7326. return 0;
  7327. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  7328. nid = 0x03;
  7329. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7330. "Headphone Playback Switch",
  7331. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7332. if (err < 0)
  7333. return err;
  7334. spec->multiout.hp_nid = nid;
  7335. }
  7336. return 0;
  7337. }
  7338. /* create playback/capture controls for input pins */
  7339. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  7340. const struct auto_pin_cfg *cfg)
  7341. {
  7342. struct hda_input_mux *imux = &spec->private_imux;
  7343. int i, err, idx, idx1;
  7344. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7345. switch (cfg->input_pins[i]) {
  7346. case 0x0c:
  7347. idx1 = 1;
  7348. idx = 2; /* Line In */
  7349. break;
  7350. case 0x0f:
  7351. idx1 = 2;
  7352. idx = 2; /* Line In */
  7353. break;
  7354. case 0x0d:
  7355. idx1 = 0;
  7356. idx = 1; /* Mic In */
  7357. break;
  7358. case 0x10:
  7359. idx1 = 3;
  7360. idx = 1; /* Mic In */
  7361. break;
  7362. case 0x11:
  7363. idx1 = 4;
  7364. idx = 0; /* CD */
  7365. break;
  7366. default:
  7367. continue;
  7368. }
  7369. err = new_analog_input(spec, cfg->input_pins[i],
  7370. auto_pin_cfg_labels[i], idx, 0x15);
  7371. if (err < 0)
  7372. return err;
  7373. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7374. imux->items[imux->num_items].index = idx1;
  7375. imux->num_items++;
  7376. }
  7377. return 0;
  7378. }
  7379. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  7380. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7381. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7382. {
  7383. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7384. /* The multiple "Capture Source" controls confuse alsamixer
  7385. * So call somewhat different..
  7386. *FIXME: the controls appear in the "playback" view!
  7387. */
  7388. /* .name = "Capture Source", */
  7389. .name = "Input Source",
  7390. .count = 1,
  7391. .info = alc_mux_enum_info,
  7392. .get = alc_mux_enum_get,
  7393. .put = alc_mux_enum_put,
  7394. },
  7395. { } /* end */
  7396. };
  7397. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  7398. hda_nid_t nid,
  7399. int pin_type, int dac_idx)
  7400. {
  7401. /* set as output */
  7402. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  7403. pin_type);
  7404. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7405. AMP_OUT_UNMUTE);
  7406. }
  7407. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  7408. {
  7409. struct alc_spec *spec = codec->spec;
  7410. int i;
  7411. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  7412. for (i = 0; i < spec->autocfg.line_outs; i++) {
  7413. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7414. if (nid)
  7415. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT,
  7416. spec->multiout.dac_nids[i]);
  7417. }
  7418. }
  7419. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  7420. {
  7421. struct alc_spec *spec = codec->spec;
  7422. hda_nid_t pin;
  7423. pin = spec->autocfg.hp_pins[0];
  7424. if (pin) /* connect to front */
  7425. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  7426. spec->multiout.dac_nids[0]);
  7427. }
  7428. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  7429. {
  7430. struct alc_spec *spec = codec->spec;
  7431. int i;
  7432. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7433. hda_nid_t nid = spec->autocfg.input_pins[i];
  7434. if (nid >= 0x0c && nid <= 0x11) {
  7435. snd_hda_codec_write(codec, nid, 0,
  7436. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7437. i <= AUTO_PIN_FRONT_MIC ?
  7438. PIN_VREF80 : PIN_IN);
  7439. }
  7440. }
  7441. }
  7442. /* parse the BIOS configuration and set up the alc_spec */
  7443. /* return 1 if successful, 0 if the proper config is not found,
  7444. * or a negative error code
  7445. */
  7446. static int alc861_parse_auto_config(struct hda_codec *codec)
  7447. {
  7448. struct alc_spec *spec = codec->spec;
  7449. int err;
  7450. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  7451. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7452. alc861_ignore);
  7453. if (err < 0)
  7454. return err;
  7455. if (!spec->autocfg.line_outs)
  7456. return 0; /* can't find valid BIOS pin config */
  7457. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  7458. if (err < 0)
  7459. return err;
  7460. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7461. if (err < 0)
  7462. return err;
  7463. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  7464. if (err < 0)
  7465. return err;
  7466. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7467. if (err < 0)
  7468. return err;
  7469. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7470. if (spec->autocfg.dig_out_pin)
  7471. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7472. if (spec->kctl_alloc)
  7473. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7474. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7475. spec->num_mux_defs = 1;
  7476. spec->input_mux = &spec->private_imux;
  7477. spec->adc_nids = alc861_adc_nids;
  7478. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7479. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7480. spec->num_mixers++;
  7481. return 1;
  7482. }
  7483. /* additional initialization for auto-configuration model */
  7484. static void alc861_auto_init(struct hda_codec *codec)
  7485. {
  7486. alc861_auto_init_multi_out(codec);
  7487. alc861_auto_init_hp_out(codec);
  7488. alc861_auto_init_analog_input(codec);
  7489. }
  7490. /*
  7491. * configuration and preset
  7492. */
  7493. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7494. [ALC861_3ST] = "3stack",
  7495. [ALC660_3ST] = "3stack-660",
  7496. [ALC861_3ST_DIG] = "3stack-dig",
  7497. [ALC861_6ST_DIG] = "6stack-dig",
  7498. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7499. [ALC861_TOSHIBA] = "toshiba",
  7500. [ALC861_ASUS] = "asus",
  7501. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7502. [ALC861_AUTO] = "auto",
  7503. };
  7504. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7505. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7506. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7507. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7508. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7509. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  7510. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7511. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7512. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7513. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7514. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  7515. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7516. {}
  7517. };
  7518. static struct alc_config_preset alc861_presets[] = {
  7519. [ALC861_3ST] = {
  7520. .mixers = { alc861_3ST_mixer },
  7521. .init_verbs = { alc861_threestack_init_verbs },
  7522. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7523. .dac_nids = alc861_dac_nids,
  7524. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7525. .channel_mode = alc861_threestack_modes,
  7526. .need_dac_fix = 1,
  7527. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7528. .adc_nids = alc861_adc_nids,
  7529. .input_mux = &alc861_capture_source,
  7530. },
  7531. [ALC861_3ST_DIG] = {
  7532. .mixers = { alc861_base_mixer },
  7533. .init_verbs = { alc861_threestack_init_verbs },
  7534. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7535. .dac_nids = alc861_dac_nids,
  7536. .dig_out_nid = ALC861_DIGOUT_NID,
  7537. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7538. .channel_mode = alc861_threestack_modes,
  7539. .need_dac_fix = 1,
  7540. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7541. .adc_nids = alc861_adc_nids,
  7542. .input_mux = &alc861_capture_source,
  7543. },
  7544. [ALC861_6ST_DIG] = {
  7545. .mixers = { alc861_base_mixer },
  7546. .init_verbs = { alc861_base_init_verbs },
  7547. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7548. .dac_nids = alc861_dac_nids,
  7549. .dig_out_nid = ALC861_DIGOUT_NID,
  7550. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7551. .channel_mode = alc861_8ch_modes,
  7552. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7553. .adc_nids = alc861_adc_nids,
  7554. .input_mux = &alc861_capture_source,
  7555. },
  7556. [ALC660_3ST] = {
  7557. .mixers = { alc861_3ST_mixer },
  7558. .init_verbs = { alc861_threestack_init_verbs },
  7559. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7560. .dac_nids = alc660_dac_nids,
  7561. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7562. .channel_mode = alc861_threestack_modes,
  7563. .need_dac_fix = 1,
  7564. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7565. .adc_nids = alc861_adc_nids,
  7566. .input_mux = &alc861_capture_source,
  7567. },
  7568. [ALC861_UNIWILL_M31] = {
  7569. .mixers = { alc861_uniwill_m31_mixer },
  7570. .init_verbs = { alc861_uniwill_m31_init_verbs },
  7571. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7572. .dac_nids = alc861_dac_nids,
  7573. .dig_out_nid = ALC861_DIGOUT_NID,
  7574. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7575. .channel_mode = alc861_uniwill_m31_modes,
  7576. .need_dac_fix = 1,
  7577. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7578. .adc_nids = alc861_adc_nids,
  7579. .input_mux = &alc861_capture_source,
  7580. },
  7581. [ALC861_TOSHIBA] = {
  7582. .mixers = { alc861_toshiba_mixer },
  7583. .init_verbs = { alc861_base_init_verbs,
  7584. alc861_toshiba_init_verbs },
  7585. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7586. .dac_nids = alc861_dac_nids,
  7587. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7588. .channel_mode = alc883_3ST_2ch_modes,
  7589. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7590. .adc_nids = alc861_adc_nids,
  7591. .input_mux = &alc861_capture_source,
  7592. .unsol_event = alc861_toshiba_unsol_event,
  7593. .init_hook = alc861_toshiba_automute,
  7594. },
  7595. [ALC861_ASUS] = {
  7596. .mixers = { alc861_asus_mixer },
  7597. .init_verbs = { alc861_asus_init_verbs },
  7598. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7599. .dac_nids = alc861_dac_nids,
  7600. .dig_out_nid = ALC861_DIGOUT_NID,
  7601. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  7602. .channel_mode = alc861_asus_modes,
  7603. .need_dac_fix = 1,
  7604. .hp_nid = 0x06,
  7605. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7606. .adc_nids = alc861_adc_nids,
  7607. .input_mux = &alc861_capture_source,
  7608. },
  7609. [ALC861_ASUS_LAPTOP] = {
  7610. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  7611. .init_verbs = { alc861_asus_init_verbs,
  7612. alc861_asus_laptop_init_verbs },
  7613. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7614. .dac_nids = alc861_dac_nids,
  7615. .dig_out_nid = ALC861_DIGOUT_NID,
  7616. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7617. .channel_mode = alc883_3ST_2ch_modes,
  7618. .need_dac_fix = 1,
  7619. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7620. .adc_nids = alc861_adc_nids,
  7621. .input_mux = &alc861_capture_source,
  7622. },
  7623. };
  7624. static int patch_alc861(struct hda_codec *codec)
  7625. {
  7626. struct alc_spec *spec;
  7627. int board_config;
  7628. int err;
  7629. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7630. if (spec == NULL)
  7631. return -ENOMEM;
  7632. codec->spec = spec;
  7633. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  7634. alc861_models,
  7635. alc861_cfg_tbl);
  7636. if (board_config < 0) {
  7637. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  7638. "trying auto-probe from BIOS...\n");
  7639. board_config = ALC861_AUTO;
  7640. }
  7641. if (board_config == ALC861_AUTO) {
  7642. /* automatic parse from the BIOS config */
  7643. err = alc861_parse_auto_config(codec);
  7644. if (err < 0) {
  7645. alc_free(codec);
  7646. return err;
  7647. } else if (!err) {
  7648. printk(KERN_INFO
  7649. "hda_codec: Cannot set up configuration "
  7650. "from BIOS. Using base mode...\n");
  7651. board_config = ALC861_3ST_DIG;
  7652. }
  7653. }
  7654. if (board_config != ALC861_AUTO)
  7655. setup_preset(spec, &alc861_presets[board_config]);
  7656. spec->stream_name_analog = "ALC861 Analog";
  7657. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  7658. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  7659. spec->stream_name_digital = "ALC861 Digital";
  7660. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  7661. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  7662. codec->patch_ops = alc_patch_ops;
  7663. if (board_config == ALC861_AUTO)
  7664. spec->init_hook = alc861_auto_init;
  7665. return 0;
  7666. }
  7667. /*
  7668. * ALC861-VD support
  7669. *
  7670. * Based on ALC882
  7671. *
  7672. * In addition, an independent DAC
  7673. */
  7674. #define ALC861VD_DIGOUT_NID 0x06
  7675. static hda_nid_t alc861vd_dac_nids[4] = {
  7676. /* front, surr, clfe, side surr */
  7677. 0x02, 0x03, 0x04, 0x05
  7678. };
  7679. /* dac_nids for ALC660vd are in a different order - according to
  7680. * Realtek's driver.
  7681. * This should probably tesult in a different mixer for 6stack models
  7682. * of ALC660vd codecs, but for now there is only 3stack mixer
  7683. * - and it is the same as in 861vd.
  7684. * adc_nids in ALC660vd are (is) the same as in 861vd
  7685. */
  7686. static hda_nid_t alc660vd_dac_nids[3] = {
  7687. /* front, rear, clfe, rear_surr */
  7688. 0x02, 0x04, 0x03
  7689. };
  7690. static hda_nid_t alc861vd_adc_nids[1] = {
  7691. /* ADC0 */
  7692. 0x09,
  7693. };
  7694. /* input MUX */
  7695. /* FIXME: should be a matrix-type input source selection */
  7696. static struct hda_input_mux alc861vd_capture_source = {
  7697. .num_items = 4,
  7698. .items = {
  7699. { "Mic", 0x0 },
  7700. { "Front Mic", 0x1 },
  7701. { "Line", 0x2 },
  7702. { "CD", 0x4 },
  7703. },
  7704. };
  7705. #define alc861vd_mux_enum_info alc_mux_enum_info
  7706. #define alc861vd_mux_enum_get alc_mux_enum_get
  7707. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  7708. struct snd_ctl_elem_value *ucontrol)
  7709. {
  7710. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7711. struct alc_spec *spec = codec->spec;
  7712. const struct hda_input_mux *imux = spec->input_mux;
  7713. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7714. static hda_nid_t capture_mixers[1] = { 0x22 };
  7715. hda_nid_t nid = capture_mixers[adc_idx];
  7716. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7717. unsigned int i, idx;
  7718. idx = ucontrol->value.enumerated.item[0];
  7719. if (idx >= imux->num_items)
  7720. idx = imux->num_items - 1;
  7721. if (*cur_val == idx && !codec->in_resume)
  7722. return 0;
  7723. for (i = 0; i < imux->num_items; i++) {
  7724. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7725. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7726. v | (imux->items[i].index << 8));
  7727. }
  7728. *cur_val = idx;
  7729. return 1;
  7730. }
  7731. /*
  7732. * 2ch mode
  7733. */
  7734. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  7735. { 2, NULL }
  7736. };
  7737. /*
  7738. * 6ch mode
  7739. */
  7740. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  7741. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7742. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7743. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7744. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7745. { } /* end */
  7746. };
  7747. /*
  7748. * 8ch mode
  7749. */
  7750. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  7751. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7752. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7753. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7754. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7755. { } /* end */
  7756. };
  7757. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  7758. { 6, alc861vd_6stack_ch6_init },
  7759. { 8, alc861vd_6stack_ch8_init },
  7760. };
  7761. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  7762. {
  7763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7764. .name = "Channel Mode",
  7765. .info = alc_ch_mode_info,
  7766. .get = alc_ch_mode_get,
  7767. .put = alc_ch_mode_put,
  7768. },
  7769. { } /* end */
  7770. };
  7771. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  7772. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  7773. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  7774. {
  7775. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7776. /* The multiple "Capture Source" controls confuse alsamixer
  7777. * So call somewhat different..
  7778. *FIXME: the controls appear in the "playback" view!
  7779. */
  7780. /* .name = "Capture Source", */
  7781. .name = "Input Source",
  7782. .count = 1,
  7783. .info = alc861vd_mux_enum_info,
  7784. .get = alc861vd_mux_enum_get,
  7785. .put = alc861vd_mux_enum_put,
  7786. },
  7787. { } /* end */
  7788. };
  7789. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  7790. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  7791. */
  7792. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  7793. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7794. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7795. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  7796. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  7797. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  7798. HDA_OUTPUT),
  7799. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  7800. HDA_OUTPUT),
  7801. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  7802. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  7803. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  7804. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  7805. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7806. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7807. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7808. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7809. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7810. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7811. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7812. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7813. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7814. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7815. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7816. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7817. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7818. { } /* end */
  7819. };
  7820. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  7821. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7822. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7823. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7824. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7825. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7826. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7827. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7828. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7829. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7830. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7831. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7832. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7833. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7834. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7835. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7836. { } /* end */
  7837. };
  7838. /*
  7839. * generic initialization of ADC, input mixers and output mixers
  7840. */
  7841. static struct hda_verb alc861vd_volume_init_verbs[] = {
  7842. /*
  7843. * Unmute ADC0 and set the default input to mic-in
  7844. */
  7845. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7846. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7847. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  7848. * the analog-loopback mixer widget
  7849. */
  7850. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7852. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7853. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7854. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7855. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7856. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  7857. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7858. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7859. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7860. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
  7861. /*
  7862. * Set up output mixers (0x02 - 0x05)
  7863. */
  7864. /* set vol=0 to output mixers */
  7865. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7866. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7867. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7868. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7869. /* set up input amps for analog loopback */
  7870. /* Amp Indices: DAC = 0, mixer = 1 */
  7871. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7872. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7873. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7874. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7875. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7876. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7877. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7878. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7879. { }
  7880. };
  7881. /*
  7882. * 3-stack pin configuration:
  7883. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  7884. */
  7885. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  7886. /*
  7887. * Set pin mode and muting
  7888. */
  7889. /* set front pin widgets 0x14 for output */
  7890. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7891. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7892. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7893. /* Mic (rear) pin: input vref at 80% */
  7894. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7895. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7896. /* Front Mic pin: input vref at 80% */
  7897. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7898. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7899. /* Line In pin: input */
  7900. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7901. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7902. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7903. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7904. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7905. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7906. /* CD pin widget for input */
  7907. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7908. { }
  7909. };
  7910. /*
  7911. * 6-stack pin configuration:
  7912. */
  7913. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  7914. /*
  7915. * Set pin mode and muting
  7916. */
  7917. /* set front pin widgets 0x14 for output */
  7918. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7919. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7920. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7921. /* Rear Pin: output 1 (0x0d) */
  7922. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7923. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7924. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7925. /* CLFE Pin: output 2 (0x0e) */
  7926. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7927. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7928. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  7929. /* Side Pin: output 3 (0x0f) */
  7930. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7931. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7932. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  7933. /* Mic (rear) pin: input vref at 80% */
  7934. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7935. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7936. /* Front Mic pin: input vref at 80% */
  7937. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7938. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7939. /* Line In pin: input */
  7940. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7941. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7942. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7943. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7944. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7945. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7946. /* CD pin widget for input */
  7947. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7948. { }
  7949. };
  7950. /* pcm configuration: identiacal with ALC880 */
  7951. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  7952. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  7953. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  7954. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  7955. /*
  7956. * configuration and preset
  7957. */
  7958. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  7959. [ALC660VD_3ST] = "3stack-660",
  7960. [ALC861VD_3ST] = "3stack",
  7961. [ALC861VD_3ST_DIG] = "3stack-digout",
  7962. [ALC861VD_6ST_DIG] = "6stack-digout",
  7963. [ALC861VD_AUTO] = "auto",
  7964. };
  7965. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  7966. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  7967. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  7968. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  7969. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  7970. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
  7971. {}
  7972. };
  7973. static struct alc_config_preset alc861vd_presets[] = {
  7974. [ALC660VD_3ST] = {
  7975. .mixers = { alc861vd_3st_mixer },
  7976. .init_verbs = { alc861vd_volume_init_verbs,
  7977. alc861vd_3stack_init_verbs },
  7978. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  7979. .dac_nids = alc660vd_dac_nids,
  7980. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  7981. .adc_nids = alc861vd_adc_nids,
  7982. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7983. .channel_mode = alc861vd_3stack_2ch_modes,
  7984. .input_mux = &alc861vd_capture_source,
  7985. },
  7986. [ALC861VD_3ST] = {
  7987. .mixers = { alc861vd_3st_mixer },
  7988. .init_verbs = { alc861vd_volume_init_verbs,
  7989. alc861vd_3stack_init_verbs },
  7990. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7991. .dac_nids = alc861vd_dac_nids,
  7992. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7993. .channel_mode = alc861vd_3stack_2ch_modes,
  7994. .input_mux = &alc861vd_capture_source,
  7995. },
  7996. [ALC861VD_3ST_DIG] = {
  7997. .mixers = { alc861vd_3st_mixer },
  7998. .init_verbs = { alc861vd_volume_init_verbs,
  7999. alc861vd_3stack_init_verbs },
  8000. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8001. .dac_nids = alc861vd_dac_nids,
  8002. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8003. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8004. .channel_mode = alc861vd_3stack_2ch_modes,
  8005. .input_mux = &alc861vd_capture_source,
  8006. },
  8007. [ALC861VD_6ST_DIG] = {
  8008. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  8009. .init_verbs = { alc861vd_volume_init_verbs,
  8010. alc861vd_6stack_init_verbs },
  8011. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8012. .dac_nids = alc861vd_dac_nids,
  8013. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8014. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  8015. .channel_mode = alc861vd_6stack_modes,
  8016. .input_mux = &alc861vd_capture_source,
  8017. },
  8018. };
  8019. /*
  8020. * BIOS auto configuration
  8021. */
  8022. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  8023. hda_nid_t nid, int pin_type, int dac_idx)
  8024. {
  8025. /* set as output */
  8026. snd_hda_codec_write(codec, nid, 0,
  8027. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8028. snd_hda_codec_write(codec, nid, 0,
  8029. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8030. }
  8031. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  8032. {
  8033. struct alc_spec *spec = codec->spec;
  8034. int i;
  8035. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  8036. for (i = 0; i <= HDA_SIDE; i++) {
  8037. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8038. if (nid)
  8039. alc861vd_auto_set_output_and_unmute(codec, nid,
  8040. PIN_OUT, i);
  8041. }
  8042. }
  8043. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  8044. {
  8045. struct alc_spec *spec = codec->spec;
  8046. hda_nid_t pin;
  8047. pin = spec->autocfg.hp_pins[0];
  8048. if (pin) /* connect to front and use dac 0 */
  8049. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8050. }
  8051. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  8052. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  8053. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  8054. {
  8055. struct alc_spec *spec = codec->spec;
  8056. int i;
  8057. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8058. hda_nid_t nid = spec->autocfg.input_pins[i];
  8059. if (alc861vd_is_input_pin(nid)) {
  8060. snd_hda_codec_write(codec, nid, 0,
  8061. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8062. i <= AUTO_PIN_FRONT_MIC ?
  8063. PIN_VREF80 : PIN_IN);
  8064. if (nid != ALC861VD_PIN_CD_NID)
  8065. snd_hda_codec_write(codec, nid, 0,
  8066. AC_VERB_SET_AMP_GAIN_MUTE,
  8067. AMP_OUT_MUTE);
  8068. }
  8069. }
  8070. }
  8071. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  8072. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  8073. /* add playback controls from the parsed DAC table */
  8074. /* Based on ALC880 version. But ALC861VD has separate,
  8075. * different NIDs for mute/unmute switch and volume control */
  8076. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  8077. const struct auto_pin_cfg *cfg)
  8078. {
  8079. char name[32];
  8080. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  8081. hda_nid_t nid_v, nid_s;
  8082. int i, err;
  8083. for (i = 0; i < cfg->line_outs; i++) {
  8084. if (!spec->multiout.dac_nids[i])
  8085. continue;
  8086. nid_v = alc861vd_idx_to_mixer_vol(
  8087. alc880_dac_to_idx(
  8088. spec->multiout.dac_nids[i]));
  8089. nid_s = alc861vd_idx_to_mixer_switch(
  8090. alc880_dac_to_idx(
  8091. spec->multiout.dac_nids[i]));
  8092. if (i == 2) {
  8093. /* Center/LFE */
  8094. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8095. "Center Playback Volume",
  8096. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  8097. HDA_OUTPUT));
  8098. if (err < 0)
  8099. return err;
  8100. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8101. "LFE Playback Volume",
  8102. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  8103. HDA_OUTPUT));
  8104. if (err < 0)
  8105. return err;
  8106. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8107. "Center Playback Switch",
  8108. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  8109. HDA_INPUT));
  8110. if (err < 0)
  8111. return err;
  8112. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8113. "LFE Playback Switch",
  8114. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  8115. HDA_INPUT));
  8116. if (err < 0)
  8117. return err;
  8118. } else {
  8119. sprintf(name, "%s Playback Volume", chname[i]);
  8120. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8121. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  8122. HDA_OUTPUT));
  8123. if (err < 0)
  8124. return err;
  8125. sprintf(name, "%s Playback Switch", chname[i]);
  8126. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8127. HDA_COMPOSE_AMP_VAL(nid_v, 3, 2,
  8128. HDA_INPUT));
  8129. if (err < 0)
  8130. return err;
  8131. }
  8132. }
  8133. return 0;
  8134. }
  8135. /* add playback controls for speaker and HP outputs */
  8136. /* Based on ALC880 version. But ALC861VD has separate,
  8137. * different NIDs for mute/unmute switch and volume control */
  8138. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  8139. hda_nid_t pin, const char *pfx)
  8140. {
  8141. hda_nid_t nid_v, nid_s;
  8142. int err;
  8143. char name[32];
  8144. if (!pin)
  8145. return 0;
  8146. if (alc880_is_fixed_pin(pin)) {
  8147. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8148. /* specify the DAC as the extra output */
  8149. if (!spec->multiout.hp_nid)
  8150. spec->multiout.hp_nid = nid_v;
  8151. else
  8152. spec->multiout.extra_out_nid[0] = nid_v;
  8153. /* control HP volume/switch on the output mixer amp */
  8154. nid_v = alc861vd_idx_to_mixer_vol(
  8155. alc880_fixed_pin_idx(pin));
  8156. nid_s = alc861vd_idx_to_mixer_switch(
  8157. alc880_fixed_pin_idx(pin));
  8158. sprintf(name, "%s Playback Volume", pfx);
  8159. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8160. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  8161. if (err < 0)
  8162. return err;
  8163. sprintf(name, "%s Playback Switch", pfx);
  8164. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8165. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  8166. if (err < 0)
  8167. return err;
  8168. } else if (alc880_is_multi_pin(pin)) {
  8169. /* set manual connection */
  8170. /* we have only a switch on HP-out PIN */
  8171. sprintf(name, "%s Playback Switch", pfx);
  8172. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8173. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8174. if (err < 0)
  8175. return err;
  8176. }
  8177. return 0;
  8178. }
  8179. /* parse the BIOS configuration and set up the alc_spec
  8180. * return 1 if successful, 0 if the proper config is not found,
  8181. * or a negative error code
  8182. * Based on ALC880 version - had to change it to override
  8183. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  8184. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  8185. {
  8186. struct alc_spec *spec = codec->spec;
  8187. int err;
  8188. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  8189. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8190. alc861vd_ignore);
  8191. if (err < 0)
  8192. return err;
  8193. if (!spec->autocfg.line_outs)
  8194. return 0; /* can't find valid BIOS pin config */
  8195. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8196. if (err < 0)
  8197. return err;
  8198. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8199. if (err < 0)
  8200. return err;
  8201. err = alc861vd_auto_create_extra_out(spec,
  8202. spec->autocfg.speaker_pins[0],
  8203. "Speaker");
  8204. if (err < 0)
  8205. return err;
  8206. err = alc861vd_auto_create_extra_out(spec,
  8207. spec->autocfg.hp_pins[0],
  8208. "Headphone");
  8209. if (err < 0)
  8210. return err;
  8211. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8212. if (err < 0)
  8213. return err;
  8214. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8215. if (spec->autocfg.dig_out_pin)
  8216. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  8217. if (spec->kctl_alloc)
  8218. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8219. spec->init_verbs[spec->num_init_verbs++]
  8220. = alc861vd_volume_init_verbs;
  8221. spec->num_mux_defs = 1;
  8222. spec->input_mux = &spec->private_imux;
  8223. return 1;
  8224. }
  8225. /* additional initialization for auto-configuration model */
  8226. static void alc861vd_auto_init(struct hda_codec *codec)
  8227. {
  8228. alc861vd_auto_init_multi_out(codec);
  8229. alc861vd_auto_init_hp_out(codec);
  8230. alc861vd_auto_init_analog_input(codec);
  8231. }
  8232. static int patch_alc861vd(struct hda_codec *codec)
  8233. {
  8234. struct alc_spec *spec;
  8235. int err, board_config;
  8236. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8237. if (spec == NULL)
  8238. return -ENOMEM;
  8239. codec->spec = spec;
  8240. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  8241. alc861vd_models,
  8242. alc861vd_cfg_tbl);
  8243. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  8244. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  8245. "ALC861VD, trying auto-probe from BIOS...\n");
  8246. board_config = ALC861VD_AUTO;
  8247. }
  8248. if (board_config == ALC861VD_AUTO) {
  8249. /* automatic parse from the BIOS config */
  8250. err = alc861vd_parse_auto_config(codec);
  8251. if (err < 0) {
  8252. alc_free(codec);
  8253. return err;
  8254. } else if (!err) {
  8255. printk(KERN_INFO
  8256. "hda_codec: Cannot set up configuration "
  8257. "from BIOS. Using base mode...\n");
  8258. board_config = ALC861VD_3ST;
  8259. }
  8260. }
  8261. if (board_config != ALC861VD_AUTO)
  8262. setup_preset(spec, &alc861vd_presets[board_config]);
  8263. spec->stream_name_analog = "ALC861VD Analog";
  8264. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  8265. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  8266. spec->stream_name_digital = "ALC861VD Digital";
  8267. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  8268. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  8269. spec->adc_nids = alc861vd_adc_nids;
  8270. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  8271. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  8272. spec->num_mixers++;
  8273. codec->patch_ops = alc_patch_ops;
  8274. if (board_config == ALC861VD_AUTO)
  8275. spec->init_hook = alc861vd_auto_init;
  8276. return 0;
  8277. }
  8278. /*
  8279. * ALC662 support
  8280. *
  8281. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  8282. * configuration. Each pin widget can choose any input DACs and a mixer.
  8283. * Each ADC is connected from a mixer of all inputs. This makes possible
  8284. * 6-channel independent captures.
  8285. *
  8286. * In addition, an independent DAC for the multi-playback (not used in this
  8287. * driver yet).
  8288. */
  8289. #define ALC662_DIGOUT_NID 0x06
  8290. #define ALC662_DIGIN_NID 0x0a
  8291. static hda_nid_t alc662_dac_nids[4] = {
  8292. /* front, rear, clfe, rear_surr */
  8293. 0x02, 0x03, 0x04
  8294. };
  8295. static hda_nid_t alc662_adc_nids[1] = {
  8296. /* ADC1-2 */
  8297. 0x09,
  8298. };
  8299. /* input MUX */
  8300. /* FIXME: should be a matrix-type input source selection */
  8301. static struct hda_input_mux alc662_capture_source = {
  8302. .num_items = 4,
  8303. .items = {
  8304. { "Mic", 0x0 },
  8305. { "Front Mic", 0x1 },
  8306. { "Line", 0x2 },
  8307. { "CD", 0x4 },
  8308. },
  8309. };
  8310. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  8311. .num_items = 2,
  8312. .items = {
  8313. { "Mic", 0x1 },
  8314. { "Line", 0x2 },
  8315. },
  8316. };
  8317. #define alc662_mux_enum_info alc_mux_enum_info
  8318. #define alc662_mux_enum_get alc_mux_enum_get
  8319. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  8320. struct snd_ctl_elem_value *ucontrol)
  8321. {
  8322. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8323. struct alc_spec *spec = codec->spec;
  8324. const struct hda_input_mux *imux = spec->input_mux;
  8325. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8326. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  8327. hda_nid_t nid = capture_mixers[adc_idx];
  8328. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8329. unsigned int i, idx;
  8330. idx = ucontrol->value.enumerated.item[0];
  8331. if (idx >= imux->num_items)
  8332. idx = imux->num_items - 1;
  8333. if (*cur_val == idx && !codec->in_resume)
  8334. return 0;
  8335. for (i = 0; i < imux->num_items; i++) {
  8336. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8337. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8338. v | (imux->items[i].index << 8));
  8339. }
  8340. *cur_val = idx;
  8341. return 1;
  8342. }
  8343. /*
  8344. * 2ch mode
  8345. */
  8346. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  8347. { 2, NULL }
  8348. };
  8349. /*
  8350. * 2ch mode
  8351. */
  8352. static struct hda_verb alc662_3ST_ch2_init[] = {
  8353. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  8354. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8355. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  8356. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8357. { } /* end */
  8358. };
  8359. /*
  8360. * 6ch mode
  8361. */
  8362. static struct hda_verb alc662_3ST_ch6_init[] = {
  8363. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8364. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8365. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  8366. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8367. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8368. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8369. { } /* end */
  8370. };
  8371. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  8372. { 2, alc662_3ST_ch2_init },
  8373. { 6, alc662_3ST_ch6_init },
  8374. };
  8375. /*
  8376. * 2ch mode
  8377. */
  8378. static struct hda_verb alc662_sixstack_ch6_init[] = {
  8379. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8380. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8381. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8382. { } /* end */
  8383. };
  8384. /*
  8385. * 6ch mode
  8386. */
  8387. static struct hda_verb alc662_sixstack_ch8_init[] = {
  8388. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8389. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8390. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8391. { } /* end */
  8392. };
  8393. static struct hda_channel_mode alc662_5stack_modes[2] = {
  8394. { 2, alc662_sixstack_ch6_init },
  8395. { 6, alc662_sixstack_ch8_init },
  8396. };
  8397. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8398. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8399. */
  8400. static struct snd_kcontrol_new alc662_base_mixer[] = {
  8401. /* output mixer control */
  8402. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8403. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  8404. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8405. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8406. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  8407. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  8408. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  8409. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  8410. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8411. /*Input mixer control */
  8412. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  8413. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  8414. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  8415. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  8416. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  8417. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  8418. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  8419. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  8420. /* Capture mixer control */
  8421. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8422. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8423. {
  8424. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8425. .name = "Capture Source",
  8426. .count = 1,
  8427. .info = alc_mux_enum_info,
  8428. .get = alc_mux_enum_get,
  8429. .put = alc_mux_enum_put,
  8430. },
  8431. { } /* end */
  8432. };
  8433. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  8434. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8435. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8436. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8439. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8440. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8441. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8442. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8443. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8444. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8445. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8446. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8447. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8448. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8449. {
  8450. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8451. /* .name = "Capture Source", */
  8452. .name = "Input Source",
  8453. .count = 1,
  8454. .info = alc662_mux_enum_info,
  8455. .get = alc662_mux_enum_get,
  8456. .put = alc662_mux_enum_put,
  8457. },
  8458. { } /* end */
  8459. };
  8460. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  8461. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8462. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8463. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8464. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  8465. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  8466. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  8467. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  8468. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  8469. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8470. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8471. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8472. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8473. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8474. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8475. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8476. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8477. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8478. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8479. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8480. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8481. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8482. {
  8483. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8484. /* .name = "Capture Source", */
  8485. .name = "Input Source",
  8486. .count = 1,
  8487. .info = alc662_mux_enum_info,
  8488. .get = alc662_mux_enum_get,
  8489. .put = alc662_mux_enum_put,
  8490. },
  8491. { } /* end */
  8492. };
  8493. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  8494. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8495. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8496. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8497. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  8498. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8499. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8500. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8501. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8502. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8503. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8504. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8505. {
  8506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8507. /* .name = "Capture Source", */
  8508. .name = "Input Source",
  8509. .count = 1,
  8510. .info = alc662_mux_enum_info,
  8511. .get = alc662_mux_enum_get,
  8512. .put = alc662_mux_enum_put,
  8513. },
  8514. { } /* end */
  8515. };
  8516. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  8517. {
  8518. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8519. .name = "Channel Mode",
  8520. .info = alc_ch_mode_info,
  8521. .get = alc_ch_mode_get,
  8522. .put = alc_ch_mode_put,
  8523. },
  8524. { } /* end */
  8525. };
  8526. static struct hda_verb alc662_init_verbs[] = {
  8527. /* ADC: mute amp left and right */
  8528. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8529. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8530. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  8531. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8532. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8533. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8534. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8535. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8536. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8537. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8538. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8539. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8540. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8541. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8542. /* Front Pin: output 0 (0x0c) */
  8543. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8544. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8545. /* Rear Pin: output 1 (0x0d) */
  8546. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8547. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8548. /* CLFE Pin: output 2 (0x0e) */
  8549. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8550. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8551. /* Mic (rear) pin: input vref at 80% */
  8552. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8553. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8554. /* Front Mic pin: input vref at 80% */
  8555. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8556. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8557. /* Line In pin: input */
  8558. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8559. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8560. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8561. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8562. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8563. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8564. /* CD pin widget for input */
  8565. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8566. /* FIXME: use matrix-type input source selection */
  8567. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  8568. /* Input mixer */
  8569. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8570. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8571. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8572. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8573. { }
  8574. };
  8575. static struct hda_verb alc662_sue_init_verbs[] = {
  8576. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  8577. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  8578. {}
  8579. };
  8580. /*
  8581. * generic initialization of ADC, input mixers and output mixers
  8582. */
  8583. static struct hda_verb alc662_auto_init_verbs[] = {
  8584. /*
  8585. * Unmute ADC and set the default input to mic-in
  8586. */
  8587. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8588. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8589. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  8590. * mixer widget
  8591. * Note: PASD motherboards uses the Line In 2 as the input for front
  8592. * panel mic (mic 2)
  8593. */
  8594. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8595. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8596. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8597. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8598. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8599. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8600. /*
  8601. * Set up output mixers (0x0c - 0x0f)
  8602. */
  8603. /* set vol=0 to output mixers */
  8604. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8605. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8606. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8607. /* set up input amps for analog loopback */
  8608. /* Amp Indices: DAC = 0, mixer = 1 */
  8609. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8610. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8611. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8612. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8613. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8614. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8615. /* FIXME: use matrix-type input source selection */
  8616. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  8617. /* Input mixer */
  8618. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8619. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8620. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8621. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  8622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8623. { }
  8624. };
  8625. /* capture mixer elements */
  8626. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  8627. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8628. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8629. {
  8630. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8631. /* The multiple "Capture Source" controls confuse alsamixer
  8632. * So call somewhat different..
  8633. * FIXME: the controls appear in the "playback" view!
  8634. */
  8635. /* .name = "Capture Source", */
  8636. .name = "Input Source",
  8637. .count = 1,
  8638. .info = alc882_mux_enum_info,
  8639. .get = alc882_mux_enum_get,
  8640. .put = alc882_mux_enum_put,
  8641. },
  8642. { } /* end */
  8643. };
  8644. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  8645. {
  8646. unsigned int present;
  8647. unsigned char bits;
  8648. present = snd_hda_codec_read(codec, 0x14, 0,
  8649. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8650. bits = present ? 0x80 : 0;
  8651. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  8652. 0x80, bits);
  8653. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  8654. 0x80, bits);
  8655. }
  8656. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  8657. {
  8658. unsigned int present;
  8659. unsigned char bits;
  8660. present = snd_hda_codec_read(codec, 0x1b, 0,
  8661. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8662. bits = present ? 0x80 : 0;
  8663. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  8664. 0x80, bits);
  8665. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  8666. 0x80, bits);
  8667. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8668. 0x80, bits);
  8669. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8670. 0x80, bits);
  8671. }
  8672. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  8673. unsigned int res)
  8674. {
  8675. if ((res >> 26) == ALC880_HP_EVENT)
  8676. alc662_lenovo_101e_all_automute(codec);
  8677. if ((res >> 26) == ALC880_FRONT_EVENT)
  8678. alc662_lenovo_101e_ispeaker_automute(codec);
  8679. }
  8680. /* pcm configuration: identiacal with ALC880 */
  8681. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  8682. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  8683. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  8684. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  8685. /*
  8686. * configuration and preset
  8687. */
  8688. static const char *alc662_models[ALC662_MODEL_LAST] = {
  8689. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  8690. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  8691. [ALC662_3ST_6ch] = "3stack-6ch",
  8692. [ALC662_5ST_DIG] = "6stack-dig",
  8693. [ALC662_LENOVO_101E] = "lenovo-101e",
  8694. [ALC662_AUTO] = "auto",
  8695. };
  8696. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  8697. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  8698. {}
  8699. };
  8700. static struct alc_config_preset alc662_presets[] = {
  8701. [ALC662_3ST_2ch_DIG] = {
  8702. .mixers = { alc662_3ST_2ch_mixer },
  8703. .init_verbs = { alc662_init_verbs },
  8704. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8705. .dac_nids = alc662_dac_nids,
  8706. .dig_out_nid = ALC662_DIGOUT_NID,
  8707. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8708. .adc_nids = alc662_adc_nids,
  8709. .dig_in_nid = ALC662_DIGIN_NID,
  8710. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  8711. .channel_mode = alc662_3ST_2ch_modes,
  8712. .input_mux = &alc662_capture_source,
  8713. },
  8714. [ALC662_3ST_6ch_DIG] = {
  8715. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  8716. .init_verbs = { alc662_init_verbs },
  8717. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8718. .dac_nids = alc662_dac_nids,
  8719. .dig_out_nid = ALC662_DIGOUT_NID,
  8720. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8721. .adc_nids = alc662_adc_nids,
  8722. .dig_in_nid = ALC662_DIGIN_NID,
  8723. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  8724. .channel_mode = alc662_3ST_6ch_modes,
  8725. .need_dac_fix = 1,
  8726. .input_mux = &alc662_capture_source,
  8727. },
  8728. [ALC662_3ST_6ch] = {
  8729. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  8730. .init_verbs = { alc662_init_verbs },
  8731. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8732. .dac_nids = alc662_dac_nids,
  8733. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8734. .adc_nids = alc662_adc_nids,
  8735. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  8736. .channel_mode = alc662_3ST_6ch_modes,
  8737. .need_dac_fix = 1,
  8738. .input_mux = &alc662_capture_source,
  8739. },
  8740. [ALC662_5ST_DIG] = {
  8741. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  8742. .init_verbs = { alc662_init_verbs },
  8743. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8744. .dac_nids = alc662_dac_nids,
  8745. .dig_out_nid = ALC662_DIGOUT_NID,
  8746. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8747. .adc_nids = alc662_adc_nids,
  8748. .dig_in_nid = ALC662_DIGIN_NID,
  8749. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  8750. .channel_mode = alc662_5stack_modes,
  8751. .input_mux = &alc662_capture_source,
  8752. },
  8753. [ALC662_LENOVO_101E] = {
  8754. .mixers = { alc662_lenovo_101e_mixer },
  8755. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  8756. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8757. .dac_nids = alc662_dac_nids,
  8758. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8759. .adc_nids = alc662_adc_nids,
  8760. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  8761. .channel_mode = alc662_3ST_2ch_modes,
  8762. .input_mux = &alc662_lenovo_101e_capture_source,
  8763. .unsol_event = alc662_lenovo_101e_unsol_event,
  8764. .init_hook = alc662_lenovo_101e_all_automute,
  8765. },
  8766. };
  8767. /*
  8768. * BIOS auto configuration
  8769. */
  8770. /* add playback controls from the parsed DAC table */
  8771. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  8772. const struct auto_pin_cfg *cfg)
  8773. {
  8774. char name[32];
  8775. static const char *chname[4] = {
  8776. "Front", "Surround", NULL /*CLFE*/, "Side"
  8777. };
  8778. hda_nid_t nid;
  8779. int i, err;
  8780. for (i = 0; i < cfg->line_outs; i++) {
  8781. if (!spec->multiout.dac_nids[i])
  8782. continue;
  8783. nid = alc880_idx_to_dac(i);
  8784. if (i == 2) {
  8785. /* Center/LFE */
  8786. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8787. "Center Playback Volume",
  8788. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8789. HDA_OUTPUT));
  8790. if (err < 0)
  8791. return err;
  8792. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8793. "LFE Playback Volume",
  8794. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8795. HDA_OUTPUT));
  8796. if (err < 0)
  8797. return err;
  8798. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8799. "Center Playback Switch",
  8800. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  8801. HDA_INPUT));
  8802. if (err < 0)
  8803. return err;
  8804. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8805. "LFE Playback Switch",
  8806. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  8807. HDA_INPUT));
  8808. if (err < 0)
  8809. return err;
  8810. } else {
  8811. sprintf(name, "%s Playback Volume", chname[i]);
  8812. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8813. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8814. HDA_OUTPUT));
  8815. if (err < 0)
  8816. return err;
  8817. sprintf(name, "%s Playback Switch", chname[i]);
  8818. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8819. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  8820. HDA_INPUT));
  8821. if (err < 0)
  8822. return err;
  8823. }
  8824. }
  8825. return 0;
  8826. }
  8827. /* add playback controls for speaker and HP outputs */
  8828. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  8829. const char *pfx)
  8830. {
  8831. hda_nid_t nid;
  8832. int err;
  8833. char name[32];
  8834. if (!pin)
  8835. return 0;
  8836. if (alc880_is_fixed_pin(pin)) {
  8837. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8838. /* printk("DAC nid=%x\n",nid); */
  8839. /* specify the DAC as the extra output */
  8840. if (!spec->multiout.hp_nid)
  8841. spec->multiout.hp_nid = nid;
  8842. else
  8843. spec->multiout.extra_out_nid[0] = nid;
  8844. /* control HP volume/switch on the output mixer amp */
  8845. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8846. sprintf(name, "%s Playback Volume", pfx);
  8847. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8848. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8849. if (err < 0)
  8850. return err;
  8851. sprintf(name, "%s Playback Switch", pfx);
  8852. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8853. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  8854. if (err < 0)
  8855. return err;
  8856. } else if (alc880_is_multi_pin(pin)) {
  8857. /* set manual connection */
  8858. /* we have only a switch on HP-out PIN */
  8859. sprintf(name, "%s Playback Switch", pfx);
  8860. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8861. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8862. if (err < 0)
  8863. return err;
  8864. }
  8865. return 0;
  8866. }
  8867. /* create playback/capture controls for input pins */
  8868. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  8869. const struct auto_pin_cfg *cfg)
  8870. {
  8871. struct hda_input_mux *imux = &spec->private_imux;
  8872. int i, err, idx;
  8873. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8874. if (alc880_is_input_pin(cfg->input_pins[i])) {
  8875. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  8876. err = new_analog_input(spec, cfg->input_pins[i],
  8877. auto_pin_cfg_labels[i],
  8878. idx, 0x0b);
  8879. if (err < 0)
  8880. return err;
  8881. imux->items[imux->num_items].label =
  8882. auto_pin_cfg_labels[i];
  8883. imux->items[imux->num_items].index =
  8884. alc880_input_pin_idx(cfg->input_pins[i]);
  8885. imux->num_items++;
  8886. }
  8887. }
  8888. return 0;
  8889. }
  8890. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  8891. hda_nid_t nid, int pin_type,
  8892. int dac_idx)
  8893. {
  8894. /* set as output */
  8895. snd_hda_codec_write(codec, nid, 0,
  8896. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8897. snd_hda_codec_write(codec, nid, 0,
  8898. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8899. /* need the manual connection? */
  8900. if (alc880_is_multi_pin(nid)) {
  8901. struct alc_spec *spec = codec->spec;
  8902. int idx = alc880_multi_pin_idx(nid);
  8903. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  8904. AC_VERB_SET_CONNECT_SEL,
  8905. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  8906. }
  8907. }
  8908. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  8909. {
  8910. struct alc_spec *spec = codec->spec;
  8911. int i;
  8912. for (i = 0; i <= HDA_SIDE; i++) {
  8913. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8914. if (nid)
  8915. alc662_auto_set_output_and_unmute(codec, nid, PIN_OUT,
  8916. i);
  8917. }
  8918. }
  8919. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  8920. {
  8921. struct alc_spec *spec = codec->spec;
  8922. hda_nid_t pin;
  8923. pin = spec->autocfg.hp_pins[0];
  8924. if (pin) /* connect to front */
  8925. /* use dac 0 */
  8926. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8927. }
  8928. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  8929. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  8930. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  8931. {
  8932. struct alc_spec *spec = codec->spec;
  8933. int i;
  8934. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8935. hda_nid_t nid = spec->autocfg.input_pins[i];
  8936. if (alc662_is_input_pin(nid)) {
  8937. snd_hda_codec_write(codec, nid, 0,
  8938. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8939. (i <= AUTO_PIN_FRONT_MIC ?
  8940. PIN_VREF80 : PIN_IN));
  8941. if (nid != ALC662_PIN_CD_NID)
  8942. snd_hda_codec_write(codec, nid, 0,
  8943. AC_VERB_SET_AMP_GAIN_MUTE,
  8944. AMP_OUT_MUTE);
  8945. }
  8946. }
  8947. }
  8948. static int alc662_parse_auto_config(struct hda_codec *codec)
  8949. {
  8950. struct alc_spec *spec = codec->spec;
  8951. int err;
  8952. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  8953. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8954. alc662_ignore);
  8955. if (err < 0)
  8956. return err;
  8957. if (!spec->autocfg.line_outs)
  8958. return 0; /* can't find valid BIOS pin config */
  8959. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8960. if (err < 0)
  8961. return err;
  8962. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8963. if (err < 0)
  8964. return err;
  8965. err = alc662_auto_create_extra_out(spec,
  8966. spec->autocfg.speaker_pins[0],
  8967. "Speaker");
  8968. if (err < 0)
  8969. return err;
  8970. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  8971. "Headphone");
  8972. if (err < 0)
  8973. return err;
  8974. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8975. if (err < 0)
  8976. return err;
  8977. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8978. if (spec->autocfg.dig_out_pin)
  8979. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  8980. if (spec->kctl_alloc)
  8981. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8982. spec->num_mux_defs = 1;
  8983. spec->input_mux = &spec->private_imux;
  8984. if (err < 0)
  8985. return err;
  8986. else if (err > 0)
  8987. /* hack - override the init verbs */
  8988. spec->init_verbs[0] = alc662_auto_init_verbs;
  8989. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  8990. spec->num_mixers++;
  8991. return err;
  8992. }
  8993. /* additional initialization for auto-configuration model */
  8994. static void alc662_auto_init(struct hda_codec *codec)
  8995. {
  8996. alc662_auto_init_multi_out(codec);
  8997. alc662_auto_init_hp_out(codec);
  8998. alc662_auto_init_analog_input(codec);
  8999. }
  9000. static int patch_alc662(struct hda_codec *codec)
  9001. {
  9002. struct alc_spec *spec;
  9003. int err, board_config;
  9004. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9005. if (!spec)
  9006. return -ENOMEM;
  9007. codec->spec = spec;
  9008. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  9009. alc662_models,
  9010. alc662_cfg_tbl);
  9011. if (board_config < 0) {
  9012. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  9013. "trying auto-probe from BIOS...\n");
  9014. board_config = ALC662_AUTO;
  9015. }
  9016. if (board_config == ALC662_AUTO) {
  9017. /* automatic parse from the BIOS config */
  9018. err = alc662_parse_auto_config(codec);
  9019. if (err < 0) {
  9020. alc_free(codec);
  9021. return err;
  9022. } else if (err) {
  9023. printk(KERN_INFO
  9024. "hda_codec: Cannot set up configuration "
  9025. "from BIOS. Using base mode...\n");
  9026. board_config = ALC662_3ST_2ch_DIG;
  9027. }
  9028. }
  9029. if (board_config != ALC662_AUTO)
  9030. setup_preset(spec, &alc662_presets[board_config]);
  9031. spec->stream_name_analog = "ALC662 Analog";
  9032. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  9033. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  9034. spec->stream_name_digital = "ALC662 Digital";
  9035. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  9036. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  9037. if (!spec->adc_nids && spec->input_mux) {
  9038. spec->adc_nids = alc662_adc_nids;
  9039. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  9040. }
  9041. codec->patch_ops = alc_patch_ops;
  9042. if (board_config == ALC662_AUTO)
  9043. spec->init_hook = alc662_auto_init;
  9044. return 0;
  9045. }
  9046. /*
  9047. * patch entries
  9048. */
  9049. struct hda_codec_preset snd_hda_preset_realtek[] = {
  9050. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  9051. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  9052. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  9053. .patch = patch_alc861 },
  9054. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  9055. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  9056. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  9057. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  9058. .patch = patch_alc883 },
  9059. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  9060. .patch = patch_alc662 },
  9061. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  9062. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  9063. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  9064. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  9065. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  9066. {} /* terminator */
  9067. };