patch_realtek.c 385 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC885_IMAC24,
  147. ALC882_AUTO,
  148. ALC882_MODEL_LAST,
  149. };
  150. /* ALC883 models */
  151. enum {
  152. ALC883_3ST_2ch_DIG,
  153. ALC883_3ST_6ch_DIG,
  154. ALC883_3ST_6ch,
  155. ALC883_6ST_DIG,
  156. ALC883_TARGA_DIG,
  157. ALC883_TARGA_2ch_DIG,
  158. ALC883_ACER,
  159. ALC883_MEDION,
  160. ALC883_MEDION_MD2,
  161. ALC883_LAPTOP_EAPD,
  162. ALC883_LENOVO_101E_2ch,
  163. ALC883_LENOVO_NB0763,
  164. ALC888_LENOVO_MS7195_DIG,
  165. ALC888_6ST_HP,
  166. ALC888_3ST_HP,
  167. ALC883_AUTO,
  168. ALC883_MODEL_LAST,
  169. };
  170. /* for GPIO Poll */
  171. #define GPIO_MASK 0x03
  172. struct alc_spec {
  173. /* codec parameterization */
  174. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  175. unsigned int num_mixers;
  176. const struct hda_verb *init_verbs[5]; /* initialization verbs
  177. * don't forget NULL
  178. * termination!
  179. */
  180. unsigned int num_init_verbs;
  181. char *stream_name_analog; /* analog PCM stream */
  182. struct hda_pcm_stream *stream_analog_playback;
  183. struct hda_pcm_stream *stream_analog_capture;
  184. char *stream_name_digital; /* digital PCM stream */
  185. struct hda_pcm_stream *stream_digital_playback;
  186. struct hda_pcm_stream *stream_digital_capture;
  187. /* playback */
  188. struct hda_multi_out multiout; /* playback set-up
  189. * max_channels, dacs must be set
  190. * dig_out_nid and hp_nid are optional
  191. */
  192. /* capture */
  193. unsigned int num_adc_nids;
  194. hda_nid_t *adc_nids;
  195. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  196. /* capture source */
  197. unsigned int num_mux_defs;
  198. const struct hda_input_mux *input_mux;
  199. unsigned int cur_mux[3];
  200. /* channel model */
  201. const struct hda_channel_mode *channel_mode;
  202. int num_channel_mode;
  203. int need_dac_fix;
  204. /* PCM information */
  205. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  206. /* dynamic controls, init_verbs and input_mux */
  207. struct auto_pin_cfg autocfg;
  208. unsigned int num_kctl_alloc, num_kctl_used;
  209. struct snd_kcontrol_new *kctl_alloc;
  210. struct hda_input_mux private_imux;
  211. hda_nid_t private_dac_nids[5];
  212. /* hooks */
  213. void (*init_hook)(struct hda_codec *codec);
  214. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  215. /* for pin sensing */
  216. unsigned int sense_updated: 1;
  217. unsigned int jack_present: 1;
  218. };
  219. /*
  220. * configuration template - to be copied to the spec instance
  221. */
  222. struct alc_config_preset {
  223. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  224. * with spec
  225. */
  226. const struct hda_verb *init_verbs[5];
  227. unsigned int num_dacs;
  228. hda_nid_t *dac_nids;
  229. hda_nid_t dig_out_nid; /* optional */
  230. hda_nid_t hp_nid; /* optional */
  231. unsigned int num_adc_nids;
  232. hda_nid_t *adc_nids;
  233. hda_nid_t dig_in_nid;
  234. unsigned int num_channel_mode;
  235. const struct hda_channel_mode *channel_mode;
  236. int need_dac_fix;
  237. unsigned int num_mux_defs;
  238. const struct hda_input_mux *input_mux;
  239. void (*unsol_event)(struct hda_codec *, unsigned int);
  240. void (*init_hook)(struct hda_codec *);
  241. };
  242. /*
  243. * input MUX handling
  244. */
  245. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  246. struct snd_ctl_elem_info *uinfo)
  247. {
  248. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  249. struct alc_spec *spec = codec->spec;
  250. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  251. if (mux_idx >= spec->num_mux_defs)
  252. mux_idx = 0;
  253. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  254. }
  255. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  256. struct snd_ctl_elem_value *ucontrol)
  257. {
  258. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  259. struct alc_spec *spec = codec->spec;
  260. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  261. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  262. return 0;
  263. }
  264. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  265. struct snd_ctl_elem_value *ucontrol)
  266. {
  267. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  268. struct alc_spec *spec = codec->spec;
  269. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  270. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  271. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  272. spec->adc_nids[adc_idx],
  273. &spec->cur_mux[adc_idx]);
  274. }
  275. /*
  276. * channel mode setting
  277. */
  278. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_info *uinfo)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  284. spec->num_channel_mode);
  285. }
  286. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol)
  288. {
  289. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  290. struct alc_spec *spec = codec->spec;
  291. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  292. spec->num_channel_mode,
  293. spec->multiout.max_channels);
  294. }
  295. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  296. struct snd_ctl_elem_value *ucontrol)
  297. {
  298. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  299. struct alc_spec *spec = codec->spec;
  300. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  301. spec->num_channel_mode,
  302. &spec->multiout.max_channels);
  303. if (err >= 0 && spec->need_dac_fix)
  304. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  305. return err;
  306. }
  307. /*
  308. * Control the mode of pin widget settings via the mixer. "pc" is used
  309. * instead of "%" to avoid consequences of accidently treating the % as
  310. * being part of a format specifier. Maximum allowed length of a value is
  311. * 63 characters plus NULL terminator.
  312. *
  313. * Note: some retasking pin complexes seem to ignore requests for input
  314. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  315. * are requested. Therefore order this list so that this behaviour will not
  316. * cause problems when mixer clients move through the enum sequentially.
  317. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  318. * March 2006.
  319. */
  320. static char *alc_pin_mode_names[] = {
  321. "Mic 50pc bias", "Mic 80pc bias",
  322. "Line in", "Line out", "Headphone out",
  323. };
  324. static unsigned char alc_pin_mode_values[] = {
  325. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  326. };
  327. /* The control can present all 5 options, or it can limit the options based
  328. * in the pin being assumed to be exclusively an input or an output pin. In
  329. * addition, "input" pins may or may not process the mic bias option
  330. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  331. * accept requests for bias as of chip versions up to March 2006) and/or
  332. * wiring in the computer.
  333. */
  334. #define ALC_PIN_DIR_IN 0x00
  335. #define ALC_PIN_DIR_OUT 0x01
  336. #define ALC_PIN_DIR_INOUT 0x02
  337. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  338. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  339. /* Info about the pin modes supported by the different pin direction modes.
  340. * For each direction the minimum and maximum values are given.
  341. */
  342. static signed char alc_pin_mode_dir_info[5][2] = {
  343. { 0, 2 }, /* ALC_PIN_DIR_IN */
  344. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  345. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  346. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  347. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  348. };
  349. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  350. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  351. #define alc_pin_mode_n_items(_dir) \
  352. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  353. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  354. struct snd_ctl_elem_info *uinfo)
  355. {
  356. unsigned int item_num = uinfo->value.enumerated.item;
  357. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  358. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  359. uinfo->count = 1;
  360. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  361. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  362. item_num = alc_pin_mode_min(dir);
  363. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  364. return 0;
  365. }
  366. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  367. struct snd_ctl_elem_value *ucontrol)
  368. {
  369. unsigned int i;
  370. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  371. hda_nid_t nid = kcontrol->private_value & 0xffff;
  372. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  373. long *valp = ucontrol->value.integer.value;
  374. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  375. AC_VERB_GET_PIN_WIDGET_CONTROL,
  376. 0x00);
  377. /* Find enumerated value for current pinctl setting */
  378. i = alc_pin_mode_min(dir);
  379. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  380. i++;
  381. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  382. return 0;
  383. }
  384. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  385. struct snd_ctl_elem_value *ucontrol)
  386. {
  387. signed int change;
  388. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  389. hda_nid_t nid = kcontrol->private_value & 0xffff;
  390. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  391. long val = *ucontrol->value.integer.value;
  392. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  393. AC_VERB_GET_PIN_WIDGET_CONTROL,
  394. 0x00);
  395. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  396. val = alc_pin_mode_min(dir);
  397. change = pinctl != alc_pin_mode_values[val];
  398. if (change) {
  399. /* Set pin mode to that requested */
  400. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  401. alc_pin_mode_values[val]);
  402. /* Also enable the retasking pin's input/output as required
  403. * for the requested pin mode. Enum values of 2 or less are
  404. * input modes.
  405. *
  406. * Dynamically switching the input/output buffers probably
  407. * reduces noise slightly (particularly on input) so we'll
  408. * do it. However, having both input and output buffers
  409. * enabled simultaneously doesn't seem to be problematic if
  410. * this turns out to be necessary in the future.
  411. */
  412. if (val <= 2) {
  413. snd_hda_codec_write(codec, nid, 0,
  414. AC_VERB_SET_AMP_GAIN_MUTE,
  415. AMP_OUT_MUTE);
  416. snd_hda_codec_write(codec, nid, 0,
  417. AC_VERB_SET_AMP_GAIN_MUTE,
  418. AMP_IN_UNMUTE(0));
  419. } else {
  420. snd_hda_codec_write(codec, nid, 0,
  421. AC_VERB_SET_AMP_GAIN_MUTE,
  422. AMP_IN_MUTE(0));
  423. snd_hda_codec_write(codec, nid, 0,
  424. AC_VERB_SET_AMP_GAIN_MUTE,
  425. AMP_OUT_UNMUTE);
  426. }
  427. }
  428. return change;
  429. }
  430. #define ALC_PIN_MODE(xname, nid, dir) \
  431. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  432. .info = alc_pin_mode_info, \
  433. .get = alc_pin_mode_get, \
  434. .put = alc_pin_mode_put, \
  435. .private_value = nid | (dir<<16) }
  436. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  437. * together using a mask with more than one bit set. This control is
  438. * currently used only by the ALC260 test model. At this stage they are not
  439. * needed for any "production" models.
  440. */
  441. #ifdef CONFIG_SND_DEBUG
  442. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  443. struct snd_ctl_elem_info *uinfo)
  444. {
  445. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  446. uinfo->count = 1;
  447. uinfo->value.integer.min = 0;
  448. uinfo->value.integer.max = 1;
  449. return 0;
  450. }
  451. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  452. struct snd_ctl_elem_value *ucontrol)
  453. {
  454. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  455. hda_nid_t nid = kcontrol->private_value & 0xffff;
  456. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  457. long *valp = ucontrol->value.integer.value;
  458. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  459. AC_VERB_GET_GPIO_DATA, 0x00);
  460. *valp = (val & mask) != 0;
  461. return 0;
  462. }
  463. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  464. struct snd_ctl_elem_value *ucontrol)
  465. {
  466. signed int change;
  467. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  468. hda_nid_t nid = kcontrol->private_value & 0xffff;
  469. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  470. long val = *ucontrol->value.integer.value;
  471. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  472. AC_VERB_GET_GPIO_DATA,
  473. 0x00);
  474. /* Set/unset the masked GPIO bit(s) as needed */
  475. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  476. if (val == 0)
  477. gpio_data &= ~mask;
  478. else
  479. gpio_data |= mask;
  480. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  481. return change;
  482. }
  483. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  484. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  485. .info = alc_gpio_data_info, \
  486. .get = alc_gpio_data_get, \
  487. .put = alc_gpio_data_put, \
  488. .private_value = nid | (mask<<16) }
  489. #endif /* CONFIG_SND_DEBUG */
  490. /* A switch control to allow the enabling of the digital IO pins on the
  491. * ALC260. This is incredibly simplistic; the intention of this control is
  492. * to provide something in the test model allowing digital outputs to be
  493. * identified if present. If models are found which can utilise these
  494. * outputs a more complete mixer control can be devised for those models if
  495. * necessary.
  496. */
  497. #ifdef CONFIG_SND_DEBUG
  498. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  499. struct snd_ctl_elem_info *uinfo)
  500. {
  501. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  502. uinfo->count = 1;
  503. uinfo->value.integer.min = 0;
  504. uinfo->value.integer.max = 1;
  505. return 0;
  506. }
  507. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  508. struct snd_ctl_elem_value *ucontrol)
  509. {
  510. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  511. hda_nid_t nid = kcontrol->private_value & 0xffff;
  512. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  513. long *valp = ucontrol->value.integer.value;
  514. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  515. AC_VERB_GET_DIGI_CONVERT, 0x00);
  516. *valp = (val & mask) != 0;
  517. return 0;
  518. }
  519. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  520. struct snd_ctl_elem_value *ucontrol)
  521. {
  522. signed int change;
  523. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  524. hda_nid_t nid = kcontrol->private_value & 0xffff;
  525. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  526. long val = *ucontrol->value.integer.value;
  527. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  528. AC_VERB_GET_DIGI_CONVERT,
  529. 0x00);
  530. /* Set/unset the masked control bit(s) as needed */
  531. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  532. if (val==0)
  533. ctrl_data &= ~mask;
  534. else
  535. ctrl_data |= mask;
  536. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  537. ctrl_data);
  538. return change;
  539. }
  540. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  541. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  542. .info = alc_spdif_ctrl_info, \
  543. .get = alc_spdif_ctrl_get, \
  544. .put = alc_spdif_ctrl_put, \
  545. .private_value = nid | (mask<<16) }
  546. #endif /* CONFIG_SND_DEBUG */
  547. /*
  548. * set up from the preset table
  549. */
  550. static void setup_preset(struct alc_spec *spec,
  551. const struct alc_config_preset *preset)
  552. {
  553. int i;
  554. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  555. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  556. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  557. i++)
  558. spec->init_verbs[spec->num_init_verbs++] =
  559. preset->init_verbs[i];
  560. spec->channel_mode = preset->channel_mode;
  561. spec->num_channel_mode = preset->num_channel_mode;
  562. spec->need_dac_fix = preset->need_dac_fix;
  563. spec->multiout.max_channels = spec->channel_mode[0].channels;
  564. spec->multiout.num_dacs = preset->num_dacs;
  565. spec->multiout.dac_nids = preset->dac_nids;
  566. spec->multiout.dig_out_nid = preset->dig_out_nid;
  567. spec->multiout.hp_nid = preset->hp_nid;
  568. spec->num_mux_defs = preset->num_mux_defs;
  569. if (!spec->num_mux_defs)
  570. spec->num_mux_defs = 1;
  571. spec->input_mux = preset->input_mux;
  572. spec->num_adc_nids = preset->num_adc_nids;
  573. spec->adc_nids = preset->adc_nids;
  574. spec->dig_in_nid = preset->dig_in_nid;
  575. spec->unsol_event = preset->unsol_event;
  576. spec->init_hook = preset->init_hook;
  577. }
  578. /* Enable GPIO mask and set output */
  579. static struct hda_verb alc_gpio1_init_verbs[] = {
  580. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  582. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  583. { }
  584. };
  585. static struct hda_verb alc_gpio2_init_verbs[] = {
  586. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  588. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  589. { }
  590. };
  591. static struct hda_verb alc_gpio3_init_verbs[] = {
  592. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  594. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  595. { }
  596. };
  597. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  598. * 31 ~ 16 : Manufacture ID
  599. * 15 ~ 8 : SKU ID
  600. * 7 ~ 0 : Assembly ID
  601. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  602. */
  603. static void alc_subsystem_id(struct hda_codec *codec,
  604. unsigned int porta, unsigned int porte,
  605. unsigned int portd)
  606. {
  607. unsigned int ass, tmp;
  608. ass = codec->subsystem_id;
  609. if (!(ass & 1))
  610. return;
  611. /* Override */
  612. tmp = (ass & 0x38) >> 3; /* external Amp control */
  613. switch (tmp) {
  614. case 1:
  615. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  616. break;
  617. case 3:
  618. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  619. break;
  620. case 7:
  621. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  622. break;
  623. case 5:
  624. switch (codec->vendor_id) {
  625. case 0x10ec0862:
  626. case 0x10ec0660:
  627. case 0x10ec0662:
  628. case 0x10ec0267:
  629. case 0x10ec0268:
  630. snd_hda_codec_write(codec, 0x14, 0,
  631. AC_VERB_SET_EAPD_BTLENABLE, 2);
  632. snd_hda_codec_write(codec, 0x15, 0,
  633. AC_VERB_SET_EAPD_BTLENABLE, 2);
  634. return;
  635. }
  636. case 6:
  637. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  638. hda_nid_t port = 0;
  639. tmp = (ass & 0x1800) >> 11;
  640. switch (tmp) {
  641. case 0: port = porta; break;
  642. case 1: port = porte; break;
  643. case 2: port = portd; break;
  644. }
  645. if (port)
  646. snd_hda_codec_write(codec, port, 0,
  647. AC_VERB_SET_EAPD_BTLENABLE,
  648. 2);
  649. }
  650. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  651. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  652. (tmp == 5 ? 0x3040 : 0x3050));
  653. break;
  654. }
  655. }
  656. /*
  657. * Fix-up pin default configurations
  658. */
  659. struct alc_pincfg {
  660. hda_nid_t nid;
  661. u32 val;
  662. };
  663. static void alc_fix_pincfg(struct hda_codec *codec,
  664. const struct snd_pci_quirk *quirk,
  665. const struct alc_pincfg **pinfix)
  666. {
  667. const struct alc_pincfg *cfg;
  668. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  669. if (!quirk)
  670. return;
  671. cfg = pinfix[quirk->value];
  672. for (; cfg->nid; cfg++) {
  673. int i;
  674. u32 val = cfg->val;
  675. for (i = 0; i < 4; i++) {
  676. snd_hda_codec_write(codec, cfg->nid, 0,
  677. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  678. val & 0xff);
  679. val >>= 8;
  680. }
  681. }
  682. }
  683. /*
  684. * ALC880 3-stack model
  685. *
  686. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  687. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  688. * F-Mic = 0x1b, HP = 0x19
  689. */
  690. static hda_nid_t alc880_dac_nids[4] = {
  691. /* front, rear, clfe, rear_surr */
  692. 0x02, 0x05, 0x04, 0x03
  693. };
  694. static hda_nid_t alc880_adc_nids[3] = {
  695. /* ADC0-2 */
  696. 0x07, 0x08, 0x09,
  697. };
  698. /* The datasheet says the node 0x07 is connected from inputs,
  699. * but it shows zero connection in the real implementation on some devices.
  700. * Note: this is a 915GAV bug, fixed on 915GLV
  701. */
  702. static hda_nid_t alc880_adc_nids_alt[2] = {
  703. /* ADC1-2 */
  704. 0x08, 0x09,
  705. };
  706. #define ALC880_DIGOUT_NID 0x06
  707. #define ALC880_DIGIN_NID 0x0a
  708. static struct hda_input_mux alc880_capture_source = {
  709. .num_items = 4,
  710. .items = {
  711. { "Mic", 0x0 },
  712. { "Front Mic", 0x3 },
  713. { "Line", 0x2 },
  714. { "CD", 0x4 },
  715. },
  716. };
  717. /* channel source setting (2/6 channel selection for 3-stack) */
  718. /* 2ch mode */
  719. static struct hda_verb alc880_threestack_ch2_init[] = {
  720. /* set line-in to input, mute it */
  721. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  722. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  723. /* set mic-in to input vref 80%, mute it */
  724. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  725. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  726. { } /* end */
  727. };
  728. /* 6ch mode */
  729. static struct hda_verb alc880_threestack_ch6_init[] = {
  730. /* set line-in to output, unmute it */
  731. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  732. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  733. /* set mic-in to output, unmute it */
  734. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  735. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  736. { } /* end */
  737. };
  738. static struct hda_channel_mode alc880_threestack_modes[2] = {
  739. { 2, alc880_threestack_ch2_init },
  740. { 6, alc880_threestack_ch6_init },
  741. };
  742. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  743. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  744. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  745. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  747. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  748. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  749. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  750. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  751. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  752. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  754. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  755. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  756. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  757. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  758. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  759. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  760. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  761. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  762. {
  763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  764. .name = "Channel Mode",
  765. .info = alc_ch_mode_info,
  766. .get = alc_ch_mode_get,
  767. .put = alc_ch_mode_put,
  768. },
  769. { } /* end */
  770. };
  771. /* capture mixer elements */
  772. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  773. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  774. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  775. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  776. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  777. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  778. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  779. {
  780. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  781. /* The multiple "Capture Source" controls confuse alsamixer
  782. * So call somewhat different..
  783. * FIXME: the controls appear in the "playback" view!
  784. */
  785. /* .name = "Capture Source", */
  786. .name = "Input Source",
  787. .count = 3,
  788. .info = alc_mux_enum_info,
  789. .get = alc_mux_enum_get,
  790. .put = alc_mux_enum_put,
  791. },
  792. { } /* end */
  793. };
  794. /* capture mixer elements (in case NID 0x07 not available) */
  795. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  796. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  797. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  798. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  799. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  800. {
  801. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  802. /* The multiple "Capture Source" controls confuse alsamixer
  803. * So call somewhat different..
  804. * FIXME: the controls appear in the "playback" view!
  805. */
  806. /* .name = "Capture Source", */
  807. .name = "Input Source",
  808. .count = 2,
  809. .info = alc_mux_enum_info,
  810. .get = alc_mux_enum_get,
  811. .put = alc_mux_enum_put,
  812. },
  813. { } /* end */
  814. };
  815. /*
  816. * ALC880 5-stack model
  817. *
  818. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  819. * Side = 0x02 (0xd)
  820. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  821. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  822. */
  823. /* additional mixers to alc880_three_stack_mixer */
  824. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  825. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  826. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  827. { } /* end */
  828. };
  829. /* channel source setting (6/8 channel selection for 5-stack) */
  830. /* 6ch mode */
  831. static struct hda_verb alc880_fivestack_ch6_init[] = {
  832. /* set line-in to input, mute it */
  833. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  834. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  835. { } /* end */
  836. };
  837. /* 8ch mode */
  838. static struct hda_verb alc880_fivestack_ch8_init[] = {
  839. /* set line-in to output, unmute it */
  840. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  841. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  842. { } /* end */
  843. };
  844. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  845. { 6, alc880_fivestack_ch6_init },
  846. { 8, alc880_fivestack_ch8_init },
  847. };
  848. /*
  849. * ALC880 6-stack model
  850. *
  851. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  852. * Side = 0x05 (0x0f)
  853. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  854. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  855. */
  856. static hda_nid_t alc880_6st_dac_nids[4] = {
  857. /* front, rear, clfe, rear_surr */
  858. 0x02, 0x03, 0x04, 0x05
  859. };
  860. static struct hda_input_mux alc880_6stack_capture_source = {
  861. .num_items = 4,
  862. .items = {
  863. { "Mic", 0x0 },
  864. { "Front Mic", 0x1 },
  865. { "Line", 0x2 },
  866. { "CD", 0x4 },
  867. },
  868. };
  869. /* fixed 8-channels */
  870. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  871. { 8, NULL },
  872. };
  873. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  874. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  875. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  876. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  877. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  878. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  879. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  881. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  882. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  883. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  884. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  885. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  886. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  887. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  888. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  889. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  890. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  891. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  892. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  893. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  894. {
  895. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  896. .name = "Channel Mode",
  897. .info = alc_ch_mode_info,
  898. .get = alc_ch_mode_get,
  899. .put = alc_ch_mode_put,
  900. },
  901. { } /* end */
  902. };
  903. /*
  904. * ALC880 W810 model
  905. *
  906. * W810 has rear IO for:
  907. * Front (DAC 02)
  908. * Surround (DAC 03)
  909. * Center/LFE (DAC 04)
  910. * Digital out (06)
  911. *
  912. * The system also has a pair of internal speakers, and a headphone jack.
  913. * These are both connected to Line2 on the codec, hence to DAC 02.
  914. *
  915. * There is a variable resistor to control the speaker or headphone
  916. * volume. This is a hardware-only device without a software API.
  917. *
  918. * Plugging headphones in will disable the internal speakers. This is
  919. * implemented in hardware, not via the driver using jack sense. In
  920. * a similar fashion, plugging into the rear socket marked "front" will
  921. * disable both the speakers and headphones.
  922. *
  923. * For input, there's a microphone jack, and an "audio in" jack.
  924. * These may not do anything useful with this driver yet, because I
  925. * haven't setup any initialization verbs for these yet...
  926. */
  927. static hda_nid_t alc880_w810_dac_nids[3] = {
  928. /* front, rear/surround, clfe */
  929. 0x02, 0x03, 0x04
  930. };
  931. /* fixed 6 channels */
  932. static struct hda_channel_mode alc880_w810_modes[1] = {
  933. { 6, NULL }
  934. };
  935. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  936. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  937. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  938. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  940. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  941. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  942. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  943. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  944. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  945. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  946. { } /* end */
  947. };
  948. /*
  949. * Z710V model
  950. *
  951. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  952. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  953. * Line = 0x1a
  954. */
  955. static hda_nid_t alc880_z71v_dac_nids[1] = {
  956. 0x02
  957. };
  958. #define ALC880_Z71V_HP_DAC 0x03
  959. /* fixed 2 channels */
  960. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  961. { 2, NULL }
  962. };
  963. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  964. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  965. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  966. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  967. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  968. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  969. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  970. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  971. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  972. { } /* end */
  973. };
  974. /* FIXME! */
  975. /*
  976. * ALC880 F1734 model
  977. *
  978. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  979. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  980. */
  981. static hda_nid_t alc880_f1734_dac_nids[1] = {
  982. 0x03
  983. };
  984. #define ALC880_F1734_HP_DAC 0x02
  985. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  986. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  987. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  988. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  989. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  990. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  991. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  992. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  993. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  994. { } /* end */
  995. };
  996. /* FIXME! */
  997. /*
  998. * ALC880 ASUS model
  999. *
  1000. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1001. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1002. * Mic = 0x18, Line = 0x1a
  1003. */
  1004. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1005. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1006. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1007. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1008. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1009. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1010. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1011. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1012. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1013. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1014. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1015. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1016. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1017. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1018. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1020. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1021. {
  1022. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1023. .name = "Channel Mode",
  1024. .info = alc_ch_mode_info,
  1025. .get = alc_ch_mode_get,
  1026. .put = alc_ch_mode_put,
  1027. },
  1028. { } /* end */
  1029. };
  1030. /* FIXME! */
  1031. /*
  1032. * ALC880 ASUS W1V model
  1033. *
  1034. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1035. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1036. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1037. */
  1038. /* additional mixers to alc880_asus_mixer */
  1039. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1040. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1041. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1042. { } /* end */
  1043. };
  1044. /* additional mixers to alc880_asus_mixer */
  1045. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1046. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1047. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1048. { } /* end */
  1049. };
  1050. /* TCL S700 */
  1051. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1052. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1054. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1055. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1056. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1059. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1060. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1061. {
  1062. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1063. /* The multiple "Capture Source" controls confuse alsamixer
  1064. * So call somewhat different..
  1065. * FIXME: the controls appear in the "playback" view!
  1066. */
  1067. /* .name = "Capture Source", */
  1068. .name = "Input Source",
  1069. .count = 1,
  1070. .info = alc_mux_enum_info,
  1071. .get = alc_mux_enum_get,
  1072. .put = alc_mux_enum_put,
  1073. },
  1074. { } /* end */
  1075. };
  1076. /* Uniwill */
  1077. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1078. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1080. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1081. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1082. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1083. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1084. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1085. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1087. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1088. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1089. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1091. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1093. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1094. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1095. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1096. {
  1097. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1098. .name = "Channel Mode",
  1099. .info = alc_ch_mode_info,
  1100. .get = alc_ch_mode_get,
  1101. .put = alc_ch_mode_put,
  1102. },
  1103. { } /* end */
  1104. };
  1105. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1106. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1107. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1109. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1110. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1111. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1112. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1113. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1114. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1115. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1116. { } /* end */
  1117. };
  1118. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1119. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1120. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1121. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1122. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1123. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1124. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1125. { } /* end */
  1126. };
  1127. /*
  1128. * build control elements
  1129. */
  1130. static int alc_build_controls(struct hda_codec *codec)
  1131. {
  1132. struct alc_spec *spec = codec->spec;
  1133. int err;
  1134. int i;
  1135. for (i = 0; i < spec->num_mixers; i++) {
  1136. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1137. if (err < 0)
  1138. return err;
  1139. }
  1140. if (spec->multiout.dig_out_nid) {
  1141. err = snd_hda_create_spdif_out_ctls(codec,
  1142. spec->multiout.dig_out_nid);
  1143. if (err < 0)
  1144. return err;
  1145. }
  1146. if (spec->dig_in_nid) {
  1147. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1148. if (err < 0)
  1149. return err;
  1150. }
  1151. return 0;
  1152. }
  1153. /*
  1154. * initialize the codec volumes, etc
  1155. */
  1156. /*
  1157. * generic initialization of ADC, input mixers and output mixers
  1158. */
  1159. static struct hda_verb alc880_volume_init_verbs[] = {
  1160. /*
  1161. * Unmute ADC0-2 and set the default input to mic-in
  1162. */
  1163. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1164. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1165. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1166. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1167. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1168. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1169. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1170. * mixer widget
  1171. * Note: PASD motherboards uses the Line In 2 as the input for front
  1172. * panel mic (mic 2)
  1173. */
  1174. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1180. /*
  1181. * Set up output mixers (0x0c - 0x0f)
  1182. */
  1183. /* set vol=0 to output mixers */
  1184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1188. /* set up input amps for analog loopback */
  1189. /* Amp Indices: DAC = 0, mixer = 1 */
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1198. { }
  1199. };
  1200. /*
  1201. * 3-stack pin configuration:
  1202. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1203. */
  1204. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1205. /*
  1206. * preset connection lists of input pins
  1207. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1208. */
  1209. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1210. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1211. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1212. /*
  1213. * Set pin mode and muting
  1214. */
  1215. /* set front pin widgets 0x14 for output */
  1216. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1219. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. /* Mic2 (as headphone out) for HP output */
  1222. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1223. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1224. /* Line In pin widget for input */
  1225. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1228. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1229. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* CD pin widget for input */
  1231. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1232. { }
  1233. };
  1234. /*
  1235. * 5-stack pin configuration:
  1236. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1237. * line-in/side = 0x1a, f-mic = 0x1b
  1238. */
  1239. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1240. /*
  1241. * preset connection lists of input pins
  1242. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1243. */
  1244. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1245. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1246. /*
  1247. * Set pin mode and muting
  1248. */
  1249. /* set pin widgets 0x14-0x17 for output */
  1250. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. /* unmute pins for output (no gain on this amp) */
  1255. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1259. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1260. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1261. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1262. /* Mic2 (as headphone out) for HP output */
  1263. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1264. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1265. /* Line In pin widget for input */
  1266. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1268. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1269. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1270. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1271. /* CD pin widget for input */
  1272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1273. { }
  1274. };
  1275. /*
  1276. * W810 pin configuration:
  1277. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1278. */
  1279. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1280. /* hphone/speaker input selector: front DAC */
  1281. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1282. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1287. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1288. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1289. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1290. { }
  1291. };
  1292. /*
  1293. * Z71V pin configuration:
  1294. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1295. */
  1296. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1297. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1298. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1300. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1301. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1302. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1303. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1304. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1305. { }
  1306. };
  1307. /*
  1308. * 6-stack pin configuration:
  1309. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1310. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1311. */
  1312. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1313. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1314. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1319. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1321. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1322. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1326. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1327. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1328. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1329. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1330. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1331. { }
  1332. };
  1333. /*
  1334. * Uniwill pin configuration:
  1335. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1336. * line = 0x1a
  1337. */
  1338. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1339. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1342. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1361. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1362. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1363. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1364. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1365. { }
  1366. };
  1367. /*
  1368. * Uniwill P53
  1369. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1370. */
  1371. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1372. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1385. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1386. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1387. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1388. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1389. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1390. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1391. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1392. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1393. { }
  1394. };
  1395. static struct hda_verb alc880_beep_init_verbs[] = {
  1396. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1397. { }
  1398. };
  1399. /* toggle speaker-output according to the hp-jack state */
  1400. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1401. {
  1402. unsigned int present;
  1403. unsigned char bits;
  1404. present = snd_hda_codec_read(codec, 0x14, 0,
  1405. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1406. bits = present ? 0x80 : 0;
  1407. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1408. 0x80, bits);
  1409. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1410. 0x80, bits);
  1411. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1412. 0x80, bits);
  1413. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1414. 0x80, bits);
  1415. }
  1416. /* auto-toggle front mic */
  1417. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1418. {
  1419. unsigned int present;
  1420. unsigned char bits;
  1421. present = snd_hda_codec_read(codec, 0x18, 0,
  1422. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1423. bits = present ? 0x80 : 0;
  1424. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1425. 0x80, bits);
  1426. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1427. 0x80, bits);
  1428. }
  1429. static void alc880_uniwill_automute(struct hda_codec *codec)
  1430. {
  1431. alc880_uniwill_hp_automute(codec);
  1432. alc880_uniwill_mic_automute(codec);
  1433. }
  1434. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1435. unsigned int res)
  1436. {
  1437. /* Looks like the unsol event is incompatible with the standard
  1438. * definition. 4bit tag is placed at 28 bit!
  1439. */
  1440. switch (res >> 28) {
  1441. case ALC880_HP_EVENT:
  1442. alc880_uniwill_hp_automute(codec);
  1443. break;
  1444. case ALC880_MIC_EVENT:
  1445. alc880_uniwill_mic_automute(codec);
  1446. break;
  1447. }
  1448. }
  1449. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1450. {
  1451. unsigned int present;
  1452. unsigned char bits;
  1453. present = snd_hda_codec_read(codec, 0x14, 0,
  1454. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1455. bits = present ? 0x80 : 0;
  1456. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1457. 0x80, bits);
  1458. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1459. 0x80, bits);
  1460. }
  1461. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1462. {
  1463. unsigned int present;
  1464. present = snd_hda_codec_read(codec, 0x21, 0,
  1465. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1466. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1467. 0x7f, present);
  1468. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1469. 0x7f, present);
  1470. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1471. 0x7f, present);
  1472. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1473. 0x7f, present);
  1474. }
  1475. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1476. unsigned int res)
  1477. {
  1478. /* Looks like the unsol event is incompatible with the standard
  1479. * definition. 4bit tag is placed at 28 bit!
  1480. */
  1481. if ((res >> 28) == ALC880_HP_EVENT)
  1482. alc880_uniwill_p53_hp_automute(codec);
  1483. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1484. alc880_uniwill_p53_dcvol_automute(codec);
  1485. }
  1486. /* FIXME! */
  1487. /*
  1488. * F1734 pin configuration:
  1489. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1490. */
  1491. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1492. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1493. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1494. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1495. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1496. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1500. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1501. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1502. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1503. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1504. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1505. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1506. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1507. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1508. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1509. { }
  1510. };
  1511. /* FIXME! */
  1512. /*
  1513. * ASUS pin configuration:
  1514. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1515. */
  1516. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1517. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1518. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1519. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1520. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1521. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1522. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1523. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1524. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1526. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1527. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1528. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1529. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1531. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1532. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1533. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1534. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1535. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1536. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1538. { }
  1539. };
  1540. /* Enable GPIO mask and set output */
  1541. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1542. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1543. /* Clevo m520g init */
  1544. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1545. /* headphone output */
  1546. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1547. /* line-out */
  1548. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1549. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1550. /* Line-in */
  1551. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1552. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1553. /* CD */
  1554. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1555. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1556. /* Mic1 (rear panel) */
  1557. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1558. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1559. /* Mic2 (front panel) */
  1560. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1561. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1562. /* headphone */
  1563. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1564. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1565. /* change to EAPD mode */
  1566. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1567. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1568. { }
  1569. };
  1570. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1571. /* change to EAPD mode */
  1572. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1573. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1574. /* Headphone output */
  1575. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1576. /* Front output*/
  1577. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1578. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1579. /* Line In pin widget for input */
  1580. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1581. /* CD pin widget for input */
  1582. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1583. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1584. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1585. /* change to EAPD mode */
  1586. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1587. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1588. { }
  1589. };
  1590. /*
  1591. * LG m1 express dual
  1592. *
  1593. * Pin assignment:
  1594. * Rear Line-In/Out (blue): 0x14
  1595. * Build-in Mic-In: 0x15
  1596. * Speaker-out: 0x17
  1597. * HP-Out (green): 0x1b
  1598. * Mic-In/Out (red): 0x19
  1599. * SPDIF-Out: 0x1e
  1600. */
  1601. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1602. static hda_nid_t alc880_lg_dac_nids[3] = {
  1603. 0x05, 0x02, 0x03
  1604. };
  1605. /* seems analog CD is not working */
  1606. static struct hda_input_mux alc880_lg_capture_source = {
  1607. .num_items = 3,
  1608. .items = {
  1609. { "Mic", 0x1 },
  1610. { "Line", 0x5 },
  1611. { "Internal Mic", 0x6 },
  1612. },
  1613. };
  1614. /* 2,4,6 channel modes */
  1615. static struct hda_verb alc880_lg_ch2_init[] = {
  1616. /* set line-in and mic-in to input */
  1617. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1618. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1619. { }
  1620. };
  1621. static struct hda_verb alc880_lg_ch4_init[] = {
  1622. /* set line-in to out and mic-in to input */
  1623. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1624. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1625. { }
  1626. };
  1627. static struct hda_verb alc880_lg_ch6_init[] = {
  1628. /* set line-in and mic-in to output */
  1629. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1630. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1631. { }
  1632. };
  1633. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1634. { 2, alc880_lg_ch2_init },
  1635. { 4, alc880_lg_ch4_init },
  1636. { 6, alc880_lg_ch6_init },
  1637. };
  1638. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1639. /* FIXME: it's not really "master" but front channels */
  1640. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1641. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1642. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1643. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1644. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1645. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1646. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1647. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1648. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1649. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1650. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1651. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1652. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1653. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1654. {
  1655. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1656. .name = "Channel Mode",
  1657. .info = alc_ch_mode_info,
  1658. .get = alc_ch_mode_get,
  1659. .put = alc_ch_mode_put,
  1660. },
  1661. { } /* end */
  1662. };
  1663. static struct hda_verb alc880_lg_init_verbs[] = {
  1664. /* set capture source to mic-in */
  1665. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1666. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1667. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1668. /* mute all amp mixer inputs */
  1669. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1670. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1671. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1672. /* line-in to input */
  1673. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1674. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1675. /* built-in mic */
  1676. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1677. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1678. /* speaker-out */
  1679. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1680. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1681. /* mic-in to input */
  1682. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1683. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1684. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1685. /* HP-out */
  1686. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1687. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1688. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1689. /* jack sense */
  1690. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1691. { }
  1692. };
  1693. /* toggle speaker-output according to the hp-jack state */
  1694. static void alc880_lg_automute(struct hda_codec *codec)
  1695. {
  1696. unsigned int present;
  1697. unsigned char bits;
  1698. present = snd_hda_codec_read(codec, 0x1b, 0,
  1699. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1700. bits = present ? 0x80 : 0;
  1701. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1702. 0x80, bits);
  1703. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1704. 0x80, bits);
  1705. }
  1706. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1707. {
  1708. /* Looks like the unsol event is incompatible with the standard
  1709. * definition. 4bit tag is placed at 28 bit!
  1710. */
  1711. if ((res >> 28) == 0x01)
  1712. alc880_lg_automute(codec);
  1713. }
  1714. /*
  1715. * LG LW20
  1716. *
  1717. * Pin assignment:
  1718. * Speaker-out: 0x14
  1719. * Mic-In: 0x18
  1720. * Built-in Mic-In: 0x19
  1721. * Line-In: 0x1b
  1722. * HP-Out: 0x1a
  1723. * SPDIF-Out: 0x1e
  1724. */
  1725. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1726. .num_items = 3,
  1727. .items = {
  1728. { "Mic", 0x0 },
  1729. { "Internal Mic", 0x1 },
  1730. { "Line In", 0x2 },
  1731. },
  1732. };
  1733. #define alc880_lg_lw_modes alc880_threestack_modes
  1734. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1735. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1736. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1737. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1738. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1739. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1740. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1741. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1742. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1743. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1744. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1745. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1746. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1747. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1748. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1749. {
  1750. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1751. .name = "Channel Mode",
  1752. .info = alc_ch_mode_info,
  1753. .get = alc_ch_mode_get,
  1754. .put = alc_ch_mode_put,
  1755. },
  1756. { } /* end */
  1757. };
  1758. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1759. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1760. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1761. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1762. /* set capture source to mic-in */
  1763. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1764. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1765. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1766. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1767. /* speaker-out */
  1768. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1769. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1770. /* HP-out */
  1771. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1772. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1773. /* mic-in to input */
  1774. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1775. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1776. /* built-in mic */
  1777. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1778. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1779. /* jack sense */
  1780. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1781. { }
  1782. };
  1783. /* toggle speaker-output according to the hp-jack state */
  1784. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1785. {
  1786. unsigned int present;
  1787. unsigned char bits;
  1788. present = snd_hda_codec_read(codec, 0x1b, 0,
  1789. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1790. bits = present ? 0x80 : 0;
  1791. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1792. 0x80, bits);
  1793. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1794. 0x80, bits);
  1795. }
  1796. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1797. {
  1798. /* Looks like the unsol event is incompatible with the standard
  1799. * definition. 4bit tag is placed at 28 bit!
  1800. */
  1801. if ((res >> 28) == 0x01)
  1802. alc880_lg_lw_automute(codec);
  1803. }
  1804. /*
  1805. * Common callbacks
  1806. */
  1807. static int alc_init(struct hda_codec *codec)
  1808. {
  1809. struct alc_spec *spec = codec->spec;
  1810. unsigned int i;
  1811. for (i = 0; i < spec->num_init_verbs; i++)
  1812. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1813. if (spec->init_hook)
  1814. spec->init_hook(codec);
  1815. return 0;
  1816. }
  1817. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1818. {
  1819. struct alc_spec *spec = codec->spec;
  1820. if (spec->unsol_event)
  1821. spec->unsol_event(codec, res);
  1822. }
  1823. #ifdef CONFIG_PM
  1824. /*
  1825. * resume
  1826. */
  1827. static int alc_resume(struct hda_codec *codec)
  1828. {
  1829. struct alc_spec *spec = codec->spec;
  1830. int i;
  1831. alc_init(codec);
  1832. for (i = 0; i < spec->num_mixers; i++)
  1833. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1834. if (spec->multiout.dig_out_nid)
  1835. snd_hda_resume_spdif_out(codec);
  1836. if (spec->dig_in_nid)
  1837. snd_hda_resume_spdif_in(codec);
  1838. return 0;
  1839. }
  1840. #endif
  1841. /*
  1842. * Analog playback callbacks
  1843. */
  1844. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1845. struct hda_codec *codec,
  1846. struct snd_pcm_substream *substream)
  1847. {
  1848. struct alc_spec *spec = codec->spec;
  1849. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1850. }
  1851. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1852. struct hda_codec *codec,
  1853. unsigned int stream_tag,
  1854. unsigned int format,
  1855. struct snd_pcm_substream *substream)
  1856. {
  1857. struct alc_spec *spec = codec->spec;
  1858. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1859. stream_tag, format, substream);
  1860. }
  1861. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1862. struct hda_codec *codec,
  1863. struct snd_pcm_substream *substream)
  1864. {
  1865. struct alc_spec *spec = codec->spec;
  1866. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1867. }
  1868. /*
  1869. * Digital out
  1870. */
  1871. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1872. struct hda_codec *codec,
  1873. struct snd_pcm_substream *substream)
  1874. {
  1875. struct alc_spec *spec = codec->spec;
  1876. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1877. }
  1878. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1879. struct hda_codec *codec,
  1880. unsigned int stream_tag,
  1881. unsigned int format,
  1882. struct snd_pcm_substream *substream)
  1883. {
  1884. struct alc_spec *spec = codec->spec;
  1885. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1886. stream_tag, format, substream);
  1887. }
  1888. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1889. struct hda_codec *codec,
  1890. struct snd_pcm_substream *substream)
  1891. {
  1892. struct alc_spec *spec = codec->spec;
  1893. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1894. }
  1895. /*
  1896. * Analog capture
  1897. */
  1898. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1899. struct hda_codec *codec,
  1900. unsigned int stream_tag,
  1901. unsigned int format,
  1902. struct snd_pcm_substream *substream)
  1903. {
  1904. struct alc_spec *spec = codec->spec;
  1905. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1906. stream_tag, 0, format);
  1907. return 0;
  1908. }
  1909. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1910. struct hda_codec *codec,
  1911. struct snd_pcm_substream *substream)
  1912. {
  1913. struct alc_spec *spec = codec->spec;
  1914. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1915. 0, 0, 0);
  1916. return 0;
  1917. }
  1918. /*
  1919. */
  1920. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1921. .substreams = 1,
  1922. .channels_min = 2,
  1923. .channels_max = 8,
  1924. /* NID is set in alc_build_pcms */
  1925. .ops = {
  1926. .open = alc880_playback_pcm_open,
  1927. .prepare = alc880_playback_pcm_prepare,
  1928. .cleanup = alc880_playback_pcm_cleanup
  1929. },
  1930. };
  1931. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1932. .substreams = 2,
  1933. .channels_min = 2,
  1934. .channels_max = 2,
  1935. /* NID is set in alc_build_pcms */
  1936. .ops = {
  1937. .prepare = alc880_capture_pcm_prepare,
  1938. .cleanup = alc880_capture_pcm_cleanup
  1939. },
  1940. };
  1941. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1942. .substreams = 1,
  1943. .channels_min = 2,
  1944. .channels_max = 2,
  1945. /* NID is set in alc_build_pcms */
  1946. .ops = {
  1947. .open = alc880_dig_playback_pcm_open,
  1948. .close = alc880_dig_playback_pcm_close,
  1949. .prepare = alc880_dig_playback_pcm_prepare
  1950. },
  1951. };
  1952. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1953. .substreams = 1,
  1954. .channels_min = 2,
  1955. .channels_max = 2,
  1956. /* NID is set in alc_build_pcms */
  1957. };
  1958. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1959. static struct hda_pcm_stream alc_pcm_null_playback = {
  1960. .substreams = 0,
  1961. .channels_min = 0,
  1962. .channels_max = 0,
  1963. };
  1964. static int alc_build_pcms(struct hda_codec *codec)
  1965. {
  1966. struct alc_spec *spec = codec->spec;
  1967. struct hda_pcm *info = spec->pcm_rec;
  1968. int i;
  1969. codec->num_pcms = 1;
  1970. codec->pcm_info = info;
  1971. info->name = spec->stream_name_analog;
  1972. if (spec->stream_analog_playback) {
  1973. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1974. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1975. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1976. }
  1977. if (spec->stream_analog_capture) {
  1978. snd_assert(spec->adc_nids, return -EINVAL);
  1979. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1980. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1981. }
  1982. if (spec->channel_mode) {
  1983. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1984. for (i = 0; i < spec->num_channel_mode; i++) {
  1985. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1986. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1987. }
  1988. }
  1989. }
  1990. /* SPDIF for stream index #1 */
  1991. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1992. codec->num_pcms = 2;
  1993. info = spec->pcm_rec + 1;
  1994. info->name = spec->stream_name_digital;
  1995. if (spec->multiout.dig_out_nid &&
  1996. spec->stream_digital_playback) {
  1997. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1998. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1999. }
  2000. if (spec->dig_in_nid &&
  2001. spec->stream_digital_capture) {
  2002. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2003. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2004. }
  2005. }
  2006. /* If the use of more than one ADC is requested for the current
  2007. * model, configure a second analog capture-only PCM.
  2008. */
  2009. /* Additional Analaog capture for index #2 */
  2010. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2011. spec->adc_nids) {
  2012. codec->num_pcms = 3;
  2013. info = spec->pcm_rec + 2;
  2014. info->name = spec->stream_name_analog;
  2015. /* No playback stream for second PCM */
  2016. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2017. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2018. if (spec->stream_analog_capture) {
  2019. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2020. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2021. }
  2022. }
  2023. return 0;
  2024. }
  2025. static void alc_free(struct hda_codec *codec)
  2026. {
  2027. struct alc_spec *spec = codec->spec;
  2028. unsigned int i;
  2029. if (!spec)
  2030. return;
  2031. if (spec->kctl_alloc) {
  2032. for (i = 0; i < spec->num_kctl_used; i++)
  2033. kfree(spec->kctl_alloc[i].name);
  2034. kfree(spec->kctl_alloc);
  2035. }
  2036. kfree(spec);
  2037. }
  2038. /*
  2039. */
  2040. static struct hda_codec_ops alc_patch_ops = {
  2041. .build_controls = alc_build_controls,
  2042. .build_pcms = alc_build_pcms,
  2043. .init = alc_init,
  2044. .free = alc_free,
  2045. .unsol_event = alc_unsol_event,
  2046. #ifdef CONFIG_PM
  2047. .resume = alc_resume,
  2048. #endif
  2049. };
  2050. /*
  2051. * Test configuration for debugging
  2052. *
  2053. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2054. * enum controls.
  2055. */
  2056. #ifdef CONFIG_SND_DEBUG
  2057. static hda_nid_t alc880_test_dac_nids[4] = {
  2058. 0x02, 0x03, 0x04, 0x05
  2059. };
  2060. static struct hda_input_mux alc880_test_capture_source = {
  2061. .num_items = 7,
  2062. .items = {
  2063. { "In-1", 0x0 },
  2064. { "In-2", 0x1 },
  2065. { "In-3", 0x2 },
  2066. { "In-4", 0x3 },
  2067. { "CD", 0x4 },
  2068. { "Front", 0x5 },
  2069. { "Surround", 0x6 },
  2070. },
  2071. };
  2072. static struct hda_channel_mode alc880_test_modes[4] = {
  2073. { 2, NULL },
  2074. { 4, NULL },
  2075. { 6, NULL },
  2076. { 8, NULL },
  2077. };
  2078. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2079. struct snd_ctl_elem_info *uinfo)
  2080. {
  2081. static char *texts[] = {
  2082. "N/A", "Line Out", "HP Out",
  2083. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2084. };
  2085. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2086. uinfo->count = 1;
  2087. uinfo->value.enumerated.items = 8;
  2088. if (uinfo->value.enumerated.item >= 8)
  2089. uinfo->value.enumerated.item = 7;
  2090. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2091. return 0;
  2092. }
  2093. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2094. struct snd_ctl_elem_value *ucontrol)
  2095. {
  2096. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2097. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2098. unsigned int pin_ctl, item = 0;
  2099. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2100. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2101. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2102. if (pin_ctl & AC_PINCTL_HP_EN)
  2103. item = 2;
  2104. else
  2105. item = 1;
  2106. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2107. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2108. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2109. case AC_PINCTL_VREF_50: item = 4; break;
  2110. case AC_PINCTL_VREF_GRD: item = 5; break;
  2111. case AC_PINCTL_VREF_80: item = 6; break;
  2112. case AC_PINCTL_VREF_100: item = 7; break;
  2113. }
  2114. }
  2115. ucontrol->value.enumerated.item[0] = item;
  2116. return 0;
  2117. }
  2118. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2119. struct snd_ctl_elem_value *ucontrol)
  2120. {
  2121. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2122. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2123. static unsigned int ctls[] = {
  2124. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2125. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2126. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2127. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2128. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2129. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2130. };
  2131. unsigned int old_ctl, new_ctl;
  2132. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2133. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2134. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2135. if (old_ctl != new_ctl) {
  2136. snd_hda_codec_write(codec, nid, 0,
  2137. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2138. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2139. (ucontrol->value.enumerated.item[0] >= 3 ?
  2140. 0xb080 : 0xb000));
  2141. return 1;
  2142. }
  2143. return 0;
  2144. }
  2145. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2146. struct snd_ctl_elem_info *uinfo)
  2147. {
  2148. static char *texts[] = {
  2149. "Front", "Surround", "CLFE", "Side"
  2150. };
  2151. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2152. uinfo->count = 1;
  2153. uinfo->value.enumerated.items = 4;
  2154. if (uinfo->value.enumerated.item >= 4)
  2155. uinfo->value.enumerated.item = 3;
  2156. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2157. return 0;
  2158. }
  2159. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2160. struct snd_ctl_elem_value *ucontrol)
  2161. {
  2162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2163. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2164. unsigned int sel;
  2165. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2166. ucontrol->value.enumerated.item[0] = sel & 3;
  2167. return 0;
  2168. }
  2169. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2170. struct snd_ctl_elem_value *ucontrol)
  2171. {
  2172. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2173. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2174. unsigned int sel;
  2175. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2176. if (ucontrol->value.enumerated.item[0] != sel) {
  2177. sel = ucontrol->value.enumerated.item[0] & 3;
  2178. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2179. return 1;
  2180. }
  2181. return 0;
  2182. }
  2183. #define PIN_CTL_TEST(xname,nid) { \
  2184. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2185. .name = xname, \
  2186. .info = alc_test_pin_ctl_info, \
  2187. .get = alc_test_pin_ctl_get, \
  2188. .put = alc_test_pin_ctl_put, \
  2189. .private_value = nid \
  2190. }
  2191. #define PIN_SRC_TEST(xname,nid) { \
  2192. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2193. .name = xname, \
  2194. .info = alc_test_pin_src_info, \
  2195. .get = alc_test_pin_src_get, \
  2196. .put = alc_test_pin_src_put, \
  2197. .private_value = nid \
  2198. }
  2199. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2200. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2201. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2202. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2203. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2204. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2205. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2206. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2207. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2208. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2209. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2210. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2211. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2212. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2213. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2214. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2215. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2216. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2217. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2218. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2219. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2220. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2221. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2222. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2223. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2224. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2225. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2226. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2227. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2228. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2229. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2230. {
  2231. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2232. .name = "Channel Mode",
  2233. .info = alc_ch_mode_info,
  2234. .get = alc_ch_mode_get,
  2235. .put = alc_ch_mode_put,
  2236. },
  2237. { } /* end */
  2238. };
  2239. static struct hda_verb alc880_test_init_verbs[] = {
  2240. /* Unmute inputs of 0x0c - 0x0f */
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2247. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2248. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2249. /* Vol output for 0x0c-0x0f */
  2250. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2251. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2253. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2254. /* Set output pins 0x14-0x17 */
  2255. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2257. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2258. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2259. /* Unmute output pins 0x14-0x17 */
  2260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2262. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2263. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2264. /* Set input pins 0x18-0x1c */
  2265. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2266. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2267. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2269. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2270. /* Mute input pins 0x18-0x1b */
  2271. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2272. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2273. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2274. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2275. /* ADC set up */
  2276. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2277. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2278. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2279. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2280. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2281. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2282. /* Analog input/passthru */
  2283. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2284. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2286. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2287. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2288. { }
  2289. };
  2290. #endif
  2291. /*
  2292. */
  2293. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2294. [ALC880_3ST] = "3stack",
  2295. [ALC880_TCL_S700] = "tcl",
  2296. [ALC880_3ST_DIG] = "3stack-digout",
  2297. [ALC880_CLEVO] = "clevo",
  2298. [ALC880_5ST] = "5stack",
  2299. [ALC880_5ST_DIG] = "5stack-digout",
  2300. [ALC880_W810] = "w810",
  2301. [ALC880_Z71V] = "z71v",
  2302. [ALC880_6ST] = "6stack",
  2303. [ALC880_6ST_DIG] = "6stack-digout",
  2304. [ALC880_ASUS] = "asus",
  2305. [ALC880_ASUS_W1V] = "asus-w1v",
  2306. [ALC880_ASUS_DIG] = "asus-dig",
  2307. [ALC880_ASUS_DIG2] = "asus-dig2",
  2308. [ALC880_UNIWILL_DIG] = "uniwill",
  2309. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2310. [ALC880_FUJITSU] = "fujitsu",
  2311. [ALC880_F1734] = "F1734",
  2312. [ALC880_LG] = "lg",
  2313. [ALC880_LG_LW] = "lg-lw",
  2314. #ifdef CONFIG_SND_DEBUG
  2315. [ALC880_TEST] = "test",
  2316. #endif
  2317. [ALC880_AUTO] = "auto",
  2318. };
  2319. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2320. /* Broken BIOS configuration */
  2321. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2323. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2324. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2325. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2326. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2327. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2328. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2329. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2330. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2331. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2332. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2333. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2334. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2335. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2339. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2340. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2341. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2342. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2343. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2344. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2345. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2346. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2347. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2348. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2349. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2350. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2351. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2352. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2353. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2354. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2355. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2356. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2357. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2358. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2359. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2360. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2361. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2362. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2363. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2364. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2365. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2366. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2367. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2368. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2369. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2370. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2371. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2372. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2373. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2374. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2375. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2376. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2377. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2378. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2379. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2382. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2383. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2384. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2385. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2386. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2387. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2388. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2389. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2390. {}
  2391. };
  2392. /*
  2393. * ALC880 codec presets
  2394. */
  2395. static struct alc_config_preset alc880_presets[] = {
  2396. [ALC880_3ST] = {
  2397. .mixers = { alc880_three_stack_mixer },
  2398. .init_verbs = { alc880_volume_init_verbs,
  2399. alc880_pin_3stack_init_verbs },
  2400. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2401. .dac_nids = alc880_dac_nids,
  2402. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2403. .channel_mode = alc880_threestack_modes,
  2404. .need_dac_fix = 1,
  2405. .input_mux = &alc880_capture_source,
  2406. },
  2407. [ALC880_3ST_DIG] = {
  2408. .mixers = { alc880_three_stack_mixer },
  2409. .init_verbs = { alc880_volume_init_verbs,
  2410. alc880_pin_3stack_init_verbs },
  2411. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2412. .dac_nids = alc880_dac_nids,
  2413. .dig_out_nid = ALC880_DIGOUT_NID,
  2414. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2415. .channel_mode = alc880_threestack_modes,
  2416. .need_dac_fix = 1,
  2417. .input_mux = &alc880_capture_source,
  2418. },
  2419. [ALC880_TCL_S700] = {
  2420. .mixers = { alc880_tcl_s700_mixer },
  2421. .init_verbs = { alc880_volume_init_verbs,
  2422. alc880_pin_tcl_S700_init_verbs,
  2423. alc880_gpio2_init_verbs },
  2424. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2425. .dac_nids = alc880_dac_nids,
  2426. .hp_nid = 0x03,
  2427. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2428. .channel_mode = alc880_2_jack_modes,
  2429. .input_mux = &alc880_capture_source,
  2430. },
  2431. [ALC880_5ST] = {
  2432. .mixers = { alc880_three_stack_mixer,
  2433. alc880_five_stack_mixer},
  2434. .init_verbs = { alc880_volume_init_verbs,
  2435. alc880_pin_5stack_init_verbs },
  2436. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2437. .dac_nids = alc880_dac_nids,
  2438. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2439. .channel_mode = alc880_fivestack_modes,
  2440. .input_mux = &alc880_capture_source,
  2441. },
  2442. [ALC880_5ST_DIG] = {
  2443. .mixers = { alc880_three_stack_mixer,
  2444. alc880_five_stack_mixer },
  2445. .init_verbs = { alc880_volume_init_verbs,
  2446. alc880_pin_5stack_init_verbs },
  2447. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2448. .dac_nids = alc880_dac_nids,
  2449. .dig_out_nid = ALC880_DIGOUT_NID,
  2450. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2451. .channel_mode = alc880_fivestack_modes,
  2452. .input_mux = &alc880_capture_source,
  2453. },
  2454. [ALC880_6ST] = {
  2455. .mixers = { alc880_six_stack_mixer },
  2456. .init_verbs = { alc880_volume_init_verbs,
  2457. alc880_pin_6stack_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2459. .dac_nids = alc880_6st_dac_nids,
  2460. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2461. .channel_mode = alc880_sixstack_modes,
  2462. .input_mux = &alc880_6stack_capture_source,
  2463. },
  2464. [ALC880_6ST_DIG] = {
  2465. .mixers = { alc880_six_stack_mixer },
  2466. .init_verbs = { alc880_volume_init_verbs,
  2467. alc880_pin_6stack_init_verbs },
  2468. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2469. .dac_nids = alc880_6st_dac_nids,
  2470. .dig_out_nid = ALC880_DIGOUT_NID,
  2471. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2472. .channel_mode = alc880_sixstack_modes,
  2473. .input_mux = &alc880_6stack_capture_source,
  2474. },
  2475. [ALC880_W810] = {
  2476. .mixers = { alc880_w810_base_mixer },
  2477. .init_verbs = { alc880_volume_init_verbs,
  2478. alc880_pin_w810_init_verbs,
  2479. alc880_gpio2_init_verbs },
  2480. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2481. .dac_nids = alc880_w810_dac_nids,
  2482. .dig_out_nid = ALC880_DIGOUT_NID,
  2483. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2484. .channel_mode = alc880_w810_modes,
  2485. .input_mux = &alc880_capture_source,
  2486. },
  2487. [ALC880_Z71V] = {
  2488. .mixers = { alc880_z71v_mixer },
  2489. .init_verbs = { alc880_volume_init_verbs,
  2490. alc880_pin_z71v_init_verbs },
  2491. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2492. .dac_nids = alc880_z71v_dac_nids,
  2493. .dig_out_nid = ALC880_DIGOUT_NID,
  2494. .hp_nid = 0x03,
  2495. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2496. .channel_mode = alc880_2_jack_modes,
  2497. .input_mux = &alc880_capture_source,
  2498. },
  2499. [ALC880_F1734] = {
  2500. .mixers = { alc880_f1734_mixer },
  2501. .init_verbs = { alc880_volume_init_verbs,
  2502. alc880_pin_f1734_init_verbs },
  2503. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2504. .dac_nids = alc880_f1734_dac_nids,
  2505. .hp_nid = 0x02,
  2506. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2507. .channel_mode = alc880_2_jack_modes,
  2508. .input_mux = &alc880_capture_source,
  2509. },
  2510. [ALC880_ASUS] = {
  2511. .mixers = { alc880_asus_mixer },
  2512. .init_verbs = { alc880_volume_init_verbs,
  2513. alc880_pin_asus_init_verbs,
  2514. alc880_gpio1_init_verbs },
  2515. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2516. .dac_nids = alc880_asus_dac_nids,
  2517. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2518. .channel_mode = alc880_asus_modes,
  2519. .need_dac_fix = 1,
  2520. .input_mux = &alc880_capture_source,
  2521. },
  2522. [ALC880_ASUS_DIG] = {
  2523. .mixers = { alc880_asus_mixer },
  2524. .init_verbs = { alc880_volume_init_verbs,
  2525. alc880_pin_asus_init_verbs,
  2526. alc880_gpio1_init_verbs },
  2527. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2528. .dac_nids = alc880_asus_dac_nids,
  2529. .dig_out_nid = ALC880_DIGOUT_NID,
  2530. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2531. .channel_mode = alc880_asus_modes,
  2532. .need_dac_fix = 1,
  2533. .input_mux = &alc880_capture_source,
  2534. },
  2535. [ALC880_ASUS_DIG2] = {
  2536. .mixers = { alc880_asus_mixer },
  2537. .init_verbs = { alc880_volume_init_verbs,
  2538. alc880_pin_asus_init_verbs,
  2539. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2540. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2541. .dac_nids = alc880_asus_dac_nids,
  2542. .dig_out_nid = ALC880_DIGOUT_NID,
  2543. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2544. .channel_mode = alc880_asus_modes,
  2545. .need_dac_fix = 1,
  2546. .input_mux = &alc880_capture_source,
  2547. },
  2548. [ALC880_ASUS_W1V] = {
  2549. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2550. .init_verbs = { alc880_volume_init_verbs,
  2551. alc880_pin_asus_init_verbs,
  2552. alc880_gpio1_init_verbs },
  2553. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2554. .dac_nids = alc880_asus_dac_nids,
  2555. .dig_out_nid = ALC880_DIGOUT_NID,
  2556. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2557. .channel_mode = alc880_asus_modes,
  2558. .need_dac_fix = 1,
  2559. .input_mux = &alc880_capture_source,
  2560. },
  2561. [ALC880_UNIWILL_DIG] = {
  2562. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2563. .init_verbs = { alc880_volume_init_verbs,
  2564. alc880_pin_asus_init_verbs },
  2565. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2566. .dac_nids = alc880_asus_dac_nids,
  2567. .dig_out_nid = ALC880_DIGOUT_NID,
  2568. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2569. .channel_mode = alc880_asus_modes,
  2570. .need_dac_fix = 1,
  2571. .input_mux = &alc880_capture_source,
  2572. },
  2573. [ALC880_UNIWILL] = {
  2574. .mixers = { alc880_uniwill_mixer },
  2575. .init_verbs = { alc880_volume_init_verbs,
  2576. alc880_uniwill_init_verbs },
  2577. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2578. .dac_nids = alc880_asus_dac_nids,
  2579. .dig_out_nid = ALC880_DIGOUT_NID,
  2580. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2581. .channel_mode = alc880_threestack_modes,
  2582. .need_dac_fix = 1,
  2583. .input_mux = &alc880_capture_source,
  2584. .unsol_event = alc880_uniwill_unsol_event,
  2585. .init_hook = alc880_uniwill_automute,
  2586. },
  2587. [ALC880_UNIWILL_P53] = {
  2588. .mixers = { alc880_uniwill_p53_mixer },
  2589. .init_verbs = { alc880_volume_init_verbs,
  2590. alc880_uniwill_p53_init_verbs },
  2591. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2592. .dac_nids = alc880_asus_dac_nids,
  2593. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2594. .channel_mode = alc880_threestack_modes,
  2595. .input_mux = &alc880_capture_source,
  2596. .unsol_event = alc880_uniwill_p53_unsol_event,
  2597. .init_hook = alc880_uniwill_p53_hp_automute,
  2598. },
  2599. [ALC880_FUJITSU] = {
  2600. .mixers = { alc880_fujitsu_mixer,
  2601. alc880_pcbeep_mixer, },
  2602. .init_verbs = { alc880_volume_init_verbs,
  2603. alc880_uniwill_p53_init_verbs,
  2604. alc880_beep_init_verbs },
  2605. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2606. .dac_nids = alc880_dac_nids,
  2607. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2608. .channel_mode = alc880_2_jack_modes,
  2609. .input_mux = &alc880_capture_source,
  2610. .unsol_event = alc880_uniwill_p53_unsol_event,
  2611. .init_hook = alc880_uniwill_p53_hp_automute,
  2612. },
  2613. [ALC880_CLEVO] = {
  2614. .mixers = { alc880_three_stack_mixer },
  2615. .init_verbs = { alc880_volume_init_verbs,
  2616. alc880_pin_clevo_init_verbs },
  2617. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2618. .dac_nids = alc880_dac_nids,
  2619. .hp_nid = 0x03,
  2620. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2621. .channel_mode = alc880_threestack_modes,
  2622. .need_dac_fix = 1,
  2623. .input_mux = &alc880_capture_source,
  2624. },
  2625. [ALC880_LG] = {
  2626. .mixers = { alc880_lg_mixer },
  2627. .init_verbs = { alc880_volume_init_verbs,
  2628. alc880_lg_init_verbs },
  2629. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2630. .dac_nids = alc880_lg_dac_nids,
  2631. .dig_out_nid = ALC880_DIGOUT_NID,
  2632. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2633. .channel_mode = alc880_lg_ch_modes,
  2634. .need_dac_fix = 1,
  2635. .input_mux = &alc880_lg_capture_source,
  2636. .unsol_event = alc880_lg_unsol_event,
  2637. .init_hook = alc880_lg_automute,
  2638. },
  2639. [ALC880_LG_LW] = {
  2640. .mixers = { alc880_lg_lw_mixer },
  2641. .init_verbs = { alc880_volume_init_verbs,
  2642. alc880_lg_lw_init_verbs },
  2643. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2644. .dac_nids = alc880_dac_nids,
  2645. .dig_out_nid = ALC880_DIGOUT_NID,
  2646. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2647. .channel_mode = alc880_lg_lw_modes,
  2648. .input_mux = &alc880_lg_lw_capture_source,
  2649. .unsol_event = alc880_lg_lw_unsol_event,
  2650. .init_hook = alc880_lg_lw_automute,
  2651. },
  2652. #ifdef CONFIG_SND_DEBUG
  2653. [ALC880_TEST] = {
  2654. .mixers = { alc880_test_mixer },
  2655. .init_verbs = { alc880_test_init_verbs },
  2656. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2657. .dac_nids = alc880_test_dac_nids,
  2658. .dig_out_nid = ALC880_DIGOUT_NID,
  2659. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2660. .channel_mode = alc880_test_modes,
  2661. .input_mux = &alc880_test_capture_source,
  2662. },
  2663. #endif
  2664. };
  2665. /*
  2666. * Automatic parse of I/O pins from the BIOS configuration
  2667. */
  2668. #define NUM_CONTROL_ALLOC 32
  2669. #define NUM_VERB_ALLOC 32
  2670. enum {
  2671. ALC_CTL_WIDGET_VOL,
  2672. ALC_CTL_WIDGET_MUTE,
  2673. ALC_CTL_BIND_MUTE,
  2674. };
  2675. static struct snd_kcontrol_new alc880_control_templates[] = {
  2676. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2677. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2678. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2679. };
  2680. /* add dynamic controls */
  2681. static int add_control(struct alc_spec *spec, int type, const char *name,
  2682. unsigned long val)
  2683. {
  2684. struct snd_kcontrol_new *knew;
  2685. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2686. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2687. /* array + terminator */
  2688. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2689. if (!knew)
  2690. return -ENOMEM;
  2691. if (spec->kctl_alloc) {
  2692. memcpy(knew, spec->kctl_alloc,
  2693. sizeof(*knew) * spec->num_kctl_alloc);
  2694. kfree(spec->kctl_alloc);
  2695. }
  2696. spec->kctl_alloc = knew;
  2697. spec->num_kctl_alloc = num;
  2698. }
  2699. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2700. *knew = alc880_control_templates[type];
  2701. knew->name = kstrdup(name, GFP_KERNEL);
  2702. if (!knew->name)
  2703. return -ENOMEM;
  2704. knew->private_value = val;
  2705. spec->num_kctl_used++;
  2706. return 0;
  2707. }
  2708. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2709. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2710. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2711. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2712. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2713. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2714. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2715. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2716. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2717. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2718. #define ALC880_PIN_CD_NID 0x1c
  2719. /* fill in the dac_nids table from the parsed pin configuration */
  2720. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2721. const struct auto_pin_cfg *cfg)
  2722. {
  2723. hda_nid_t nid;
  2724. int assigned[4];
  2725. int i, j;
  2726. memset(assigned, 0, sizeof(assigned));
  2727. spec->multiout.dac_nids = spec->private_dac_nids;
  2728. /* check the pins hardwired to audio widget */
  2729. for (i = 0; i < cfg->line_outs; i++) {
  2730. nid = cfg->line_out_pins[i];
  2731. if (alc880_is_fixed_pin(nid)) {
  2732. int idx = alc880_fixed_pin_idx(nid);
  2733. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2734. assigned[idx] = 1;
  2735. }
  2736. }
  2737. /* left pins can be connect to any audio widget */
  2738. for (i = 0; i < cfg->line_outs; i++) {
  2739. nid = cfg->line_out_pins[i];
  2740. if (alc880_is_fixed_pin(nid))
  2741. continue;
  2742. /* search for an empty channel */
  2743. for (j = 0; j < cfg->line_outs; j++) {
  2744. if (!assigned[j]) {
  2745. spec->multiout.dac_nids[i] =
  2746. alc880_idx_to_dac(j);
  2747. assigned[j] = 1;
  2748. break;
  2749. }
  2750. }
  2751. }
  2752. spec->multiout.num_dacs = cfg->line_outs;
  2753. return 0;
  2754. }
  2755. /* add playback controls from the parsed DAC table */
  2756. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2757. const struct auto_pin_cfg *cfg)
  2758. {
  2759. char name[32];
  2760. static const char *chname[4] = {
  2761. "Front", "Surround", NULL /*CLFE*/, "Side"
  2762. };
  2763. hda_nid_t nid;
  2764. int i, err;
  2765. for (i = 0; i < cfg->line_outs; i++) {
  2766. if (!spec->multiout.dac_nids[i])
  2767. continue;
  2768. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2769. if (i == 2) {
  2770. /* Center/LFE */
  2771. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2772. "Center Playback Volume",
  2773. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2774. HDA_OUTPUT));
  2775. if (err < 0)
  2776. return err;
  2777. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2778. "LFE Playback Volume",
  2779. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2780. HDA_OUTPUT));
  2781. if (err < 0)
  2782. return err;
  2783. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2784. "Center Playback Switch",
  2785. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2786. HDA_INPUT));
  2787. if (err < 0)
  2788. return err;
  2789. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2790. "LFE Playback Switch",
  2791. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2792. HDA_INPUT));
  2793. if (err < 0)
  2794. return err;
  2795. } else {
  2796. sprintf(name, "%s Playback Volume", chname[i]);
  2797. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2798. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2799. HDA_OUTPUT));
  2800. if (err < 0)
  2801. return err;
  2802. sprintf(name, "%s Playback Switch", chname[i]);
  2803. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2804. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2805. HDA_INPUT));
  2806. if (err < 0)
  2807. return err;
  2808. }
  2809. }
  2810. return 0;
  2811. }
  2812. /* add playback controls for speaker and HP outputs */
  2813. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2814. const char *pfx)
  2815. {
  2816. hda_nid_t nid;
  2817. int err;
  2818. char name[32];
  2819. if (!pin)
  2820. return 0;
  2821. if (alc880_is_fixed_pin(pin)) {
  2822. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2823. /* specify the DAC as the extra output */
  2824. if (!spec->multiout.hp_nid)
  2825. spec->multiout.hp_nid = nid;
  2826. else
  2827. spec->multiout.extra_out_nid[0] = nid;
  2828. /* control HP volume/switch on the output mixer amp */
  2829. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2830. sprintf(name, "%s Playback Volume", pfx);
  2831. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2832. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2833. if (err < 0)
  2834. return err;
  2835. sprintf(name, "%s Playback Switch", pfx);
  2836. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2837. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2838. if (err < 0)
  2839. return err;
  2840. } else if (alc880_is_multi_pin(pin)) {
  2841. /* set manual connection */
  2842. /* we have only a switch on HP-out PIN */
  2843. sprintf(name, "%s Playback Switch", pfx);
  2844. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2845. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2846. if (err < 0)
  2847. return err;
  2848. }
  2849. return 0;
  2850. }
  2851. /* create input playback/capture controls for the given pin */
  2852. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2853. const char *ctlname,
  2854. int idx, hda_nid_t mix_nid)
  2855. {
  2856. char name[32];
  2857. int err;
  2858. sprintf(name, "%s Playback Volume", ctlname);
  2859. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2860. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2861. if (err < 0)
  2862. return err;
  2863. sprintf(name, "%s Playback Switch", ctlname);
  2864. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2865. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2866. if (err < 0)
  2867. return err;
  2868. return 0;
  2869. }
  2870. /* create playback/capture controls for input pins */
  2871. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2872. const struct auto_pin_cfg *cfg)
  2873. {
  2874. struct hda_input_mux *imux = &spec->private_imux;
  2875. int i, err, idx;
  2876. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2877. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2878. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2879. err = new_analog_input(spec, cfg->input_pins[i],
  2880. auto_pin_cfg_labels[i],
  2881. idx, 0x0b);
  2882. if (err < 0)
  2883. return err;
  2884. imux->items[imux->num_items].label =
  2885. auto_pin_cfg_labels[i];
  2886. imux->items[imux->num_items].index =
  2887. alc880_input_pin_idx(cfg->input_pins[i]);
  2888. imux->num_items++;
  2889. }
  2890. }
  2891. return 0;
  2892. }
  2893. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2894. hda_nid_t nid, int pin_type,
  2895. int dac_idx)
  2896. {
  2897. /* set as output */
  2898. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2899. pin_type);
  2900. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2901. AMP_OUT_UNMUTE);
  2902. /* need the manual connection? */
  2903. if (alc880_is_multi_pin(nid)) {
  2904. struct alc_spec *spec = codec->spec;
  2905. int idx = alc880_multi_pin_idx(nid);
  2906. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2907. AC_VERB_SET_CONNECT_SEL,
  2908. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2909. }
  2910. }
  2911. static int get_pin_type(int line_out_type)
  2912. {
  2913. if (line_out_type == AUTO_PIN_HP_OUT)
  2914. return PIN_HP;
  2915. else
  2916. return PIN_OUT;
  2917. }
  2918. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2919. {
  2920. struct alc_spec *spec = codec->spec;
  2921. int i;
  2922. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2923. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2924. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2925. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2926. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2927. }
  2928. }
  2929. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2930. {
  2931. struct alc_spec *spec = codec->spec;
  2932. hda_nid_t pin;
  2933. pin = spec->autocfg.speaker_pins[0];
  2934. if (pin) /* connect to front */
  2935. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2936. pin = spec->autocfg.hp_pins[0];
  2937. if (pin) /* connect to front */
  2938. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2939. }
  2940. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2941. {
  2942. struct alc_spec *spec = codec->spec;
  2943. int i;
  2944. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2945. hda_nid_t nid = spec->autocfg.input_pins[i];
  2946. if (alc880_is_input_pin(nid)) {
  2947. snd_hda_codec_write(codec, nid, 0,
  2948. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2949. i <= AUTO_PIN_FRONT_MIC ?
  2950. PIN_VREF80 : PIN_IN);
  2951. if (nid != ALC880_PIN_CD_NID)
  2952. snd_hda_codec_write(codec, nid, 0,
  2953. AC_VERB_SET_AMP_GAIN_MUTE,
  2954. AMP_OUT_MUTE);
  2955. }
  2956. }
  2957. }
  2958. /* parse the BIOS configuration and set up the alc_spec */
  2959. /* return 1 if successful, 0 if the proper config is not found,
  2960. * or a negative error code
  2961. */
  2962. static int alc880_parse_auto_config(struct hda_codec *codec)
  2963. {
  2964. struct alc_spec *spec = codec->spec;
  2965. int err;
  2966. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2967. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2968. alc880_ignore);
  2969. if (err < 0)
  2970. return err;
  2971. if (!spec->autocfg.line_outs)
  2972. return 0; /* can't find valid BIOS pin config */
  2973. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2974. if (err < 0)
  2975. return err;
  2976. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2977. if (err < 0)
  2978. return err;
  2979. err = alc880_auto_create_extra_out(spec,
  2980. spec->autocfg.speaker_pins[0],
  2981. "Speaker");
  2982. if (err < 0)
  2983. return err;
  2984. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2985. "Headphone");
  2986. if (err < 0)
  2987. return err;
  2988. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2989. if (err < 0)
  2990. return err;
  2991. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2992. if (spec->autocfg.dig_out_pin)
  2993. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2994. if (spec->autocfg.dig_in_pin)
  2995. spec->dig_in_nid = ALC880_DIGIN_NID;
  2996. if (spec->kctl_alloc)
  2997. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2998. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2999. spec->num_mux_defs = 1;
  3000. spec->input_mux = &spec->private_imux;
  3001. return 1;
  3002. }
  3003. /* additional initialization for auto-configuration model */
  3004. static void alc880_auto_init(struct hda_codec *codec)
  3005. {
  3006. alc880_auto_init_multi_out(codec);
  3007. alc880_auto_init_extra_out(codec);
  3008. alc880_auto_init_analog_input(codec);
  3009. }
  3010. /*
  3011. * OK, here we have finally the patch for ALC880
  3012. */
  3013. static int patch_alc880(struct hda_codec *codec)
  3014. {
  3015. struct alc_spec *spec;
  3016. int board_config;
  3017. int err;
  3018. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3019. if (spec == NULL)
  3020. return -ENOMEM;
  3021. codec->spec = spec;
  3022. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3023. alc880_models,
  3024. alc880_cfg_tbl);
  3025. if (board_config < 0) {
  3026. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3027. "trying auto-probe from BIOS...\n");
  3028. board_config = ALC880_AUTO;
  3029. }
  3030. if (board_config == ALC880_AUTO) {
  3031. /* automatic parse from the BIOS config */
  3032. err = alc880_parse_auto_config(codec);
  3033. if (err < 0) {
  3034. alc_free(codec);
  3035. return err;
  3036. } else if (!err) {
  3037. printk(KERN_INFO
  3038. "hda_codec: Cannot set up configuration "
  3039. "from BIOS. Using 3-stack mode...\n");
  3040. board_config = ALC880_3ST;
  3041. }
  3042. }
  3043. if (board_config != ALC880_AUTO)
  3044. setup_preset(spec, &alc880_presets[board_config]);
  3045. spec->stream_name_analog = "ALC880 Analog";
  3046. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3047. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3048. spec->stream_name_digital = "ALC880 Digital";
  3049. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3050. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3051. if (!spec->adc_nids && spec->input_mux) {
  3052. /* check whether NID 0x07 is valid */
  3053. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3054. /* get type */
  3055. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3056. if (wcap != AC_WID_AUD_IN) {
  3057. spec->adc_nids = alc880_adc_nids_alt;
  3058. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3059. spec->mixers[spec->num_mixers] =
  3060. alc880_capture_alt_mixer;
  3061. spec->num_mixers++;
  3062. } else {
  3063. spec->adc_nids = alc880_adc_nids;
  3064. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3065. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3066. spec->num_mixers++;
  3067. }
  3068. }
  3069. codec->patch_ops = alc_patch_ops;
  3070. if (board_config == ALC880_AUTO)
  3071. spec->init_hook = alc880_auto_init;
  3072. return 0;
  3073. }
  3074. /*
  3075. * ALC260 support
  3076. */
  3077. static hda_nid_t alc260_dac_nids[1] = {
  3078. /* front */
  3079. 0x02,
  3080. };
  3081. static hda_nid_t alc260_adc_nids[1] = {
  3082. /* ADC0 */
  3083. 0x04,
  3084. };
  3085. static hda_nid_t alc260_adc_nids_alt[1] = {
  3086. /* ADC1 */
  3087. 0x05,
  3088. };
  3089. static hda_nid_t alc260_hp_adc_nids[2] = {
  3090. /* ADC1, 0 */
  3091. 0x05, 0x04
  3092. };
  3093. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3094. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3095. */
  3096. static hda_nid_t alc260_dual_adc_nids[2] = {
  3097. /* ADC0, ADC1 */
  3098. 0x04, 0x05
  3099. };
  3100. #define ALC260_DIGOUT_NID 0x03
  3101. #define ALC260_DIGIN_NID 0x06
  3102. static struct hda_input_mux alc260_capture_source = {
  3103. .num_items = 4,
  3104. .items = {
  3105. { "Mic", 0x0 },
  3106. { "Front Mic", 0x1 },
  3107. { "Line", 0x2 },
  3108. { "CD", 0x4 },
  3109. },
  3110. };
  3111. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3112. * headphone jack and the internal CD lines since these are the only pins at
  3113. * which audio can appear. For flexibility, also allow the option of
  3114. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3115. * connection to the mixer output).
  3116. */
  3117. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3118. {
  3119. .num_items = 3,
  3120. .items = {
  3121. { "Mic/Line", 0x0 },
  3122. { "CD", 0x4 },
  3123. { "Headphone", 0x2 },
  3124. },
  3125. },
  3126. {
  3127. .num_items = 4,
  3128. .items = {
  3129. { "Mic/Line", 0x0 },
  3130. { "CD", 0x4 },
  3131. { "Headphone", 0x2 },
  3132. { "Mixer", 0x5 },
  3133. },
  3134. },
  3135. };
  3136. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3137. * the Fujitsu S702x, but jacks are marked differently.
  3138. */
  3139. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3140. {
  3141. .num_items = 4,
  3142. .items = {
  3143. { "Mic", 0x0 },
  3144. { "Line", 0x2 },
  3145. { "CD", 0x4 },
  3146. { "Headphone", 0x5 },
  3147. },
  3148. },
  3149. {
  3150. .num_items = 5,
  3151. .items = {
  3152. { "Mic", 0x0 },
  3153. { "Line", 0x2 },
  3154. { "CD", 0x4 },
  3155. { "Headphone", 0x6 },
  3156. { "Mixer", 0x5 },
  3157. },
  3158. },
  3159. };
  3160. /*
  3161. * This is just place-holder, so there's something for alc_build_pcms to look
  3162. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3163. * element which allows changing the channel mode, so the verb list is
  3164. * never used.
  3165. */
  3166. static struct hda_channel_mode alc260_modes[1] = {
  3167. { 2, NULL },
  3168. };
  3169. /* Mixer combinations
  3170. *
  3171. * basic: base_output + input + pc_beep + capture
  3172. * HP: base_output + input + capture_alt
  3173. * HP_3013: hp_3013 + input + capture
  3174. * fujitsu: fujitsu + capture
  3175. * acer: acer + capture
  3176. */
  3177. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3178. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3179. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3180. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3181. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3182. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3183. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3184. { } /* end */
  3185. };
  3186. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3187. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3191. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3193. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3195. { } /* end */
  3196. };
  3197. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3198. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3199. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3200. { } /* end */
  3201. };
  3202. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3203. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3207. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3210. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3211. { } /* end */
  3212. };
  3213. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3214. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3215. */
  3216. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3217. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3218. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3219. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3220. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3222. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3223. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3224. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3225. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3227. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3228. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3229. { } /* end */
  3230. };
  3231. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3232. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3233. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3234. * datasheet doesn't mention this restriction. At this stage it's not clear
  3235. * whether this behaviour is intentional or is a hardware bug in chip
  3236. * revisions available in early 2006. Therefore for now allow the
  3237. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3238. * that the lack of mic bias for this NID is intentional we could change the
  3239. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3240. *
  3241. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3242. * don't appear to make the mic bias available from the "line" jack, even
  3243. * though the NID used for this jack (0x14) can supply it. The theory is
  3244. * that perhaps Acer have included blocking capacitors between the ALC260
  3245. * and the output jack. If this turns out to be the case for all such
  3246. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3247. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3248. *
  3249. * The C20x Tablet series have a mono internal speaker which is controlled
  3250. * via the chip's Mono sum widget and pin complex, so include the necessary
  3251. * controls for such models. On models without a "mono speaker" the control
  3252. * won't do anything.
  3253. */
  3254. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3255. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3256. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3257. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3258. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3259. HDA_OUTPUT),
  3260. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3261. HDA_INPUT),
  3262. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3265. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3266. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3267. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3268. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3269. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3270. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3271. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3272. { } /* end */
  3273. };
  3274. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3275. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3276. */
  3277. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3278. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3279. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3282. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3283. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3284. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3285. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3286. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3288. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3289. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3290. { } /* end */
  3291. };
  3292. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3293. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3294. */
  3295. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3296. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3297. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3298. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3299. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3300. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3301. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3303. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3304. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3305. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3306. { } /* end */
  3307. };
  3308. /* capture mixer elements */
  3309. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3310. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3312. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3313. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3314. {
  3315. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3316. /* The multiple "Capture Source" controls confuse alsamixer
  3317. * So call somewhat different..
  3318. * FIXME: the controls appear in the "playback" view!
  3319. */
  3320. /* .name = "Capture Source", */
  3321. .name = "Input Source",
  3322. .count = 2,
  3323. .info = alc_mux_enum_info,
  3324. .get = alc_mux_enum_get,
  3325. .put = alc_mux_enum_put,
  3326. },
  3327. { } /* end */
  3328. };
  3329. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3330. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3331. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3332. {
  3333. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3334. /* The multiple "Capture Source" controls confuse alsamixer
  3335. * So call somewhat different..
  3336. * FIXME: the controls appear in the "playback" view!
  3337. */
  3338. /* .name = "Capture Source", */
  3339. .name = "Input Source",
  3340. .count = 1,
  3341. .info = alc_mux_enum_info,
  3342. .get = alc_mux_enum_get,
  3343. .put = alc_mux_enum_put,
  3344. },
  3345. { } /* end */
  3346. };
  3347. /*
  3348. * initialization verbs
  3349. */
  3350. static struct hda_verb alc260_init_verbs[] = {
  3351. /* Line In pin widget for input */
  3352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3353. /* CD pin widget for input */
  3354. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3355. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3356. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3357. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3358. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3359. /* LINE-2 is used for line-out in rear */
  3360. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3361. /* select line-out */
  3362. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3363. /* LINE-OUT pin */
  3364. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3365. /* enable HP */
  3366. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3367. /* enable Mono */
  3368. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3369. /* mute capture amp left and right */
  3370. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3371. /* set connection select to line in (default select for this ADC) */
  3372. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3373. /* mute capture amp left and right */
  3374. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3375. /* set connection select to line in (default select for this ADC) */
  3376. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3377. /* set vol=0 Line-Out mixer amp left and right */
  3378. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3379. /* unmute pin widget amp left and right (no gain on this amp) */
  3380. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3381. /* set vol=0 HP mixer amp left and right */
  3382. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3383. /* unmute pin widget amp left and right (no gain on this amp) */
  3384. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3385. /* set vol=0 Mono mixer amp left and right */
  3386. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3387. /* unmute pin widget amp left and right (no gain on this amp) */
  3388. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3389. /* unmute LINE-2 out pin */
  3390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3391. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3392. * Line In 2 = 0x03
  3393. */
  3394. /* mute CD */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3396. /* mute Line In */
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3398. /* mute Mic */
  3399. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3400. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3401. /* mute Front out path */
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3403. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3404. /* mute Headphone out path */
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3406. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3407. /* mute Mono out path */
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3409. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3410. { }
  3411. };
  3412. #if 0 /* should be identical with alc260_init_verbs? */
  3413. static struct hda_verb alc260_hp_init_verbs[] = {
  3414. /* Headphone and output */
  3415. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3416. /* mono output */
  3417. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3418. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3419. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3421. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3422. /* Line In pin widget for input */
  3423. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3424. /* Line-2 pin widget for output */
  3425. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3426. /* CD pin widget for input */
  3427. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3428. /* unmute amp left and right */
  3429. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3430. /* set connection select to line in (default select for this ADC) */
  3431. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3432. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3433. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3434. /* mute pin widget amp left and right (no gain on this amp) */
  3435. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3436. /* unmute HP mixer amp left and right (volume = 0) */
  3437. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3438. /* mute pin widget amp left and right (no gain on this amp) */
  3439. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3440. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3441. * Line In 2 = 0x03
  3442. */
  3443. /* unmute CD */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3445. /* unmute Line In */
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3447. /* unmute Mic */
  3448. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3449. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3450. /* Unmute Front out path */
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3452. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3453. /* Unmute Headphone out path */
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3456. /* Unmute Mono out path */
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3458. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3459. { }
  3460. };
  3461. #endif
  3462. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3463. /* Line out and output */
  3464. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3465. /* mono output */
  3466. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3467. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3468. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3469. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3470. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3471. /* Line In pin widget for input */
  3472. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3473. /* Headphone pin widget for output */
  3474. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3475. /* CD pin widget for input */
  3476. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3477. /* unmute amp left and right */
  3478. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3479. /* set connection select to line in (default select for this ADC) */
  3480. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3481. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3482. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3483. /* mute pin widget amp left and right (no gain on this amp) */
  3484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3485. /* unmute HP mixer amp left and right (volume = 0) */
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3487. /* mute pin widget amp left and right (no gain on this amp) */
  3488. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3489. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3490. * Line In 2 = 0x03
  3491. */
  3492. /* unmute CD */
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3494. /* unmute Line In */
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3496. /* unmute Mic */
  3497. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3498. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3499. /* Unmute Front out path */
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3501. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3502. /* Unmute Headphone out path */
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3504. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3505. /* Unmute Mono out path */
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3507. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3508. { }
  3509. };
  3510. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3511. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3512. * audio = 0x16, internal speaker = 0x10.
  3513. */
  3514. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3515. /* Disable all GPIOs */
  3516. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3517. /* Internal speaker is connected to headphone pin */
  3518. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3519. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3521. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3522. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3523. /* Ensure all other unused pins are disabled and muted. */
  3524. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3527. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3529. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3530. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3531. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. /* Disable digital (SPDIF) pins */
  3533. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3535. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3536. * when acting as an output.
  3537. */
  3538. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3539. /* Start with output sum widgets muted and their output gains at min */
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3542. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3545. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3548. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3549. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3550. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3551. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3552. * If the pin mode is changed by the user the pin mode control will
  3553. * take care of enabling the pin's input/output buffers as needed.
  3554. * Therefore there's no need to enable the input buffer at this
  3555. * stage.
  3556. */
  3557. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3558. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3559. * mixer ctrl)
  3560. */
  3561. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3562. /* Mute capture amp left and right */
  3563. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3564. /* Set ADC connection select to match default mixer setting - line
  3565. * in (on mic1 pin)
  3566. */
  3567. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3568. /* Do the same for the second ADC: mute capture input amp and
  3569. * set ADC connection to line in (on mic1 pin)
  3570. */
  3571. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3572. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3573. /* Mute all inputs to mixer widget (even unconnected ones) */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3582. { }
  3583. };
  3584. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3585. * similar laptops (adapted from Fujitsu init verbs).
  3586. */
  3587. static struct hda_verb alc260_acer_init_verbs[] = {
  3588. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3589. * the headphone jack. Turn this on and rely on the standard mute
  3590. * methods whenever the user wants to turn these outputs off.
  3591. */
  3592. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3594. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3595. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3596. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3597. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3598. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3599. /* Line In jack is connected to Line1 pin */
  3600. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3601. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3603. /* Ensure all other unused pins are disabled and muted. */
  3604. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3605. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3606. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3607. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3610. /* Disable digital (SPDIF) pins */
  3611. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3613. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3614. * bus when acting as outputs.
  3615. */
  3616. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3617. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3618. /* Start with output sum widgets muted and their output gains at min */
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3621. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3624. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3627. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3628. /* Unmute Line-out pin widget amp left and right
  3629. * (no equiv mixer ctrl)
  3630. */
  3631. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3632. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3633. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3634. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3635. * inputs. If the pin mode is changed by the user the pin mode control
  3636. * will take care of enabling the pin's input/output buffers as needed.
  3637. * Therefore there's no need to enable the input buffer at this
  3638. * stage.
  3639. */
  3640. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3642. /* Mute capture amp left and right */
  3643. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3644. /* Set ADC connection select to match default mixer setting - mic
  3645. * (on mic1 pin)
  3646. */
  3647. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3648. /* Do similar with the second ADC: mute capture input amp and
  3649. * set ADC connection to mic to match ALSA's default state.
  3650. */
  3651. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3652. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3653. /* Mute all inputs to mixer widget (even unconnected ones) */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3661. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3662. { }
  3663. };
  3664. static struct hda_verb alc260_will_verbs[] = {
  3665. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3666. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3668. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3669. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3670. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3671. {}
  3672. };
  3673. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3674. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3675. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3676. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3677. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3679. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3680. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3681. {}
  3682. };
  3683. /* toggle speaker-output according to the hp-jack state */
  3684. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3685. {
  3686. unsigned int present;
  3687. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3688. present = snd_hda_codec_read(codec, 0x0f, 0,
  3689. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3690. if (present) {
  3691. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3692. snd_hda_codec_write(codec, 0x0f, 0,
  3693. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3694. } else {
  3695. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3696. snd_hda_codec_write(codec, 0x0f, 0,
  3697. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3698. }
  3699. }
  3700. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3701. unsigned int res)
  3702. {
  3703. if ((res >> 26) == ALC880_HP_EVENT)
  3704. alc260_replacer_672v_automute(codec);
  3705. }
  3706. /* Test configuration for debugging, modelled after the ALC880 test
  3707. * configuration.
  3708. */
  3709. #ifdef CONFIG_SND_DEBUG
  3710. static hda_nid_t alc260_test_dac_nids[1] = {
  3711. 0x02,
  3712. };
  3713. static hda_nid_t alc260_test_adc_nids[2] = {
  3714. 0x04, 0x05,
  3715. };
  3716. /* For testing the ALC260, each input MUX needs its own definition since
  3717. * the signal assignments are different. This assumes that the first ADC
  3718. * is NID 0x04.
  3719. */
  3720. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3721. {
  3722. .num_items = 7,
  3723. .items = {
  3724. { "MIC1 pin", 0x0 },
  3725. { "MIC2 pin", 0x1 },
  3726. { "LINE1 pin", 0x2 },
  3727. { "LINE2 pin", 0x3 },
  3728. { "CD pin", 0x4 },
  3729. { "LINE-OUT pin", 0x5 },
  3730. { "HP-OUT pin", 0x6 },
  3731. },
  3732. },
  3733. {
  3734. .num_items = 8,
  3735. .items = {
  3736. { "MIC1 pin", 0x0 },
  3737. { "MIC2 pin", 0x1 },
  3738. { "LINE1 pin", 0x2 },
  3739. { "LINE2 pin", 0x3 },
  3740. { "CD pin", 0x4 },
  3741. { "Mixer", 0x5 },
  3742. { "LINE-OUT pin", 0x6 },
  3743. { "HP-OUT pin", 0x7 },
  3744. },
  3745. },
  3746. };
  3747. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3748. /* Output driver widgets */
  3749. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3750. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3751. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3752. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3753. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3754. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3755. /* Modes for retasking pin widgets
  3756. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3757. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3758. * mention this restriction. At this stage it's not clear whether
  3759. * this behaviour is intentional or is a hardware bug in chip
  3760. * revisions available at least up until early 2006. Therefore for
  3761. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3762. * choices, but if it turns out that the lack of mic bias for these
  3763. * NIDs is intentional we could change their modes from
  3764. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3765. */
  3766. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3772. /* Loopback mixer controls */
  3773. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3774. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3775. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3776. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3777. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3778. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3779. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3780. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3781. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3782. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3783. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3784. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3786. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3787. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3788. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3789. /* Controls for GPIO pins, assuming they are configured as outputs */
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3792. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3794. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3795. * is ambigious as to which NID is which; testing on laptops which
  3796. * make this output available should provide clarification.
  3797. */
  3798. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3799. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3800. { } /* end */
  3801. };
  3802. static struct hda_verb alc260_test_init_verbs[] = {
  3803. /* Enable all GPIOs as outputs with an initial value of 0 */
  3804. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3805. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3806. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3807. /* Enable retasking pins as output, initially without power amp */
  3808. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. /* Disable digital (SPDIF) pins initially, but users can enable
  3815. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3816. * payload also sets the generation to 0, output to be in "consumer"
  3817. * PCM format, copyright asserted, no pre-emphasis and no validity
  3818. * control.
  3819. */
  3820. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3821. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3822. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3823. * OUT1 sum bus when acting as an output.
  3824. */
  3825. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3826. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3827. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3828. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3829. /* Start with output sum widgets muted and their output gains at min */
  3830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3832. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3837. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3838. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3839. /* Unmute retasking pin widget output buffers since the default
  3840. * state appears to be output. As the pin mode is changed by the
  3841. * user the pin mode control will take care of enabling the pin's
  3842. * input/output buffers as needed.
  3843. */
  3844. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. /* Also unmute the mono-out pin widget */
  3851. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. /* Mute capture amp left and right */
  3853. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3854. /* Set ADC connection select to match default mixer setting (mic1
  3855. * pin)
  3856. */
  3857. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3858. /* Do the same for the second ADC: mute capture input amp and
  3859. * set ADC connection to mic1 pin
  3860. */
  3861. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3862. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3863. /* Mute all inputs to mixer widget (even unconnected ones) */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3872. { }
  3873. };
  3874. #endif
  3875. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3876. .substreams = 1,
  3877. .channels_min = 2,
  3878. .channels_max = 2,
  3879. };
  3880. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3881. .substreams = 1,
  3882. .channels_min = 2,
  3883. .channels_max = 2,
  3884. };
  3885. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3886. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3887. /*
  3888. * for BIOS auto-configuration
  3889. */
  3890. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3891. const char *pfx)
  3892. {
  3893. hda_nid_t nid_vol;
  3894. unsigned long vol_val, sw_val;
  3895. char name[32];
  3896. int err;
  3897. if (nid >= 0x0f && nid < 0x11) {
  3898. nid_vol = nid - 0x7;
  3899. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3900. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3901. } else if (nid == 0x11) {
  3902. nid_vol = nid - 0x7;
  3903. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3904. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3905. } else if (nid >= 0x12 && nid <= 0x15) {
  3906. nid_vol = 0x08;
  3907. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3908. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3909. } else
  3910. return 0; /* N/A */
  3911. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3912. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3913. if (err < 0)
  3914. return err;
  3915. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3916. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3917. if (err < 0)
  3918. return err;
  3919. return 1;
  3920. }
  3921. /* add playback controls from the parsed DAC table */
  3922. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3923. const struct auto_pin_cfg *cfg)
  3924. {
  3925. hda_nid_t nid;
  3926. int err;
  3927. spec->multiout.num_dacs = 1;
  3928. spec->multiout.dac_nids = spec->private_dac_nids;
  3929. spec->multiout.dac_nids[0] = 0x02;
  3930. nid = cfg->line_out_pins[0];
  3931. if (nid) {
  3932. err = alc260_add_playback_controls(spec, nid, "Front");
  3933. if (err < 0)
  3934. return err;
  3935. }
  3936. nid = cfg->speaker_pins[0];
  3937. if (nid) {
  3938. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3939. if (err < 0)
  3940. return err;
  3941. }
  3942. nid = cfg->hp_pins[0];
  3943. if (nid) {
  3944. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3945. if (err < 0)
  3946. return err;
  3947. }
  3948. return 0;
  3949. }
  3950. /* create playback/capture controls for input pins */
  3951. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3952. const struct auto_pin_cfg *cfg)
  3953. {
  3954. struct hda_input_mux *imux = &spec->private_imux;
  3955. int i, err, idx;
  3956. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3957. if (cfg->input_pins[i] >= 0x12) {
  3958. idx = cfg->input_pins[i] - 0x12;
  3959. err = new_analog_input(spec, cfg->input_pins[i],
  3960. auto_pin_cfg_labels[i], idx,
  3961. 0x07);
  3962. if (err < 0)
  3963. return err;
  3964. imux->items[imux->num_items].label =
  3965. auto_pin_cfg_labels[i];
  3966. imux->items[imux->num_items].index = idx;
  3967. imux->num_items++;
  3968. }
  3969. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3970. idx = cfg->input_pins[i] - 0x09;
  3971. err = new_analog_input(spec, cfg->input_pins[i],
  3972. auto_pin_cfg_labels[i], idx,
  3973. 0x07);
  3974. if (err < 0)
  3975. return err;
  3976. imux->items[imux->num_items].label =
  3977. auto_pin_cfg_labels[i];
  3978. imux->items[imux->num_items].index = idx;
  3979. imux->num_items++;
  3980. }
  3981. }
  3982. return 0;
  3983. }
  3984. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3985. hda_nid_t nid, int pin_type,
  3986. int sel_idx)
  3987. {
  3988. /* set as output */
  3989. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3990. pin_type);
  3991. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3992. AMP_OUT_UNMUTE);
  3993. /* need the manual connection? */
  3994. if (nid >= 0x12) {
  3995. int idx = nid - 0x12;
  3996. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3997. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3998. }
  3999. }
  4000. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4001. {
  4002. struct alc_spec *spec = codec->spec;
  4003. hda_nid_t nid;
  4004. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4005. nid = spec->autocfg.line_out_pins[0];
  4006. if (nid) {
  4007. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4008. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4009. }
  4010. nid = spec->autocfg.speaker_pins[0];
  4011. if (nid)
  4012. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4013. nid = spec->autocfg.hp_pins[0];
  4014. if (nid)
  4015. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4016. }
  4017. #define ALC260_PIN_CD_NID 0x16
  4018. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4019. {
  4020. struct alc_spec *spec = codec->spec;
  4021. int i;
  4022. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4023. hda_nid_t nid = spec->autocfg.input_pins[i];
  4024. if (nid >= 0x12) {
  4025. snd_hda_codec_write(codec, nid, 0,
  4026. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4027. i <= AUTO_PIN_FRONT_MIC ?
  4028. PIN_VREF80 : PIN_IN);
  4029. if (nid != ALC260_PIN_CD_NID)
  4030. snd_hda_codec_write(codec, nid, 0,
  4031. AC_VERB_SET_AMP_GAIN_MUTE,
  4032. AMP_OUT_MUTE);
  4033. }
  4034. }
  4035. }
  4036. /*
  4037. * generic initialization of ADC, input mixers and output mixers
  4038. */
  4039. static struct hda_verb alc260_volume_init_verbs[] = {
  4040. /*
  4041. * Unmute ADC0-1 and set the default input to mic-in
  4042. */
  4043. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4044. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4045. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4046. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4047. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4048. * mixer widget
  4049. * Note: PASD motherboards uses the Line In 2 as the input for
  4050. * front panel mic (mic 2)
  4051. */
  4052. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4053. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4058. /*
  4059. * Set up output mixers (0x08 - 0x0a)
  4060. */
  4061. /* set vol=0 to output mixers */
  4062. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4063. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4064. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4065. /* set up input amps for analog loopback */
  4066. /* Amp Indices: DAC = 0, mixer = 1 */
  4067. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4068. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4069. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4070. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4071. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4072. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4073. { }
  4074. };
  4075. static int alc260_parse_auto_config(struct hda_codec *codec)
  4076. {
  4077. struct alc_spec *spec = codec->spec;
  4078. unsigned int wcap;
  4079. int err;
  4080. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4081. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4082. alc260_ignore);
  4083. if (err < 0)
  4084. return err;
  4085. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4086. if (err < 0)
  4087. return err;
  4088. if (!spec->kctl_alloc)
  4089. return 0; /* can't find valid BIOS pin config */
  4090. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4091. if (err < 0)
  4092. return err;
  4093. spec->multiout.max_channels = 2;
  4094. if (spec->autocfg.dig_out_pin)
  4095. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4096. if (spec->kctl_alloc)
  4097. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4098. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4099. spec->num_mux_defs = 1;
  4100. spec->input_mux = &spec->private_imux;
  4101. /* check whether NID 0x04 is valid */
  4102. wcap = get_wcaps(codec, 0x04);
  4103. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4104. if (wcap != AC_WID_AUD_IN) {
  4105. spec->adc_nids = alc260_adc_nids_alt;
  4106. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4107. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4108. } else {
  4109. spec->adc_nids = alc260_adc_nids;
  4110. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4111. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4112. }
  4113. spec->num_mixers++;
  4114. return 1;
  4115. }
  4116. /* additional initialization for auto-configuration model */
  4117. static void alc260_auto_init(struct hda_codec *codec)
  4118. {
  4119. alc260_auto_init_multi_out(codec);
  4120. alc260_auto_init_analog_input(codec);
  4121. }
  4122. /*
  4123. * ALC260 configurations
  4124. */
  4125. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4126. [ALC260_BASIC] = "basic",
  4127. [ALC260_HP] = "hp",
  4128. [ALC260_HP_3013] = "hp-3013",
  4129. [ALC260_FUJITSU_S702X] = "fujitsu",
  4130. [ALC260_ACER] = "acer",
  4131. [ALC260_WILL] = "will",
  4132. [ALC260_REPLACER_672V] = "replacer",
  4133. #ifdef CONFIG_SND_DEBUG
  4134. [ALC260_TEST] = "test",
  4135. #endif
  4136. [ALC260_AUTO] = "auto",
  4137. };
  4138. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4139. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4140. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4141. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4142. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4143. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4144. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4145. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4146. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4147. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4148. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4149. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4150. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4151. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4152. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4153. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4154. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4155. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4156. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4157. {}
  4158. };
  4159. static struct alc_config_preset alc260_presets[] = {
  4160. [ALC260_BASIC] = {
  4161. .mixers = { alc260_base_output_mixer,
  4162. alc260_input_mixer,
  4163. alc260_pc_beep_mixer,
  4164. alc260_capture_mixer },
  4165. .init_verbs = { alc260_init_verbs },
  4166. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4167. .dac_nids = alc260_dac_nids,
  4168. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4169. .adc_nids = alc260_adc_nids,
  4170. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4171. .channel_mode = alc260_modes,
  4172. .input_mux = &alc260_capture_source,
  4173. },
  4174. [ALC260_HP] = {
  4175. .mixers = { alc260_base_output_mixer,
  4176. alc260_input_mixer,
  4177. alc260_capture_alt_mixer },
  4178. .init_verbs = { alc260_init_verbs },
  4179. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4180. .dac_nids = alc260_dac_nids,
  4181. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4182. .adc_nids = alc260_hp_adc_nids,
  4183. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4184. .channel_mode = alc260_modes,
  4185. .input_mux = &alc260_capture_source,
  4186. },
  4187. [ALC260_HP_3013] = {
  4188. .mixers = { alc260_hp_3013_mixer,
  4189. alc260_input_mixer,
  4190. alc260_capture_alt_mixer },
  4191. .init_verbs = { alc260_hp_3013_init_verbs },
  4192. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4193. .dac_nids = alc260_dac_nids,
  4194. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4195. .adc_nids = alc260_hp_adc_nids,
  4196. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4197. .channel_mode = alc260_modes,
  4198. .input_mux = &alc260_capture_source,
  4199. },
  4200. [ALC260_FUJITSU_S702X] = {
  4201. .mixers = { alc260_fujitsu_mixer,
  4202. alc260_capture_mixer },
  4203. .init_verbs = { alc260_fujitsu_init_verbs },
  4204. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4205. .dac_nids = alc260_dac_nids,
  4206. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4207. .adc_nids = alc260_dual_adc_nids,
  4208. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4209. .channel_mode = alc260_modes,
  4210. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4211. .input_mux = alc260_fujitsu_capture_sources,
  4212. },
  4213. [ALC260_ACER] = {
  4214. .mixers = { alc260_acer_mixer,
  4215. alc260_capture_mixer },
  4216. .init_verbs = { alc260_acer_init_verbs },
  4217. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4218. .dac_nids = alc260_dac_nids,
  4219. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4220. .adc_nids = alc260_dual_adc_nids,
  4221. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4222. .channel_mode = alc260_modes,
  4223. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4224. .input_mux = alc260_acer_capture_sources,
  4225. },
  4226. [ALC260_WILL] = {
  4227. .mixers = { alc260_will_mixer,
  4228. alc260_capture_mixer },
  4229. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4230. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4231. .dac_nids = alc260_dac_nids,
  4232. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4233. .adc_nids = alc260_adc_nids,
  4234. .dig_out_nid = ALC260_DIGOUT_NID,
  4235. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4236. .channel_mode = alc260_modes,
  4237. .input_mux = &alc260_capture_source,
  4238. },
  4239. [ALC260_REPLACER_672V] = {
  4240. .mixers = { alc260_replacer_672v_mixer,
  4241. alc260_capture_mixer },
  4242. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4243. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4244. .dac_nids = alc260_dac_nids,
  4245. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4246. .adc_nids = alc260_adc_nids,
  4247. .dig_out_nid = ALC260_DIGOUT_NID,
  4248. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4249. .channel_mode = alc260_modes,
  4250. .input_mux = &alc260_capture_source,
  4251. .unsol_event = alc260_replacer_672v_unsol_event,
  4252. .init_hook = alc260_replacer_672v_automute,
  4253. },
  4254. #ifdef CONFIG_SND_DEBUG
  4255. [ALC260_TEST] = {
  4256. .mixers = { alc260_test_mixer,
  4257. alc260_capture_mixer },
  4258. .init_verbs = { alc260_test_init_verbs },
  4259. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4260. .dac_nids = alc260_test_dac_nids,
  4261. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4262. .adc_nids = alc260_test_adc_nids,
  4263. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4264. .channel_mode = alc260_modes,
  4265. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4266. .input_mux = alc260_test_capture_sources,
  4267. },
  4268. #endif
  4269. };
  4270. static int patch_alc260(struct hda_codec *codec)
  4271. {
  4272. struct alc_spec *spec;
  4273. int err, board_config;
  4274. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4275. if (spec == NULL)
  4276. return -ENOMEM;
  4277. codec->spec = spec;
  4278. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4279. alc260_models,
  4280. alc260_cfg_tbl);
  4281. if (board_config < 0) {
  4282. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4283. "trying auto-probe from BIOS...\n");
  4284. board_config = ALC260_AUTO;
  4285. }
  4286. if (board_config == ALC260_AUTO) {
  4287. /* automatic parse from the BIOS config */
  4288. err = alc260_parse_auto_config(codec);
  4289. if (err < 0) {
  4290. alc_free(codec);
  4291. return err;
  4292. } else if (!err) {
  4293. printk(KERN_INFO
  4294. "hda_codec: Cannot set up configuration "
  4295. "from BIOS. Using base mode...\n");
  4296. board_config = ALC260_BASIC;
  4297. }
  4298. }
  4299. if (board_config != ALC260_AUTO)
  4300. setup_preset(spec, &alc260_presets[board_config]);
  4301. spec->stream_name_analog = "ALC260 Analog";
  4302. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4303. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4304. spec->stream_name_digital = "ALC260 Digital";
  4305. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4306. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4307. codec->patch_ops = alc_patch_ops;
  4308. if (board_config == ALC260_AUTO)
  4309. spec->init_hook = alc260_auto_init;
  4310. return 0;
  4311. }
  4312. /*
  4313. * ALC882 support
  4314. *
  4315. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4316. * configuration. Each pin widget can choose any input DACs and a mixer.
  4317. * Each ADC is connected from a mixer of all inputs. This makes possible
  4318. * 6-channel independent captures.
  4319. *
  4320. * In addition, an independent DAC for the multi-playback (not used in this
  4321. * driver yet).
  4322. */
  4323. #define ALC882_DIGOUT_NID 0x06
  4324. #define ALC882_DIGIN_NID 0x0a
  4325. static struct hda_channel_mode alc882_ch_modes[1] = {
  4326. { 8, NULL }
  4327. };
  4328. static hda_nid_t alc882_dac_nids[4] = {
  4329. /* front, rear, clfe, rear_surr */
  4330. 0x02, 0x03, 0x04, 0x05
  4331. };
  4332. /* identical with ALC880 */
  4333. #define alc882_adc_nids alc880_adc_nids
  4334. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4335. /* input MUX */
  4336. /* FIXME: should be a matrix-type input source selection */
  4337. static struct hda_input_mux alc882_capture_source = {
  4338. .num_items = 4,
  4339. .items = {
  4340. { "Mic", 0x0 },
  4341. { "Front Mic", 0x1 },
  4342. { "Line", 0x2 },
  4343. { "CD", 0x4 },
  4344. },
  4345. };
  4346. #define alc882_mux_enum_info alc_mux_enum_info
  4347. #define alc882_mux_enum_get alc_mux_enum_get
  4348. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4349. struct snd_ctl_elem_value *ucontrol)
  4350. {
  4351. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4352. struct alc_spec *spec = codec->spec;
  4353. const struct hda_input_mux *imux = spec->input_mux;
  4354. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4355. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4356. hda_nid_t nid = capture_mixers[adc_idx];
  4357. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4358. unsigned int i, idx;
  4359. idx = ucontrol->value.enumerated.item[0];
  4360. if (idx >= imux->num_items)
  4361. idx = imux->num_items - 1;
  4362. if (*cur_val == idx && !codec->in_resume)
  4363. return 0;
  4364. for (i = 0; i < imux->num_items; i++) {
  4365. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4366. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4367. v | (imux->items[i].index << 8));
  4368. }
  4369. *cur_val = idx;
  4370. return 1;
  4371. }
  4372. /*
  4373. * 2ch mode
  4374. */
  4375. static struct hda_verb alc882_3ST_ch2_init[] = {
  4376. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4377. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4378. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4379. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4380. { } /* end */
  4381. };
  4382. /*
  4383. * 6ch mode
  4384. */
  4385. static struct hda_verb alc882_3ST_ch6_init[] = {
  4386. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4387. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4388. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4389. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4390. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4391. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4392. { } /* end */
  4393. };
  4394. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4395. { 2, alc882_3ST_ch2_init },
  4396. { 6, alc882_3ST_ch6_init },
  4397. };
  4398. /*
  4399. * 6ch mode
  4400. */
  4401. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4402. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4403. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4404. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4405. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4406. { } /* end */
  4407. };
  4408. /*
  4409. * 8ch mode
  4410. */
  4411. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4412. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4413. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4414. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4415. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4416. { } /* end */
  4417. };
  4418. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4419. { 6, alc882_sixstack_ch6_init },
  4420. { 8, alc882_sixstack_ch8_init },
  4421. };
  4422. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4423. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4424. */
  4425. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4427. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4428. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4429. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4430. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4431. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4432. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4433. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4434. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4435. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4436. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4443. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4445. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4446. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4447. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4448. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4449. { } /* end */
  4450. };
  4451. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4452. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4453. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4454. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4456. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4459. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4460. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4461. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4462. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4463. { } /* end */
  4464. };
  4465. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4466. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4467. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4468. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4469. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4470. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4471. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4472. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4473. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4474. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4475. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4476. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4477. { } /* end */
  4478. };
  4479. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4480. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4481. */
  4482. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4483. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4486. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4487. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4488. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4490. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4493. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4494. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4495. { } /* end */
  4496. };
  4497. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4498. {
  4499. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4500. .name = "Channel Mode",
  4501. .info = alc_ch_mode_info,
  4502. .get = alc_ch_mode_get,
  4503. .put = alc_ch_mode_put,
  4504. },
  4505. { } /* end */
  4506. };
  4507. static struct hda_verb alc882_init_verbs[] = {
  4508. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4509. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4510. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4511. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4512. /* Rear mixer */
  4513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4514. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4515. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4516. /* CLFE mixer */
  4517. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4518. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4519. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4520. /* Side mixer */
  4521. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4522. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4523. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4524. /* Front Pin: output 0 (0x0c) */
  4525. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4526. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4527. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4528. /* Rear Pin: output 1 (0x0d) */
  4529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4531. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4532. /* CLFE Pin: output 2 (0x0e) */
  4533. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4534. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4535. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4536. /* Side Pin: output 3 (0x0f) */
  4537. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4538. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4539. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4540. /* Mic (rear) pin: input vref at 80% */
  4541. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4542. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4543. /* Front Mic pin: input vref at 80% */
  4544. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4545. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4546. /* Line In pin: input */
  4547. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4548. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4549. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4550. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4551. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4552. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4553. /* CD pin widget for input */
  4554. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4555. /* FIXME: use matrix-type input source selection */
  4556. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4557. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4558. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4559. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4560. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4561. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4562. /* Input mixer2 */
  4563. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4564. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4565. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4566. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4567. /* Input mixer3 */
  4568. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4569. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4570. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4571. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4572. /* ADC1: mute amp left and right */
  4573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4574. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4575. /* ADC2: mute amp left and right */
  4576. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4577. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4578. /* ADC3: mute amp left and right */
  4579. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4580. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4581. { }
  4582. };
  4583. static struct hda_verb alc882_eapd_verbs[] = {
  4584. /* change to EAPD mode */
  4585. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4586. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4587. { }
  4588. };
  4589. /* Mac Pro test */
  4590. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4591. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4592. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4593. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4594. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4595. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4596. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4597. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4598. { } /* end */
  4599. };
  4600. static struct hda_verb alc882_macpro_init_verbs[] = {
  4601. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4602. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4604. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4605. /* Front Pin: output 0 (0x0c) */
  4606. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4607. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4608. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4609. /* Front Mic pin: input vref at 80% */
  4610. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4611. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4612. /* Speaker: output */
  4613. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4614. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4615. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4616. /* Headphone output (output 0 - 0x0c) */
  4617. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4618. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4619. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4620. /* FIXME: use matrix-type input source selection */
  4621. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4622. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4623. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4624. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4625. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4626. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4627. /* Input mixer2 */
  4628. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4629. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4630. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4631. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4632. /* Input mixer3 */
  4633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4635. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4636. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4637. /* ADC1: mute amp left and right */
  4638. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4639. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4640. /* ADC2: mute amp left and right */
  4641. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4642. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4643. /* ADC3: mute amp left and right */
  4644. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4645. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4646. { }
  4647. };
  4648. /* iMac 24 mixer. */
  4649. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4650. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4651. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4652. { } /* end */
  4653. };
  4654. /* iMac 24 init verbs. */
  4655. static struct hda_verb alc885_imac24_init_verbs[] = {
  4656. /* Internal speakers: output 0 (0x0c) */
  4657. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4658. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4659. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4660. /* Internal speakers: output 0 (0x0c) */
  4661. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4662. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4663. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4664. /* Headphone: output 0 (0x0c) */
  4665. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4666. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4667. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4668. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4669. /* Front Mic: input vref at 80% */
  4670. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4671. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4672. { }
  4673. };
  4674. /* Toggle speaker-output according to the hp-jack state */
  4675. static void alc885_imac24_automute(struct hda_codec *codec)
  4676. {
  4677. unsigned int present;
  4678. present = snd_hda_codec_read(codec, 0x14, 0,
  4679. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4680. snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
  4681. 0x80, present ? 0x80 : 0);
  4682. snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
  4683. 0x80, present ? 0x80 : 0);
  4684. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
  4685. 0x80, present ? 0x80 : 0);
  4686. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
  4687. 0x80, present ? 0x80 : 0);
  4688. }
  4689. /* Processes unsolicited events. */
  4690. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4691. unsigned int res)
  4692. {
  4693. /* Headphone insertion or removal. */
  4694. if ((res >> 26) == ALC880_HP_EVENT)
  4695. alc885_imac24_automute(codec);
  4696. }
  4697. static struct hda_verb alc882_targa_verbs[] = {
  4698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4699. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4700. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4701. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4702. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4703. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4704. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4705. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4706. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4707. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4708. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4709. { } /* end */
  4710. };
  4711. /* toggle speaker-output according to the hp-jack state */
  4712. static void alc882_targa_automute(struct hda_codec *codec)
  4713. {
  4714. unsigned int present;
  4715. present = snd_hda_codec_read(codec, 0x14, 0,
  4716. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4717. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4718. 0x80, present ? 0x80 : 0);
  4719. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4720. 0x80, present ? 0x80 : 0);
  4721. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4722. }
  4723. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4724. {
  4725. /* Looks like the unsol event is incompatible with the standard
  4726. * definition. 4bit tag is placed at 26 bit!
  4727. */
  4728. if (((res >> 26) == ALC880_HP_EVENT)) {
  4729. alc882_targa_automute(codec);
  4730. }
  4731. }
  4732. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4733. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4734. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4735. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4736. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4737. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4738. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4739. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4740. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4741. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4742. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4743. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4744. { } /* end */
  4745. };
  4746. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4747. {
  4748. unsigned int gpiostate, gpiomask, gpiodir;
  4749. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4750. AC_VERB_GET_GPIO_DATA, 0);
  4751. if (!muted)
  4752. gpiostate |= (1 << pin);
  4753. else
  4754. gpiostate &= ~(1 << pin);
  4755. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4756. AC_VERB_GET_GPIO_MASK, 0);
  4757. gpiomask |= (1 << pin);
  4758. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4759. AC_VERB_GET_GPIO_DIRECTION, 0);
  4760. gpiodir |= (1 << pin);
  4761. snd_hda_codec_write(codec, codec->afg, 0,
  4762. AC_VERB_SET_GPIO_MASK, gpiomask);
  4763. snd_hda_codec_write(codec, codec->afg, 0,
  4764. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4765. msleep(1);
  4766. snd_hda_codec_write(codec, codec->afg, 0,
  4767. AC_VERB_SET_GPIO_DATA, gpiostate);
  4768. }
  4769. /*
  4770. * generic initialization of ADC, input mixers and output mixers
  4771. */
  4772. static struct hda_verb alc882_auto_init_verbs[] = {
  4773. /*
  4774. * Unmute ADC0-2 and set the default input to mic-in
  4775. */
  4776. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4777. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4778. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4779. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4780. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4781. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4782. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4783. * mixer widget
  4784. * Note: PASD motherboards uses the Line In 2 as the input for
  4785. * front panel mic (mic 2)
  4786. */
  4787. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4788. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4789. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4790. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4791. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4793. /*
  4794. * Set up output mixers (0x0c - 0x0f)
  4795. */
  4796. /* set vol=0 to output mixers */
  4797. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4798. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4799. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4800. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4801. /* set up input amps for analog loopback */
  4802. /* Amp Indices: DAC = 0, mixer = 1 */
  4803. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4804. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4805. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4806. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4807. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4808. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4809. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4810. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4811. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4812. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4813. /* FIXME: use matrix-type input source selection */
  4814. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4815. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4816. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4817. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4818. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4819. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4820. /* Input mixer2 */
  4821. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4822. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4823. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4824. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4825. /* Input mixer3 */
  4826. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4827. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4828. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4829. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4830. { }
  4831. };
  4832. /* capture mixer elements */
  4833. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4834. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4835. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4836. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4837. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4838. {
  4839. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4840. /* The multiple "Capture Source" controls confuse alsamixer
  4841. * So call somewhat different..
  4842. * FIXME: the controls appear in the "playback" view!
  4843. */
  4844. /* .name = "Capture Source", */
  4845. .name = "Input Source",
  4846. .count = 2,
  4847. .info = alc882_mux_enum_info,
  4848. .get = alc882_mux_enum_get,
  4849. .put = alc882_mux_enum_put,
  4850. },
  4851. { } /* end */
  4852. };
  4853. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4854. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4855. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4856. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4857. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4858. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4859. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4860. {
  4861. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4862. /* The multiple "Capture Source" controls confuse alsamixer
  4863. * So call somewhat different..
  4864. * FIXME: the controls appear in the "playback" view!
  4865. */
  4866. /* .name = "Capture Source", */
  4867. .name = "Input Source",
  4868. .count = 3,
  4869. .info = alc882_mux_enum_info,
  4870. .get = alc882_mux_enum_get,
  4871. .put = alc882_mux_enum_put,
  4872. },
  4873. { } /* end */
  4874. };
  4875. /* pcm configuration: identiacal with ALC880 */
  4876. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4877. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4878. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4879. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4880. /*
  4881. * configuration and preset
  4882. */
  4883. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4884. [ALC882_3ST_DIG] = "3stack-dig",
  4885. [ALC882_6ST_DIG] = "6stack-dig",
  4886. [ALC882_ARIMA] = "arima",
  4887. [ALC882_W2JC] = "w2jc",
  4888. [ALC885_MACPRO] = "macpro",
  4889. [ALC885_IMAC24] = "imac24",
  4890. [ALC882_AUTO] = "auto",
  4891. };
  4892. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4893. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4894. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4895. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4896. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4897. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4898. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4899. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  4900. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4901. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4902. {}
  4903. };
  4904. static struct alc_config_preset alc882_presets[] = {
  4905. [ALC882_3ST_DIG] = {
  4906. .mixers = { alc882_base_mixer },
  4907. .init_verbs = { alc882_init_verbs },
  4908. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4909. .dac_nids = alc882_dac_nids,
  4910. .dig_out_nid = ALC882_DIGOUT_NID,
  4911. .dig_in_nid = ALC882_DIGIN_NID,
  4912. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4913. .channel_mode = alc882_ch_modes,
  4914. .need_dac_fix = 1,
  4915. .input_mux = &alc882_capture_source,
  4916. },
  4917. [ALC882_6ST_DIG] = {
  4918. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4919. .init_verbs = { alc882_init_verbs },
  4920. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4921. .dac_nids = alc882_dac_nids,
  4922. .dig_out_nid = ALC882_DIGOUT_NID,
  4923. .dig_in_nid = ALC882_DIGIN_NID,
  4924. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4925. .channel_mode = alc882_sixstack_modes,
  4926. .input_mux = &alc882_capture_source,
  4927. },
  4928. [ALC882_ARIMA] = {
  4929. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4930. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4931. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4932. .dac_nids = alc882_dac_nids,
  4933. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4934. .channel_mode = alc882_sixstack_modes,
  4935. .input_mux = &alc882_capture_source,
  4936. },
  4937. [ALC882_W2JC] = {
  4938. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4939. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4940. alc880_gpio1_init_verbs },
  4941. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4942. .dac_nids = alc882_dac_nids,
  4943. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4944. .channel_mode = alc880_threestack_modes,
  4945. .need_dac_fix = 1,
  4946. .input_mux = &alc882_capture_source,
  4947. .dig_out_nid = ALC882_DIGOUT_NID,
  4948. },
  4949. [ALC885_MACPRO] = {
  4950. .mixers = { alc882_macpro_mixer },
  4951. .init_verbs = { alc882_macpro_init_verbs },
  4952. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4953. .dac_nids = alc882_dac_nids,
  4954. .dig_out_nid = ALC882_DIGOUT_NID,
  4955. .dig_in_nid = ALC882_DIGIN_NID,
  4956. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4957. .channel_mode = alc882_ch_modes,
  4958. .input_mux = &alc882_capture_source,
  4959. },
  4960. [ALC885_IMAC24] = {
  4961. .mixers = { alc885_imac24_mixer },
  4962. .init_verbs = { alc885_imac24_init_verbs },
  4963. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4964. .dac_nids = alc882_dac_nids,
  4965. .dig_out_nid = ALC882_DIGOUT_NID,
  4966. .dig_in_nid = ALC882_DIGIN_NID,
  4967. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4968. .channel_mode = alc882_ch_modes,
  4969. .input_mux = &alc882_capture_source,
  4970. .unsol_event = alc885_imac24_unsol_event,
  4971. .init_hook = alc885_imac24_automute,
  4972. },
  4973. [ALC882_TARGA] = {
  4974. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4975. alc882_capture_mixer },
  4976. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4977. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4978. .dac_nids = alc882_dac_nids,
  4979. .dig_out_nid = ALC882_DIGOUT_NID,
  4980. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4981. .adc_nids = alc882_adc_nids,
  4982. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4983. .channel_mode = alc882_3ST_6ch_modes,
  4984. .need_dac_fix = 1,
  4985. .input_mux = &alc882_capture_source,
  4986. .unsol_event = alc882_targa_unsol_event,
  4987. .init_hook = alc882_targa_automute,
  4988. },
  4989. [ALC882_ASUS_A7J] = {
  4990. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4991. alc882_capture_mixer },
  4992. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4993. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4994. .dac_nids = alc882_dac_nids,
  4995. .dig_out_nid = ALC882_DIGOUT_NID,
  4996. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4997. .adc_nids = alc882_adc_nids,
  4998. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4999. .channel_mode = alc882_3ST_6ch_modes,
  5000. .need_dac_fix = 1,
  5001. .input_mux = &alc882_capture_source,
  5002. },
  5003. };
  5004. /*
  5005. * Pin config fixes
  5006. */
  5007. enum {
  5008. PINFIX_ABIT_AW9D_MAX
  5009. };
  5010. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5011. { 0x15, 0x01080104 }, /* side */
  5012. { 0x16, 0x01011012 }, /* rear */
  5013. { 0x17, 0x01016011 }, /* clfe */
  5014. { }
  5015. };
  5016. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5017. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5018. };
  5019. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5020. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5021. {}
  5022. };
  5023. /*
  5024. * BIOS auto configuration
  5025. */
  5026. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5027. hda_nid_t nid, int pin_type,
  5028. int dac_idx)
  5029. {
  5030. /* set as output */
  5031. struct alc_spec *spec = codec->spec;
  5032. int idx;
  5033. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5034. idx = 4;
  5035. else
  5036. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5037. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5038. pin_type);
  5039. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5040. AMP_OUT_UNMUTE);
  5041. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5042. }
  5043. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5044. {
  5045. struct alc_spec *spec = codec->spec;
  5046. int i;
  5047. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5048. for (i = 0; i <= HDA_SIDE; i++) {
  5049. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5050. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5051. if (nid)
  5052. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5053. i);
  5054. }
  5055. }
  5056. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5057. {
  5058. struct alc_spec *spec = codec->spec;
  5059. hda_nid_t pin;
  5060. pin = spec->autocfg.hp_pins[0];
  5061. if (pin) /* connect to front */
  5062. /* use dac 0 */
  5063. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5064. }
  5065. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5066. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5067. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5068. {
  5069. struct alc_spec *spec = codec->spec;
  5070. int i;
  5071. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5072. hda_nid_t nid = spec->autocfg.input_pins[i];
  5073. if (alc882_is_input_pin(nid)) {
  5074. snd_hda_codec_write(codec, nid, 0,
  5075. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5076. i <= AUTO_PIN_FRONT_MIC ?
  5077. PIN_VREF80 : PIN_IN);
  5078. if (nid != ALC882_PIN_CD_NID)
  5079. snd_hda_codec_write(codec, nid, 0,
  5080. AC_VERB_SET_AMP_GAIN_MUTE,
  5081. AMP_OUT_MUTE);
  5082. }
  5083. }
  5084. }
  5085. /* almost identical with ALC880 parser... */
  5086. static int alc882_parse_auto_config(struct hda_codec *codec)
  5087. {
  5088. struct alc_spec *spec = codec->spec;
  5089. int err = alc880_parse_auto_config(codec);
  5090. if (err < 0)
  5091. return err;
  5092. else if (err > 0)
  5093. /* hack - override the init verbs */
  5094. spec->init_verbs[0] = alc882_auto_init_verbs;
  5095. return err;
  5096. }
  5097. /* additional initialization for auto-configuration model */
  5098. static void alc882_auto_init(struct hda_codec *codec)
  5099. {
  5100. alc882_auto_init_multi_out(codec);
  5101. alc882_auto_init_hp_out(codec);
  5102. alc882_auto_init_analog_input(codec);
  5103. }
  5104. static int patch_alc882(struct hda_codec *codec)
  5105. {
  5106. struct alc_spec *spec;
  5107. int err, board_config;
  5108. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5109. if (spec == NULL)
  5110. return -ENOMEM;
  5111. codec->spec = spec;
  5112. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5113. alc882_models,
  5114. alc882_cfg_tbl);
  5115. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5116. /* Pick up systems that don't supply PCI SSID */
  5117. switch (codec->subsystem_id) {
  5118. case 0x106b0c00: /* Mac Pro */
  5119. board_config = ALC885_MACPRO;
  5120. break;
  5121. case 0x106b1000: /* iMac 24 */
  5122. board_config = ALC885_IMAC24;
  5123. break;
  5124. default:
  5125. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5126. "trying auto-probe from BIOS...\n");
  5127. board_config = ALC882_AUTO;
  5128. }
  5129. }
  5130. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5131. if (board_config == ALC882_AUTO) {
  5132. /* automatic parse from the BIOS config */
  5133. err = alc882_parse_auto_config(codec);
  5134. if (err < 0) {
  5135. alc_free(codec);
  5136. return err;
  5137. } else if (!err) {
  5138. printk(KERN_INFO
  5139. "hda_codec: Cannot set up configuration "
  5140. "from BIOS. Using base mode...\n");
  5141. board_config = ALC882_3ST_DIG;
  5142. }
  5143. }
  5144. if (board_config != ALC882_AUTO)
  5145. setup_preset(spec, &alc882_presets[board_config]);
  5146. if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
  5147. alc882_gpio_mute(codec, 0, 0);
  5148. alc882_gpio_mute(codec, 1, 0);
  5149. }
  5150. spec->stream_name_analog = "ALC882 Analog";
  5151. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5152. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5153. spec->stream_name_digital = "ALC882 Digital";
  5154. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5155. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5156. if (!spec->adc_nids && spec->input_mux) {
  5157. /* check whether NID 0x07 is valid */
  5158. unsigned int wcap = get_wcaps(codec, 0x07);
  5159. /* get type */
  5160. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5161. if (wcap != AC_WID_AUD_IN) {
  5162. spec->adc_nids = alc882_adc_nids_alt;
  5163. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5164. spec->mixers[spec->num_mixers] =
  5165. alc882_capture_alt_mixer;
  5166. spec->num_mixers++;
  5167. } else {
  5168. spec->adc_nids = alc882_adc_nids;
  5169. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5170. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5171. spec->num_mixers++;
  5172. }
  5173. }
  5174. codec->patch_ops = alc_patch_ops;
  5175. if (board_config == ALC882_AUTO)
  5176. spec->init_hook = alc882_auto_init;
  5177. return 0;
  5178. }
  5179. /*
  5180. * ALC883 support
  5181. *
  5182. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5183. * configuration. Each pin widget can choose any input DACs and a mixer.
  5184. * Each ADC is connected from a mixer of all inputs. This makes possible
  5185. * 6-channel independent captures.
  5186. *
  5187. * In addition, an independent DAC for the multi-playback (not used in this
  5188. * driver yet).
  5189. */
  5190. #define ALC883_DIGOUT_NID 0x06
  5191. #define ALC883_DIGIN_NID 0x0a
  5192. static hda_nid_t alc883_dac_nids[4] = {
  5193. /* front, rear, clfe, rear_surr */
  5194. 0x02, 0x04, 0x03, 0x05
  5195. };
  5196. static hda_nid_t alc883_adc_nids[2] = {
  5197. /* ADC1-2 */
  5198. 0x08, 0x09,
  5199. };
  5200. /* input MUX */
  5201. /* FIXME: should be a matrix-type input source selection */
  5202. static struct hda_input_mux alc883_capture_source = {
  5203. .num_items = 4,
  5204. .items = {
  5205. { "Mic", 0x0 },
  5206. { "Front Mic", 0x1 },
  5207. { "Line", 0x2 },
  5208. { "CD", 0x4 },
  5209. },
  5210. };
  5211. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5212. .num_items = 2,
  5213. .items = {
  5214. { "Mic", 0x1 },
  5215. { "Line", 0x2 },
  5216. },
  5217. };
  5218. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5219. .num_items = 4,
  5220. .items = {
  5221. { "Mic", 0x0 },
  5222. { "iMic", 0x1 },
  5223. { "Line", 0x2 },
  5224. { "CD", 0x4 },
  5225. },
  5226. };
  5227. #define alc883_mux_enum_info alc_mux_enum_info
  5228. #define alc883_mux_enum_get alc_mux_enum_get
  5229. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5230. struct snd_ctl_elem_value *ucontrol)
  5231. {
  5232. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5233. struct alc_spec *spec = codec->spec;
  5234. const struct hda_input_mux *imux = spec->input_mux;
  5235. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5236. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5237. hda_nid_t nid = capture_mixers[adc_idx];
  5238. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5239. unsigned int i, idx;
  5240. idx = ucontrol->value.enumerated.item[0];
  5241. if (idx >= imux->num_items)
  5242. idx = imux->num_items - 1;
  5243. if (*cur_val == idx && !codec->in_resume)
  5244. return 0;
  5245. for (i = 0; i < imux->num_items; i++) {
  5246. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5247. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5248. v | (imux->items[i].index << 8));
  5249. }
  5250. *cur_val = idx;
  5251. return 1;
  5252. }
  5253. /*
  5254. * 2ch mode
  5255. */
  5256. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5257. { 2, NULL }
  5258. };
  5259. /*
  5260. * 2ch mode
  5261. */
  5262. static struct hda_verb alc883_3ST_ch2_init[] = {
  5263. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5264. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5265. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5266. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5267. { } /* end */
  5268. };
  5269. /*
  5270. * 6ch mode
  5271. */
  5272. static struct hda_verb alc883_3ST_ch6_init[] = {
  5273. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5274. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5275. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5276. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5277. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5278. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5279. { } /* end */
  5280. };
  5281. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5282. { 2, alc883_3ST_ch2_init },
  5283. { 6, alc883_3ST_ch6_init },
  5284. };
  5285. /*
  5286. * 6ch mode
  5287. */
  5288. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5289. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5290. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5291. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5292. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5293. { } /* end */
  5294. };
  5295. /*
  5296. * 8ch mode
  5297. */
  5298. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5299. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5300. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5301. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5302. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5303. { } /* end */
  5304. };
  5305. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5306. { 6, alc883_sixstack_ch6_init },
  5307. { 8, alc883_sixstack_ch8_init },
  5308. };
  5309. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5310. /* eanable EAPD on medion laptop */
  5311. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5312. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5313. { }
  5314. };
  5315. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5316. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5317. */
  5318. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5319. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5320. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5321. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5322. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5323. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5324. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5325. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5326. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5327. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5328. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5331. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5333. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5335. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5336. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5339. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5341. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5342. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5343. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5344. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5345. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5346. {
  5347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5348. /* .name = "Capture Source", */
  5349. .name = "Input Source",
  5350. .count = 2,
  5351. .info = alc883_mux_enum_info,
  5352. .get = alc883_mux_enum_get,
  5353. .put = alc883_mux_enum_put,
  5354. },
  5355. { } /* end */
  5356. };
  5357. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5358. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5359. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5360. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5361. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5362. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5363. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5364. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5365. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5366. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5367. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5368. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5369. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5370. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5371. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5372. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5373. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5374. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5375. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5376. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5377. {
  5378. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5379. /* .name = "Capture Source", */
  5380. .name = "Input Source",
  5381. .count = 2,
  5382. .info = alc883_mux_enum_info,
  5383. .get = alc883_mux_enum_get,
  5384. .put = alc883_mux_enum_put,
  5385. },
  5386. { } /* end */
  5387. };
  5388. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5389. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5390. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5391. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5392. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5393. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5394. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5395. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5396. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5397. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5398. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5399. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5400. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5401. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5402. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5403. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5404. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5405. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5407. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5408. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5409. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5410. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5411. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5412. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5413. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5414. {
  5415. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5416. /* .name = "Capture Source", */
  5417. .name = "Input Source",
  5418. .count = 2,
  5419. .info = alc883_mux_enum_info,
  5420. .get = alc883_mux_enum_get,
  5421. .put = alc883_mux_enum_put,
  5422. },
  5423. { } /* end */
  5424. };
  5425. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5429. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5430. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5431. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5432. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5433. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5434. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5435. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5436. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5437. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5438. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5439. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5440. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5441. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5442. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5443. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5444. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5445. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5446. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5447. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5448. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5449. {
  5450. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5451. /* .name = "Capture Source", */
  5452. .name = "Input Source",
  5453. .count = 1,
  5454. .info = alc883_mux_enum_info,
  5455. .get = alc883_mux_enum_get,
  5456. .put = alc883_mux_enum_put,
  5457. },
  5458. { } /* end */
  5459. };
  5460. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5461. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5462. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5463. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5464. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5465. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5466. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5467. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5468. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5469. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5470. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5471. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5472. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5473. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5474. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5475. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5476. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5477. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5478. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5479. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5480. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5481. {
  5482. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5483. /* .name = "Capture Source", */
  5484. .name = "Input Source",
  5485. .count = 2,
  5486. .info = alc883_mux_enum_info,
  5487. .get = alc883_mux_enum_get,
  5488. .put = alc883_mux_enum_put,
  5489. },
  5490. { } /* end */
  5491. };
  5492. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5493. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5494. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5495. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5496. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5497. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5498. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5499. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5500. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5501. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5502. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5503. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5504. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5505. {
  5506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5507. /* .name = "Capture Source", */
  5508. .name = "Input Source",
  5509. .count = 2,
  5510. .info = alc883_mux_enum_info,
  5511. .get = alc883_mux_enum_get,
  5512. .put = alc883_mux_enum_put,
  5513. },
  5514. { } /* end */
  5515. };
  5516. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5517. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5518. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5519. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5520. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5521. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5522. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5524. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5525. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5526. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5527. {
  5528. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5529. /* .name = "Capture Source", */
  5530. .name = "Input Source",
  5531. .count = 1,
  5532. .info = alc883_mux_enum_info,
  5533. .get = alc883_mux_enum_get,
  5534. .put = alc883_mux_enum_put,
  5535. },
  5536. { } /* end */
  5537. };
  5538. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5539. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5540. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5541. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5542. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5543. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5544. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5545. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5546. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5547. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5548. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5549. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5550. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5551. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5552. {
  5553. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5554. /* .name = "Capture Source", */
  5555. .name = "Input Source",
  5556. .count = 2,
  5557. .info = alc883_mux_enum_info,
  5558. .get = alc883_mux_enum_get,
  5559. .put = alc883_mux_enum_put,
  5560. },
  5561. { } /* end */
  5562. };
  5563. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5564. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5565. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5566. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5567. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5568. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5569. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5570. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5571. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5572. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5573. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5574. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5575. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5576. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5577. {
  5578. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5579. /* .name = "Capture Source", */
  5580. .name = "Input Source",
  5581. .count = 2,
  5582. .info = alc883_mux_enum_info,
  5583. .get = alc883_mux_enum_get,
  5584. .put = alc883_mux_enum_put,
  5585. },
  5586. { } /* end */
  5587. };
  5588. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5589. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5590. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5592. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5593. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5594. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5595. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5596. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5598. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5599. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5600. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5601. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5602. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5603. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5604. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5605. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5606. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5607. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5608. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5609. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5610. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5611. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5612. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5613. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5614. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5615. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5616. {
  5617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5618. /* .name = "Capture Source", */
  5619. .name = "Input Source",
  5620. .count = 2,
  5621. .info = alc883_mux_enum_info,
  5622. .get = alc883_mux_enum_get,
  5623. .put = alc883_mux_enum_put,
  5624. },
  5625. { } /* end */
  5626. };
  5627. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5628. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5629. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5630. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5631. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5632. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5633. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5634. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5635. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5636. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5637. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5638. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5639. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5640. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5641. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5642. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5643. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5644. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5645. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5646. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5647. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5648. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5649. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5650. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5651. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5652. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5653. {
  5654. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5655. /* .name = "Capture Source", */
  5656. .name = "Input Source",
  5657. .count = 2,
  5658. .info = alc883_mux_enum_info,
  5659. .get = alc883_mux_enum_get,
  5660. .put = alc883_mux_enum_put,
  5661. },
  5662. { } /* end */
  5663. };
  5664. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5665. {
  5666. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5667. .name = "Channel Mode",
  5668. .info = alc_ch_mode_info,
  5669. .get = alc_ch_mode_get,
  5670. .put = alc_ch_mode_put,
  5671. },
  5672. { } /* end */
  5673. };
  5674. static struct hda_verb alc883_init_verbs[] = {
  5675. /* ADC1: mute amp left and right */
  5676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5677. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5678. /* ADC2: mute amp left and right */
  5679. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5680. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5681. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5684. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5685. /* Rear mixer */
  5686. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5687. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5688. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5689. /* CLFE mixer */
  5690. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5693. /* Side mixer */
  5694. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5695. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5696. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5698. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5699. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5702. /* Front Pin: output 0 (0x0c) */
  5703. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5704. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5705. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5706. /* Rear Pin: output 1 (0x0d) */
  5707. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5708. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5709. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5710. /* CLFE Pin: output 2 (0x0e) */
  5711. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5712. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5713. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5714. /* Side Pin: output 3 (0x0f) */
  5715. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5716. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5717. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5718. /* Mic (rear) pin: input vref at 80% */
  5719. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5720. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5721. /* Front Mic pin: input vref at 80% */
  5722. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5723. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5724. /* Line In pin: input */
  5725. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5726. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5727. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5728. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5729. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5730. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5731. /* CD pin widget for input */
  5732. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5733. /* FIXME: use matrix-type input source selection */
  5734. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5735. /* Input mixer2 */
  5736. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5737. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5738. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5739. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5740. /* Input mixer3 */
  5741. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5742. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5743. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5744. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5745. { }
  5746. };
  5747. static struct hda_verb alc883_tagra_verbs[] = {
  5748. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5749. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5750. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5751. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5752. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5753. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5754. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5755. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5756. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5757. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5758. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5759. { } /* end */
  5760. };
  5761. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5762. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5763. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5764. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5765. { } /* end */
  5766. };
  5767. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5768. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5769. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5770. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5771. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5772. { } /* end */
  5773. };
  5774. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5775. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5776. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5777. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5778. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5779. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5780. { } /* end */
  5781. };
  5782. static struct hda_verb alc888_6st_hp_verbs[] = {
  5783. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5784. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5785. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5786. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5787. { }
  5788. };
  5789. static struct hda_verb alc888_3st_hp_verbs[] = {
  5790. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5791. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5792. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5793. { }
  5794. };
  5795. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5796. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5797. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5798. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5799. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5800. { }
  5801. };
  5802. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5803. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5804. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5805. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5806. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5807. { }
  5808. };
  5809. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5810. { 2, alc888_3st_hp_2ch_init },
  5811. { 6, alc888_3st_hp_6ch_init },
  5812. };
  5813. /* toggle front-jack and RCA according to the hp-jack state */
  5814. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5815. {
  5816. unsigned int present;
  5817. present = snd_hda_codec_read(codec, 0x1b, 0,
  5818. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5819. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5820. 0x80, present ? 0x80 : 0);
  5821. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5822. 0x80, present ? 0x80 : 0);
  5823. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5824. 0x80, present ? 0x80 : 0);
  5825. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5826. 0x80, present ? 0x80 : 0);
  5827. }
  5828. /* toggle RCA according to the front-jack state */
  5829. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5830. {
  5831. unsigned int present;
  5832. present = snd_hda_codec_read(codec, 0x14, 0,
  5833. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5834. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5835. 0x80, present ? 0x80 : 0);
  5836. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5837. 0x80, present ? 0x80 : 0);
  5838. }
  5839. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5840. unsigned int res)
  5841. {
  5842. if ((res >> 26) == ALC880_HP_EVENT)
  5843. alc888_lenovo_ms7195_front_automute(codec);
  5844. if ((res >> 26) == ALC880_FRONT_EVENT)
  5845. alc888_lenovo_ms7195_rca_automute(codec);
  5846. }
  5847. static struct hda_verb alc883_medion_md2_verbs[] = {
  5848. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5849. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5850. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5851. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5852. { } /* end */
  5853. };
  5854. /* toggle speaker-output according to the hp-jack state */
  5855. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5856. {
  5857. unsigned int present;
  5858. present = snd_hda_codec_read(codec, 0x14, 0,
  5859. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5860. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5861. 0x80, present ? 0x80 : 0);
  5862. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5863. 0x80, present ? 0x80 : 0);
  5864. }
  5865. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5866. unsigned int res)
  5867. {
  5868. if ((res >> 26) == ALC880_HP_EVENT)
  5869. alc883_medion_md2_automute(codec);
  5870. }
  5871. /* toggle speaker-output according to the hp-jack state */
  5872. static void alc883_tagra_automute(struct hda_codec *codec)
  5873. {
  5874. unsigned int present;
  5875. unsigned char bits;
  5876. present = snd_hda_codec_read(codec, 0x14, 0,
  5877. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5878. bits = present ? 0x80 : 0;
  5879. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5880. 0x80, bits);
  5881. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5882. 0x80, bits);
  5883. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5884. present ? 1 : 3);
  5885. }
  5886. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5887. {
  5888. if ((res >> 26) == ALC880_HP_EVENT)
  5889. alc883_tagra_automute(codec);
  5890. }
  5891. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5892. {
  5893. unsigned int present;
  5894. unsigned char bits;
  5895. present = snd_hda_codec_read(codec, 0x14, 0,
  5896. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5897. bits = present ? 0x80 : 0;
  5898. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5899. 0x80, bits);
  5900. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5901. 0x80, bits);
  5902. }
  5903. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5904. {
  5905. unsigned int present;
  5906. unsigned char bits;
  5907. present = snd_hda_codec_read(codec, 0x1b, 0,
  5908. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5909. bits = present ? 0x80 : 0;
  5910. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5911. 0x80, bits);
  5912. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5913. 0x80, bits);
  5914. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5915. 0x80, bits);
  5916. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5917. 0x80, bits);
  5918. }
  5919. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5920. unsigned int res)
  5921. {
  5922. if ((res >> 26) == ALC880_HP_EVENT)
  5923. alc883_lenovo_101e_all_automute(codec);
  5924. if ((res >> 26) == ALC880_FRONT_EVENT)
  5925. alc883_lenovo_101e_ispeaker_automute(codec);
  5926. }
  5927. /*
  5928. * generic initialization of ADC, input mixers and output mixers
  5929. */
  5930. static struct hda_verb alc883_auto_init_verbs[] = {
  5931. /*
  5932. * Unmute ADC0-2 and set the default input to mic-in
  5933. */
  5934. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5935. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5936. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5937. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5938. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5939. * mixer widget
  5940. * Note: PASD motherboards uses the Line In 2 as the input for
  5941. * front panel mic (mic 2)
  5942. */
  5943. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5944. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5945. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5946. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5948. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5949. /*
  5950. * Set up output mixers (0x0c - 0x0f)
  5951. */
  5952. /* set vol=0 to output mixers */
  5953. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5954. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5955. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5956. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5957. /* set up input amps for analog loopback */
  5958. /* Amp Indices: DAC = 0, mixer = 1 */
  5959. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5960. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5961. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5962. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5963. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5964. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5965. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5966. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5967. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5968. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5969. /* FIXME: use matrix-type input source selection */
  5970. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5971. /* Input mixer1 */
  5972. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5973. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5974. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5975. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5976. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5977. /* Input mixer2 */
  5978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5981. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5982. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5983. { }
  5984. };
  5985. /* capture mixer elements */
  5986. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5987. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5988. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5989. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5990. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5991. {
  5992. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5993. /* The multiple "Capture Source" controls confuse alsamixer
  5994. * So call somewhat different..
  5995. * FIXME: the controls appear in the "playback" view!
  5996. */
  5997. /* .name = "Capture Source", */
  5998. .name = "Input Source",
  5999. .count = 2,
  6000. .info = alc882_mux_enum_info,
  6001. .get = alc882_mux_enum_get,
  6002. .put = alc882_mux_enum_put,
  6003. },
  6004. { } /* end */
  6005. };
  6006. /* pcm configuration: identiacal with ALC880 */
  6007. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6008. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6009. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6010. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6011. /*
  6012. * configuration and preset
  6013. */
  6014. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6015. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6016. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6017. [ALC883_3ST_6ch] = "3stack-6ch",
  6018. [ALC883_6ST_DIG] = "6stack-dig",
  6019. [ALC883_TARGA_DIG] = "targa-dig",
  6020. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6021. [ALC883_ACER] = "acer",
  6022. [ALC883_MEDION] = "medion",
  6023. [ALC883_MEDION_MD2] = "medion-md2",
  6024. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6025. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6026. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6027. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6028. [ALC888_6ST_HP] = "6stack-hp",
  6029. [ALC888_3ST_HP] = "3stack-hp",
  6030. [ALC883_AUTO] = "auto",
  6031. };
  6032. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6033. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6034. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6035. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6036. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6037. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6038. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6039. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6040. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6041. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6042. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6043. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6044. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6045. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6046. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6047. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6048. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6049. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6050. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6051. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6052. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6053. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6054. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6055. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6056. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6057. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6058. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6059. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6060. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6061. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6062. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6063. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6064. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6065. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6066. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6067. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6068. {}
  6069. };
  6070. static struct alc_config_preset alc883_presets[] = {
  6071. [ALC883_3ST_2ch_DIG] = {
  6072. .mixers = { alc883_3ST_2ch_mixer },
  6073. .init_verbs = { alc883_init_verbs },
  6074. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6075. .dac_nids = alc883_dac_nids,
  6076. .dig_out_nid = ALC883_DIGOUT_NID,
  6077. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6078. .adc_nids = alc883_adc_nids,
  6079. .dig_in_nid = ALC883_DIGIN_NID,
  6080. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6081. .channel_mode = alc883_3ST_2ch_modes,
  6082. .input_mux = &alc883_capture_source,
  6083. },
  6084. [ALC883_3ST_6ch_DIG] = {
  6085. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6086. .init_verbs = { alc883_init_verbs },
  6087. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6088. .dac_nids = alc883_dac_nids,
  6089. .dig_out_nid = ALC883_DIGOUT_NID,
  6090. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6091. .adc_nids = alc883_adc_nids,
  6092. .dig_in_nid = ALC883_DIGIN_NID,
  6093. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6094. .channel_mode = alc883_3ST_6ch_modes,
  6095. .need_dac_fix = 1,
  6096. .input_mux = &alc883_capture_source,
  6097. },
  6098. [ALC883_3ST_6ch] = {
  6099. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6100. .init_verbs = { alc883_init_verbs },
  6101. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6102. .dac_nids = alc883_dac_nids,
  6103. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6104. .adc_nids = alc883_adc_nids,
  6105. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6106. .channel_mode = alc883_3ST_6ch_modes,
  6107. .need_dac_fix = 1,
  6108. .input_mux = &alc883_capture_source,
  6109. },
  6110. [ALC883_6ST_DIG] = {
  6111. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6112. .init_verbs = { alc883_init_verbs },
  6113. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6114. .dac_nids = alc883_dac_nids,
  6115. .dig_out_nid = ALC883_DIGOUT_NID,
  6116. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6117. .adc_nids = alc883_adc_nids,
  6118. .dig_in_nid = ALC883_DIGIN_NID,
  6119. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6120. .channel_mode = alc883_sixstack_modes,
  6121. .input_mux = &alc883_capture_source,
  6122. },
  6123. [ALC883_TARGA_DIG] = {
  6124. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6125. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6126. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6127. .dac_nids = alc883_dac_nids,
  6128. .dig_out_nid = ALC883_DIGOUT_NID,
  6129. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6130. .adc_nids = alc883_adc_nids,
  6131. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6132. .channel_mode = alc883_3ST_6ch_modes,
  6133. .need_dac_fix = 1,
  6134. .input_mux = &alc883_capture_source,
  6135. .unsol_event = alc883_tagra_unsol_event,
  6136. .init_hook = alc883_tagra_automute,
  6137. },
  6138. [ALC883_TARGA_2ch_DIG] = {
  6139. .mixers = { alc883_tagra_2ch_mixer},
  6140. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6141. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6142. .dac_nids = alc883_dac_nids,
  6143. .dig_out_nid = ALC883_DIGOUT_NID,
  6144. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6145. .adc_nids = alc883_adc_nids,
  6146. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6147. .channel_mode = alc883_3ST_2ch_modes,
  6148. .input_mux = &alc883_capture_source,
  6149. .unsol_event = alc883_tagra_unsol_event,
  6150. .init_hook = alc883_tagra_automute,
  6151. },
  6152. [ALC883_ACER] = {
  6153. .mixers = { alc883_base_mixer,
  6154. alc883_chmode_mixer },
  6155. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6156. * and the headphone jack. Turn this on and rely on the
  6157. * standard mute methods whenever the user wants to turn
  6158. * these outputs off.
  6159. */
  6160. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6161. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6162. .dac_nids = alc883_dac_nids,
  6163. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6164. .adc_nids = alc883_adc_nids,
  6165. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6166. .channel_mode = alc883_3ST_2ch_modes,
  6167. .input_mux = &alc883_capture_source,
  6168. },
  6169. [ALC883_MEDION] = {
  6170. .mixers = { alc883_fivestack_mixer,
  6171. alc883_chmode_mixer },
  6172. .init_verbs = { alc883_init_verbs,
  6173. alc883_medion_eapd_verbs },
  6174. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6175. .dac_nids = alc883_dac_nids,
  6176. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6177. .adc_nids = alc883_adc_nids,
  6178. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6179. .channel_mode = alc883_sixstack_modes,
  6180. .input_mux = &alc883_capture_source,
  6181. },
  6182. [ALC883_MEDION_MD2] = {
  6183. .mixers = { alc883_medion_md2_mixer},
  6184. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6185. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6186. .dac_nids = alc883_dac_nids,
  6187. .dig_out_nid = ALC883_DIGOUT_NID,
  6188. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6189. .adc_nids = alc883_adc_nids,
  6190. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6191. .channel_mode = alc883_3ST_2ch_modes,
  6192. .input_mux = &alc883_capture_source,
  6193. .unsol_event = alc883_medion_md2_unsol_event,
  6194. .init_hook = alc883_medion_md2_automute,
  6195. },
  6196. [ALC883_LAPTOP_EAPD] = {
  6197. .mixers = { alc883_base_mixer,
  6198. alc883_chmode_mixer },
  6199. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6200. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6201. .dac_nids = alc883_dac_nids,
  6202. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6203. .adc_nids = alc883_adc_nids,
  6204. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6205. .channel_mode = alc883_3ST_2ch_modes,
  6206. .input_mux = &alc883_capture_source,
  6207. },
  6208. [ALC883_LENOVO_101E_2ch] = {
  6209. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6210. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6211. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6212. .dac_nids = alc883_dac_nids,
  6213. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6214. .adc_nids = alc883_adc_nids,
  6215. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6216. .channel_mode = alc883_3ST_2ch_modes,
  6217. .input_mux = &alc883_lenovo_101e_capture_source,
  6218. .unsol_event = alc883_lenovo_101e_unsol_event,
  6219. .init_hook = alc883_lenovo_101e_all_automute,
  6220. },
  6221. [ALC883_LENOVO_NB0763] = {
  6222. .mixers = { alc883_lenovo_nb0763_mixer },
  6223. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6224. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6225. .dac_nids = alc883_dac_nids,
  6226. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6227. .adc_nids = alc883_adc_nids,
  6228. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6229. .channel_mode = alc883_3ST_2ch_modes,
  6230. .need_dac_fix = 1,
  6231. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6232. .unsol_event = alc883_medion_md2_unsol_event,
  6233. .init_hook = alc883_medion_md2_automute,
  6234. },
  6235. [ALC888_LENOVO_MS7195_DIG] = {
  6236. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6237. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6238. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6239. .dac_nids = alc883_dac_nids,
  6240. .dig_out_nid = ALC883_DIGOUT_NID,
  6241. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6242. .adc_nids = alc883_adc_nids,
  6243. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6244. .channel_mode = alc883_3ST_6ch_modes,
  6245. .need_dac_fix = 1,
  6246. .input_mux = &alc883_capture_source,
  6247. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6248. .init_hook = alc888_lenovo_ms7195_front_automute,
  6249. },
  6250. [ALC888_6ST_HP] = {
  6251. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6252. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6253. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6254. .dac_nids = alc883_dac_nids,
  6255. .dig_out_nid = ALC883_DIGOUT_NID,
  6256. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6257. .adc_nids = alc883_adc_nids,
  6258. .dig_in_nid = ALC883_DIGIN_NID,
  6259. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6260. .channel_mode = alc883_sixstack_modes,
  6261. .input_mux = &alc883_capture_source,
  6262. },
  6263. [ALC888_3ST_HP] = {
  6264. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6265. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6266. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6267. .dac_nids = alc883_dac_nids,
  6268. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6269. .adc_nids = alc883_adc_nids,
  6270. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6271. .channel_mode = alc888_3st_hp_modes,
  6272. .need_dac_fix = 1,
  6273. .input_mux = &alc883_capture_source,
  6274. },
  6275. };
  6276. /*
  6277. * BIOS auto configuration
  6278. */
  6279. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6280. hda_nid_t nid, int pin_type,
  6281. int dac_idx)
  6282. {
  6283. /* set as output */
  6284. struct alc_spec *spec = codec->spec;
  6285. int idx;
  6286. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6287. idx = 4;
  6288. else
  6289. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6290. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6291. pin_type);
  6292. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6293. AMP_OUT_UNMUTE);
  6294. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6295. }
  6296. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6297. {
  6298. struct alc_spec *spec = codec->spec;
  6299. int i;
  6300. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6301. for (i = 0; i <= HDA_SIDE; i++) {
  6302. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6303. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6304. if (nid)
  6305. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6306. i);
  6307. }
  6308. }
  6309. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6310. {
  6311. struct alc_spec *spec = codec->spec;
  6312. hda_nid_t pin;
  6313. pin = spec->autocfg.hp_pins[0];
  6314. if (pin) /* connect to front */
  6315. /* use dac 0 */
  6316. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6317. }
  6318. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6319. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6320. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6321. {
  6322. struct alc_spec *spec = codec->spec;
  6323. int i;
  6324. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6325. hda_nid_t nid = spec->autocfg.input_pins[i];
  6326. if (alc883_is_input_pin(nid)) {
  6327. snd_hda_codec_write(codec, nid, 0,
  6328. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6329. (i <= AUTO_PIN_FRONT_MIC ?
  6330. PIN_VREF80 : PIN_IN));
  6331. if (nid != ALC883_PIN_CD_NID)
  6332. snd_hda_codec_write(codec, nid, 0,
  6333. AC_VERB_SET_AMP_GAIN_MUTE,
  6334. AMP_OUT_MUTE);
  6335. }
  6336. }
  6337. }
  6338. /* almost identical with ALC880 parser... */
  6339. static int alc883_parse_auto_config(struct hda_codec *codec)
  6340. {
  6341. struct alc_spec *spec = codec->spec;
  6342. int err = alc880_parse_auto_config(codec);
  6343. if (err < 0)
  6344. return err;
  6345. else if (err > 0)
  6346. /* hack - override the init verbs */
  6347. spec->init_verbs[0] = alc883_auto_init_verbs;
  6348. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6349. spec->num_mixers++;
  6350. return err;
  6351. }
  6352. /* additional initialization for auto-configuration model */
  6353. static void alc883_auto_init(struct hda_codec *codec)
  6354. {
  6355. alc883_auto_init_multi_out(codec);
  6356. alc883_auto_init_hp_out(codec);
  6357. alc883_auto_init_analog_input(codec);
  6358. }
  6359. static int patch_alc883(struct hda_codec *codec)
  6360. {
  6361. struct alc_spec *spec;
  6362. int err, board_config;
  6363. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6364. if (spec == NULL)
  6365. return -ENOMEM;
  6366. codec->spec = spec;
  6367. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6368. alc883_models,
  6369. alc883_cfg_tbl);
  6370. if (board_config < 0) {
  6371. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6372. "trying auto-probe from BIOS...\n");
  6373. board_config = ALC883_AUTO;
  6374. }
  6375. if (board_config == ALC883_AUTO) {
  6376. /* automatic parse from the BIOS config */
  6377. err = alc883_parse_auto_config(codec);
  6378. if (err < 0) {
  6379. alc_free(codec);
  6380. return err;
  6381. } else if (!err) {
  6382. printk(KERN_INFO
  6383. "hda_codec: Cannot set up configuration "
  6384. "from BIOS. Using base mode...\n");
  6385. board_config = ALC883_3ST_2ch_DIG;
  6386. }
  6387. }
  6388. if (board_config != ALC883_AUTO)
  6389. setup_preset(spec, &alc883_presets[board_config]);
  6390. spec->stream_name_analog = "ALC883 Analog";
  6391. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6392. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6393. spec->stream_name_digital = "ALC883 Digital";
  6394. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6395. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6396. if (!spec->adc_nids && spec->input_mux) {
  6397. spec->adc_nids = alc883_adc_nids;
  6398. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6399. }
  6400. codec->patch_ops = alc_patch_ops;
  6401. if (board_config == ALC883_AUTO)
  6402. spec->init_hook = alc883_auto_init;
  6403. return 0;
  6404. }
  6405. /*
  6406. * ALC262 support
  6407. */
  6408. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6409. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6410. #define alc262_dac_nids alc260_dac_nids
  6411. #define alc262_adc_nids alc882_adc_nids
  6412. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6413. #define alc262_modes alc260_modes
  6414. #define alc262_capture_source alc882_capture_source
  6415. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6416. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6417. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6418. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6419. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6420. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6421. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6422. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6423. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6424. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6425. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6426. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6427. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6428. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6429. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6430. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6431. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6432. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6433. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6434. { } /* end */
  6435. };
  6436. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6437. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6438. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6439. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6440. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6441. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6442. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6443. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6444. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6445. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6446. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6447. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6448. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6449. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6450. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6451. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6452. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6453. { } /* end */
  6454. };
  6455. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6456. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6457. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6458. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6459. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6460. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6461. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6462. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6463. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6464. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6465. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6466. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6467. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6468. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6469. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6470. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6471. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6472. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6473. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6474. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6475. { } /* end */
  6476. };
  6477. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6478. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6479. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6480. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6481. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6482. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6483. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6484. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6485. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6486. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6487. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6488. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6489. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6490. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6491. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6492. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6493. { } /* end */
  6494. };
  6495. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6496. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6497. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6498. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6499. { } /* end */
  6500. };
  6501. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6502. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6503. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6504. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6505. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6506. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6507. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6508. { } /* end */
  6509. };
  6510. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6511. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6512. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6513. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6514. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6515. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6516. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6517. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6518. { } /* end */
  6519. };
  6520. #define alc262_capture_mixer alc882_capture_mixer
  6521. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6522. /*
  6523. * generic initialization of ADC, input mixers and output mixers
  6524. */
  6525. static struct hda_verb alc262_init_verbs[] = {
  6526. /*
  6527. * Unmute ADC0-2 and set the default input to mic-in
  6528. */
  6529. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6531. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6532. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6533. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6534. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6535. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6536. * mixer widget
  6537. * Note: PASD motherboards uses the Line In 2 as the input for
  6538. * front panel mic (mic 2)
  6539. */
  6540. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6541. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6542. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6543. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6544. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6546. /*
  6547. * Set up output mixers (0x0c - 0x0e)
  6548. */
  6549. /* set vol=0 to output mixers */
  6550. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6551. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6552. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6553. /* set up input amps for analog loopback */
  6554. /* Amp Indices: DAC = 0, mixer = 1 */
  6555. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6556. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6557. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6558. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6559. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6560. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6561. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6562. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6563. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6564. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6565. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6566. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6567. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6568. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6569. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6570. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6571. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6572. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6573. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6574. /* FIXME: use matrix-type input source selection */
  6575. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6576. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6577. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6578. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6579. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6580. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6581. /* Input mixer2 */
  6582. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6583. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6584. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6585. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6586. /* Input mixer3 */
  6587. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6588. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6589. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6590. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6591. { }
  6592. };
  6593. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6594. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6595. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6596. {}
  6597. };
  6598. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6599. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6600. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6601. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6602. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6603. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6604. {}
  6605. };
  6606. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6607. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6608. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6609. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6610. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6611. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6612. };
  6613. /* mute/unmute internal speaker according to the hp jack and mute state */
  6614. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6615. {
  6616. struct alc_spec *spec = codec->spec;
  6617. unsigned int mute;
  6618. if (force || !spec->sense_updated) {
  6619. unsigned int present;
  6620. /* need to execute and sync at first */
  6621. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6622. present = snd_hda_codec_read(codec, 0x15, 0,
  6623. AC_VERB_GET_PIN_SENSE, 0);
  6624. spec->jack_present = (present & 0x80000000) != 0;
  6625. spec->sense_updated = 1;
  6626. }
  6627. if (spec->jack_present) {
  6628. /* mute internal speaker */
  6629. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6630. 0x80, 0x80);
  6631. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6632. 0x80, 0x80);
  6633. } else {
  6634. /* unmute internal speaker if necessary */
  6635. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6636. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6637. 0x80, mute & 0x80);
  6638. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6639. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6640. 0x80, mute & 0x80);
  6641. }
  6642. }
  6643. /* unsolicited event for HP jack sensing */
  6644. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6645. unsigned int res)
  6646. {
  6647. if ((res >> 26) != ALC880_HP_EVENT)
  6648. return;
  6649. alc262_hippo_automute(codec, 1);
  6650. }
  6651. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6652. {
  6653. struct alc_spec *spec = codec->spec;
  6654. unsigned int mute;
  6655. if (force || !spec->sense_updated) {
  6656. unsigned int present;
  6657. /* need to execute and sync at first */
  6658. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6659. present = snd_hda_codec_read(codec, 0x1b, 0,
  6660. AC_VERB_GET_PIN_SENSE, 0);
  6661. spec->jack_present = (present & 0x80000000) != 0;
  6662. spec->sense_updated = 1;
  6663. }
  6664. if (spec->jack_present) {
  6665. /* mute internal speaker */
  6666. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6667. 0x80, 0x80);
  6668. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6669. 0x80, 0x80);
  6670. } else {
  6671. /* unmute internal speaker if necessary */
  6672. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6673. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6674. 0x80, mute & 0x80);
  6675. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6676. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6677. 0x80, mute & 0x80);
  6678. }
  6679. }
  6680. /* unsolicited event for HP jack sensing */
  6681. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6682. unsigned int res)
  6683. {
  6684. if ((res >> 26) != ALC880_HP_EVENT)
  6685. return;
  6686. alc262_hippo1_automute(codec, 1);
  6687. }
  6688. /*
  6689. * fujitsu model
  6690. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6691. */
  6692. #define ALC_HP_EVENT 0x37
  6693. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6694. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6696. {}
  6697. };
  6698. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6699. .num_items = 2,
  6700. .items = {
  6701. { "Mic", 0x0 },
  6702. { "CD", 0x4 },
  6703. },
  6704. };
  6705. static struct hda_input_mux alc262_HP_capture_source = {
  6706. .num_items = 5,
  6707. .items = {
  6708. { "Mic", 0x0 },
  6709. { "Front Mic", 0x3 },
  6710. { "Line", 0x2 },
  6711. { "CD", 0x4 },
  6712. { "AUX IN", 0x6 },
  6713. },
  6714. };
  6715. /* mute/unmute internal speaker according to the hp jack and mute state */
  6716. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6717. {
  6718. struct alc_spec *spec = codec->spec;
  6719. unsigned int mute;
  6720. if (force || !spec->sense_updated) {
  6721. unsigned int present;
  6722. /* need to execute and sync at first */
  6723. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6724. present = snd_hda_codec_read(codec, 0x14, 0,
  6725. AC_VERB_GET_PIN_SENSE, 0);
  6726. spec->jack_present = (present & 0x80000000) != 0;
  6727. spec->sense_updated = 1;
  6728. }
  6729. if (spec->jack_present) {
  6730. /* mute internal speaker */
  6731. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6732. 0x80, 0x80);
  6733. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6734. 0x80, 0x80);
  6735. } else {
  6736. /* unmute internal speaker if necessary */
  6737. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6738. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6739. 0x80, mute & 0x80);
  6740. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6741. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6742. 0x80, mute & 0x80);
  6743. }
  6744. }
  6745. /* unsolicited event for HP jack sensing */
  6746. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6747. unsigned int res)
  6748. {
  6749. if ((res >> 26) != ALC_HP_EVENT)
  6750. return;
  6751. alc262_fujitsu_automute(codec, 1);
  6752. }
  6753. /* bind volumes of both NID 0x0c and 0x0d */
  6754. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6755. struct snd_ctl_elem_value *ucontrol)
  6756. {
  6757. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6758. long *valp = ucontrol->value.integer.value;
  6759. int change;
  6760. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6761. 0x7f, valp[0] & 0x7f);
  6762. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6763. 0x7f, valp[1] & 0x7f);
  6764. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6765. 0x7f, valp[0] & 0x7f);
  6766. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6767. 0x7f, valp[1] & 0x7f);
  6768. return change;
  6769. }
  6770. /* bind hp and internal speaker mute (with plug check) */
  6771. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6772. struct snd_ctl_elem_value *ucontrol)
  6773. {
  6774. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6775. long *valp = ucontrol->value.integer.value;
  6776. int change;
  6777. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6778. 0x80, valp[0] ? 0 : 0x80);
  6779. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6780. 0x80, valp[1] ? 0 : 0x80);
  6781. if (change || codec->in_resume)
  6782. alc262_fujitsu_automute(codec, codec->in_resume);
  6783. return change;
  6784. }
  6785. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6786. {
  6787. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6788. .name = "Master Playback Volume",
  6789. .info = snd_hda_mixer_amp_volume_info,
  6790. .get = snd_hda_mixer_amp_volume_get,
  6791. .put = alc262_fujitsu_master_vol_put,
  6792. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6793. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6794. },
  6795. {
  6796. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6797. .name = "Master Playback Switch",
  6798. .info = snd_hda_mixer_amp_switch_info,
  6799. .get = snd_hda_mixer_amp_switch_get,
  6800. .put = alc262_fujitsu_master_sw_put,
  6801. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6802. },
  6803. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6804. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6805. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6806. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6807. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6808. { } /* end */
  6809. };
  6810. /* additional init verbs for Benq laptops */
  6811. static struct hda_verb alc262_EAPD_verbs[] = {
  6812. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6813. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6814. {}
  6815. };
  6816. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6817. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6818. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6819. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6820. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6821. {}
  6822. };
  6823. /* add playback controls from the parsed DAC table */
  6824. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6825. const struct auto_pin_cfg *cfg)
  6826. {
  6827. hda_nid_t nid;
  6828. int err;
  6829. spec->multiout.num_dacs = 1; /* only use one dac */
  6830. spec->multiout.dac_nids = spec->private_dac_nids;
  6831. spec->multiout.dac_nids[0] = 2;
  6832. nid = cfg->line_out_pins[0];
  6833. if (nid) {
  6834. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6835. "Front Playback Volume",
  6836. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6837. if (err < 0)
  6838. return err;
  6839. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6840. "Front Playback Switch",
  6841. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6842. if (err < 0)
  6843. return err;
  6844. }
  6845. nid = cfg->speaker_pins[0];
  6846. if (nid) {
  6847. if (nid == 0x16) {
  6848. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6849. "Speaker Playback Volume",
  6850. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6851. HDA_OUTPUT));
  6852. if (err < 0)
  6853. return err;
  6854. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6855. "Speaker Playback Switch",
  6856. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6857. HDA_OUTPUT));
  6858. if (err < 0)
  6859. return err;
  6860. } else {
  6861. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6862. "Speaker Playback Switch",
  6863. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6864. HDA_OUTPUT));
  6865. if (err < 0)
  6866. return err;
  6867. }
  6868. }
  6869. nid = cfg->hp_pins[0];
  6870. if (nid) {
  6871. /* spec->multiout.hp_nid = 2; */
  6872. if (nid == 0x16) {
  6873. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6874. "Headphone Playback Volume",
  6875. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6876. HDA_OUTPUT));
  6877. if (err < 0)
  6878. return err;
  6879. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6880. "Headphone Playback Switch",
  6881. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6882. HDA_OUTPUT));
  6883. if (err < 0)
  6884. return err;
  6885. } else {
  6886. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6887. "Headphone Playback Switch",
  6888. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6889. HDA_OUTPUT));
  6890. if (err < 0)
  6891. return err;
  6892. }
  6893. }
  6894. return 0;
  6895. }
  6896. /* identical with ALC880 */
  6897. #define alc262_auto_create_analog_input_ctls \
  6898. alc880_auto_create_analog_input_ctls
  6899. /*
  6900. * generic initialization of ADC, input mixers and output mixers
  6901. */
  6902. static struct hda_verb alc262_volume_init_verbs[] = {
  6903. /*
  6904. * Unmute ADC0-2 and set the default input to mic-in
  6905. */
  6906. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6907. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6908. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6909. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6910. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6911. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6912. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6913. * mixer widget
  6914. * Note: PASD motherboards uses the Line In 2 as the input for
  6915. * front panel mic (mic 2)
  6916. */
  6917. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6920. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6921. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6922. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6923. /*
  6924. * Set up output mixers (0x0c - 0x0f)
  6925. */
  6926. /* set vol=0 to output mixers */
  6927. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6928. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6929. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6930. /* set up input amps for analog loopback */
  6931. /* Amp Indices: DAC = 0, mixer = 1 */
  6932. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6933. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6934. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6935. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6936. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6938. /* FIXME: use matrix-type input source selection */
  6939. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6940. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6941. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6942. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6943. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6944. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6945. /* Input mixer2 */
  6946. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6947. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6948. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6949. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6950. /* Input mixer3 */
  6951. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6952. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6953. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6954. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6955. { }
  6956. };
  6957. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6958. /*
  6959. * Unmute ADC0-2 and set the default input to mic-in
  6960. */
  6961. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6962. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6963. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6964. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6965. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6966. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6967. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6968. * mixer widget
  6969. * Note: PASD motherboards uses the Line In 2 as the input for
  6970. * front panel mic (mic 2)
  6971. */
  6972. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6973. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6974. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6975. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6976. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6980. /*
  6981. * Set up output mixers (0x0c - 0x0e)
  6982. */
  6983. /* set vol=0 to output mixers */
  6984. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6985. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6986. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6987. /* set up input amps for analog loopback */
  6988. /* Amp Indices: DAC = 0, mixer = 1 */
  6989. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6990. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6991. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6992. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6993. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6994. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6995. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6996. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6997. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6998. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6999. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7000. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7001. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7002. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7003. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7004. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7005. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7006. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7007. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7008. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7009. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7010. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7011. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7012. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7013. /* FIXME: use matrix-type input source selection */
  7014. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7015. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7016. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7017. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7018. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7019. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7020. /* Input mixer2 */
  7021. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7022. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7023. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7024. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7025. /* Input mixer3 */
  7026. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7027. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7028. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7029. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7030. { }
  7031. };
  7032. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7033. /*
  7034. * Unmute ADC0-2 and set the default input to mic-in
  7035. */
  7036. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7037. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7038. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7039. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7040. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7041. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7042. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7043. * mixer widget
  7044. * Note: PASD motherboards uses the Line In 2 as the input for front
  7045. * panel mic (mic 2)
  7046. */
  7047. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7048. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7049. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7050. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7051. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7052. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7053. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7054. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7055. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  7056. /*
  7057. * Set up output mixers (0x0c - 0x0e)
  7058. */
  7059. /* set vol=0 to output mixers */
  7060. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7061. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7062. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7063. /* set up input amps for analog loopback */
  7064. /* Amp Indices: DAC = 0, mixer = 1 */
  7065. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7066. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7067. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7068. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7069. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7070. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7071. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7072. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7073. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7074. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7075. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7076. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7077. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7078. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7079. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7080. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7081. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7082. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7083. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7084. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7085. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7086. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7087. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7088. /* FIXME: use matrix-type input source selection */
  7089. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7090. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7091. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7092. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7093. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7094. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7095. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7096. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7097. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7098. /* Input mixer2 */
  7099. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7100. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7101. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7102. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7103. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7104. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7105. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7106. /* Input mixer3 */
  7107. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7108. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7109. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7110. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7111. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7112. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7113. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7114. { }
  7115. };
  7116. /* pcm configuration: identiacal with ALC880 */
  7117. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7118. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7119. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7120. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7121. /*
  7122. * BIOS auto configuration
  7123. */
  7124. static int alc262_parse_auto_config(struct hda_codec *codec)
  7125. {
  7126. struct alc_spec *spec = codec->spec;
  7127. int err;
  7128. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7129. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7130. alc262_ignore);
  7131. if (err < 0)
  7132. return err;
  7133. if (!spec->autocfg.line_outs)
  7134. return 0; /* can't find valid BIOS pin config */
  7135. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7136. if (err < 0)
  7137. return err;
  7138. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7139. if (err < 0)
  7140. return err;
  7141. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7142. if (spec->autocfg.dig_out_pin)
  7143. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7144. if (spec->autocfg.dig_in_pin)
  7145. spec->dig_in_nid = ALC262_DIGIN_NID;
  7146. if (spec->kctl_alloc)
  7147. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7148. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7149. spec->num_mux_defs = 1;
  7150. spec->input_mux = &spec->private_imux;
  7151. return 1;
  7152. }
  7153. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7154. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7155. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7156. /* init callback for auto-configuration model -- overriding the default init */
  7157. static void alc262_auto_init(struct hda_codec *codec)
  7158. {
  7159. alc262_auto_init_multi_out(codec);
  7160. alc262_auto_init_hp_out(codec);
  7161. alc262_auto_init_analog_input(codec);
  7162. }
  7163. /*
  7164. * configuration and preset
  7165. */
  7166. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7167. [ALC262_BASIC] = "basic",
  7168. [ALC262_HIPPO] = "hippo",
  7169. [ALC262_HIPPO_1] = "hippo_1",
  7170. [ALC262_FUJITSU] = "fujitsu",
  7171. [ALC262_HP_BPC] = "hp-bpc",
  7172. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7173. [ALC262_BENQ_ED8] = "benq",
  7174. [ALC262_BENQ_T31] = "benq-t31",
  7175. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7176. [ALC262_AUTO] = "auto",
  7177. };
  7178. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7179. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7180. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7181. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7182. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7183. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7184. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7185. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7186. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7187. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7188. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7189. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7190. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7191. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7192. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7193. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7194. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7195. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7196. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7197. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7198. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7199. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7200. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7201. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7202. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7203. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7204. {}
  7205. };
  7206. static struct alc_config_preset alc262_presets[] = {
  7207. [ALC262_BASIC] = {
  7208. .mixers = { alc262_base_mixer },
  7209. .init_verbs = { alc262_init_verbs },
  7210. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7211. .dac_nids = alc262_dac_nids,
  7212. .hp_nid = 0x03,
  7213. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7214. .channel_mode = alc262_modes,
  7215. .input_mux = &alc262_capture_source,
  7216. },
  7217. [ALC262_HIPPO] = {
  7218. .mixers = { alc262_base_mixer },
  7219. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7220. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7221. .dac_nids = alc262_dac_nids,
  7222. .hp_nid = 0x03,
  7223. .dig_out_nid = ALC262_DIGOUT_NID,
  7224. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7225. .channel_mode = alc262_modes,
  7226. .input_mux = &alc262_capture_source,
  7227. .unsol_event = alc262_hippo_unsol_event,
  7228. },
  7229. [ALC262_HIPPO_1] = {
  7230. .mixers = { alc262_hippo1_mixer },
  7231. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7232. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7233. .dac_nids = alc262_dac_nids,
  7234. .hp_nid = 0x02,
  7235. .dig_out_nid = ALC262_DIGOUT_NID,
  7236. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7237. .channel_mode = alc262_modes,
  7238. .input_mux = &alc262_capture_source,
  7239. .unsol_event = alc262_hippo1_unsol_event,
  7240. },
  7241. [ALC262_FUJITSU] = {
  7242. .mixers = { alc262_fujitsu_mixer },
  7243. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7244. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7245. .dac_nids = alc262_dac_nids,
  7246. .hp_nid = 0x03,
  7247. .dig_out_nid = ALC262_DIGOUT_NID,
  7248. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7249. .channel_mode = alc262_modes,
  7250. .input_mux = &alc262_fujitsu_capture_source,
  7251. .unsol_event = alc262_fujitsu_unsol_event,
  7252. },
  7253. [ALC262_HP_BPC] = {
  7254. .mixers = { alc262_HP_BPC_mixer },
  7255. .init_verbs = { alc262_HP_BPC_init_verbs },
  7256. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7257. .dac_nids = alc262_dac_nids,
  7258. .hp_nid = 0x03,
  7259. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7260. .channel_mode = alc262_modes,
  7261. .input_mux = &alc262_HP_capture_source,
  7262. },
  7263. [ALC262_HP_BPC_D7000_WF] = {
  7264. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7265. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7266. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7267. .dac_nids = alc262_dac_nids,
  7268. .hp_nid = 0x03,
  7269. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7270. .channel_mode = alc262_modes,
  7271. .input_mux = &alc262_HP_capture_source,
  7272. },
  7273. [ALC262_HP_BPC_D7000_WL] = {
  7274. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7275. alc262_HP_BPC_WildWest_option_mixer },
  7276. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7277. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7278. .dac_nids = alc262_dac_nids,
  7279. .hp_nid = 0x03,
  7280. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7281. .channel_mode = alc262_modes,
  7282. .input_mux = &alc262_HP_capture_source,
  7283. },
  7284. [ALC262_BENQ_ED8] = {
  7285. .mixers = { alc262_base_mixer },
  7286. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7287. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7288. .dac_nids = alc262_dac_nids,
  7289. .hp_nid = 0x03,
  7290. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7291. .channel_mode = alc262_modes,
  7292. .input_mux = &alc262_capture_source,
  7293. },
  7294. [ALC262_SONY_ASSAMD] = {
  7295. .mixers = { alc262_sony_mixer },
  7296. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7297. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7298. .dac_nids = alc262_dac_nids,
  7299. .hp_nid = 0x02,
  7300. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7301. .channel_mode = alc262_modes,
  7302. .input_mux = &alc262_capture_source,
  7303. .unsol_event = alc262_hippo_unsol_event,
  7304. },
  7305. [ALC262_BENQ_T31] = {
  7306. .mixers = { alc262_benq_t31_mixer },
  7307. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7308. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7309. .dac_nids = alc262_dac_nids,
  7310. .hp_nid = 0x03,
  7311. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7312. .channel_mode = alc262_modes,
  7313. .input_mux = &alc262_capture_source,
  7314. .unsol_event = alc262_hippo_unsol_event,
  7315. },
  7316. };
  7317. static int patch_alc262(struct hda_codec *codec)
  7318. {
  7319. struct alc_spec *spec;
  7320. int board_config;
  7321. int err;
  7322. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7323. if (spec == NULL)
  7324. return -ENOMEM;
  7325. codec->spec = spec;
  7326. #if 0
  7327. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7328. * under-run
  7329. */
  7330. {
  7331. int tmp;
  7332. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7333. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7334. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7335. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7336. }
  7337. #endif
  7338. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7339. alc262_models,
  7340. alc262_cfg_tbl);
  7341. if (board_config < 0) {
  7342. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7343. "trying auto-probe from BIOS...\n");
  7344. board_config = ALC262_AUTO;
  7345. }
  7346. if (board_config == ALC262_AUTO) {
  7347. /* automatic parse from the BIOS config */
  7348. err = alc262_parse_auto_config(codec);
  7349. if (err < 0) {
  7350. alc_free(codec);
  7351. return err;
  7352. } else if (!err) {
  7353. printk(KERN_INFO
  7354. "hda_codec: Cannot set up configuration "
  7355. "from BIOS. Using base mode...\n");
  7356. board_config = ALC262_BASIC;
  7357. }
  7358. }
  7359. if (board_config != ALC262_AUTO)
  7360. setup_preset(spec, &alc262_presets[board_config]);
  7361. spec->stream_name_analog = "ALC262 Analog";
  7362. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7363. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7364. spec->stream_name_digital = "ALC262 Digital";
  7365. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7366. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7367. if (!spec->adc_nids && spec->input_mux) {
  7368. /* check whether NID 0x07 is valid */
  7369. unsigned int wcap = get_wcaps(codec, 0x07);
  7370. /* get type */
  7371. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7372. if (wcap != AC_WID_AUD_IN) {
  7373. spec->adc_nids = alc262_adc_nids_alt;
  7374. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7375. spec->mixers[spec->num_mixers] =
  7376. alc262_capture_alt_mixer;
  7377. spec->num_mixers++;
  7378. } else {
  7379. spec->adc_nids = alc262_adc_nids;
  7380. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7381. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7382. spec->num_mixers++;
  7383. }
  7384. }
  7385. codec->patch_ops = alc_patch_ops;
  7386. if (board_config == ALC262_AUTO)
  7387. spec->init_hook = alc262_auto_init;
  7388. return 0;
  7389. }
  7390. /*
  7391. * ALC268 channel source setting (2 channel)
  7392. */
  7393. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7394. #define alc268_modes alc260_modes
  7395. static hda_nid_t alc268_dac_nids[2] = {
  7396. /* front, hp */
  7397. 0x02, 0x03
  7398. };
  7399. static hda_nid_t alc268_adc_nids[2] = {
  7400. /* ADC0-1 */
  7401. 0x08, 0x07
  7402. };
  7403. static hda_nid_t alc268_adc_nids_alt[1] = {
  7404. /* ADC0 */
  7405. 0x08
  7406. };
  7407. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7408. /* output mixer control */
  7409. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7410. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7411. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7412. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7413. { }
  7414. };
  7415. /*
  7416. * generic initialization of ADC, input mixers and output mixers
  7417. */
  7418. static struct hda_verb alc268_base_init_verbs[] = {
  7419. /* Unmute DAC0-1 and set vol = 0 */
  7420. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7421. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7422. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7423. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7424. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7425. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7426. /*
  7427. * Set up output mixers (0x0c - 0x0e)
  7428. */
  7429. /* set vol=0 to output mixers */
  7430. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7431. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7432. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7433. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7434. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7435. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7436. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7437. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7438. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7439. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7440. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7441. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7442. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7443. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7444. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7445. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7446. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7447. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7448. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7449. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7450. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7451. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7452. /* FIXME: use matrix-type input source selection */
  7453. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7454. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7455. /* Input mixer2 */
  7456. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7457. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7458. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7459. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7460. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7461. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7462. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7463. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7464. { }
  7465. };
  7466. /*
  7467. * generic initialization of ADC, input mixers and output mixers
  7468. */
  7469. static struct hda_verb alc268_volume_init_verbs[] = {
  7470. /* set output DAC */
  7471. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7472. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7473. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7474. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7475. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7476. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7477. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7478. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7479. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7480. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7481. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7482. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7483. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7484. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7485. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7486. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7487. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7488. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7489. /* set PCBEEP vol = 0 */
  7490. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7491. { }
  7492. };
  7493. #define alc268_mux_enum_info alc_mux_enum_info
  7494. #define alc268_mux_enum_get alc_mux_enum_get
  7495. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7496. struct snd_ctl_elem_value *ucontrol)
  7497. {
  7498. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7499. struct alc_spec *spec = codec->spec;
  7500. const struct hda_input_mux *imux = spec->input_mux;
  7501. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7502. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7503. hda_nid_t nid = capture_mixers[adc_idx];
  7504. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7505. unsigned int i, idx;
  7506. idx = ucontrol->value.enumerated.item[0];
  7507. if (idx >= imux->num_items)
  7508. idx = imux->num_items - 1;
  7509. if (*cur_val == idx && !codec->in_resume)
  7510. return 0;
  7511. for (i = 0; i < imux->num_items; i++) {
  7512. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7513. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7514. v | (imux->items[i].index << 8));
  7515. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7516. idx );
  7517. }
  7518. *cur_val = idx;
  7519. return 1;
  7520. }
  7521. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7522. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7523. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7524. {
  7525. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7526. /* The multiple "Capture Source" controls confuse alsamixer
  7527. * So call somewhat different..
  7528. * FIXME: the controls appear in the "playback" view!
  7529. */
  7530. /* .name = "Capture Source", */
  7531. .name = "Input Source",
  7532. .count = 1,
  7533. .info = alc268_mux_enum_info,
  7534. .get = alc268_mux_enum_get,
  7535. .put = alc268_mux_enum_put,
  7536. },
  7537. { } /* end */
  7538. };
  7539. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7540. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7541. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7542. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7543. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7544. {
  7545. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7546. /* The multiple "Capture Source" controls confuse alsamixer
  7547. * So call somewhat different..
  7548. * FIXME: the controls appear in the "playback" view!
  7549. */
  7550. /* .name = "Capture Source", */
  7551. .name = "Input Source",
  7552. .count = 2,
  7553. .info = alc268_mux_enum_info,
  7554. .get = alc268_mux_enum_get,
  7555. .put = alc268_mux_enum_put,
  7556. },
  7557. { } /* end */
  7558. };
  7559. static struct hda_input_mux alc268_capture_source = {
  7560. .num_items = 4,
  7561. .items = {
  7562. { "Mic", 0x0 },
  7563. { "Front Mic", 0x1 },
  7564. { "Line", 0x2 },
  7565. { "CD", 0x3 },
  7566. },
  7567. };
  7568. /* create input playback/capture controls for the given pin */
  7569. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7570. const char *ctlname, int idx)
  7571. {
  7572. char name[32];
  7573. int err;
  7574. sprintf(name, "%s Playback Volume", ctlname);
  7575. if (nid == 0x14) {
  7576. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7577. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7578. HDA_OUTPUT));
  7579. if (err < 0)
  7580. return err;
  7581. } else if (nid == 0x15) {
  7582. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7583. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7584. HDA_OUTPUT));
  7585. if (err < 0)
  7586. return err;
  7587. } else
  7588. return -1;
  7589. sprintf(name, "%s Playback Switch", ctlname);
  7590. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7591. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7592. if (err < 0)
  7593. return err;
  7594. return 0;
  7595. }
  7596. /* add playback controls from the parsed DAC table */
  7597. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7598. const struct auto_pin_cfg *cfg)
  7599. {
  7600. hda_nid_t nid;
  7601. int err;
  7602. spec->multiout.num_dacs = 2; /* only use one dac */
  7603. spec->multiout.dac_nids = spec->private_dac_nids;
  7604. spec->multiout.dac_nids[0] = 2;
  7605. spec->multiout.dac_nids[1] = 3;
  7606. nid = cfg->line_out_pins[0];
  7607. if (nid)
  7608. alc268_new_analog_output(spec, nid, "Front", 0);
  7609. nid = cfg->speaker_pins[0];
  7610. if (nid == 0x1d) {
  7611. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7612. "Speaker Playback Volume",
  7613. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7614. if (err < 0)
  7615. return err;
  7616. }
  7617. nid = cfg->hp_pins[0];
  7618. if (nid)
  7619. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7620. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7621. if (nid == 0x16) {
  7622. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7623. "Mono Playback Switch",
  7624. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7625. if (err < 0)
  7626. return err;
  7627. }
  7628. return 0;
  7629. }
  7630. /* create playback/capture controls for input pins */
  7631. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7632. const struct auto_pin_cfg *cfg)
  7633. {
  7634. struct hda_input_mux *imux = &spec->private_imux;
  7635. int i, idx1;
  7636. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7637. switch(cfg->input_pins[i]) {
  7638. case 0x18:
  7639. idx1 = 0; /* Mic 1 */
  7640. break;
  7641. case 0x19:
  7642. idx1 = 1; /* Mic 2 */
  7643. break;
  7644. case 0x1a:
  7645. idx1 = 2; /* Line In */
  7646. break;
  7647. case 0x1c:
  7648. idx1 = 3; /* CD */
  7649. break;
  7650. default:
  7651. continue;
  7652. }
  7653. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7654. imux->items[imux->num_items].index = idx1;
  7655. imux->num_items++;
  7656. }
  7657. return 0;
  7658. }
  7659. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7660. {
  7661. struct alc_spec *spec = codec->spec;
  7662. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7663. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7664. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7665. unsigned int dac_vol1, dac_vol2;
  7666. if (speaker_nid) {
  7667. snd_hda_codec_write(codec, speaker_nid, 0,
  7668. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7669. snd_hda_codec_write(codec, 0x0f, 0,
  7670. AC_VERB_SET_AMP_GAIN_MUTE,
  7671. AMP_IN_UNMUTE(1));
  7672. snd_hda_codec_write(codec, 0x10, 0,
  7673. AC_VERB_SET_AMP_GAIN_MUTE,
  7674. AMP_IN_UNMUTE(1));
  7675. } else {
  7676. snd_hda_codec_write(codec, 0x0f, 0,
  7677. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7678. snd_hda_codec_write(codec, 0x10, 0,
  7679. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7680. }
  7681. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7682. if (line_nid == 0x14)
  7683. dac_vol2 = AMP_OUT_ZERO;
  7684. else if (line_nid == 0x15)
  7685. dac_vol1 = AMP_OUT_ZERO;
  7686. if (hp_nid == 0x14)
  7687. dac_vol2 = AMP_OUT_ZERO;
  7688. else if (hp_nid == 0x15)
  7689. dac_vol1 = AMP_OUT_ZERO;
  7690. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7691. spec->autocfg.line_out_pins[1] != 0x16 ||
  7692. spec->autocfg.line_out_pins[2] != 0x16)
  7693. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7694. snd_hda_codec_write(codec, 0x02, 0,
  7695. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7696. snd_hda_codec_write(codec, 0x03, 0,
  7697. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7698. }
  7699. /* pcm configuration: identiacal with ALC880 */
  7700. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7701. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7702. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7703. /*
  7704. * BIOS auto configuration
  7705. */
  7706. static int alc268_parse_auto_config(struct hda_codec *codec)
  7707. {
  7708. struct alc_spec *spec = codec->spec;
  7709. int err;
  7710. static hda_nid_t alc268_ignore[] = { 0 };
  7711. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7712. alc268_ignore);
  7713. if (err < 0)
  7714. return err;
  7715. if (!spec->autocfg.line_outs)
  7716. return 0; /* can't find valid BIOS pin config */
  7717. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7718. if (err < 0)
  7719. return err;
  7720. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7721. if (err < 0)
  7722. return err;
  7723. spec->multiout.max_channels = 2;
  7724. /* digital only support output */
  7725. if (spec->autocfg.dig_out_pin)
  7726. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7727. if (spec->kctl_alloc)
  7728. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7729. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7730. spec->num_mux_defs = 1;
  7731. spec->input_mux = &spec->private_imux;
  7732. return 1;
  7733. }
  7734. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7735. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7736. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7737. /* init callback for auto-configuration model -- overriding the default init */
  7738. static void alc268_auto_init(struct hda_codec *codec)
  7739. {
  7740. alc268_auto_init_multi_out(codec);
  7741. alc268_auto_init_hp_out(codec);
  7742. alc268_auto_init_mono_speaker_out(codec);
  7743. alc268_auto_init_analog_input(codec);
  7744. }
  7745. /*
  7746. * configuration and preset
  7747. */
  7748. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7749. [ALC268_3ST] = "3stack",
  7750. [ALC268_AUTO] = "auto",
  7751. };
  7752. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7753. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7754. {}
  7755. };
  7756. static struct alc_config_preset alc268_presets[] = {
  7757. [ALC268_3ST] = {
  7758. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7759. .init_verbs = { alc268_base_init_verbs },
  7760. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7761. .dac_nids = alc268_dac_nids,
  7762. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7763. .adc_nids = alc268_adc_nids_alt,
  7764. .hp_nid = 0x03,
  7765. .dig_out_nid = ALC268_DIGOUT_NID,
  7766. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7767. .channel_mode = alc268_modes,
  7768. .input_mux = &alc268_capture_source,
  7769. },
  7770. };
  7771. static int patch_alc268(struct hda_codec *codec)
  7772. {
  7773. struct alc_spec *spec;
  7774. int board_config;
  7775. int err;
  7776. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7777. if (spec == NULL)
  7778. return -ENOMEM;
  7779. codec->spec = spec;
  7780. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7781. alc268_models,
  7782. alc268_cfg_tbl);
  7783. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7784. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7785. "trying auto-probe from BIOS...\n");
  7786. board_config = ALC268_AUTO;
  7787. }
  7788. if (board_config == ALC268_AUTO) {
  7789. /* automatic parse from the BIOS config */
  7790. err = alc268_parse_auto_config(codec);
  7791. if (err < 0) {
  7792. alc_free(codec);
  7793. return err;
  7794. } else if (!err) {
  7795. printk(KERN_INFO
  7796. "hda_codec: Cannot set up configuration "
  7797. "from BIOS. Using base mode...\n");
  7798. board_config = ALC268_3ST;
  7799. }
  7800. }
  7801. if (board_config != ALC268_AUTO)
  7802. setup_preset(spec, &alc268_presets[board_config]);
  7803. spec->stream_name_analog = "ALC268 Analog";
  7804. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7805. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7806. spec->stream_name_digital = "ALC268 Digital";
  7807. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7808. if (board_config == ALC268_AUTO) {
  7809. if (!spec->adc_nids && spec->input_mux) {
  7810. /* check whether NID 0x07 is valid */
  7811. unsigned int wcap = get_wcaps(codec, 0x07);
  7812. /* get type */
  7813. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7814. if (wcap != AC_WID_AUD_IN) {
  7815. spec->adc_nids = alc268_adc_nids_alt;
  7816. spec->num_adc_nids =
  7817. ARRAY_SIZE(alc268_adc_nids_alt);
  7818. spec->mixers[spec->num_mixers] =
  7819. alc268_capture_alt_mixer;
  7820. spec->num_mixers++;
  7821. } else {
  7822. spec->adc_nids = alc268_adc_nids;
  7823. spec->num_adc_nids =
  7824. ARRAY_SIZE(alc268_adc_nids);
  7825. spec->mixers[spec->num_mixers] =
  7826. alc268_capture_mixer;
  7827. spec->num_mixers++;
  7828. }
  7829. }
  7830. }
  7831. codec->patch_ops = alc_patch_ops;
  7832. if (board_config == ALC268_AUTO)
  7833. spec->init_hook = alc268_auto_init;
  7834. return 0;
  7835. }
  7836. /*
  7837. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7838. */
  7839. /*
  7840. * set the path ways for 2 channel output
  7841. * need to set the codec line out and mic 1 pin widgets to inputs
  7842. */
  7843. static struct hda_verb alc861_threestack_ch2_init[] = {
  7844. /* set pin widget 1Ah (line in) for input */
  7845. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7846. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7847. * the vref
  7848. */
  7849. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7850. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7851. #if 0
  7852. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7853. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7854. #endif
  7855. { } /* end */
  7856. };
  7857. /*
  7858. * 6ch mode
  7859. * need to set the codec line out and mic 1 pin widgets to outputs
  7860. */
  7861. static struct hda_verb alc861_threestack_ch6_init[] = {
  7862. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7863. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7864. /* set pin widget 18h (mic1) for output (CLFE)*/
  7865. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7866. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7867. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7868. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7869. #if 0
  7870. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7871. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7872. #endif
  7873. { } /* end */
  7874. };
  7875. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7876. { 2, alc861_threestack_ch2_init },
  7877. { 6, alc861_threestack_ch6_init },
  7878. };
  7879. /* Set mic1 as input and unmute the mixer */
  7880. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7881. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7882. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7883. { } /* end */
  7884. };
  7885. /* Set mic1 as output and mute mixer */
  7886. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7887. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7888. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7889. { } /* end */
  7890. };
  7891. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7892. { 2, alc861_uniwill_m31_ch2_init },
  7893. { 4, alc861_uniwill_m31_ch4_init },
  7894. };
  7895. /* Set mic1 and line-in as input and unmute the mixer */
  7896. static struct hda_verb alc861_asus_ch2_init[] = {
  7897. /* set pin widget 1Ah (line in) for input */
  7898. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7899. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7900. * the vref
  7901. */
  7902. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7903. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7904. #if 0
  7905. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7906. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7907. #endif
  7908. { } /* end */
  7909. };
  7910. /* Set mic1 nad line-in as output and mute mixer */
  7911. static struct hda_verb alc861_asus_ch6_init[] = {
  7912. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7913. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7914. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7915. /* set pin widget 18h (mic1) for output (CLFE)*/
  7916. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7917. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7918. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7919. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7920. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7921. #if 0
  7922. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7923. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7924. #endif
  7925. { } /* end */
  7926. };
  7927. static struct hda_channel_mode alc861_asus_modes[2] = {
  7928. { 2, alc861_asus_ch2_init },
  7929. { 6, alc861_asus_ch6_init },
  7930. };
  7931. /* patch-ALC861 */
  7932. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7933. /* output mixer control */
  7934. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7935. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7936. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7937. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7938. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7939. /*Input mixer control */
  7940. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7941. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7942. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7943. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7944. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7945. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7946. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7947. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7948. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7949. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7950. /* Capture mixer control */
  7951. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7952. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7953. {
  7954. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7955. .name = "Capture Source",
  7956. .count = 1,
  7957. .info = alc_mux_enum_info,
  7958. .get = alc_mux_enum_get,
  7959. .put = alc_mux_enum_put,
  7960. },
  7961. { } /* end */
  7962. };
  7963. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7964. /* output mixer control */
  7965. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7966. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7967. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7968. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7969. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7970. /* Input mixer control */
  7971. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7972. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7973. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7974. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7975. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7976. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7977. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7978. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7979. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7980. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7981. /* Capture mixer control */
  7982. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7983. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7984. {
  7985. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7986. .name = "Capture Source",
  7987. .count = 1,
  7988. .info = alc_mux_enum_info,
  7989. .get = alc_mux_enum_get,
  7990. .put = alc_mux_enum_put,
  7991. },
  7992. {
  7993. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7994. .name = "Channel Mode",
  7995. .info = alc_ch_mode_info,
  7996. .get = alc_ch_mode_get,
  7997. .put = alc_ch_mode_put,
  7998. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7999. },
  8000. { } /* end */
  8001. };
  8002. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8003. /* output mixer control */
  8004. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8005. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8006. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8007. /*Capture mixer control */
  8008. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8009. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8010. {
  8011. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8012. .name = "Capture Source",
  8013. .count = 1,
  8014. .info = alc_mux_enum_info,
  8015. .get = alc_mux_enum_get,
  8016. .put = alc_mux_enum_put,
  8017. },
  8018. { } /* end */
  8019. };
  8020. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8021. /* output mixer control */
  8022. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8023. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8024. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8025. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8026. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8027. /* Input mixer control */
  8028. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8029. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8030. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8031. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8032. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8033. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8034. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8035. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8036. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8037. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8038. /* Capture mixer control */
  8039. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8040. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8041. {
  8042. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8043. .name = "Capture Source",
  8044. .count = 1,
  8045. .info = alc_mux_enum_info,
  8046. .get = alc_mux_enum_get,
  8047. .put = alc_mux_enum_put,
  8048. },
  8049. {
  8050. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8051. .name = "Channel Mode",
  8052. .info = alc_ch_mode_info,
  8053. .get = alc_ch_mode_get,
  8054. .put = alc_ch_mode_put,
  8055. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8056. },
  8057. { } /* end */
  8058. };
  8059. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8060. /* output mixer control */
  8061. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8062. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8063. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8064. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8065. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8066. /* Input mixer control */
  8067. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8068. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8069. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8070. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8071. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8072. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8073. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8074. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8075. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8076. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8077. /* Capture mixer control */
  8078. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8079. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8080. {
  8081. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8082. .name = "Capture Source",
  8083. .count = 1,
  8084. .info = alc_mux_enum_info,
  8085. .get = alc_mux_enum_get,
  8086. .put = alc_mux_enum_put,
  8087. },
  8088. {
  8089. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8090. .name = "Channel Mode",
  8091. .info = alc_ch_mode_info,
  8092. .get = alc_ch_mode_get,
  8093. .put = alc_ch_mode_put,
  8094. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8095. },
  8096. { }
  8097. };
  8098. /* additional mixer */
  8099. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8100. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8101. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8102. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8103. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8104. { }
  8105. };
  8106. /*
  8107. * generic initialization of ADC, input mixers and output mixers
  8108. */
  8109. static struct hda_verb alc861_base_init_verbs[] = {
  8110. /*
  8111. * Unmute ADC0 and set the default input to mic-in
  8112. */
  8113. /* port-A for surround (rear panel) */
  8114. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8115. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8116. /* port-B for mic-in (rear panel) with vref */
  8117. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8118. /* port-C for line-in (rear panel) */
  8119. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8120. /* port-D for Front */
  8121. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8122. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8123. /* port-E for HP out (front panel) */
  8124. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8125. /* route front PCM to HP */
  8126. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8127. /* port-F for mic-in (front panel) with vref */
  8128. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8129. /* port-G for CLFE (rear panel) */
  8130. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8131. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8132. /* port-H for side (rear panel) */
  8133. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8134. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8135. /* CD-in */
  8136. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8137. /* route front mic to ADC1*/
  8138. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8139. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8140. /* Unmute DAC0~3 & spdif out*/
  8141. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8142. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8143. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8144. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8145. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8146. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8147. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8148. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8149. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8150. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8151. /* Unmute Stereo Mixer 15 */
  8152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8153. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8154. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8155. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8156. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8157. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8158. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8159. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8160. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8161. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8162. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8163. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8164. /* hp used DAC 3 (Front) */
  8165. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8166. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8167. { }
  8168. };
  8169. static struct hda_verb alc861_threestack_init_verbs[] = {
  8170. /*
  8171. * Unmute ADC0 and set the default input to mic-in
  8172. */
  8173. /* port-A for surround (rear panel) */
  8174. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8175. /* port-B for mic-in (rear panel) with vref */
  8176. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8177. /* port-C for line-in (rear panel) */
  8178. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8179. /* port-D for Front */
  8180. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8181. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8182. /* port-E for HP out (front panel) */
  8183. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8184. /* route front PCM to HP */
  8185. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8186. /* port-F for mic-in (front panel) with vref */
  8187. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8188. /* port-G for CLFE (rear panel) */
  8189. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8190. /* port-H for side (rear panel) */
  8191. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8192. /* CD-in */
  8193. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8194. /* route front mic to ADC1*/
  8195. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8196. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8197. /* Unmute DAC0~3 & spdif out*/
  8198. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8199. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8200. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8201. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8202. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8203. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8204. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8205. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8206. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8207. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8208. /* Unmute Stereo Mixer 15 */
  8209. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8210. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8212. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8213. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8214. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8215. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8216. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8217. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8218. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8219. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8220. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8221. /* hp used DAC 3 (Front) */
  8222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8223. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8224. { }
  8225. };
  8226. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8227. /*
  8228. * Unmute ADC0 and set the default input to mic-in
  8229. */
  8230. /* port-A for surround (rear panel) */
  8231. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8232. /* port-B for mic-in (rear panel) with vref */
  8233. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8234. /* port-C for line-in (rear panel) */
  8235. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8236. /* port-D for Front */
  8237. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8238. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8239. /* port-E for HP out (front panel) */
  8240. /* this has to be set to VREF80 */
  8241. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8242. /* route front PCM to HP */
  8243. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8244. /* port-F for mic-in (front panel) with vref */
  8245. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8246. /* port-G for CLFE (rear panel) */
  8247. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8248. /* port-H for side (rear panel) */
  8249. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8250. /* CD-in */
  8251. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8252. /* route front mic to ADC1*/
  8253. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8254. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8255. /* Unmute DAC0~3 & spdif out*/
  8256. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8257. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8258. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8259. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8260. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8261. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8262. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8263. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8264. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8265. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8266. /* Unmute Stereo Mixer 15 */
  8267. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8268. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8270. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8271. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8272. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8273. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8274. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8275. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8276. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8277. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8278. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8279. /* hp used DAC 3 (Front) */
  8280. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8281. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8282. { }
  8283. };
  8284. static struct hda_verb alc861_asus_init_verbs[] = {
  8285. /*
  8286. * Unmute ADC0 and set the default input to mic-in
  8287. */
  8288. /* port-A for surround (rear panel)
  8289. * according to codec#0 this is the HP jack
  8290. */
  8291. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8292. /* route front PCM to HP */
  8293. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8294. /* port-B for mic-in (rear panel) with vref */
  8295. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8296. /* port-C for line-in (rear panel) */
  8297. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8298. /* port-D for Front */
  8299. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8300. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8301. /* port-E for HP out (front panel) */
  8302. /* this has to be set to VREF80 */
  8303. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8304. /* route front PCM to HP */
  8305. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8306. /* port-F for mic-in (front panel) with vref */
  8307. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8308. /* port-G for CLFE (rear panel) */
  8309. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8310. /* port-H for side (rear panel) */
  8311. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8312. /* CD-in */
  8313. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8314. /* route front mic to ADC1*/
  8315. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8316. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8317. /* Unmute DAC0~3 & spdif out*/
  8318. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8319. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8320. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8321. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8322. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8323. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8324. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8325. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8326. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8327. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8328. /* Unmute Stereo Mixer 15 */
  8329. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8330. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8331. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8332. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8333. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8334. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8335. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8336. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8337. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8338. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8339. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8340. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8341. /* hp used DAC 3 (Front) */
  8342. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8343. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8344. { }
  8345. };
  8346. /* additional init verbs for ASUS laptops */
  8347. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8348. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8349. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8350. { }
  8351. };
  8352. /*
  8353. * generic initialization of ADC, input mixers and output mixers
  8354. */
  8355. static struct hda_verb alc861_auto_init_verbs[] = {
  8356. /*
  8357. * Unmute ADC0 and set the default input to mic-in
  8358. */
  8359. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8360. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8361. /* Unmute DAC0~3 & spdif out*/
  8362. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8363. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8364. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8365. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8366. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8367. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8368. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8369. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8370. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8371. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8372. /* Unmute Stereo Mixer 15 */
  8373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8379. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8380. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8381. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8382. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8384. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8385. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8386. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8387. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8388. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8389. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8390. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8391. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8392. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8393. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8394. { }
  8395. };
  8396. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8397. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8398. { }
  8399. };
  8400. /* toggle speaker-output according to the hp-jack state */
  8401. static void alc861_toshiba_automute(struct hda_codec *codec)
  8402. {
  8403. unsigned int present;
  8404. present = snd_hda_codec_read(codec, 0x0f, 0,
  8405. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8406. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8407. 0x80, present ? 0x80 : 0);
  8408. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8409. 0x80, present ? 0x80 : 0);
  8410. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8411. 0x80, present ? 0 : 0x80);
  8412. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8413. 0x80, present ? 0 : 0x80);
  8414. }
  8415. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8416. unsigned int res)
  8417. {
  8418. if ((res >> 26) == ALC880_HP_EVENT)
  8419. alc861_toshiba_automute(codec);
  8420. }
  8421. /* pcm configuration: identiacal with ALC880 */
  8422. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8423. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8424. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8425. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8426. #define ALC861_DIGOUT_NID 0x07
  8427. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8428. { 8, NULL }
  8429. };
  8430. static hda_nid_t alc861_dac_nids[4] = {
  8431. /* front, surround, clfe, side */
  8432. 0x03, 0x06, 0x05, 0x04
  8433. };
  8434. static hda_nid_t alc660_dac_nids[3] = {
  8435. /* front, clfe, surround */
  8436. 0x03, 0x05, 0x06
  8437. };
  8438. static hda_nid_t alc861_adc_nids[1] = {
  8439. /* ADC0-2 */
  8440. 0x08,
  8441. };
  8442. static struct hda_input_mux alc861_capture_source = {
  8443. .num_items = 5,
  8444. .items = {
  8445. { "Mic", 0x0 },
  8446. { "Front Mic", 0x3 },
  8447. { "Line", 0x1 },
  8448. { "CD", 0x4 },
  8449. { "Mixer", 0x5 },
  8450. },
  8451. };
  8452. /* fill in the dac_nids table from the parsed pin configuration */
  8453. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8454. const struct auto_pin_cfg *cfg)
  8455. {
  8456. int i;
  8457. hda_nid_t nid;
  8458. spec->multiout.dac_nids = spec->private_dac_nids;
  8459. for (i = 0; i < cfg->line_outs; i++) {
  8460. nid = cfg->line_out_pins[i];
  8461. if (nid) {
  8462. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8463. continue;
  8464. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8465. }
  8466. }
  8467. spec->multiout.num_dacs = cfg->line_outs;
  8468. return 0;
  8469. }
  8470. /* add playback controls from the parsed DAC table */
  8471. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8472. const struct auto_pin_cfg *cfg)
  8473. {
  8474. char name[32];
  8475. static const char *chname[4] = {
  8476. "Front", "Surround", NULL /*CLFE*/, "Side"
  8477. };
  8478. hda_nid_t nid;
  8479. int i, idx, err;
  8480. for (i = 0; i < cfg->line_outs; i++) {
  8481. nid = spec->multiout.dac_nids[i];
  8482. if (!nid)
  8483. continue;
  8484. if (nid == 0x05) {
  8485. /* Center/LFE */
  8486. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8487. "Center Playback Switch",
  8488. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8489. HDA_OUTPUT));
  8490. if (err < 0)
  8491. return err;
  8492. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8493. "LFE Playback Switch",
  8494. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8495. HDA_OUTPUT));
  8496. if (err < 0)
  8497. return err;
  8498. } else {
  8499. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8500. idx++)
  8501. if (nid == alc861_dac_nids[idx])
  8502. break;
  8503. sprintf(name, "%s Playback Switch", chname[idx]);
  8504. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8505. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8506. HDA_OUTPUT));
  8507. if (err < 0)
  8508. return err;
  8509. }
  8510. }
  8511. return 0;
  8512. }
  8513. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8514. {
  8515. int err;
  8516. hda_nid_t nid;
  8517. if (!pin)
  8518. return 0;
  8519. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8520. nid = 0x03;
  8521. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8522. "Headphone Playback Switch",
  8523. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8524. if (err < 0)
  8525. return err;
  8526. spec->multiout.hp_nid = nid;
  8527. }
  8528. return 0;
  8529. }
  8530. /* create playback/capture controls for input pins */
  8531. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8532. const struct auto_pin_cfg *cfg)
  8533. {
  8534. struct hda_input_mux *imux = &spec->private_imux;
  8535. int i, err, idx, idx1;
  8536. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8537. switch (cfg->input_pins[i]) {
  8538. case 0x0c:
  8539. idx1 = 1;
  8540. idx = 2; /* Line In */
  8541. break;
  8542. case 0x0f:
  8543. idx1 = 2;
  8544. idx = 2; /* Line In */
  8545. break;
  8546. case 0x0d:
  8547. idx1 = 0;
  8548. idx = 1; /* Mic In */
  8549. break;
  8550. case 0x10:
  8551. idx1 = 3;
  8552. idx = 1; /* Mic In */
  8553. break;
  8554. case 0x11:
  8555. idx1 = 4;
  8556. idx = 0; /* CD */
  8557. break;
  8558. default:
  8559. continue;
  8560. }
  8561. err = new_analog_input(spec, cfg->input_pins[i],
  8562. auto_pin_cfg_labels[i], idx, 0x15);
  8563. if (err < 0)
  8564. return err;
  8565. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8566. imux->items[imux->num_items].index = idx1;
  8567. imux->num_items++;
  8568. }
  8569. return 0;
  8570. }
  8571. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8572. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8573. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8574. {
  8575. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8576. /* The multiple "Capture Source" controls confuse alsamixer
  8577. * So call somewhat different..
  8578. *FIXME: the controls appear in the "playback" view!
  8579. */
  8580. /* .name = "Capture Source", */
  8581. .name = "Input Source",
  8582. .count = 1,
  8583. .info = alc_mux_enum_info,
  8584. .get = alc_mux_enum_get,
  8585. .put = alc_mux_enum_put,
  8586. },
  8587. { } /* end */
  8588. };
  8589. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8590. hda_nid_t nid,
  8591. int pin_type, int dac_idx)
  8592. {
  8593. /* set as output */
  8594. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8595. pin_type);
  8596. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8597. AMP_OUT_UNMUTE);
  8598. }
  8599. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8600. {
  8601. struct alc_spec *spec = codec->spec;
  8602. int i;
  8603. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8604. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8605. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8606. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8607. if (nid)
  8608. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8609. spec->multiout.dac_nids[i]);
  8610. }
  8611. }
  8612. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8613. {
  8614. struct alc_spec *spec = codec->spec;
  8615. hda_nid_t pin;
  8616. pin = spec->autocfg.hp_pins[0];
  8617. if (pin) /* connect to front */
  8618. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8619. spec->multiout.dac_nids[0]);
  8620. }
  8621. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8622. {
  8623. struct alc_spec *spec = codec->spec;
  8624. int i;
  8625. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8626. hda_nid_t nid = spec->autocfg.input_pins[i];
  8627. if (nid >= 0x0c && nid <= 0x11) {
  8628. snd_hda_codec_write(codec, nid, 0,
  8629. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8630. i <= AUTO_PIN_FRONT_MIC ?
  8631. PIN_VREF80 : PIN_IN);
  8632. }
  8633. }
  8634. }
  8635. /* parse the BIOS configuration and set up the alc_spec */
  8636. /* return 1 if successful, 0 if the proper config is not found,
  8637. * or a negative error code
  8638. */
  8639. static int alc861_parse_auto_config(struct hda_codec *codec)
  8640. {
  8641. struct alc_spec *spec = codec->spec;
  8642. int err;
  8643. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8644. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8645. alc861_ignore);
  8646. if (err < 0)
  8647. return err;
  8648. if (!spec->autocfg.line_outs)
  8649. return 0; /* can't find valid BIOS pin config */
  8650. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8651. if (err < 0)
  8652. return err;
  8653. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8654. if (err < 0)
  8655. return err;
  8656. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8657. if (err < 0)
  8658. return err;
  8659. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8660. if (err < 0)
  8661. return err;
  8662. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8663. if (spec->autocfg.dig_out_pin)
  8664. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8665. if (spec->kctl_alloc)
  8666. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8667. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8668. spec->num_mux_defs = 1;
  8669. spec->input_mux = &spec->private_imux;
  8670. spec->adc_nids = alc861_adc_nids;
  8671. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8672. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8673. spec->num_mixers++;
  8674. return 1;
  8675. }
  8676. /* additional initialization for auto-configuration model */
  8677. static void alc861_auto_init(struct hda_codec *codec)
  8678. {
  8679. alc861_auto_init_multi_out(codec);
  8680. alc861_auto_init_hp_out(codec);
  8681. alc861_auto_init_analog_input(codec);
  8682. }
  8683. /*
  8684. * configuration and preset
  8685. */
  8686. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8687. [ALC861_3ST] = "3stack",
  8688. [ALC660_3ST] = "3stack-660",
  8689. [ALC861_3ST_DIG] = "3stack-dig",
  8690. [ALC861_6ST_DIG] = "6stack-dig",
  8691. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8692. [ALC861_TOSHIBA] = "toshiba",
  8693. [ALC861_ASUS] = "asus",
  8694. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8695. [ALC861_AUTO] = "auto",
  8696. };
  8697. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8698. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8699. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8700. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8701. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8702. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8703. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8704. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8705. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8706. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8707. * Any other models that need this preset?
  8708. */
  8709. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8710. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8711. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8712. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8713. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8714. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8715. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  8716. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  8717. {}
  8718. };
  8719. static struct alc_config_preset alc861_presets[] = {
  8720. [ALC861_3ST] = {
  8721. .mixers = { alc861_3ST_mixer },
  8722. .init_verbs = { alc861_threestack_init_verbs },
  8723. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8724. .dac_nids = alc861_dac_nids,
  8725. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8726. .channel_mode = alc861_threestack_modes,
  8727. .need_dac_fix = 1,
  8728. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8729. .adc_nids = alc861_adc_nids,
  8730. .input_mux = &alc861_capture_source,
  8731. },
  8732. [ALC861_3ST_DIG] = {
  8733. .mixers = { alc861_base_mixer },
  8734. .init_verbs = { alc861_threestack_init_verbs },
  8735. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8736. .dac_nids = alc861_dac_nids,
  8737. .dig_out_nid = ALC861_DIGOUT_NID,
  8738. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8739. .channel_mode = alc861_threestack_modes,
  8740. .need_dac_fix = 1,
  8741. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8742. .adc_nids = alc861_adc_nids,
  8743. .input_mux = &alc861_capture_source,
  8744. },
  8745. [ALC861_6ST_DIG] = {
  8746. .mixers = { alc861_base_mixer },
  8747. .init_verbs = { alc861_base_init_verbs },
  8748. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8749. .dac_nids = alc861_dac_nids,
  8750. .dig_out_nid = ALC861_DIGOUT_NID,
  8751. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8752. .channel_mode = alc861_8ch_modes,
  8753. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8754. .adc_nids = alc861_adc_nids,
  8755. .input_mux = &alc861_capture_source,
  8756. },
  8757. [ALC660_3ST] = {
  8758. .mixers = { alc861_3ST_mixer },
  8759. .init_verbs = { alc861_threestack_init_verbs },
  8760. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8761. .dac_nids = alc660_dac_nids,
  8762. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8763. .channel_mode = alc861_threestack_modes,
  8764. .need_dac_fix = 1,
  8765. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8766. .adc_nids = alc861_adc_nids,
  8767. .input_mux = &alc861_capture_source,
  8768. },
  8769. [ALC861_UNIWILL_M31] = {
  8770. .mixers = { alc861_uniwill_m31_mixer },
  8771. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8772. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8773. .dac_nids = alc861_dac_nids,
  8774. .dig_out_nid = ALC861_DIGOUT_NID,
  8775. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8776. .channel_mode = alc861_uniwill_m31_modes,
  8777. .need_dac_fix = 1,
  8778. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8779. .adc_nids = alc861_adc_nids,
  8780. .input_mux = &alc861_capture_source,
  8781. },
  8782. [ALC861_TOSHIBA] = {
  8783. .mixers = { alc861_toshiba_mixer },
  8784. .init_verbs = { alc861_base_init_verbs,
  8785. alc861_toshiba_init_verbs },
  8786. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8787. .dac_nids = alc861_dac_nids,
  8788. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8789. .channel_mode = alc883_3ST_2ch_modes,
  8790. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8791. .adc_nids = alc861_adc_nids,
  8792. .input_mux = &alc861_capture_source,
  8793. .unsol_event = alc861_toshiba_unsol_event,
  8794. .init_hook = alc861_toshiba_automute,
  8795. },
  8796. [ALC861_ASUS] = {
  8797. .mixers = { alc861_asus_mixer },
  8798. .init_verbs = { alc861_asus_init_verbs },
  8799. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8800. .dac_nids = alc861_dac_nids,
  8801. .dig_out_nid = ALC861_DIGOUT_NID,
  8802. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8803. .channel_mode = alc861_asus_modes,
  8804. .need_dac_fix = 1,
  8805. .hp_nid = 0x06,
  8806. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8807. .adc_nids = alc861_adc_nids,
  8808. .input_mux = &alc861_capture_source,
  8809. },
  8810. [ALC861_ASUS_LAPTOP] = {
  8811. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8812. .init_verbs = { alc861_asus_init_verbs,
  8813. alc861_asus_laptop_init_verbs },
  8814. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8815. .dac_nids = alc861_dac_nids,
  8816. .dig_out_nid = ALC861_DIGOUT_NID,
  8817. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8818. .channel_mode = alc883_3ST_2ch_modes,
  8819. .need_dac_fix = 1,
  8820. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8821. .adc_nids = alc861_adc_nids,
  8822. .input_mux = &alc861_capture_source,
  8823. },
  8824. };
  8825. static int patch_alc861(struct hda_codec *codec)
  8826. {
  8827. struct alc_spec *spec;
  8828. int board_config;
  8829. int err;
  8830. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8831. if (spec == NULL)
  8832. return -ENOMEM;
  8833. codec->spec = spec;
  8834. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8835. alc861_models,
  8836. alc861_cfg_tbl);
  8837. if (board_config < 0) {
  8838. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8839. "trying auto-probe from BIOS...\n");
  8840. board_config = ALC861_AUTO;
  8841. }
  8842. if (board_config == ALC861_AUTO) {
  8843. /* automatic parse from the BIOS config */
  8844. err = alc861_parse_auto_config(codec);
  8845. if (err < 0) {
  8846. alc_free(codec);
  8847. return err;
  8848. } else if (!err) {
  8849. printk(KERN_INFO
  8850. "hda_codec: Cannot set up configuration "
  8851. "from BIOS. Using base mode...\n");
  8852. board_config = ALC861_3ST_DIG;
  8853. }
  8854. }
  8855. if (board_config != ALC861_AUTO)
  8856. setup_preset(spec, &alc861_presets[board_config]);
  8857. spec->stream_name_analog = "ALC861 Analog";
  8858. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8859. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8860. spec->stream_name_digital = "ALC861 Digital";
  8861. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8862. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8863. codec->patch_ops = alc_patch_ops;
  8864. if (board_config == ALC861_AUTO)
  8865. spec->init_hook = alc861_auto_init;
  8866. return 0;
  8867. }
  8868. /*
  8869. * ALC861-VD support
  8870. *
  8871. * Based on ALC882
  8872. *
  8873. * In addition, an independent DAC
  8874. */
  8875. #define ALC861VD_DIGOUT_NID 0x06
  8876. static hda_nid_t alc861vd_dac_nids[4] = {
  8877. /* front, surr, clfe, side surr */
  8878. 0x02, 0x03, 0x04, 0x05
  8879. };
  8880. /* dac_nids for ALC660vd are in a different order - according to
  8881. * Realtek's driver.
  8882. * This should probably tesult in a different mixer for 6stack models
  8883. * of ALC660vd codecs, but for now there is only 3stack mixer
  8884. * - and it is the same as in 861vd.
  8885. * adc_nids in ALC660vd are (is) the same as in 861vd
  8886. */
  8887. static hda_nid_t alc660vd_dac_nids[3] = {
  8888. /* front, rear, clfe, rear_surr */
  8889. 0x02, 0x04, 0x03
  8890. };
  8891. static hda_nid_t alc861vd_adc_nids[1] = {
  8892. /* ADC0 */
  8893. 0x09,
  8894. };
  8895. /* input MUX */
  8896. /* FIXME: should be a matrix-type input source selection */
  8897. static struct hda_input_mux alc861vd_capture_source = {
  8898. .num_items = 4,
  8899. .items = {
  8900. { "Mic", 0x0 },
  8901. { "Front Mic", 0x1 },
  8902. { "Line", 0x2 },
  8903. { "CD", 0x4 },
  8904. },
  8905. };
  8906. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8907. .num_items = 3,
  8908. .items = {
  8909. { "Front Mic", 0x0 },
  8910. { "ATAPI Mic", 0x1 },
  8911. { "Line In", 0x5 },
  8912. },
  8913. };
  8914. #define alc861vd_mux_enum_info alc_mux_enum_info
  8915. #define alc861vd_mux_enum_get alc_mux_enum_get
  8916. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8917. struct snd_ctl_elem_value *ucontrol)
  8918. {
  8919. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8920. struct alc_spec *spec = codec->spec;
  8921. const struct hda_input_mux *imux = spec->input_mux;
  8922. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8923. static hda_nid_t capture_mixers[1] = { 0x22 };
  8924. hda_nid_t nid = capture_mixers[adc_idx];
  8925. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8926. unsigned int i, idx;
  8927. idx = ucontrol->value.enumerated.item[0];
  8928. if (idx >= imux->num_items)
  8929. idx = imux->num_items - 1;
  8930. if (*cur_val == idx && !codec->in_resume)
  8931. return 0;
  8932. for (i = 0; i < imux->num_items; i++) {
  8933. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8934. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8935. v | (imux->items[i].index << 8));
  8936. }
  8937. *cur_val = idx;
  8938. return 1;
  8939. }
  8940. /*
  8941. * 2ch mode
  8942. */
  8943. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8944. { 2, NULL }
  8945. };
  8946. /*
  8947. * 6ch mode
  8948. */
  8949. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8950. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8951. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8952. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8953. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8954. { } /* end */
  8955. };
  8956. /*
  8957. * 8ch mode
  8958. */
  8959. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8960. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8961. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8962. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8963. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8964. { } /* end */
  8965. };
  8966. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8967. { 6, alc861vd_6stack_ch6_init },
  8968. { 8, alc861vd_6stack_ch8_init },
  8969. };
  8970. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8971. {
  8972. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8973. .name = "Channel Mode",
  8974. .info = alc_ch_mode_info,
  8975. .get = alc_ch_mode_get,
  8976. .put = alc_ch_mode_put,
  8977. },
  8978. { } /* end */
  8979. };
  8980. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8981. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8982. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8983. {
  8984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8985. /* The multiple "Capture Source" controls confuse alsamixer
  8986. * So call somewhat different..
  8987. *FIXME: the controls appear in the "playback" view!
  8988. */
  8989. /* .name = "Capture Source", */
  8990. .name = "Input Source",
  8991. .count = 1,
  8992. .info = alc861vd_mux_enum_info,
  8993. .get = alc861vd_mux_enum_get,
  8994. .put = alc861vd_mux_enum_put,
  8995. },
  8996. { } /* end */
  8997. };
  8998. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8999. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9000. */
  9001. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9002. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9003. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9004. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9005. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9006. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9007. HDA_OUTPUT),
  9008. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9009. HDA_OUTPUT),
  9010. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9011. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9012. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9013. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9014. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9015. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9016. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9017. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9018. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9019. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9020. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9023. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9024. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9025. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9026. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9027. { } /* end */
  9028. };
  9029. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9030. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9031. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9032. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9033. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9034. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9035. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9036. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9037. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9038. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9039. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9040. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9041. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9042. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9043. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9044. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9045. { } /* end */
  9046. };
  9047. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9048. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9049. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9050. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9051. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9052. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9053. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9054. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9055. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9056. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9057. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9058. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9059. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9060. { } /* end */
  9061. };
  9062. /* Pin assignment: Front=0x14, HP = 0x15,
  9063. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9064. */
  9065. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9066. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9067. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9068. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9069. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9070. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9071. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9072. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9073. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9074. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9075. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9076. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9077. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9078. {
  9079. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9080. /* .name = "Capture Source", */
  9081. .name = "Input Source",
  9082. .count = 1,
  9083. .info = alc882_mux_enum_info,
  9084. .get = alc882_mux_enum_get,
  9085. .put = alc882_mux_enum_put,
  9086. },
  9087. { } /* end */
  9088. };
  9089. /*
  9090. * generic initialization of ADC, input mixers and output mixers
  9091. */
  9092. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9093. /*
  9094. * Unmute ADC0 and set the default input to mic-in
  9095. */
  9096. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9097. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9098. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9099. * the analog-loopback mixer widget
  9100. */
  9101. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9103. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9104. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9105. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9106. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9107. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9108. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9109. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9110. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9111. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9112. /*
  9113. * Set up output mixers (0x02 - 0x05)
  9114. */
  9115. /* set vol=0 to output mixers */
  9116. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9117. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9118. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9119. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9120. /* set up input amps for analog loopback */
  9121. /* Amp Indices: DAC = 0, mixer = 1 */
  9122. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9123. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9124. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9125. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9126. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9128. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9129. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9130. { }
  9131. };
  9132. /*
  9133. * 3-stack pin configuration:
  9134. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9135. */
  9136. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9137. /*
  9138. * Set pin mode and muting
  9139. */
  9140. /* set front pin widgets 0x14 for output */
  9141. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9142. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9143. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9144. /* Mic (rear) pin: input vref at 80% */
  9145. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9146. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9147. /* Front Mic pin: input vref at 80% */
  9148. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9149. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9150. /* Line In pin: input */
  9151. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9152. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9153. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9154. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9155. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9156. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9157. /* CD pin widget for input */
  9158. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9159. { }
  9160. };
  9161. /*
  9162. * 6-stack pin configuration:
  9163. */
  9164. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9165. /*
  9166. * Set pin mode and muting
  9167. */
  9168. /* set front pin widgets 0x14 for output */
  9169. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9170. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9171. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9172. /* Rear Pin: output 1 (0x0d) */
  9173. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9174. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9175. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9176. /* CLFE Pin: output 2 (0x0e) */
  9177. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9178. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9179. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9180. /* Side Pin: output 3 (0x0f) */
  9181. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9182. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9183. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9184. /* Mic (rear) pin: input vref at 80% */
  9185. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9186. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9187. /* Front Mic pin: input vref at 80% */
  9188. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9189. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9190. /* Line In pin: input */
  9191. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9192. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9193. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9194. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9195. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9196. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9197. /* CD pin widget for input */
  9198. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9199. { }
  9200. };
  9201. static struct hda_verb alc861vd_eapd_verbs[] = {
  9202. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9203. { }
  9204. };
  9205. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9206. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9207. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9208. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9209. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9210. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9211. {}
  9212. };
  9213. /* toggle speaker-output according to the hp-jack state */
  9214. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9215. {
  9216. unsigned int present;
  9217. unsigned char bits;
  9218. present = snd_hda_codec_read(codec, 0x1b, 0,
  9219. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9220. bits = present ? 0x80 : 0;
  9221. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9222. 0x80, bits);
  9223. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9224. 0x80, bits);
  9225. }
  9226. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9227. {
  9228. unsigned int present;
  9229. unsigned char bits;
  9230. present = snd_hda_codec_read(codec, 0x18, 0,
  9231. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9232. bits = present ? 0x80 : 0;
  9233. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9234. 0x80, bits);
  9235. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9236. 0x80, bits);
  9237. }
  9238. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9239. {
  9240. alc861vd_lenovo_hp_automute(codec);
  9241. alc861vd_lenovo_mic_automute(codec);
  9242. }
  9243. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9244. unsigned int res)
  9245. {
  9246. switch (res >> 26) {
  9247. case ALC880_HP_EVENT:
  9248. alc861vd_lenovo_hp_automute(codec);
  9249. break;
  9250. case ALC880_MIC_EVENT:
  9251. alc861vd_lenovo_mic_automute(codec);
  9252. break;
  9253. }
  9254. }
  9255. static struct hda_verb alc861vd_dallas_verbs[] = {
  9256. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9257. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9258. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9259. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9260. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9261. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9262. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9263. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9265. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9266. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9267. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9268. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9269. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9270. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9271. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9272. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9273. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9274. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9275. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9276. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9277. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9278. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9279. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9280. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9281. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9282. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9283. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9284. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9285. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9286. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9287. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9288. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9289. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9290. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9291. { } /* end */
  9292. };
  9293. /* toggle speaker-output according to the hp-jack state */
  9294. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9295. {
  9296. unsigned int present;
  9297. present = snd_hda_codec_read(codec, 0x15, 0,
  9298. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9299. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9300. 0x80, present ? 0x80 : 0);
  9301. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9302. 0x80, present ? 0x80 : 0);
  9303. }
  9304. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9305. {
  9306. if ((res >> 26) == ALC880_HP_EVENT)
  9307. alc861vd_dallas_automute(codec);
  9308. }
  9309. /* pcm configuration: identiacal with ALC880 */
  9310. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9311. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9312. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9313. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9314. /*
  9315. * configuration and preset
  9316. */
  9317. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9318. [ALC660VD_3ST] = "3stack-660",
  9319. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9320. [ALC861VD_3ST] = "3stack",
  9321. [ALC861VD_3ST_DIG] = "3stack-digout",
  9322. [ALC861VD_6ST_DIG] = "6stack-digout",
  9323. [ALC861VD_LENOVO] = "lenovo",
  9324. [ALC861VD_DALLAS] = "dallas",
  9325. [ALC861VD_AUTO] = "auto",
  9326. };
  9327. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9328. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9329. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9330. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9331. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9332. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9333. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9334. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9335. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9336. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9337. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9338. {}
  9339. };
  9340. static struct alc_config_preset alc861vd_presets[] = {
  9341. [ALC660VD_3ST] = {
  9342. .mixers = { alc861vd_3st_mixer },
  9343. .init_verbs = { alc861vd_volume_init_verbs,
  9344. alc861vd_3stack_init_verbs },
  9345. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9346. .dac_nids = alc660vd_dac_nids,
  9347. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9348. .adc_nids = alc861vd_adc_nids,
  9349. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9350. .channel_mode = alc861vd_3stack_2ch_modes,
  9351. .input_mux = &alc861vd_capture_source,
  9352. },
  9353. [ALC660VD_3ST_DIG] = {
  9354. .mixers = { alc861vd_3st_mixer },
  9355. .init_verbs = { alc861vd_volume_init_verbs,
  9356. alc861vd_3stack_init_verbs },
  9357. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9358. .dac_nids = alc660vd_dac_nids,
  9359. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9360. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9361. .adc_nids = alc861vd_adc_nids,
  9362. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9363. .channel_mode = alc861vd_3stack_2ch_modes,
  9364. .input_mux = &alc861vd_capture_source,
  9365. },
  9366. [ALC861VD_3ST] = {
  9367. .mixers = { alc861vd_3st_mixer },
  9368. .init_verbs = { alc861vd_volume_init_verbs,
  9369. alc861vd_3stack_init_verbs },
  9370. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9371. .dac_nids = alc861vd_dac_nids,
  9372. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9373. .channel_mode = alc861vd_3stack_2ch_modes,
  9374. .input_mux = &alc861vd_capture_source,
  9375. },
  9376. [ALC861VD_3ST_DIG] = {
  9377. .mixers = { alc861vd_3st_mixer },
  9378. .init_verbs = { alc861vd_volume_init_verbs,
  9379. alc861vd_3stack_init_verbs },
  9380. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9381. .dac_nids = alc861vd_dac_nids,
  9382. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9383. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9384. .channel_mode = alc861vd_3stack_2ch_modes,
  9385. .input_mux = &alc861vd_capture_source,
  9386. },
  9387. [ALC861VD_6ST_DIG] = {
  9388. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9389. .init_verbs = { alc861vd_volume_init_verbs,
  9390. alc861vd_6stack_init_verbs },
  9391. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9392. .dac_nids = alc861vd_dac_nids,
  9393. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9394. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9395. .channel_mode = alc861vd_6stack_modes,
  9396. .input_mux = &alc861vd_capture_source,
  9397. },
  9398. [ALC861VD_LENOVO] = {
  9399. .mixers = { alc861vd_lenovo_mixer },
  9400. .init_verbs = { alc861vd_volume_init_verbs,
  9401. alc861vd_3stack_init_verbs,
  9402. alc861vd_eapd_verbs,
  9403. alc861vd_lenovo_unsol_verbs },
  9404. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9405. .dac_nids = alc660vd_dac_nids,
  9406. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9407. .adc_nids = alc861vd_adc_nids,
  9408. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9409. .channel_mode = alc861vd_3stack_2ch_modes,
  9410. .input_mux = &alc861vd_capture_source,
  9411. .unsol_event = alc861vd_lenovo_unsol_event,
  9412. .init_hook = alc861vd_lenovo_automute,
  9413. },
  9414. [ALC861VD_DALLAS] = {
  9415. .mixers = { alc861vd_dallas_mixer },
  9416. .init_verbs = { alc861vd_dallas_verbs },
  9417. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9418. .dac_nids = alc861vd_dac_nids,
  9419. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9420. .adc_nids = alc861vd_adc_nids,
  9421. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9422. .channel_mode = alc861vd_3stack_2ch_modes,
  9423. .input_mux = &alc861vd_dallas_capture_source,
  9424. .unsol_event = alc861vd_dallas_unsol_event,
  9425. .init_hook = alc861vd_dallas_automute,
  9426. },
  9427. };
  9428. /*
  9429. * BIOS auto configuration
  9430. */
  9431. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9432. hda_nid_t nid, int pin_type, int dac_idx)
  9433. {
  9434. /* set as output */
  9435. snd_hda_codec_write(codec, nid, 0,
  9436. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9437. snd_hda_codec_write(codec, nid, 0,
  9438. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9439. }
  9440. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9441. {
  9442. struct alc_spec *spec = codec->spec;
  9443. int i;
  9444. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9445. for (i = 0; i <= HDA_SIDE; i++) {
  9446. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9447. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9448. if (nid)
  9449. alc861vd_auto_set_output_and_unmute(codec, nid,
  9450. pin_type, i);
  9451. }
  9452. }
  9453. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9454. {
  9455. struct alc_spec *spec = codec->spec;
  9456. hda_nid_t pin;
  9457. pin = spec->autocfg.hp_pins[0];
  9458. if (pin) /* connect to front and use dac 0 */
  9459. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9460. }
  9461. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9462. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9463. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9464. {
  9465. struct alc_spec *spec = codec->spec;
  9466. int i;
  9467. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9468. hda_nid_t nid = spec->autocfg.input_pins[i];
  9469. if (alc861vd_is_input_pin(nid)) {
  9470. snd_hda_codec_write(codec, nid, 0,
  9471. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9472. i <= AUTO_PIN_FRONT_MIC ?
  9473. PIN_VREF80 : PIN_IN);
  9474. if (nid != ALC861VD_PIN_CD_NID)
  9475. snd_hda_codec_write(codec, nid, 0,
  9476. AC_VERB_SET_AMP_GAIN_MUTE,
  9477. AMP_OUT_MUTE);
  9478. }
  9479. }
  9480. }
  9481. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9482. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9483. /* add playback controls from the parsed DAC table */
  9484. /* Based on ALC880 version. But ALC861VD has separate,
  9485. * different NIDs for mute/unmute switch and volume control */
  9486. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9487. const struct auto_pin_cfg *cfg)
  9488. {
  9489. char name[32];
  9490. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9491. hda_nid_t nid_v, nid_s;
  9492. int i, err;
  9493. for (i = 0; i < cfg->line_outs; i++) {
  9494. if (!spec->multiout.dac_nids[i])
  9495. continue;
  9496. nid_v = alc861vd_idx_to_mixer_vol(
  9497. alc880_dac_to_idx(
  9498. spec->multiout.dac_nids[i]));
  9499. nid_s = alc861vd_idx_to_mixer_switch(
  9500. alc880_dac_to_idx(
  9501. spec->multiout.dac_nids[i]));
  9502. if (i == 2) {
  9503. /* Center/LFE */
  9504. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9505. "Center Playback Volume",
  9506. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9507. HDA_OUTPUT));
  9508. if (err < 0)
  9509. return err;
  9510. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9511. "LFE Playback Volume",
  9512. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9513. HDA_OUTPUT));
  9514. if (err < 0)
  9515. return err;
  9516. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9517. "Center Playback Switch",
  9518. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9519. HDA_INPUT));
  9520. if (err < 0)
  9521. return err;
  9522. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9523. "LFE Playback Switch",
  9524. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9525. HDA_INPUT));
  9526. if (err < 0)
  9527. return err;
  9528. } else {
  9529. sprintf(name, "%s Playback Volume", chname[i]);
  9530. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9531. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9532. HDA_OUTPUT));
  9533. if (err < 0)
  9534. return err;
  9535. sprintf(name, "%s Playback Switch", chname[i]);
  9536. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9537. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9538. HDA_INPUT));
  9539. if (err < 0)
  9540. return err;
  9541. }
  9542. }
  9543. return 0;
  9544. }
  9545. /* add playback controls for speaker and HP outputs */
  9546. /* Based on ALC880 version. But ALC861VD has separate,
  9547. * different NIDs for mute/unmute switch and volume control */
  9548. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9549. hda_nid_t pin, const char *pfx)
  9550. {
  9551. hda_nid_t nid_v, nid_s;
  9552. int err;
  9553. char name[32];
  9554. if (!pin)
  9555. return 0;
  9556. if (alc880_is_fixed_pin(pin)) {
  9557. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9558. /* specify the DAC as the extra output */
  9559. if (!spec->multiout.hp_nid)
  9560. spec->multiout.hp_nid = nid_v;
  9561. else
  9562. spec->multiout.extra_out_nid[0] = nid_v;
  9563. /* control HP volume/switch on the output mixer amp */
  9564. nid_v = alc861vd_idx_to_mixer_vol(
  9565. alc880_fixed_pin_idx(pin));
  9566. nid_s = alc861vd_idx_to_mixer_switch(
  9567. alc880_fixed_pin_idx(pin));
  9568. sprintf(name, "%s Playback Volume", pfx);
  9569. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9570. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9571. if (err < 0)
  9572. return err;
  9573. sprintf(name, "%s Playback Switch", pfx);
  9574. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9575. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9576. if (err < 0)
  9577. return err;
  9578. } else if (alc880_is_multi_pin(pin)) {
  9579. /* set manual connection */
  9580. /* we have only a switch on HP-out PIN */
  9581. sprintf(name, "%s Playback Switch", pfx);
  9582. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9583. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9584. if (err < 0)
  9585. return err;
  9586. }
  9587. return 0;
  9588. }
  9589. /* parse the BIOS configuration and set up the alc_spec
  9590. * return 1 if successful, 0 if the proper config is not found,
  9591. * or a negative error code
  9592. * Based on ALC880 version - had to change it to override
  9593. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9594. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9595. {
  9596. struct alc_spec *spec = codec->spec;
  9597. int err;
  9598. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9599. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9600. alc861vd_ignore);
  9601. if (err < 0)
  9602. return err;
  9603. if (!spec->autocfg.line_outs)
  9604. return 0; /* can't find valid BIOS pin config */
  9605. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9606. if (err < 0)
  9607. return err;
  9608. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9609. if (err < 0)
  9610. return err;
  9611. err = alc861vd_auto_create_extra_out(spec,
  9612. spec->autocfg.speaker_pins[0],
  9613. "Speaker");
  9614. if (err < 0)
  9615. return err;
  9616. err = alc861vd_auto_create_extra_out(spec,
  9617. spec->autocfg.hp_pins[0],
  9618. "Headphone");
  9619. if (err < 0)
  9620. return err;
  9621. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9622. if (err < 0)
  9623. return err;
  9624. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9625. if (spec->autocfg.dig_out_pin)
  9626. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9627. if (spec->kctl_alloc)
  9628. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9629. spec->init_verbs[spec->num_init_verbs++]
  9630. = alc861vd_volume_init_verbs;
  9631. spec->num_mux_defs = 1;
  9632. spec->input_mux = &spec->private_imux;
  9633. return 1;
  9634. }
  9635. /* additional initialization for auto-configuration model */
  9636. static void alc861vd_auto_init(struct hda_codec *codec)
  9637. {
  9638. alc861vd_auto_init_multi_out(codec);
  9639. alc861vd_auto_init_hp_out(codec);
  9640. alc861vd_auto_init_analog_input(codec);
  9641. }
  9642. static int patch_alc861vd(struct hda_codec *codec)
  9643. {
  9644. struct alc_spec *spec;
  9645. int err, board_config;
  9646. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9647. if (spec == NULL)
  9648. return -ENOMEM;
  9649. codec->spec = spec;
  9650. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9651. alc861vd_models,
  9652. alc861vd_cfg_tbl);
  9653. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9654. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9655. "ALC861VD, trying auto-probe from BIOS...\n");
  9656. board_config = ALC861VD_AUTO;
  9657. }
  9658. if (board_config == ALC861VD_AUTO) {
  9659. /* automatic parse from the BIOS config */
  9660. err = alc861vd_parse_auto_config(codec);
  9661. if (err < 0) {
  9662. alc_free(codec);
  9663. return err;
  9664. } else if (!err) {
  9665. printk(KERN_INFO
  9666. "hda_codec: Cannot set up configuration "
  9667. "from BIOS. Using base mode...\n");
  9668. board_config = ALC861VD_3ST;
  9669. }
  9670. }
  9671. if (board_config != ALC861VD_AUTO)
  9672. setup_preset(spec, &alc861vd_presets[board_config]);
  9673. spec->stream_name_analog = "ALC861VD Analog";
  9674. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9675. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9676. spec->stream_name_digital = "ALC861VD Digital";
  9677. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9678. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9679. spec->adc_nids = alc861vd_adc_nids;
  9680. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9681. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9682. spec->num_mixers++;
  9683. codec->patch_ops = alc_patch_ops;
  9684. if (board_config == ALC861VD_AUTO)
  9685. spec->init_hook = alc861vd_auto_init;
  9686. return 0;
  9687. }
  9688. /*
  9689. * ALC662 support
  9690. *
  9691. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9692. * configuration. Each pin widget can choose any input DACs and a mixer.
  9693. * Each ADC is connected from a mixer of all inputs. This makes possible
  9694. * 6-channel independent captures.
  9695. *
  9696. * In addition, an independent DAC for the multi-playback (not used in this
  9697. * driver yet).
  9698. */
  9699. #define ALC662_DIGOUT_NID 0x06
  9700. #define ALC662_DIGIN_NID 0x0a
  9701. static hda_nid_t alc662_dac_nids[4] = {
  9702. /* front, rear, clfe, rear_surr */
  9703. 0x02, 0x03, 0x04
  9704. };
  9705. static hda_nid_t alc662_adc_nids[1] = {
  9706. /* ADC1-2 */
  9707. 0x09,
  9708. };
  9709. /* input MUX */
  9710. /* FIXME: should be a matrix-type input source selection */
  9711. static struct hda_input_mux alc662_capture_source = {
  9712. .num_items = 4,
  9713. .items = {
  9714. { "Mic", 0x0 },
  9715. { "Front Mic", 0x1 },
  9716. { "Line", 0x2 },
  9717. { "CD", 0x4 },
  9718. },
  9719. };
  9720. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9721. .num_items = 2,
  9722. .items = {
  9723. { "Mic", 0x1 },
  9724. { "Line", 0x2 },
  9725. },
  9726. };
  9727. #define alc662_mux_enum_info alc_mux_enum_info
  9728. #define alc662_mux_enum_get alc_mux_enum_get
  9729. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9730. struct snd_ctl_elem_value *ucontrol)
  9731. {
  9732. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9733. struct alc_spec *spec = codec->spec;
  9734. const struct hda_input_mux *imux = spec->input_mux;
  9735. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9736. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9737. hda_nid_t nid = capture_mixers[adc_idx];
  9738. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9739. unsigned int i, idx;
  9740. idx = ucontrol->value.enumerated.item[0];
  9741. if (idx >= imux->num_items)
  9742. idx = imux->num_items - 1;
  9743. if (*cur_val == idx && !codec->in_resume)
  9744. return 0;
  9745. for (i = 0; i < imux->num_items; i++) {
  9746. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9747. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9748. v | (imux->items[i].index << 8));
  9749. }
  9750. *cur_val = idx;
  9751. return 1;
  9752. }
  9753. /*
  9754. * 2ch mode
  9755. */
  9756. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9757. { 2, NULL }
  9758. };
  9759. /*
  9760. * 2ch mode
  9761. */
  9762. static struct hda_verb alc662_3ST_ch2_init[] = {
  9763. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9764. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9765. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9766. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9767. { } /* end */
  9768. };
  9769. /*
  9770. * 6ch mode
  9771. */
  9772. static struct hda_verb alc662_3ST_ch6_init[] = {
  9773. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9774. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9775. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9776. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9777. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9778. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9779. { } /* end */
  9780. };
  9781. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9782. { 2, alc662_3ST_ch2_init },
  9783. { 6, alc662_3ST_ch6_init },
  9784. };
  9785. /*
  9786. * 2ch mode
  9787. */
  9788. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9789. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9790. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9791. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9792. { } /* end */
  9793. };
  9794. /*
  9795. * 6ch mode
  9796. */
  9797. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9798. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9799. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9800. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9801. { } /* end */
  9802. };
  9803. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9804. { 2, alc662_sixstack_ch6_init },
  9805. { 6, alc662_sixstack_ch8_init },
  9806. };
  9807. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9808. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9809. */
  9810. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9811. /* output mixer control */
  9812. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9813. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9814. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9815. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9816. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9817. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9818. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9819. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9820. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9821. /*Input mixer control */
  9822. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9823. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9824. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9825. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9826. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9827. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9828. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9829. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9830. /* Capture mixer control */
  9831. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9832. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9833. {
  9834. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9835. .name = "Capture Source",
  9836. .count = 1,
  9837. .info = alc_mux_enum_info,
  9838. .get = alc_mux_enum_get,
  9839. .put = alc_mux_enum_put,
  9840. },
  9841. { } /* end */
  9842. };
  9843. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9844. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9845. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9846. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9847. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9848. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9849. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9850. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9851. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9852. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9853. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9854. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9855. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9856. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9857. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9858. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9859. {
  9860. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9861. /* .name = "Capture Source", */
  9862. .name = "Input Source",
  9863. .count = 1,
  9864. .info = alc662_mux_enum_info,
  9865. .get = alc662_mux_enum_get,
  9866. .put = alc662_mux_enum_put,
  9867. },
  9868. { } /* end */
  9869. };
  9870. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9871. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9872. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9873. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9874. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9875. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9876. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9877. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9878. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9879. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9880. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9881. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9882. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9883. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9884. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9885. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9886. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9887. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9888. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9889. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9890. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9891. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9892. {
  9893. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9894. /* .name = "Capture Source", */
  9895. .name = "Input Source",
  9896. .count = 1,
  9897. .info = alc662_mux_enum_info,
  9898. .get = alc662_mux_enum_get,
  9899. .put = alc662_mux_enum_put,
  9900. },
  9901. { } /* end */
  9902. };
  9903. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9904. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9905. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9906. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9907. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9908. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9909. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9910. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9911. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9912. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9913. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9914. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9915. {
  9916. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9917. /* .name = "Capture Source", */
  9918. .name = "Input Source",
  9919. .count = 1,
  9920. .info = alc662_mux_enum_info,
  9921. .get = alc662_mux_enum_get,
  9922. .put = alc662_mux_enum_put,
  9923. },
  9924. { } /* end */
  9925. };
  9926. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9927. {
  9928. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9929. .name = "Channel Mode",
  9930. .info = alc_ch_mode_info,
  9931. .get = alc_ch_mode_get,
  9932. .put = alc_ch_mode_put,
  9933. },
  9934. { } /* end */
  9935. };
  9936. static struct hda_verb alc662_init_verbs[] = {
  9937. /* ADC: mute amp left and right */
  9938. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9939. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9940. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9941. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9942. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9943. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9944. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9945. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9946. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9947. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9948. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9949. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9950. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9951. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9952. /* Front Pin: output 0 (0x0c) */
  9953. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9954. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9955. /* Rear Pin: output 1 (0x0d) */
  9956. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9957. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9958. /* CLFE Pin: output 2 (0x0e) */
  9959. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9960. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9961. /* Mic (rear) pin: input vref at 80% */
  9962. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9963. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9964. /* Front Mic pin: input vref at 80% */
  9965. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9966. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9967. /* Line In pin: input */
  9968. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9969. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9970. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9971. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9972. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9973. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9974. /* CD pin widget for input */
  9975. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9976. /* FIXME: use matrix-type input source selection */
  9977. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9978. /* Input mixer */
  9979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9981. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9982. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9983. { }
  9984. };
  9985. static struct hda_verb alc662_sue_init_verbs[] = {
  9986. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9987. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9988. {}
  9989. };
  9990. /*
  9991. * generic initialization of ADC, input mixers and output mixers
  9992. */
  9993. static struct hda_verb alc662_auto_init_verbs[] = {
  9994. /*
  9995. * Unmute ADC and set the default input to mic-in
  9996. */
  9997. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9998. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9999. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10000. * mixer widget
  10001. * Note: PASD motherboards uses the Line In 2 as the input for front
  10002. * panel mic (mic 2)
  10003. */
  10004. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10005. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10006. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10007. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10008. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  10009. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10010. /*
  10011. * Set up output mixers (0x0c - 0x0f)
  10012. */
  10013. /* set vol=0 to output mixers */
  10014. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10015. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10016. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10017. /* set up input amps for analog loopback */
  10018. /* Amp Indices: DAC = 0, mixer = 1 */
  10019. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10020. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10021. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10022. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10023. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10024. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10025. /* FIXME: use matrix-type input source selection */
  10026. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10027. /* Input mixer */
  10028. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10029. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10030. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10031. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  10032. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10033. { }
  10034. };
  10035. /* capture mixer elements */
  10036. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10037. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10038. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10039. {
  10040. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10041. /* The multiple "Capture Source" controls confuse alsamixer
  10042. * So call somewhat different..
  10043. * FIXME: the controls appear in the "playback" view!
  10044. */
  10045. /* .name = "Capture Source", */
  10046. .name = "Input Source",
  10047. .count = 1,
  10048. .info = alc882_mux_enum_info,
  10049. .get = alc882_mux_enum_get,
  10050. .put = alc882_mux_enum_put,
  10051. },
  10052. { } /* end */
  10053. };
  10054. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10055. {
  10056. unsigned int present;
  10057. unsigned char bits;
  10058. present = snd_hda_codec_read(codec, 0x14, 0,
  10059. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10060. bits = present ? 0x80 : 0;
  10061. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10062. 0x80, bits);
  10063. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10064. 0x80, bits);
  10065. }
  10066. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10067. {
  10068. unsigned int present;
  10069. unsigned char bits;
  10070. present = snd_hda_codec_read(codec, 0x1b, 0,
  10071. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10072. bits = present ? 0x80 : 0;
  10073. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10074. 0x80, bits);
  10075. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10076. 0x80, bits);
  10077. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10078. 0x80, bits);
  10079. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10080. 0x80, bits);
  10081. }
  10082. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10083. unsigned int res)
  10084. {
  10085. if ((res >> 26) == ALC880_HP_EVENT)
  10086. alc662_lenovo_101e_all_automute(codec);
  10087. if ((res >> 26) == ALC880_FRONT_EVENT)
  10088. alc662_lenovo_101e_ispeaker_automute(codec);
  10089. }
  10090. /* pcm configuration: identiacal with ALC880 */
  10091. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10092. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10093. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10094. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10095. /*
  10096. * configuration and preset
  10097. */
  10098. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10099. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10100. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10101. [ALC662_3ST_6ch] = "3stack-6ch",
  10102. [ALC662_5ST_DIG] = "6stack-dig",
  10103. [ALC662_LENOVO_101E] = "lenovo-101e",
  10104. [ALC662_AUTO] = "auto",
  10105. };
  10106. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10107. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10108. {}
  10109. };
  10110. static struct alc_config_preset alc662_presets[] = {
  10111. [ALC662_3ST_2ch_DIG] = {
  10112. .mixers = { alc662_3ST_2ch_mixer },
  10113. .init_verbs = { alc662_init_verbs },
  10114. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10115. .dac_nids = alc662_dac_nids,
  10116. .dig_out_nid = ALC662_DIGOUT_NID,
  10117. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10118. .adc_nids = alc662_adc_nids,
  10119. .dig_in_nid = ALC662_DIGIN_NID,
  10120. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10121. .channel_mode = alc662_3ST_2ch_modes,
  10122. .input_mux = &alc662_capture_source,
  10123. },
  10124. [ALC662_3ST_6ch_DIG] = {
  10125. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10126. .init_verbs = { alc662_init_verbs },
  10127. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10128. .dac_nids = alc662_dac_nids,
  10129. .dig_out_nid = ALC662_DIGOUT_NID,
  10130. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10131. .adc_nids = alc662_adc_nids,
  10132. .dig_in_nid = ALC662_DIGIN_NID,
  10133. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10134. .channel_mode = alc662_3ST_6ch_modes,
  10135. .need_dac_fix = 1,
  10136. .input_mux = &alc662_capture_source,
  10137. },
  10138. [ALC662_3ST_6ch] = {
  10139. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10140. .init_verbs = { alc662_init_verbs },
  10141. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10142. .dac_nids = alc662_dac_nids,
  10143. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10144. .adc_nids = alc662_adc_nids,
  10145. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10146. .channel_mode = alc662_3ST_6ch_modes,
  10147. .need_dac_fix = 1,
  10148. .input_mux = &alc662_capture_source,
  10149. },
  10150. [ALC662_5ST_DIG] = {
  10151. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10152. .init_verbs = { alc662_init_verbs },
  10153. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10154. .dac_nids = alc662_dac_nids,
  10155. .dig_out_nid = ALC662_DIGOUT_NID,
  10156. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10157. .adc_nids = alc662_adc_nids,
  10158. .dig_in_nid = ALC662_DIGIN_NID,
  10159. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10160. .channel_mode = alc662_5stack_modes,
  10161. .input_mux = &alc662_capture_source,
  10162. },
  10163. [ALC662_LENOVO_101E] = {
  10164. .mixers = { alc662_lenovo_101e_mixer },
  10165. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10166. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10167. .dac_nids = alc662_dac_nids,
  10168. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10169. .adc_nids = alc662_adc_nids,
  10170. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10171. .channel_mode = alc662_3ST_2ch_modes,
  10172. .input_mux = &alc662_lenovo_101e_capture_source,
  10173. .unsol_event = alc662_lenovo_101e_unsol_event,
  10174. .init_hook = alc662_lenovo_101e_all_automute,
  10175. },
  10176. };
  10177. /*
  10178. * BIOS auto configuration
  10179. */
  10180. /* add playback controls from the parsed DAC table */
  10181. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10182. const struct auto_pin_cfg *cfg)
  10183. {
  10184. char name[32];
  10185. static const char *chname[4] = {
  10186. "Front", "Surround", NULL /*CLFE*/, "Side"
  10187. };
  10188. hda_nid_t nid;
  10189. int i, err;
  10190. for (i = 0; i < cfg->line_outs; i++) {
  10191. if (!spec->multiout.dac_nids[i])
  10192. continue;
  10193. nid = alc880_idx_to_mixer(i);
  10194. if (i == 2) {
  10195. /* Center/LFE */
  10196. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10197. "Center Playback Volume",
  10198. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10199. HDA_OUTPUT));
  10200. if (err < 0)
  10201. return err;
  10202. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10203. "LFE Playback Volume",
  10204. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10205. HDA_OUTPUT));
  10206. if (err < 0)
  10207. return err;
  10208. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10209. "Center Playback Switch",
  10210. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10211. HDA_INPUT));
  10212. if (err < 0)
  10213. return err;
  10214. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10215. "LFE Playback Switch",
  10216. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10217. HDA_INPUT));
  10218. if (err < 0)
  10219. return err;
  10220. } else {
  10221. sprintf(name, "%s Playback Volume", chname[i]);
  10222. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10223. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10224. HDA_OUTPUT));
  10225. if (err < 0)
  10226. return err;
  10227. sprintf(name, "%s Playback Switch", chname[i]);
  10228. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10229. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10230. HDA_INPUT));
  10231. if (err < 0)
  10232. return err;
  10233. }
  10234. }
  10235. return 0;
  10236. }
  10237. /* add playback controls for speaker and HP outputs */
  10238. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10239. const char *pfx)
  10240. {
  10241. hda_nid_t nid;
  10242. int err;
  10243. char name[32];
  10244. if (!pin)
  10245. return 0;
  10246. if (alc880_is_fixed_pin(pin)) {
  10247. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10248. /* printk("DAC nid=%x\n",nid); */
  10249. /* specify the DAC as the extra output */
  10250. if (!spec->multiout.hp_nid)
  10251. spec->multiout.hp_nid = nid;
  10252. else
  10253. spec->multiout.extra_out_nid[0] = nid;
  10254. /* control HP volume/switch on the output mixer amp */
  10255. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10256. sprintf(name, "%s Playback Volume", pfx);
  10257. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10258. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10259. if (err < 0)
  10260. return err;
  10261. sprintf(name, "%s Playback Switch", pfx);
  10262. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10263. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10264. if (err < 0)
  10265. return err;
  10266. } else if (alc880_is_multi_pin(pin)) {
  10267. /* set manual connection */
  10268. /* we have only a switch on HP-out PIN */
  10269. sprintf(name, "%s Playback Switch", pfx);
  10270. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10271. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10272. if (err < 0)
  10273. return err;
  10274. }
  10275. return 0;
  10276. }
  10277. /* create playback/capture controls for input pins */
  10278. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10279. const struct auto_pin_cfg *cfg)
  10280. {
  10281. struct hda_input_mux *imux = &spec->private_imux;
  10282. int i, err, idx;
  10283. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10284. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10285. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10286. err = new_analog_input(spec, cfg->input_pins[i],
  10287. auto_pin_cfg_labels[i],
  10288. idx, 0x0b);
  10289. if (err < 0)
  10290. return err;
  10291. imux->items[imux->num_items].label =
  10292. auto_pin_cfg_labels[i];
  10293. imux->items[imux->num_items].index =
  10294. alc880_input_pin_idx(cfg->input_pins[i]);
  10295. imux->num_items++;
  10296. }
  10297. }
  10298. return 0;
  10299. }
  10300. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10301. hda_nid_t nid, int pin_type,
  10302. int dac_idx)
  10303. {
  10304. /* set as output */
  10305. snd_hda_codec_write(codec, nid, 0,
  10306. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10307. snd_hda_codec_write(codec, nid, 0,
  10308. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10309. /* need the manual connection? */
  10310. if (alc880_is_multi_pin(nid)) {
  10311. struct alc_spec *spec = codec->spec;
  10312. int idx = alc880_multi_pin_idx(nid);
  10313. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10314. AC_VERB_SET_CONNECT_SEL,
  10315. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10316. }
  10317. }
  10318. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10319. {
  10320. struct alc_spec *spec = codec->spec;
  10321. int i;
  10322. for (i = 0; i <= HDA_SIDE; i++) {
  10323. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10324. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10325. if (nid)
  10326. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10327. i);
  10328. }
  10329. }
  10330. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10331. {
  10332. struct alc_spec *spec = codec->spec;
  10333. hda_nid_t pin;
  10334. pin = spec->autocfg.hp_pins[0];
  10335. if (pin) /* connect to front */
  10336. /* use dac 0 */
  10337. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10338. }
  10339. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10340. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10341. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10342. {
  10343. struct alc_spec *spec = codec->spec;
  10344. int i;
  10345. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10346. hda_nid_t nid = spec->autocfg.input_pins[i];
  10347. if (alc662_is_input_pin(nid)) {
  10348. snd_hda_codec_write(codec, nid, 0,
  10349. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10350. (i <= AUTO_PIN_FRONT_MIC ?
  10351. PIN_VREF80 : PIN_IN));
  10352. if (nid != ALC662_PIN_CD_NID)
  10353. snd_hda_codec_write(codec, nid, 0,
  10354. AC_VERB_SET_AMP_GAIN_MUTE,
  10355. AMP_OUT_MUTE);
  10356. }
  10357. }
  10358. }
  10359. static int alc662_parse_auto_config(struct hda_codec *codec)
  10360. {
  10361. struct alc_spec *spec = codec->spec;
  10362. int err;
  10363. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10364. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10365. alc662_ignore);
  10366. if (err < 0)
  10367. return err;
  10368. if (!spec->autocfg.line_outs)
  10369. return 0; /* can't find valid BIOS pin config */
  10370. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10371. if (err < 0)
  10372. return err;
  10373. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10374. if (err < 0)
  10375. return err;
  10376. err = alc662_auto_create_extra_out(spec,
  10377. spec->autocfg.speaker_pins[0],
  10378. "Speaker");
  10379. if (err < 0)
  10380. return err;
  10381. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10382. "Headphone");
  10383. if (err < 0)
  10384. return err;
  10385. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10386. if (err < 0)
  10387. return err;
  10388. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10389. if (spec->autocfg.dig_out_pin)
  10390. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10391. if (spec->kctl_alloc)
  10392. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10393. spec->num_mux_defs = 1;
  10394. spec->input_mux = &spec->private_imux;
  10395. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10396. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10397. spec->num_mixers++;
  10398. return 1;
  10399. }
  10400. /* additional initialization for auto-configuration model */
  10401. static void alc662_auto_init(struct hda_codec *codec)
  10402. {
  10403. alc662_auto_init_multi_out(codec);
  10404. alc662_auto_init_hp_out(codec);
  10405. alc662_auto_init_analog_input(codec);
  10406. }
  10407. static int patch_alc662(struct hda_codec *codec)
  10408. {
  10409. struct alc_spec *spec;
  10410. int err, board_config;
  10411. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10412. if (!spec)
  10413. return -ENOMEM;
  10414. codec->spec = spec;
  10415. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10416. alc662_models,
  10417. alc662_cfg_tbl);
  10418. if (board_config < 0) {
  10419. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10420. "trying auto-probe from BIOS...\n");
  10421. board_config = ALC662_AUTO;
  10422. }
  10423. if (board_config == ALC662_AUTO) {
  10424. /* automatic parse from the BIOS config */
  10425. err = alc662_parse_auto_config(codec);
  10426. if (err < 0) {
  10427. alc_free(codec);
  10428. return err;
  10429. } else if (!err) {
  10430. printk(KERN_INFO
  10431. "hda_codec: Cannot set up configuration "
  10432. "from BIOS. Using base mode...\n");
  10433. board_config = ALC662_3ST_2ch_DIG;
  10434. }
  10435. }
  10436. if (board_config != ALC662_AUTO)
  10437. setup_preset(spec, &alc662_presets[board_config]);
  10438. spec->stream_name_analog = "ALC662 Analog";
  10439. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10440. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10441. spec->stream_name_digital = "ALC662 Digital";
  10442. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10443. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10444. if (!spec->adc_nids && spec->input_mux) {
  10445. spec->adc_nids = alc662_adc_nids;
  10446. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10447. }
  10448. codec->patch_ops = alc_patch_ops;
  10449. if (board_config == ALC662_AUTO)
  10450. spec->init_hook = alc662_auto_init;
  10451. return 0;
  10452. }
  10453. /*
  10454. * patch entries
  10455. */
  10456. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10457. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10458. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10459. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10460. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10461. .patch = patch_alc861 },
  10462. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10463. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10464. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10465. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10466. .patch = patch_alc883 },
  10467. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10468. .patch = patch_alc662 },
  10469. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10470. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10471. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10472. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10473. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10474. {} /* terminator */
  10475. };