patch_realtek.c 412 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_ASUS_EEEPC_P701,
  138. ALC662_AUTO,
  139. ALC662_MODEL_LAST,
  140. };
  141. /* ALC882 models */
  142. enum {
  143. ALC882_3ST_DIG,
  144. ALC882_6ST_DIG,
  145. ALC882_ARIMA,
  146. ALC882_W2JC,
  147. ALC882_TARGA,
  148. ALC882_ASUS_A7J,
  149. ALC882_ASUS_A7M,
  150. ALC885_MACPRO,
  151. ALC885_MBP3,
  152. ALC885_IMAC24,
  153. ALC882_AUTO,
  154. ALC882_MODEL_LAST,
  155. };
  156. /* ALC883 models */
  157. enum {
  158. ALC883_3ST_2ch_DIG,
  159. ALC883_3ST_6ch_DIG,
  160. ALC883_3ST_6ch,
  161. ALC883_6ST_DIG,
  162. ALC883_TARGA_DIG,
  163. ALC883_TARGA_2ch_DIG,
  164. ALC883_ACER,
  165. ALC883_ACER_ASPIRE,
  166. ALC883_MEDION,
  167. ALC883_MEDION_MD2,
  168. ALC883_LAPTOP_EAPD,
  169. ALC883_LENOVO_101E_2ch,
  170. ALC883_LENOVO_NB0763,
  171. ALC888_LENOVO_MS7195_DIG,
  172. ALC883_HAIER_W66,
  173. ALC888_6ST_HP,
  174. ALC888_3ST_HP,
  175. ALC883_AUTO,
  176. ALC883_MODEL_LAST,
  177. };
  178. /* for GPIO Poll */
  179. #define GPIO_MASK 0x03
  180. struct alc_spec {
  181. /* codec parameterization */
  182. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  183. unsigned int num_mixers;
  184. const struct hda_verb *init_verbs[5]; /* initialization verbs
  185. * don't forget NULL
  186. * termination!
  187. */
  188. unsigned int num_init_verbs;
  189. char *stream_name_analog; /* analog PCM stream */
  190. struct hda_pcm_stream *stream_analog_playback;
  191. struct hda_pcm_stream *stream_analog_capture;
  192. char *stream_name_digital; /* digital PCM stream */
  193. struct hda_pcm_stream *stream_digital_playback;
  194. struct hda_pcm_stream *stream_digital_capture;
  195. /* playback */
  196. struct hda_multi_out multiout; /* playback set-up
  197. * max_channels, dacs must be set
  198. * dig_out_nid and hp_nid are optional
  199. */
  200. /* capture */
  201. unsigned int num_adc_nids;
  202. hda_nid_t *adc_nids;
  203. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  204. /* capture source */
  205. unsigned int num_mux_defs;
  206. const struct hda_input_mux *input_mux;
  207. unsigned int cur_mux[3];
  208. /* channel model */
  209. const struct hda_channel_mode *channel_mode;
  210. int num_channel_mode;
  211. int need_dac_fix;
  212. /* PCM information */
  213. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  214. /* dynamic controls, init_verbs and input_mux */
  215. struct auto_pin_cfg autocfg;
  216. unsigned int num_kctl_alloc, num_kctl_used;
  217. struct snd_kcontrol_new *kctl_alloc;
  218. struct hda_input_mux private_imux;
  219. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  220. /* hooks */
  221. void (*init_hook)(struct hda_codec *codec);
  222. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  223. /* for pin sensing */
  224. unsigned int sense_updated: 1;
  225. unsigned int jack_present: 1;
  226. #ifdef CONFIG_SND_HDA_POWER_SAVE
  227. struct hda_loopback_check loopback;
  228. #endif
  229. };
  230. /*
  231. * configuration template - to be copied to the spec instance
  232. */
  233. struct alc_config_preset {
  234. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  235. * with spec
  236. */
  237. const struct hda_verb *init_verbs[5];
  238. unsigned int num_dacs;
  239. hda_nid_t *dac_nids;
  240. hda_nid_t dig_out_nid; /* optional */
  241. hda_nid_t hp_nid; /* optional */
  242. unsigned int num_adc_nids;
  243. hda_nid_t *adc_nids;
  244. hda_nid_t dig_in_nid;
  245. unsigned int num_channel_mode;
  246. const struct hda_channel_mode *channel_mode;
  247. int need_dac_fix;
  248. unsigned int num_mux_defs;
  249. const struct hda_input_mux *input_mux;
  250. void (*unsol_event)(struct hda_codec *, unsigned int);
  251. void (*init_hook)(struct hda_codec *);
  252. #ifdef CONFIG_SND_HDA_POWER_SAVE
  253. struct hda_amp_list *loopbacks;
  254. #endif
  255. };
  256. /*
  257. * input MUX handling
  258. */
  259. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  265. if (mux_idx >= spec->num_mux_defs)
  266. mux_idx = 0;
  267. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  268. }
  269. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  270. struct snd_ctl_elem_value *ucontrol)
  271. {
  272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  273. struct alc_spec *spec = codec->spec;
  274. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  275. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  276. return 0;
  277. }
  278. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_value *ucontrol)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  284. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  285. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  286. spec->adc_nids[adc_idx],
  287. &spec->cur_mux[adc_idx]);
  288. }
  289. /*
  290. * channel mode setting
  291. */
  292. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  293. struct snd_ctl_elem_info *uinfo)
  294. {
  295. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  296. struct alc_spec *spec = codec->spec;
  297. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  298. spec->num_channel_mode);
  299. }
  300. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  301. struct snd_ctl_elem_value *ucontrol)
  302. {
  303. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  304. struct alc_spec *spec = codec->spec;
  305. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  306. spec->num_channel_mode,
  307. spec->multiout.max_channels);
  308. }
  309. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_value *ucontrol)
  311. {
  312. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  313. struct alc_spec *spec = codec->spec;
  314. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  315. spec->num_channel_mode,
  316. &spec->multiout.max_channels);
  317. if (err >= 0 && spec->need_dac_fix)
  318. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  319. return err;
  320. }
  321. /*
  322. * Control the mode of pin widget settings via the mixer. "pc" is used
  323. * instead of "%" to avoid consequences of accidently treating the % as
  324. * being part of a format specifier. Maximum allowed length of a value is
  325. * 63 characters plus NULL terminator.
  326. *
  327. * Note: some retasking pin complexes seem to ignore requests for input
  328. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  329. * are requested. Therefore order this list so that this behaviour will not
  330. * cause problems when mixer clients move through the enum sequentially.
  331. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  332. * March 2006.
  333. */
  334. static char *alc_pin_mode_names[] = {
  335. "Mic 50pc bias", "Mic 80pc bias",
  336. "Line in", "Line out", "Headphone out",
  337. };
  338. static unsigned char alc_pin_mode_values[] = {
  339. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  340. };
  341. /* The control can present all 5 options, or it can limit the options based
  342. * in the pin being assumed to be exclusively an input or an output pin. In
  343. * addition, "input" pins may or may not process the mic bias option
  344. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  345. * accept requests for bias as of chip versions up to March 2006) and/or
  346. * wiring in the computer.
  347. */
  348. #define ALC_PIN_DIR_IN 0x00
  349. #define ALC_PIN_DIR_OUT 0x01
  350. #define ALC_PIN_DIR_INOUT 0x02
  351. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  352. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  353. /* Info about the pin modes supported by the different pin direction modes.
  354. * For each direction the minimum and maximum values are given.
  355. */
  356. static signed char alc_pin_mode_dir_info[5][2] = {
  357. { 0, 2 }, /* ALC_PIN_DIR_IN */
  358. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  359. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  360. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  361. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  362. };
  363. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  364. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  365. #define alc_pin_mode_n_items(_dir) \
  366. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  367. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  368. struct snd_ctl_elem_info *uinfo)
  369. {
  370. unsigned int item_num = uinfo->value.enumerated.item;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  373. uinfo->count = 1;
  374. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  375. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  376. item_num = alc_pin_mode_min(dir);
  377. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  378. return 0;
  379. }
  380. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. unsigned int i;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long *valp = ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. /* Find enumerated value for current pinctl setting */
  392. i = alc_pin_mode_min(dir);
  393. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  394. i++;
  395. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  396. return 0;
  397. }
  398. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_value *ucontrol)
  400. {
  401. signed int change;
  402. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  403. hda_nid_t nid = kcontrol->private_value & 0xffff;
  404. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  405. long val = *ucontrol->value.integer.value;
  406. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  407. AC_VERB_GET_PIN_WIDGET_CONTROL,
  408. 0x00);
  409. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  410. val = alc_pin_mode_min(dir);
  411. change = pinctl != alc_pin_mode_values[val];
  412. if (change) {
  413. /* Set pin mode to that requested */
  414. snd_hda_codec_write_cache(codec, nid, 0,
  415. AC_VERB_SET_PIN_WIDGET_CONTROL,
  416. alc_pin_mode_values[val]);
  417. /* Also enable the retasking pin's input/output as required
  418. * for the requested pin mode. Enum values of 2 or less are
  419. * input modes.
  420. *
  421. * Dynamically switching the input/output buffers probably
  422. * reduces noise slightly (particularly on input) so we'll
  423. * do it. However, having both input and output buffers
  424. * enabled simultaneously doesn't seem to be problematic if
  425. * this turns out to be necessary in the future.
  426. */
  427. if (val <= 2) {
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  429. HDA_AMP_MUTE, HDA_AMP_MUTE);
  430. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  431. HDA_AMP_MUTE, 0);
  432. } else {
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  434. HDA_AMP_MUTE, HDA_AMP_MUTE);
  435. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  436. HDA_AMP_MUTE, 0);
  437. }
  438. }
  439. return change;
  440. }
  441. #define ALC_PIN_MODE(xname, nid, dir) \
  442. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  443. .info = alc_pin_mode_info, \
  444. .get = alc_pin_mode_get, \
  445. .put = alc_pin_mode_put, \
  446. .private_value = nid | (dir<<16) }
  447. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  448. * together using a mask with more than one bit set. This control is
  449. * currently used only by the ALC260 test model. At this stage they are not
  450. * needed for any "production" models.
  451. */
  452. #ifdef CONFIG_SND_DEBUG
  453. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  454. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  455. struct snd_ctl_elem_value *ucontrol)
  456. {
  457. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  458. hda_nid_t nid = kcontrol->private_value & 0xffff;
  459. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  460. long *valp = ucontrol->value.integer.value;
  461. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  462. AC_VERB_GET_GPIO_DATA, 0x00);
  463. *valp = (val & mask) != 0;
  464. return 0;
  465. }
  466. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_value *ucontrol)
  468. {
  469. signed int change;
  470. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  471. hda_nid_t nid = kcontrol->private_value & 0xffff;
  472. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  473. long val = *ucontrol->value.integer.value;
  474. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  475. AC_VERB_GET_GPIO_DATA,
  476. 0x00);
  477. /* Set/unset the masked GPIO bit(s) as needed */
  478. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  479. if (val == 0)
  480. gpio_data &= ~mask;
  481. else
  482. gpio_data |= mask;
  483. snd_hda_codec_write_cache(codec, nid, 0,
  484. AC_VERB_SET_GPIO_DATA, gpio_data);
  485. return change;
  486. }
  487. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  488. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  489. .info = alc_gpio_data_info, \
  490. .get = alc_gpio_data_get, \
  491. .put = alc_gpio_data_put, \
  492. .private_value = nid | (mask<<16) }
  493. #endif /* CONFIG_SND_DEBUG */
  494. /* A switch control to allow the enabling of the digital IO pins on the
  495. * ALC260. This is incredibly simplistic; the intention of this control is
  496. * to provide something in the test model allowing digital outputs to be
  497. * identified if present. If models are found which can utilise these
  498. * outputs a more complete mixer control can be devised for those models if
  499. * necessary.
  500. */
  501. #ifdef CONFIG_SND_DEBUG
  502. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. #ifdef CONFIG_SND_HDA_POWER_SAVE
  574. spec->loopback.amplist = preset->loopbacks;
  575. #endif
  576. }
  577. /* Enable GPIO mask and set output */
  578. static struct hda_verb alc_gpio1_init_verbs[] = {
  579. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  582. { }
  583. };
  584. static struct hda_verb alc_gpio2_init_verbs[] = {
  585. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  588. { }
  589. };
  590. static struct hda_verb alc_gpio3_init_verbs[] = {
  591. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  594. { }
  595. };
  596. static void alc_sku_automute(struct hda_codec *codec)
  597. {
  598. struct alc_spec *spec = codec->spec;
  599. unsigned int mute;
  600. unsigned int present;
  601. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  602. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  603. /* need to execute and sync at first */
  604. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  605. present = snd_hda_codec_read(codec, hp_nid, 0,
  606. AC_VERB_GET_PIN_SENSE, 0);
  607. spec->jack_present = (present & 0x80000000) != 0;
  608. if (spec->jack_present) {
  609. /* mute internal speaker */
  610. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  611. HDA_AMP_MUTE, HDA_AMP_MUTE);
  612. } else {
  613. /* unmute internal speaker if necessary */
  614. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  615. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  616. HDA_AMP_MUTE, mute);
  617. }
  618. }
  619. /* unsolicited event for HP jack sensing */
  620. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  621. {
  622. if (codec->vendor_id == 0x10ec0880)
  623. res >>= 28;
  624. else
  625. res >>= 26;
  626. if (res != ALC880_HP_EVENT)
  627. return;
  628. alc_sku_automute(codec);
  629. }
  630. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  631. * 31 ~ 16 : Manufacture ID
  632. * 15 ~ 8 : SKU ID
  633. * 7 ~ 0 : Assembly ID
  634. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  635. */
  636. static void alc_subsystem_id(struct hda_codec *codec,
  637. unsigned int porta, unsigned int porte,
  638. unsigned int portd)
  639. {
  640. unsigned int ass, tmp, i;
  641. unsigned nid;
  642. struct alc_spec *spec = codec->spec;
  643. ass = codec->subsystem_id & 0xffff;
  644. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  645. goto do_sku;
  646. /*
  647. * 31~30 : port conetcivity
  648. * 29~21 : reserve
  649. * 20 : PCBEEP input
  650. * 19~16 : Check sum (15:1)
  651. * 15~1 : Custom
  652. * 0 : override
  653. */
  654. nid = 0x1d;
  655. if (codec->vendor_id == 0x10ec0260)
  656. nid = 0x17;
  657. ass = snd_hda_codec_read(codec, nid, 0,
  658. AC_VERB_GET_CONFIG_DEFAULT, 0);
  659. if (!(ass & 1) && !(ass & 0x100000))
  660. return;
  661. if ((ass >> 30) != 1) /* no physical connection */
  662. return;
  663. /* check sum */
  664. tmp = 0;
  665. for (i = 1; i < 16; i++) {
  666. if ((ass >> i) && 1)
  667. tmp++;
  668. }
  669. if (((ass >> 16) & 0xf) != tmp)
  670. return;
  671. do_sku:
  672. /*
  673. * 0 : override
  674. * 1 : Swap Jack
  675. * 2 : 0 --> Desktop, 1 --> Laptop
  676. * 3~5 : External Amplifier control
  677. * 7~6 : Reserved
  678. */
  679. tmp = (ass & 0x38) >> 3; /* external Amp control */
  680. switch (tmp) {
  681. case 1:
  682. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  683. break;
  684. case 3:
  685. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  686. break;
  687. case 7:
  688. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  689. break;
  690. case 5: /* set EAPD output high */
  691. switch (codec->vendor_id) {
  692. case 0x10ec0260:
  693. snd_hda_codec_write(codec, 0x0f, 0,
  694. AC_VERB_SET_EAPD_BTLENABLE, 2);
  695. snd_hda_codec_write(codec, 0x10, 0,
  696. AC_VERB_SET_EAPD_BTLENABLE, 2);
  697. break;
  698. case 0x10ec0262:
  699. case 0x10ec0267:
  700. case 0x10ec0268:
  701. case 0x10ec0269:
  702. case 0x10ec0862:
  703. case 0x10ec0662:
  704. snd_hda_codec_write(codec, 0x14, 0,
  705. AC_VERB_SET_EAPD_BTLENABLE, 2);
  706. snd_hda_codec_write(codec, 0x15, 0,
  707. AC_VERB_SET_EAPD_BTLENABLE, 2);
  708. break;
  709. }
  710. switch (codec->vendor_id) {
  711. case 0x10ec0260:
  712. snd_hda_codec_write(codec, 0x1a, 0,
  713. AC_VERB_SET_COEF_INDEX, 7);
  714. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  715. AC_VERB_GET_PROC_COEF, 0);
  716. snd_hda_codec_write(codec, 0x1a, 0,
  717. AC_VERB_SET_COEF_INDEX, 7);
  718. snd_hda_codec_write(codec, 0x1a, 0,
  719. AC_VERB_SET_PROC_COEF,
  720. tmp | 0x2010);
  721. break;
  722. case 0x10ec0262:
  723. case 0x10ec0880:
  724. case 0x10ec0882:
  725. case 0x10ec0883:
  726. case 0x10ec0885:
  727. case 0x10ec0888:
  728. snd_hda_codec_write(codec, 0x20, 0,
  729. AC_VERB_SET_COEF_INDEX, 7);
  730. tmp = snd_hda_codec_read(codec, 0x20, 0,
  731. AC_VERB_GET_PROC_COEF, 0);
  732. snd_hda_codec_write(codec, 0x20, 0,
  733. AC_VERB_SET_COEF_INDEX, 7);
  734. snd_hda_codec_write(codec, 0x20, 0,
  735. AC_VERB_SET_PROC_COEF,
  736. tmp | 0x2010);
  737. break;
  738. case 0x10ec0267:
  739. case 0x10ec0268:
  740. snd_hda_codec_write(codec, 0x20, 0,
  741. AC_VERB_SET_COEF_INDEX, 7);
  742. tmp = snd_hda_codec_read(codec, 0x20, 0,
  743. AC_VERB_GET_PROC_COEF, 0);
  744. snd_hda_codec_write(codec, 0x20, 0,
  745. AC_VERB_SET_COEF_INDEX, 7);
  746. snd_hda_codec_write(codec, 0x20, 0,
  747. AC_VERB_SET_PROC_COEF,
  748. tmp | 0x3000);
  749. break;
  750. }
  751. default:
  752. break;
  753. }
  754. /* is laptop and enable the function "Mute internal speaker
  755. * when the external headphone out jack is plugged"
  756. */
  757. if (!(ass & 0x4) || !(ass & 0x8000))
  758. return;
  759. /*
  760. * 10~8 : Jack location
  761. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  762. * 14~13: Resvered
  763. * 15 : 1 --> enable the function "Mute internal speaker
  764. * when the external headphone out jack is plugged"
  765. */
  766. if (!spec->autocfg.speaker_pins[0]) {
  767. if (spec->multiout.dac_nids[0])
  768. spec->autocfg.speaker_pins[0] =
  769. spec->multiout.dac_nids[0];
  770. else
  771. return;
  772. }
  773. if (!spec->autocfg.hp_pins[0]) {
  774. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  775. if (tmp == 0)
  776. spec->autocfg.hp_pins[0] = porta;
  777. else if (tmp == 1)
  778. spec->autocfg.hp_pins[0] = porte;
  779. else if (tmp == 2)
  780. spec->autocfg.hp_pins[0] = portd;
  781. else
  782. return;
  783. }
  784. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  785. AC_VERB_SET_UNSOLICITED_ENABLE,
  786. AC_USRSP_EN | ALC880_HP_EVENT);
  787. spec->unsol_event = alc_sku_unsol_event;
  788. spec->init_hook = alc_sku_automute;
  789. }
  790. /*
  791. * Fix-up pin default configurations
  792. */
  793. struct alc_pincfg {
  794. hda_nid_t nid;
  795. u32 val;
  796. };
  797. static void alc_fix_pincfg(struct hda_codec *codec,
  798. const struct snd_pci_quirk *quirk,
  799. const struct alc_pincfg **pinfix)
  800. {
  801. const struct alc_pincfg *cfg;
  802. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  803. if (!quirk)
  804. return;
  805. cfg = pinfix[quirk->value];
  806. for (; cfg->nid; cfg++) {
  807. int i;
  808. u32 val = cfg->val;
  809. for (i = 0; i < 4; i++) {
  810. snd_hda_codec_write(codec, cfg->nid, 0,
  811. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  812. val & 0xff);
  813. val >>= 8;
  814. }
  815. }
  816. }
  817. /*
  818. * ALC880 3-stack model
  819. *
  820. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  821. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  822. * F-Mic = 0x1b, HP = 0x19
  823. */
  824. static hda_nid_t alc880_dac_nids[4] = {
  825. /* front, rear, clfe, rear_surr */
  826. 0x02, 0x05, 0x04, 0x03
  827. };
  828. static hda_nid_t alc880_adc_nids[3] = {
  829. /* ADC0-2 */
  830. 0x07, 0x08, 0x09,
  831. };
  832. /* The datasheet says the node 0x07 is connected from inputs,
  833. * but it shows zero connection in the real implementation on some devices.
  834. * Note: this is a 915GAV bug, fixed on 915GLV
  835. */
  836. static hda_nid_t alc880_adc_nids_alt[2] = {
  837. /* ADC1-2 */
  838. 0x08, 0x09,
  839. };
  840. #define ALC880_DIGOUT_NID 0x06
  841. #define ALC880_DIGIN_NID 0x0a
  842. static struct hda_input_mux alc880_capture_source = {
  843. .num_items = 4,
  844. .items = {
  845. { "Mic", 0x0 },
  846. { "Front Mic", 0x3 },
  847. { "Line", 0x2 },
  848. { "CD", 0x4 },
  849. },
  850. };
  851. /* channel source setting (2/6 channel selection for 3-stack) */
  852. /* 2ch mode */
  853. static struct hda_verb alc880_threestack_ch2_init[] = {
  854. /* set line-in to input, mute it */
  855. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  856. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  857. /* set mic-in to input vref 80%, mute it */
  858. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  859. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  860. { } /* end */
  861. };
  862. /* 6ch mode */
  863. static struct hda_verb alc880_threestack_ch6_init[] = {
  864. /* set line-in to output, unmute it */
  865. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  866. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  867. /* set mic-in to output, unmute it */
  868. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  869. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  870. { } /* end */
  871. };
  872. static struct hda_channel_mode alc880_threestack_modes[2] = {
  873. { 2, alc880_threestack_ch2_init },
  874. { 6, alc880_threestack_ch6_init },
  875. };
  876. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  877. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  878. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  882. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  883. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  884. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  885. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  886. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  888. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  890. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  891. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  892. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  893. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  894. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  895. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  896. {
  897. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  898. .name = "Channel Mode",
  899. .info = alc_ch_mode_info,
  900. .get = alc_ch_mode_get,
  901. .put = alc_ch_mode_put,
  902. },
  903. { } /* end */
  904. };
  905. /* capture mixer elements */
  906. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  907. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  908. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  909. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  910. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  911. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  912. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  913. {
  914. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  915. /* The multiple "Capture Source" controls confuse alsamixer
  916. * So call somewhat different..
  917. * FIXME: the controls appear in the "playback" view!
  918. */
  919. /* .name = "Capture Source", */
  920. .name = "Input Source",
  921. .count = 3,
  922. .info = alc_mux_enum_info,
  923. .get = alc_mux_enum_get,
  924. .put = alc_mux_enum_put,
  925. },
  926. { } /* end */
  927. };
  928. /* capture mixer elements (in case NID 0x07 not available) */
  929. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  930. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  931. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  932. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  933. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  934. {
  935. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  936. /* The multiple "Capture Source" controls confuse alsamixer
  937. * So call somewhat different..
  938. * FIXME: the controls appear in the "playback" view!
  939. */
  940. /* .name = "Capture Source", */
  941. .name = "Input Source",
  942. .count = 2,
  943. .info = alc_mux_enum_info,
  944. .get = alc_mux_enum_get,
  945. .put = alc_mux_enum_put,
  946. },
  947. { } /* end */
  948. };
  949. /*
  950. * ALC880 5-stack model
  951. *
  952. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  953. * Side = 0x02 (0xd)
  954. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  955. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  956. */
  957. /* additional mixers to alc880_three_stack_mixer */
  958. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  959. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  960. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  961. { } /* end */
  962. };
  963. /* channel source setting (6/8 channel selection for 5-stack) */
  964. /* 6ch mode */
  965. static struct hda_verb alc880_fivestack_ch6_init[] = {
  966. /* set line-in to input, mute it */
  967. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  968. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  969. { } /* end */
  970. };
  971. /* 8ch mode */
  972. static struct hda_verb alc880_fivestack_ch8_init[] = {
  973. /* set line-in to output, unmute it */
  974. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  975. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  976. { } /* end */
  977. };
  978. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  979. { 6, alc880_fivestack_ch6_init },
  980. { 8, alc880_fivestack_ch8_init },
  981. };
  982. /*
  983. * ALC880 6-stack model
  984. *
  985. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  986. * Side = 0x05 (0x0f)
  987. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  988. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  989. */
  990. static hda_nid_t alc880_6st_dac_nids[4] = {
  991. /* front, rear, clfe, rear_surr */
  992. 0x02, 0x03, 0x04, 0x05
  993. };
  994. static struct hda_input_mux alc880_6stack_capture_source = {
  995. .num_items = 4,
  996. .items = {
  997. { "Mic", 0x0 },
  998. { "Front Mic", 0x1 },
  999. { "Line", 0x2 },
  1000. { "CD", 0x4 },
  1001. },
  1002. };
  1003. /* fixed 8-channels */
  1004. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1005. { 8, NULL },
  1006. };
  1007. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1008. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1011. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1013. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1014. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1015. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1017. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1019. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1020. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1021. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1022. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1023. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1024. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1025. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1027. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1028. {
  1029. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1030. .name = "Channel Mode",
  1031. .info = alc_ch_mode_info,
  1032. .get = alc_ch_mode_get,
  1033. .put = alc_ch_mode_put,
  1034. },
  1035. { } /* end */
  1036. };
  1037. /*
  1038. * ALC880 W810 model
  1039. *
  1040. * W810 has rear IO for:
  1041. * Front (DAC 02)
  1042. * Surround (DAC 03)
  1043. * Center/LFE (DAC 04)
  1044. * Digital out (06)
  1045. *
  1046. * The system also has a pair of internal speakers, and a headphone jack.
  1047. * These are both connected to Line2 on the codec, hence to DAC 02.
  1048. *
  1049. * There is a variable resistor to control the speaker or headphone
  1050. * volume. This is a hardware-only device without a software API.
  1051. *
  1052. * Plugging headphones in will disable the internal speakers. This is
  1053. * implemented in hardware, not via the driver using jack sense. In
  1054. * a similar fashion, plugging into the rear socket marked "front" will
  1055. * disable both the speakers and headphones.
  1056. *
  1057. * For input, there's a microphone jack, and an "audio in" jack.
  1058. * These may not do anything useful with this driver yet, because I
  1059. * haven't setup any initialization verbs for these yet...
  1060. */
  1061. static hda_nid_t alc880_w810_dac_nids[3] = {
  1062. /* front, rear/surround, clfe */
  1063. 0x02, 0x03, 0x04
  1064. };
  1065. /* fixed 6 channels */
  1066. static struct hda_channel_mode alc880_w810_modes[1] = {
  1067. { 6, NULL }
  1068. };
  1069. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1070. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1071. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1072. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1073. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1074. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1075. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1076. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1078. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1079. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1080. { } /* end */
  1081. };
  1082. /*
  1083. * Z710V model
  1084. *
  1085. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1086. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1087. * Line = 0x1a
  1088. */
  1089. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1090. 0x02
  1091. };
  1092. #define ALC880_Z71V_HP_DAC 0x03
  1093. /* fixed 2 channels */
  1094. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1095. { 2, NULL }
  1096. };
  1097. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1098. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1099. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1100. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1101. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1102. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1103. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1104. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1105. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1106. { } /* end */
  1107. };
  1108. /* FIXME! */
  1109. /*
  1110. * ALC880 F1734 model
  1111. *
  1112. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1113. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1114. */
  1115. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1116. 0x03
  1117. };
  1118. #define ALC880_F1734_HP_DAC 0x02
  1119. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1120. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1121. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1122. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1123. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1124. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1125. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1126. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1127. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1128. { } /* end */
  1129. };
  1130. /* FIXME! */
  1131. /*
  1132. * ALC880 ASUS model
  1133. *
  1134. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1135. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1136. * Mic = 0x18, Line = 0x1a
  1137. */
  1138. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1139. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1140. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1141. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1142. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1143. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1144. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1145. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1146. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1147. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1148. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1149. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1150. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1151. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1152. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1153. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1154. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1155. {
  1156. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1157. .name = "Channel Mode",
  1158. .info = alc_ch_mode_info,
  1159. .get = alc_ch_mode_get,
  1160. .put = alc_ch_mode_put,
  1161. },
  1162. { } /* end */
  1163. };
  1164. /* FIXME! */
  1165. /*
  1166. * ALC880 ASUS W1V model
  1167. *
  1168. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1169. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1170. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1171. */
  1172. /* additional mixers to alc880_asus_mixer */
  1173. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1174. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1175. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1176. { } /* end */
  1177. };
  1178. /* additional mixers to alc880_asus_mixer */
  1179. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1180. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1181. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1182. { } /* end */
  1183. };
  1184. /* TCL S700 */
  1185. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1186. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1187. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1188. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1189. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1190. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1191. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1192. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1193. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1194. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1195. {
  1196. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1197. /* The multiple "Capture Source" controls confuse alsamixer
  1198. * So call somewhat different..
  1199. * FIXME: the controls appear in the "playback" view!
  1200. */
  1201. /* .name = "Capture Source", */
  1202. .name = "Input Source",
  1203. .count = 1,
  1204. .info = alc_mux_enum_info,
  1205. .get = alc_mux_enum_get,
  1206. .put = alc_mux_enum_put,
  1207. },
  1208. { } /* end */
  1209. };
  1210. /* Uniwill */
  1211. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1212. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1213. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1214. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1215. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1216. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1217. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1218. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1219. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1220. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1221. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1222. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1223. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1224. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1225. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1226. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1227. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1229. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1230. {
  1231. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1232. .name = "Channel Mode",
  1233. .info = alc_ch_mode_info,
  1234. .get = alc_ch_mode_get,
  1235. .put = alc_ch_mode_put,
  1236. },
  1237. { } /* end */
  1238. };
  1239. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1240. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1241. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1242. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1243. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1244. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1245. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1246. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1247. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1248. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1249. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1250. { } /* end */
  1251. };
  1252. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1253. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1254. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1255. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1256. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1257. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1258. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1259. { } /* end */
  1260. };
  1261. /*
  1262. * build control elements
  1263. */
  1264. static int alc_build_controls(struct hda_codec *codec)
  1265. {
  1266. struct alc_spec *spec = codec->spec;
  1267. int err;
  1268. int i;
  1269. for (i = 0; i < spec->num_mixers; i++) {
  1270. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1271. if (err < 0)
  1272. return err;
  1273. }
  1274. if (spec->multiout.dig_out_nid) {
  1275. err = snd_hda_create_spdif_out_ctls(codec,
  1276. spec->multiout.dig_out_nid);
  1277. if (err < 0)
  1278. return err;
  1279. }
  1280. if (spec->dig_in_nid) {
  1281. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1282. if (err < 0)
  1283. return err;
  1284. }
  1285. return 0;
  1286. }
  1287. /*
  1288. * initialize the codec volumes, etc
  1289. */
  1290. /*
  1291. * generic initialization of ADC, input mixers and output mixers
  1292. */
  1293. static struct hda_verb alc880_volume_init_verbs[] = {
  1294. /*
  1295. * Unmute ADC0-2 and set the default input to mic-in
  1296. */
  1297. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1298. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1299. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1300. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1301. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1302. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1303. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1304. * mixer widget
  1305. * Note: PASD motherboards uses the Line In 2 as the input for front
  1306. * panel mic (mic 2)
  1307. */
  1308. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1309. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1310. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1314. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1315. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1316. /*
  1317. * Set up output mixers (0x0c - 0x0f)
  1318. */
  1319. /* set vol=0 to output mixers */
  1320. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1321. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1323. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1324. /* set up input amps for analog loopback */
  1325. /* Amp Indices: DAC = 0, mixer = 1 */
  1326. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1327. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1328. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1329. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1330. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1331. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1332. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1333. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1334. { }
  1335. };
  1336. /*
  1337. * 3-stack pin configuration:
  1338. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1339. */
  1340. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1341. /*
  1342. * preset connection lists of input pins
  1343. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1344. */
  1345. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1346. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1347. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1348. /*
  1349. * Set pin mode and muting
  1350. */
  1351. /* set front pin widgets 0x14 for output */
  1352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1353. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1355. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. /* Mic2 (as headphone out) for HP output */
  1358. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1359. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1360. /* Line In pin widget for input */
  1361. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1363. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1364. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1365. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1366. /* CD pin widget for input */
  1367. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1368. { }
  1369. };
  1370. /*
  1371. * 5-stack pin configuration:
  1372. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1373. * line-in/side = 0x1a, f-mic = 0x1b
  1374. */
  1375. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1376. /*
  1377. * preset connection lists of input pins
  1378. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1379. */
  1380. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1381. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1382. /*
  1383. * Set pin mode and muting
  1384. */
  1385. /* set pin widgets 0x14-0x17 for output */
  1386. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1387. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1388. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1389. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1390. /* unmute pins for output (no gain on this amp) */
  1391. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1393. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1394. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1395. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1396. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1397. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1398. /* Mic2 (as headphone out) for HP output */
  1399. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1400. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. /* Line In pin widget for input */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1404. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1405. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1406. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1407. /* CD pin widget for input */
  1408. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1409. { }
  1410. };
  1411. /*
  1412. * W810 pin configuration:
  1413. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1414. */
  1415. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1416. /* hphone/speaker input selector: front DAC */
  1417. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1418. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1419. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1420. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1421. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1422. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1423. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1424. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1425. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1426. { }
  1427. };
  1428. /*
  1429. * Z71V pin configuration:
  1430. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1431. */
  1432. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1433. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1434. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1435. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1436. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1438. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1439. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1440. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1441. { }
  1442. };
  1443. /*
  1444. * 6-stack pin configuration:
  1445. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1446. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1447. */
  1448. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1449. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1450. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1451. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1452. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1453. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1454. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1455. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1456. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1457. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1458. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1459. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1460. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1461. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1462. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1463. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1464. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1465. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1466. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1467. { }
  1468. };
  1469. /*
  1470. * Uniwill pin configuration:
  1471. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1472. * line = 0x1a
  1473. */
  1474. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1475. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1476. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1477. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1478. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1479. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1480. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1481. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1482. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1483. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1485. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1486. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1487. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1488. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1489. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1490. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1491. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1492. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1493. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1494. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1496. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1497. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1498. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1499. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1500. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1501. { }
  1502. };
  1503. /*
  1504. * Uniwill P53
  1505. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1506. */
  1507. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1508. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1509. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1512. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1514. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1516. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1517. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1518. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1519. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1520. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1521. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1522. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1523. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1524. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1525. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1526. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1527. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1528. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1529. { }
  1530. };
  1531. static struct hda_verb alc880_beep_init_verbs[] = {
  1532. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1533. { }
  1534. };
  1535. /* toggle speaker-output according to the hp-jack state */
  1536. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1537. {
  1538. unsigned int present;
  1539. unsigned char bits;
  1540. present = snd_hda_codec_read(codec, 0x14, 0,
  1541. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1542. bits = present ? HDA_AMP_MUTE : 0;
  1543. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1544. HDA_AMP_MUTE, bits);
  1545. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1546. HDA_AMP_MUTE, bits);
  1547. }
  1548. /* auto-toggle front mic */
  1549. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1550. {
  1551. unsigned int present;
  1552. unsigned char bits;
  1553. present = snd_hda_codec_read(codec, 0x18, 0,
  1554. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1555. bits = present ? HDA_AMP_MUTE : 0;
  1556. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1557. }
  1558. static void alc880_uniwill_automute(struct hda_codec *codec)
  1559. {
  1560. alc880_uniwill_hp_automute(codec);
  1561. alc880_uniwill_mic_automute(codec);
  1562. }
  1563. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1564. unsigned int res)
  1565. {
  1566. /* Looks like the unsol event is incompatible with the standard
  1567. * definition. 4bit tag is placed at 28 bit!
  1568. */
  1569. switch (res >> 28) {
  1570. case ALC880_HP_EVENT:
  1571. alc880_uniwill_hp_automute(codec);
  1572. break;
  1573. case ALC880_MIC_EVENT:
  1574. alc880_uniwill_mic_automute(codec);
  1575. break;
  1576. }
  1577. }
  1578. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1579. {
  1580. unsigned int present;
  1581. unsigned char bits;
  1582. present = snd_hda_codec_read(codec, 0x14, 0,
  1583. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1584. bits = present ? HDA_AMP_MUTE : 0;
  1585. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1586. }
  1587. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1588. {
  1589. unsigned int present;
  1590. present = snd_hda_codec_read(codec, 0x21, 0,
  1591. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1592. present &= HDA_AMP_VOLMASK;
  1593. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1594. HDA_AMP_VOLMASK, present);
  1595. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1596. HDA_AMP_VOLMASK, present);
  1597. }
  1598. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1599. unsigned int res)
  1600. {
  1601. /* Looks like the unsol event is incompatible with the standard
  1602. * definition. 4bit tag is placed at 28 bit!
  1603. */
  1604. if ((res >> 28) == ALC880_HP_EVENT)
  1605. alc880_uniwill_p53_hp_automute(codec);
  1606. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1607. alc880_uniwill_p53_dcvol_automute(codec);
  1608. }
  1609. /* FIXME! */
  1610. /*
  1611. * F1734 pin configuration:
  1612. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1613. */
  1614. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1615. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1616. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1617. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1618. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1619. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1620. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1621. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1622. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1623. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1624. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1625. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1626. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1627. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1628. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1629. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1630. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1631. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1632. { }
  1633. };
  1634. /* FIXME! */
  1635. /*
  1636. * ASUS pin configuration:
  1637. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1638. */
  1639. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1640. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1641. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1642. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1643. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1644. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1645. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1646. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1647. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1648. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1649. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1651. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1652. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1653. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1655. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1656. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1657. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1658. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1660. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1661. { }
  1662. };
  1663. /* Enable GPIO mask and set output */
  1664. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1665. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1666. /* Clevo m520g init */
  1667. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1668. /* headphone output */
  1669. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1670. /* line-out */
  1671. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1672. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1673. /* Line-in */
  1674. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1675. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1676. /* CD */
  1677. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1678. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1679. /* Mic1 (rear panel) */
  1680. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1681. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1682. /* Mic2 (front panel) */
  1683. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1684. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1685. /* headphone */
  1686. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1687. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1688. /* change to EAPD mode */
  1689. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1690. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1691. { }
  1692. };
  1693. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1694. /* change to EAPD mode */
  1695. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1696. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1697. /* Headphone output */
  1698. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1699. /* Front output*/
  1700. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1701. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1702. /* Line In pin widget for input */
  1703. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1704. /* CD pin widget for input */
  1705. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1706. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1707. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1708. /* change to EAPD mode */
  1709. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1710. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1711. { }
  1712. };
  1713. /*
  1714. * LG m1 express dual
  1715. *
  1716. * Pin assignment:
  1717. * Rear Line-In/Out (blue): 0x14
  1718. * Build-in Mic-In: 0x15
  1719. * Speaker-out: 0x17
  1720. * HP-Out (green): 0x1b
  1721. * Mic-In/Out (red): 0x19
  1722. * SPDIF-Out: 0x1e
  1723. */
  1724. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1725. static hda_nid_t alc880_lg_dac_nids[3] = {
  1726. 0x05, 0x02, 0x03
  1727. };
  1728. /* seems analog CD is not working */
  1729. static struct hda_input_mux alc880_lg_capture_source = {
  1730. .num_items = 3,
  1731. .items = {
  1732. { "Mic", 0x1 },
  1733. { "Line", 0x5 },
  1734. { "Internal Mic", 0x6 },
  1735. },
  1736. };
  1737. /* 2,4,6 channel modes */
  1738. static struct hda_verb alc880_lg_ch2_init[] = {
  1739. /* set line-in and mic-in to input */
  1740. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1741. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1742. { }
  1743. };
  1744. static struct hda_verb alc880_lg_ch4_init[] = {
  1745. /* set line-in to out and mic-in to input */
  1746. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1747. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1748. { }
  1749. };
  1750. static struct hda_verb alc880_lg_ch6_init[] = {
  1751. /* set line-in and mic-in to output */
  1752. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1753. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1754. { }
  1755. };
  1756. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1757. { 2, alc880_lg_ch2_init },
  1758. { 4, alc880_lg_ch4_init },
  1759. { 6, alc880_lg_ch6_init },
  1760. };
  1761. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1762. /* FIXME: it's not really "master" but front channels */
  1763. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1764. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1765. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1766. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1767. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1768. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1769. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1770. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1771. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1772. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1773. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1774. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1775. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1776. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1777. {
  1778. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1779. .name = "Channel Mode",
  1780. .info = alc_ch_mode_info,
  1781. .get = alc_ch_mode_get,
  1782. .put = alc_ch_mode_put,
  1783. },
  1784. { } /* end */
  1785. };
  1786. static struct hda_verb alc880_lg_init_verbs[] = {
  1787. /* set capture source to mic-in */
  1788. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1789. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1790. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1791. /* mute all amp mixer inputs */
  1792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1793. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1795. /* line-in to input */
  1796. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1797. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1798. /* built-in mic */
  1799. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1800. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1801. /* speaker-out */
  1802. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1803. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1804. /* mic-in to input */
  1805. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1806. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1807. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1808. /* HP-out */
  1809. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1810. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1811. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1812. /* jack sense */
  1813. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1814. { }
  1815. };
  1816. /* toggle speaker-output according to the hp-jack state */
  1817. static void alc880_lg_automute(struct hda_codec *codec)
  1818. {
  1819. unsigned int present;
  1820. unsigned char bits;
  1821. present = snd_hda_codec_read(codec, 0x1b, 0,
  1822. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1823. bits = present ? HDA_AMP_MUTE : 0;
  1824. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1825. HDA_AMP_MUTE, bits);
  1826. }
  1827. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1828. {
  1829. /* Looks like the unsol event is incompatible with the standard
  1830. * definition. 4bit tag is placed at 28 bit!
  1831. */
  1832. if ((res >> 28) == 0x01)
  1833. alc880_lg_automute(codec);
  1834. }
  1835. /*
  1836. * LG LW20
  1837. *
  1838. * Pin assignment:
  1839. * Speaker-out: 0x14
  1840. * Mic-In: 0x18
  1841. * Built-in Mic-In: 0x19
  1842. * Line-In: 0x1b
  1843. * HP-Out: 0x1a
  1844. * SPDIF-Out: 0x1e
  1845. */
  1846. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1847. .num_items = 3,
  1848. .items = {
  1849. { "Mic", 0x0 },
  1850. { "Internal Mic", 0x1 },
  1851. { "Line In", 0x2 },
  1852. },
  1853. };
  1854. #define alc880_lg_lw_modes alc880_threestack_modes
  1855. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1856. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1857. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1858. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1859. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1860. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1861. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1862. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1863. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1864. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1865. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1866. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1867. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1868. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1869. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1870. {
  1871. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1872. .name = "Channel Mode",
  1873. .info = alc_ch_mode_info,
  1874. .get = alc_ch_mode_get,
  1875. .put = alc_ch_mode_put,
  1876. },
  1877. { } /* end */
  1878. };
  1879. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1880. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1881. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1882. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1883. /* set capture source to mic-in */
  1884. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1885. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1886. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1887. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1888. /* speaker-out */
  1889. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1891. /* HP-out */
  1892. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1893. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1894. /* mic-in to input */
  1895. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1896. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1897. /* built-in mic */
  1898. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1899. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1900. /* jack sense */
  1901. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1902. { }
  1903. };
  1904. /* toggle speaker-output according to the hp-jack state */
  1905. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1906. {
  1907. unsigned int present;
  1908. unsigned char bits;
  1909. present = snd_hda_codec_read(codec, 0x1b, 0,
  1910. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1911. bits = present ? HDA_AMP_MUTE : 0;
  1912. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1913. HDA_AMP_MUTE, bits);
  1914. }
  1915. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1916. {
  1917. /* Looks like the unsol event is incompatible with the standard
  1918. * definition. 4bit tag is placed at 28 bit!
  1919. */
  1920. if ((res >> 28) == 0x01)
  1921. alc880_lg_lw_automute(codec);
  1922. }
  1923. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1924. static struct hda_amp_list alc880_loopbacks[] = {
  1925. { 0x0b, HDA_INPUT, 0 },
  1926. { 0x0b, HDA_INPUT, 1 },
  1927. { 0x0b, HDA_INPUT, 2 },
  1928. { 0x0b, HDA_INPUT, 3 },
  1929. { 0x0b, HDA_INPUT, 4 },
  1930. { } /* end */
  1931. };
  1932. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1933. { 0x0b, HDA_INPUT, 1 },
  1934. { 0x0b, HDA_INPUT, 6 },
  1935. { 0x0b, HDA_INPUT, 7 },
  1936. { } /* end */
  1937. };
  1938. #endif
  1939. /*
  1940. * Common callbacks
  1941. */
  1942. static int alc_init(struct hda_codec *codec)
  1943. {
  1944. struct alc_spec *spec = codec->spec;
  1945. unsigned int i;
  1946. for (i = 0; i < spec->num_init_verbs; i++)
  1947. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1948. if (spec->init_hook)
  1949. spec->init_hook(codec);
  1950. return 0;
  1951. }
  1952. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1953. {
  1954. struct alc_spec *spec = codec->spec;
  1955. if (spec->unsol_event)
  1956. spec->unsol_event(codec, res);
  1957. }
  1958. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1959. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1960. {
  1961. struct alc_spec *spec = codec->spec;
  1962. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1963. }
  1964. #endif
  1965. /*
  1966. * Analog playback callbacks
  1967. */
  1968. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1969. struct hda_codec *codec,
  1970. struct snd_pcm_substream *substream)
  1971. {
  1972. struct alc_spec *spec = codec->spec;
  1973. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1974. }
  1975. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1976. struct hda_codec *codec,
  1977. unsigned int stream_tag,
  1978. unsigned int format,
  1979. struct snd_pcm_substream *substream)
  1980. {
  1981. struct alc_spec *spec = codec->spec;
  1982. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1983. stream_tag, format, substream);
  1984. }
  1985. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1986. struct hda_codec *codec,
  1987. struct snd_pcm_substream *substream)
  1988. {
  1989. struct alc_spec *spec = codec->spec;
  1990. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1991. }
  1992. /*
  1993. * Digital out
  1994. */
  1995. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1996. struct hda_codec *codec,
  1997. struct snd_pcm_substream *substream)
  1998. {
  1999. struct alc_spec *spec = codec->spec;
  2000. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2001. }
  2002. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2003. struct hda_codec *codec,
  2004. unsigned int stream_tag,
  2005. unsigned int format,
  2006. struct snd_pcm_substream *substream)
  2007. {
  2008. struct alc_spec *spec = codec->spec;
  2009. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2010. stream_tag, format, substream);
  2011. }
  2012. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2013. struct hda_codec *codec,
  2014. struct snd_pcm_substream *substream)
  2015. {
  2016. struct alc_spec *spec = codec->spec;
  2017. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2018. }
  2019. /*
  2020. * Analog capture
  2021. */
  2022. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2023. struct hda_codec *codec,
  2024. unsigned int stream_tag,
  2025. unsigned int format,
  2026. struct snd_pcm_substream *substream)
  2027. {
  2028. struct alc_spec *spec = codec->spec;
  2029. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2030. stream_tag, 0, format);
  2031. return 0;
  2032. }
  2033. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2034. struct hda_codec *codec,
  2035. struct snd_pcm_substream *substream)
  2036. {
  2037. struct alc_spec *spec = codec->spec;
  2038. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2039. 0, 0, 0);
  2040. return 0;
  2041. }
  2042. /*
  2043. */
  2044. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2045. .substreams = 1,
  2046. .channels_min = 2,
  2047. .channels_max = 8,
  2048. /* NID is set in alc_build_pcms */
  2049. .ops = {
  2050. .open = alc880_playback_pcm_open,
  2051. .prepare = alc880_playback_pcm_prepare,
  2052. .cleanup = alc880_playback_pcm_cleanup
  2053. },
  2054. };
  2055. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2056. .substreams = 2,
  2057. .channels_min = 2,
  2058. .channels_max = 2,
  2059. /* NID is set in alc_build_pcms */
  2060. .ops = {
  2061. .prepare = alc880_capture_pcm_prepare,
  2062. .cleanup = alc880_capture_pcm_cleanup
  2063. },
  2064. };
  2065. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2066. .substreams = 1,
  2067. .channels_min = 2,
  2068. .channels_max = 2,
  2069. /* NID is set in alc_build_pcms */
  2070. .ops = {
  2071. .open = alc880_dig_playback_pcm_open,
  2072. .close = alc880_dig_playback_pcm_close,
  2073. .prepare = alc880_dig_playback_pcm_prepare
  2074. },
  2075. };
  2076. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2077. .substreams = 1,
  2078. .channels_min = 2,
  2079. .channels_max = 2,
  2080. /* NID is set in alc_build_pcms */
  2081. };
  2082. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2083. static struct hda_pcm_stream alc_pcm_null_playback = {
  2084. .substreams = 0,
  2085. .channels_min = 0,
  2086. .channels_max = 0,
  2087. };
  2088. static int alc_build_pcms(struct hda_codec *codec)
  2089. {
  2090. struct alc_spec *spec = codec->spec;
  2091. struct hda_pcm *info = spec->pcm_rec;
  2092. int i;
  2093. codec->num_pcms = 1;
  2094. codec->pcm_info = info;
  2095. info->name = spec->stream_name_analog;
  2096. if (spec->stream_analog_playback) {
  2097. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2098. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2099. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2100. }
  2101. if (spec->stream_analog_capture) {
  2102. snd_assert(spec->adc_nids, return -EINVAL);
  2103. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2104. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2105. }
  2106. if (spec->channel_mode) {
  2107. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2108. for (i = 0; i < spec->num_channel_mode; i++) {
  2109. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2110. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2111. }
  2112. }
  2113. }
  2114. /* SPDIF for stream index #1 */
  2115. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2116. codec->num_pcms = 2;
  2117. info = spec->pcm_rec + 1;
  2118. info->name = spec->stream_name_digital;
  2119. if (spec->multiout.dig_out_nid &&
  2120. spec->stream_digital_playback) {
  2121. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2122. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2123. }
  2124. if (spec->dig_in_nid &&
  2125. spec->stream_digital_capture) {
  2126. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2127. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2128. }
  2129. }
  2130. /* If the use of more than one ADC is requested for the current
  2131. * model, configure a second analog capture-only PCM.
  2132. */
  2133. /* Additional Analaog capture for index #2 */
  2134. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2135. spec->adc_nids) {
  2136. codec->num_pcms = 3;
  2137. info = spec->pcm_rec + 2;
  2138. info->name = spec->stream_name_analog;
  2139. /* No playback stream for second PCM */
  2140. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2141. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2142. if (spec->stream_analog_capture) {
  2143. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2144. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2145. }
  2146. }
  2147. return 0;
  2148. }
  2149. static void alc_free(struct hda_codec *codec)
  2150. {
  2151. struct alc_spec *spec = codec->spec;
  2152. unsigned int i;
  2153. if (!spec)
  2154. return;
  2155. if (spec->kctl_alloc) {
  2156. for (i = 0; i < spec->num_kctl_used; i++)
  2157. kfree(spec->kctl_alloc[i].name);
  2158. kfree(spec->kctl_alloc);
  2159. }
  2160. kfree(spec);
  2161. }
  2162. /*
  2163. */
  2164. static struct hda_codec_ops alc_patch_ops = {
  2165. .build_controls = alc_build_controls,
  2166. .build_pcms = alc_build_pcms,
  2167. .init = alc_init,
  2168. .free = alc_free,
  2169. .unsol_event = alc_unsol_event,
  2170. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2171. .check_power_status = alc_check_power_status,
  2172. #endif
  2173. };
  2174. /*
  2175. * Test configuration for debugging
  2176. *
  2177. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2178. * enum controls.
  2179. */
  2180. #ifdef CONFIG_SND_DEBUG
  2181. static hda_nid_t alc880_test_dac_nids[4] = {
  2182. 0x02, 0x03, 0x04, 0x05
  2183. };
  2184. static struct hda_input_mux alc880_test_capture_source = {
  2185. .num_items = 7,
  2186. .items = {
  2187. { "In-1", 0x0 },
  2188. { "In-2", 0x1 },
  2189. { "In-3", 0x2 },
  2190. { "In-4", 0x3 },
  2191. { "CD", 0x4 },
  2192. { "Front", 0x5 },
  2193. { "Surround", 0x6 },
  2194. },
  2195. };
  2196. static struct hda_channel_mode alc880_test_modes[4] = {
  2197. { 2, NULL },
  2198. { 4, NULL },
  2199. { 6, NULL },
  2200. { 8, NULL },
  2201. };
  2202. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2203. struct snd_ctl_elem_info *uinfo)
  2204. {
  2205. static char *texts[] = {
  2206. "N/A", "Line Out", "HP Out",
  2207. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2208. };
  2209. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2210. uinfo->count = 1;
  2211. uinfo->value.enumerated.items = 8;
  2212. if (uinfo->value.enumerated.item >= 8)
  2213. uinfo->value.enumerated.item = 7;
  2214. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2215. return 0;
  2216. }
  2217. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2218. struct snd_ctl_elem_value *ucontrol)
  2219. {
  2220. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2221. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2222. unsigned int pin_ctl, item = 0;
  2223. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2224. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2225. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2226. if (pin_ctl & AC_PINCTL_HP_EN)
  2227. item = 2;
  2228. else
  2229. item = 1;
  2230. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2231. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2232. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2233. case AC_PINCTL_VREF_50: item = 4; break;
  2234. case AC_PINCTL_VREF_GRD: item = 5; break;
  2235. case AC_PINCTL_VREF_80: item = 6; break;
  2236. case AC_PINCTL_VREF_100: item = 7; break;
  2237. }
  2238. }
  2239. ucontrol->value.enumerated.item[0] = item;
  2240. return 0;
  2241. }
  2242. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2243. struct snd_ctl_elem_value *ucontrol)
  2244. {
  2245. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2246. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2247. static unsigned int ctls[] = {
  2248. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2249. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2250. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2251. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2252. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2253. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2254. };
  2255. unsigned int old_ctl, new_ctl;
  2256. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2257. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2258. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2259. if (old_ctl != new_ctl) {
  2260. int val;
  2261. snd_hda_codec_write_cache(codec, nid, 0,
  2262. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2263. new_ctl);
  2264. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2265. HDA_AMP_MUTE : 0;
  2266. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2267. HDA_AMP_MUTE, val);
  2268. return 1;
  2269. }
  2270. return 0;
  2271. }
  2272. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2273. struct snd_ctl_elem_info *uinfo)
  2274. {
  2275. static char *texts[] = {
  2276. "Front", "Surround", "CLFE", "Side"
  2277. };
  2278. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2279. uinfo->count = 1;
  2280. uinfo->value.enumerated.items = 4;
  2281. if (uinfo->value.enumerated.item >= 4)
  2282. uinfo->value.enumerated.item = 3;
  2283. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2284. return 0;
  2285. }
  2286. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2287. struct snd_ctl_elem_value *ucontrol)
  2288. {
  2289. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2290. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2291. unsigned int sel;
  2292. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2293. ucontrol->value.enumerated.item[0] = sel & 3;
  2294. return 0;
  2295. }
  2296. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2297. struct snd_ctl_elem_value *ucontrol)
  2298. {
  2299. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2300. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2301. unsigned int sel;
  2302. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2303. if (ucontrol->value.enumerated.item[0] != sel) {
  2304. sel = ucontrol->value.enumerated.item[0] & 3;
  2305. snd_hda_codec_write_cache(codec, nid, 0,
  2306. AC_VERB_SET_CONNECT_SEL, sel);
  2307. return 1;
  2308. }
  2309. return 0;
  2310. }
  2311. #define PIN_CTL_TEST(xname,nid) { \
  2312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2313. .name = xname, \
  2314. .info = alc_test_pin_ctl_info, \
  2315. .get = alc_test_pin_ctl_get, \
  2316. .put = alc_test_pin_ctl_put, \
  2317. .private_value = nid \
  2318. }
  2319. #define PIN_SRC_TEST(xname,nid) { \
  2320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2321. .name = xname, \
  2322. .info = alc_test_pin_src_info, \
  2323. .get = alc_test_pin_src_get, \
  2324. .put = alc_test_pin_src_put, \
  2325. .private_value = nid \
  2326. }
  2327. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2328. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2329. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2330. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2331. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2332. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2333. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2334. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2335. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2336. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2337. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2338. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2339. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2340. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2341. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2342. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2343. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2344. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2345. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2346. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2347. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2348. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2349. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2350. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2351. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2352. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2353. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2354. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2355. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2356. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2357. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2358. {
  2359. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2360. .name = "Channel Mode",
  2361. .info = alc_ch_mode_info,
  2362. .get = alc_ch_mode_get,
  2363. .put = alc_ch_mode_put,
  2364. },
  2365. { } /* end */
  2366. };
  2367. static struct hda_verb alc880_test_init_verbs[] = {
  2368. /* Unmute inputs of 0x0c - 0x0f */
  2369. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2370. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2371. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2372. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2373. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2374. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2375. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2376. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2377. /* Vol output for 0x0c-0x0f */
  2378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2380. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2381. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2382. /* Set output pins 0x14-0x17 */
  2383. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2384. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2385. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2386. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2387. /* Unmute output pins 0x14-0x17 */
  2388. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2390. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2391. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2392. /* Set input pins 0x18-0x1c */
  2393. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2394. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2395. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2396. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2397. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2398. /* Mute input pins 0x18-0x1b */
  2399. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2400. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2401. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2402. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2403. /* ADC set up */
  2404. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2405. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2406. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2407. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2408. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2409. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2410. /* Analog input/passthru */
  2411. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2412. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2413. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2414. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2415. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2416. { }
  2417. };
  2418. #endif
  2419. /*
  2420. */
  2421. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2422. [ALC880_3ST] = "3stack",
  2423. [ALC880_TCL_S700] = "tcl",
  2424. [ALC880_3ST_DIG] = "3stack-digout",
  2425. [ALC880_CLEVO] = "clevo",
  2426. [ALC880_5ST] = "5stack",
  2427. [ALC880_5ST_DIG] = "5stack-digout",
  2428. [ALC880_W810] = "w810",
  2429. [ALC880_Z71V] = "z71v",
  2430. [ALC880_6ST] = "6stack",
  2431. [ALC880_6ST_DIG] = "6stack-digout",
  2432. [ALC880_ASUS] = "asus",
  2433. [ALC880_ASUS_W1V] = "asus-w1v",
  2434. [ALC880_ASUS_DIG] = "asus-dig",
  2435. [ALC880_ASUS_DIG2] = "asus-dig2",
  2436. [ALC880_UNIWILL_DIG] = "uniwill",
  2437. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2438. [ALC880_FUJITSU] = "fujitsu",
  2439. [ALC880_F1734] = "F1734",
  2440. [ALC880_LG] = "lg",
  2441. [ALC880_LG_LW] = "lg-lw",
  2442. #ifdef CONFIG_SND_DEBUG
  2443. [ALC880_TEST] = "test",
  2444. #endif
  2445. [ALC880_AUTO] = "auto",
  2446. };
  2447. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2448. /* Broken BIOS configuration */
  2449. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2450. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2451. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2452. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2453. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2454. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2455. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2456. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2457. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2458. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2459. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2460. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2461. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2462. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2463. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2464. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2465. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2466. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2467. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2468. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2469. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2470. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2471. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2472. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2473. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2474. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2475. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2476. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2477. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2478. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2479. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2480. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2481. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2482. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2483. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2484. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2485. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2486. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2487. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2488. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2489. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2490. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2491. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2492. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2493. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2494. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2495. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2496. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2497. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2498. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2499. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2500. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2501. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2502. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2503. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2504. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2505. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2506. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2507. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2508. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2509. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2510. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2511. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2512. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2513. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2514. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2515. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2516. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2517. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2518. {}
  2519. };
  2520. /*
  2521. * ALC880 codec presets
  2522. */
  2523. static struct alc_config_preset alc880_presets[] = {
  2524. [ALC880_3ST] = {
  2525. .mixers = { alc880_three_stack_mixer },
  2526. .init_verbs = { alc880_volume_init_verbs,
  2527. alc880_pin_3stack_init_verbs },
  2528. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2529. .dac_nids = alc880_dac_nids,
  2530. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2531. .channel_mode = alc880_threestack_modes,
  2532. .need_dac_fix = 1,
  2533. .input_mux = &alc880_capture_source,
  2534. },
  2535. [ALC880_3ST_DIG] = {
  2536. .mixers = { alc880_three_stack_mixer },
  2537. .init_verbs = { alc880_volume_init_verbs,
  2538. alc880_pin_3stack_init_verbs },
  2539. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2540. .dac_nids = alc880_dac_nids,
  2541. .dig_out_nid = ALC880_DIGOUT_NID,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2543. .channel_mode = alc880_threestack_modes,
  2544. .need_dac_fix = 1,
  2545. .input_mux = &alc880_capture_source,
  2546. },
  2547. [ALC880_TCL_S700] = {
  2548. .mixers = { alc880_tcl_s700_mixer },
  2549. .init_verbs = { alc880_volume_init_verbs,
  2550. alc880_pin_tcl_S700_init_verbs,
  2551. alc880_gpio2_init_verbs },
  2552. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2553. .dac_nids = alc880_dac_nids,
  2554. .hp_nid = 0x03,
  2555. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2556. .channel_mode = alc880_2_jack_modes,
  2557. .input_mux = &alc880_capture_source,
  2558. },
  2559. [ALC880_5ST] = {
  2560. .mixers = { alc880_three_stack_mixer,
  2561. alc880_five_stack_mixer},
  2562. .init_verbs = { alc880_volume_init_verbs,
  2563. alc880_pin_5stack_init_verbs },
  2564. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2565. .dac_nids = alc880_dac_nids,
  2566. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2567. .channel_mode = alc880_fivestack_modes,
  2568. .input_mux = &alc880_capture_source,
  2569. },
  2570. [ALC880_5ST_DIG] = {
  2571. .mixers = { alc880_three_stack_mixer,
  2572. alc880_five_stack_mixer },
  2573. .init_verbs = { alc880_volume_init_verbs,
  2574. alc880_pin_5stack_init_verbs },
  2575. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2576. .dac_nids = alc880_dac_nids,
  2577. .dig_out_nid = ALC880_DIGOUT_NID,
  2578. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2579. .channel_mode = alc880_fivestack_modes,
  2580. .input_mux = &alc880_capture_source,
  2581. },
  2582. [ALC880_6ST] = {
  2583. .mixers = { alc880_six_stack_mixer },
  2584. .init_verbs = { alc880_volume_init_verbs,
  2585. alc880_pin_6stack_init_verbs },
  2586. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2587. .dac_nids = alc880_6st_dac_nids,
  2588. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2589. .channel_mode = alc880_sixstack_modes,
  2590. .input_mux = &alc880_6stack_capture_source,
  2591. },
  2592. [ALC880_6ST_DIG] = {
  2593. .mixers = { alc880_six_stack_mixer },
  2594. .init_verbs = { alc880_volume_init_verbs,
  2595. alc880_pin_6stack_init_verbs },
  2596. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2597. .dac_nids = alc880_6st_dac_nids,
  2598. .dig_out_nid = ALC880_DIGOUT_NID,
  2599. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2600. .channel_mode = alc880_sixstack_modes,
  2601. .input_mux = &alc880_6stack_capture_source,
  2602. },
  2603. [ALC880_W810] = {
  2604. .mixers = { alc880_w810_base_mixer },
  2605. .init_verbs = { alc880_volume_init_verbs,
  2606. alc880_pin_w810_init_verbs,
  2607. alc880_gpio2_init_verbs },
  2608. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2609. .dac_nids = alc880_w810_dac_nids,
  2610. .dig_out_nid = ALC880_DIGOUT_NID,
  2611. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2612. .channel_mode = alc880_w810_modes,
  2613. .input_mux = &alc880_capture_source,
  2614. },
  2615. [ALC880_Z71V] = {
  2616. .mixers = { alc880_z71v_mixer },
  2617. .init_verbs = { alc880_volume_init_verbs,
  2618. alc880_pin_z71v_init_verbs },
  2619. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2620. .dac_nids = alc880_z71v_dac_nids,
  2621. .dig_out_nid = ALC880_DIGOUT_NID,
  2622. .hp_nid = 0x03,
  2623. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2624. .channel_mode = alc880_2_jack_modes,
  2625. .input_mux = &alc880_capture_source,
  2626. },
  2627. [ALC880_F1734] = {
  2628. .mixers = { alc880_f1734_mixer },
  2629. .init_verbs = { alc880_volume_init_verbs,
  2630. alc880_pin_f1734_init_verbs },
  2631. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2632. .dac_nids = alc880_f1734_dac_nids,
  2633. .hp_nid = 0x02,
  2634. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2635. .channel_mode = alc880_2_jack_modes,
  2636. .input_mux = &alc880_capture_source,
  2637. },
  2638. [ALC880_ASUS] = {
  2639. .mixers = { alc880_asus_mixer },
  2640. .init_verbs = { alc880_volume_init_verbs,
  2641. alc880_pin_asus_init_verbs,
  2642. alc880_gpio1_init_verbs },
  2643. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2644. .dac_nids = alc880_asus_dac_nids,
  2645. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2646. .channel_mode = alc880_asus_modes,
  2647. .need_dac_fix = 1,
  2648. .input_mux = &alc880_capture_source,
  2649. },
  2650. [ALC880_ASUS_DIG] = {
  2651. .mixers = { alc880_asus_mixer },
  2652. .init_verbs = { alc880_volume_init_verbs,
  2653. alc880_pin_asus_init_verbs,
  2654. alc880_gpio1_init_verbs },
  2655. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2656. .dac_nids = alc880_asus_dac_nids,
  2657. .dig_out_nid = ALC880_DIGOUT_NID,
  2658. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2659. .channel_mode = alc880_asus_modes,
  2660. .need_dac_fix = 1,
  2661. .input_mux = &alc880_capture_source,
  2662. },
  2663. [ALC880_ASUS_DIG2] = {
  2664. .mixers = { alc880_asus_mixer },
  2665. .init_verbs = { alc880_volume_init_verbs,
  2666. alc880_pin_asus_init_verbs,
  2667. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2668. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2669. .dac_nids = alc880_asus_dac_nids,
  2670. .dig_out_nid = ALC880_DIGOUT_NID,
  2671. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2672. .channel_mode = alc880_asus_modes,
  2673. .need_dac_fix = 1,
  2674. .input_mux = &alc880_capture_source,
  2675. },
  2676. [ALC880_ASUS_W1V] = {
  2677. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2678. .init_verbs = { alc880_volume_init_verbs,
  2679. alc880_pin_asus_init_verbs,
  2680. alc880_gpio1_init_verbs },
  2681. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2682. .dac_nids = alc880_asus_dac_nids,
  2683. .dig_out_nid = ALC880_DIGOUT_NID,
  2684. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2685. .channel_mode = alc880_asus_modes,
  2686. .need_dac_fix = 1,
  2687. .input_mux = &alc880_capture_source,
  2688. },
  2689. [ALC880_UNIWILL_DIG] = {
  2690. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2691. .init_verbs = { alc880_volume_init_verbs,
  2692. alc880_pin_asus_init_verbs },
  2693. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2694. .dac_nids = alc880_asus_dac_nids,
  2695. .dig_out_nid = ALC880_DIGOUT_NID,
  2696. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2697. .channel_mode = alc880_asus_modes,
  2698. .need_dac_fix = 1,
  2699. .input_mux = &alc880_capture_source,
  2700. },
  2701. [ALC880_UNIWILL] = {
  2702. .mixers = { alc880_uniwill_mixer },
  2703. .init_verbs = { alc880_volume_init_verbs,
  2704. alc880_uniwill_init_verbs },
  2705. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2706. .dac_nids = alc880_asus_dac_nids,
  2707. .dig_out_nid = ALC880_DIGOUT_NID,
  2708. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2709. .channel_mode = alc880_threestack_modes,
  2710. .need_dac_fix = 1,
  2711. .input_mux = &alc880_capture_source,
  2712. .unsol_event = alc880_uniwill_unsol_event,
  2713. .init_hook = alc880_uniwill_automute,
  2714. },
  2715. [ALC880_UNIWILL_P53] = {
  2716. .mixers = { alc880_uniwill_p53_mixer },
  2717. .init_verbs = { alc880_volume_init_verbs,
  2718. alc880_uniwill_p53_init_verbs },
  2719. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2720. .dac_nids = alc880_asus_dac_nids,
  2721. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2722. .channel_mode = alc880_threestack_modes,
  2723. .input_mux = &alc880_capture_source,
  2724. .unsol_event = alc880_uniwill_p53_unsol_event,
  2725. .init_hook = alc880_uniwill_p53_hp_automute,
  2726. },
  2727. [ALC880_FUJITSU] = {
  2728. .mixers = { alc880_fujitsu_mixer,
  2729. alc880_pcbeep_mixer, },
  2730. .init_verbs = { alc880_volume_init_verbs,
  2731. alc880_uniwill_p53_init_verbs,
  2732. alc880_beep_init_verbs },
  2733. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2734. .dac_nids = alc880_dac_nids,
  2735. .dig_out_nid = ALC880_DIGOUT_NID,
  2736. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2737. .channel_mode = alc880_2_jack_modes,
  2738. .input_mux = &alc880_capture_source,
  2739. .unsol_event = alc880_uniwill_p53_unsol_event,
  2740. .init_hook = alc880_uniwill_p53_hp_automute,
  2741. },
  2742. [ALC880_CLEVO] = {
  2743. .mixers = { alc880_three_stack_mixer },
  2744. .init_verbs = { alc880_volume_init_verbs,
  2745. alc880_pin_clevo_init_verbs },
  2746. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2747. .dac_nids = alc880_dac_nids,
  2748. .hp_nid = 0x03,
  2749. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2750. .channel_mode = alc880_threestack_modes,
  2751. .need_dac_fix = 1,
  2752. .input_mux = &alc880_capture_source,
  2753. },
  2754. [ALC880_LG] = {
  2755. .mixers = { alc880_lg_mixer },
  2756. .init_verbs = { alc880_volume_init_verbs,
  2757. alc880_lg_init_verbs },
  2758. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2759. .dac_nids = alc880_lg_dac_nids,
  2760. .dig_out_nid = ALC880_DIGOUT_NID,
  2761. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2762. .channel_mode = alc880_lg_ch_modes,
  2763. .need_dac_fix = 1,
  2764. .input_mux = &alc880_lg_capture_source,
  2765. .unsol_event = alc880_lg_unsol_event,
  2766. .init_hook = alc880_lg_automute,
  2767. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2768. .loopbacks = alc880_lg_loopbacks,
  2769. #endif
  2770. },
  2771. [ALC880_LG_LW] = {
  2772. .mixers = { alc880_lg_lw_mixer },
  2773. .init_verbs = { alc880_volume_init_verbs,
  2774. alc880_lg_lw_init_verbs },
  2775. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2776. .dac_nids = alc880_dac_nids,
  2777. .dig_out_nid = ALC880_DIGOUT_NID,
  2778. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2779. .channel_mode = alc880_lg_lw_modes,
  2780. .input_mux = &alc880_lg_lw_capture_source,
  2781. .unsol_event = alc880_lg_lw_unsol_event,
  2782. .init_hook = alc880_lg_lw_automute,
  2783. },
  2784. #ifdef CONFIG_SND_DEBUG
  2785. [ALC880_TEST] = {
  2786. .mixers = { alc880_test_mixer },
  2787. .init_verbs = { alc880_test_init_verbs },
  2788. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2789. .dac_nids = alc880_test_dac_nids,
  2790. .dig_out_nid = ALC880_DIGOUT_NID,
  2791. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2792. .channel_mode = alc880_test_modes,
  2793. .input_mux = &alc880_test_capture_source,
  2794. },
  2795. #endif
  2796. };
  2797. /*
  2798. * Automatic parse of I/O pins from the BIOS configuration
  2799. */
  2800. #define NUM_CONTROL_ALLOC 32
  2801. #define NUM_VERB_ALLOC 32
  2802. enum {
  2803. ALC_CTL_WIDGET_VOL,
  2804. ALC_CTL_WIDGET_MUTE,
  2805. ALC_CTL_BIND_MUTE,
  2806. };
  2807. static struct snd_kcontrol_new alc880_control_templates[] = {
  2808. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2809. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2810. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2811. };
  2812. /* add dynamic controls */
  2813. static int add_control(struct alc_spec *spec, int type, const char *name,
  2814. unsigned long val)
  2815. {
  2816. struct snd_kcontrol_new *knew;
  2817. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2818. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2819. /* array + terminator */
  2820. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2821. if (!knew)
  2822. return -ENOMEM;
  2823. if (spec->kctl_alloc) {
  2824. memcpy(knew, spec->kctl_alloc,
  2825. sizeof(*knew) * spec->num_kctl_alloc);
  2826. kfree(spec->kctl_alloc);
  2827. }
  2828. spec->kctl_alloc = knew;
  2829. spec->num_kctl_alloc = num;
  2830. }
  2831. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2832. *knew = alc880_control_templates[type];
  2833. knew->name = kstrdup(name, GFP_KERNEL);
  2834. if (!knew->name)
  2835. return -ENOMEM;
  2836. knew->private_value = val;
  2837. spec->num_kctl_used++;
  2838. return 0;
  2839. }
  2840. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2841. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2842. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2843. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2844. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2845. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2846. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2847. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2848. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2849. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2850. #define ALC880_PIN_CD_NID 0x1c
  2851. /* fill in the dac_nids table from the parsed pin configuration */
  2852. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2853. const struct auto_pin_cfg *cfg)
  2854. {
  2855. hda_nid_t nid;
  2856. int assigned[4];
  2857. int i, j;
  2858. memset(assigned, 0, sizeof(assigned));
  2859. spec->multiout.dac_nids = spec->private_dac_nids;
  2860. /* check the pins hardwired to audio widget */
  2861. for (i = 0; i < cfg->line_outs; i++) {
  2862. nid = cfg->line_out_pins[i];
  2863. if (alc880_is_fixed_pin(nid)) {
  2864. int idx = alc880_fixed_pin_idx(nid);
  2865. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2866. assigned[idx] = 1;
  2867. }
  2868. }
  2869. /* left pins can be connect to any audio widget */
  2870. for (i = 0; i < cfg->line_outs; i++) {
  2871. nid = cfg->line_out_pins[i];
  2872. if (alc880_is_fixed_pin(nid))
  2873. continue;
  2874. /* search for an empty channel */
  2875. for (j = 0; j < cfg->line_outs; j++) {
  2876. if (!assigned[j]) {
  2877. spec->multiout.dac_nids[i] =
  2878. alc880_idx_to_dac(j);
  2879. assigned[j] = 1;
  2880. break;
  2881. }
  2882. }
  2883. }
  2884. spec->multiout.num_dacs = cfg->line_outs;
  2885. return 0;
  2886. }
  2887. /* add playback controls from the parsed DAC table */
  2888. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2889. const struct auto_pin_cfg *cfg)
  2890. {
  2891. char name[32];
  2892. static const char *chname[4] = {
  2893. "Front", "Surround", NULL /*CLFE*/, "Side"
  2894. };
  2895. hda_nid_t nid;
  2896. int i, err;
  2897. for (i = 0; i < cfg->line_outs; i++) {
  2898. if (!spec->multiout.dac_nids[i])
  2899. continue;
  2900. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2901. if (i == 2) {
  2902. /* Center/LFE */
  2903. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2904. "Center Playback Volume",
  2905. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2906. HDA_OUTPUT));
  2907. if (err < 0)
  2908. return err;
  2909. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2910. "LFE Playback Volume",
  2911. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2912. HDA_OUTPUT));
  2913. if (err < 0)
  2914. return err;
  2915. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2916. "Center Playback Switch",
  2917. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2918. HDA_INPUT));
  2919. if (err < 0)
  2920. return err;
  2921. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2922. "LFE Playback Switch",
  2923. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2924. HDA_INPUT));
  2925. if (err < 0)
  2926. return err;
  2927. } else {
  2928. sprintf(name, "%s Playback Volume", chname[i]);
  2929. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2930. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2931. HDA_OUTPUT));
  2932. if (err < 0)
  2933. return err;
  2934. sprintf(name, "%s Playback Switch", chname[i]);
  2935. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2936. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2937. HDA_INPUT));
  2938. if (err < 0)
  2939. return err;
  2940. }
  2941. }
  2942. return 0;
  2943. }
  2944. /* add playback controls for speaker and HP outputs */
  2945. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2946. const char *pfx)
  2947. {
  2948. hda_nid_t nid;
  2949. int err;
  2950. char name[32];
  2951. if (!pin)
  2952. return 0;
  2953. if (alc880_is_fixed_pin(pin)) {
  2954. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2955. /* specify the DAC as the extra output */
  2956. if (!spec->multiout.hp_nid)
  2957. spec->multiout.hp_nid = nid;
  2958. else
  2959. spec->multiout.extra_out_nid[0] = nid;
  2960. /* control HP volume/switch on the output mixer amp */
  2961. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2962. sprintf(name, "%s Playback Volume", pfx);
  2963. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2964. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2965. if (err < 0)
  2966. return err;
  2967. sprintf(name, "%s Playback Switch", pfx);
  2968. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2969. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2970. if (err < 0)
  2971. return err;
  2972. } else if (alc880_is_multi_pin(pin)) {
  2973. /* set manual connection */
  2974. /* we have only a switch on HP-out PIN */
  2975. sprintf(name, "%s Playback Switch", pfx);
  2976. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2977. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2978. if (err < 0)
  2979. return err;
  2980. }
  2981. return 0;
  2982. }
  2983. /* create input playback/capture controls for the given pin */
  2984. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2985. const char *ctlname,
  2986. int idx, hda_nid_t mix_nid)
  2987. {
  2988. char name[32];
  2989. int err;
  2990. sprintf(name, "%s Playback Volume", ctlname);
  2991. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2992. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2993. if (err < 0)
  2994. return err;
  2995. sprintf(name, "%s Playback Switch", ctlname);
  2996. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2997. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2998. if (err < 0)
  2999. return err;
  3000. return 0;
  3001. }
  3002. /* create playback/capture controls for input pins */
  3003. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3004. const struct auto_pin_cfg *cfg)
  3005. {
  3006. struct hda_input_mux *imux = &spec->private_imux;
  3007. int i, err, idx;
  3008. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3009. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3010. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3011. err = new_analog_input(spec, cfg->input_pins[i],
  3012. auto_pin_cfg_labels[i],
  3013. idx, 0x0b);
  3014. if (err < 0)
  3015. return err;
  3016. imux->items[imux->num_items].label =
  3017. auto_pin_cfg_labels[i];
  3018. imux->items[imux->num_items].index =
  3019. alc880_input_pin_idx(cfg->input_pins[i]);
  3020. imux->num_items++;
  3021. }
  3022. }
  3023. return 0;
  3024. }
  3025. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3026. hda_nid_t nid, int pin_type,
  3027. int dac_idx)
  3028. {
  3029. /* set as output */
  3030. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3031. pin_type);
  3032. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3033. AMP_OUT_UNMUTE);
  3034. /* need the manual connection? */
  3035. if (alc880_is_multi_pin(nid)) {
  3036. struct alc_spec *spec = codec->spec;
  3037. int idx = alc880_multi_pin_idx(nid);
  3038. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3039. AC_VERB_SET_CONNECT_SEL,
  3040. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3041. }
  3042. }
  3043. static int get_pin_type(int line_out_type)
  3044. {
  3045. if (line_out_type == AUTO_PIN_HP_OUT)
  3046. return PIN_HP;
  3047. else
  3048. return PIN_OUT;
  3049. }
  3050. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3051. {
  3052. struct alc_spec *spec = codec->spec;
  3053. int i;
  3054. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3055. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3056. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3057. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3058. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3059. }
  3060. }
  3061. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3062. {
  3063. struct alc_spec *spec = codec->spec;
  3064. hda_nid_t pin;
  3065. pin = spec->autocfg.speaker_pins[0];
  3066. if (pin) /* connect to front */
  3067. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3068. pin = spec->autocfg.hp_pins[0];
  3069. if (pin) /* connect to front */
  3070. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3071. }
  3072. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3073. {
  3074. struct alc_spec *spec = codec->spec;
  3075. int i;
  3076. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3077. hda_nid_t nid = spec->autocfg.input_pins[i];
  3078. if (alc880_is_input_pin(nid)) {
  3079. snd_hda_codec_write(codec, nid, 0,
  3080. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3081. i <= AUTO_PIN_FRONT_MIC ?
  3082. PIN_VREF80 : PIN_IN);
  3083. if (nid != ALC880_PIN_CD_NID)
  3084. snd_hda_codec_write(codec, nid, 0,
  3085. AC_VERB_SET_AMP_GAIN_MUTE,
  3086. AMP_OUT_MUTE);
  3087. }
  3088. }
  3089. }
  3090. /* parse the BIOS configuration and set up the alc_spec */
  3091. /* return 1 if successful, 0 if the proper config is not found,
  3092. * or a negative error code
  3093. */
  3094. static int alc880_parse_auto_config(struct hda_codec *codec)
  3095. {
  3096. struct alc_spec *spec = codec->spec;
  3097. int err;
  3098. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3099. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3100. alc880_ignore);
  3101. if (err < 0)
  3102. return err;
  3103. if (!spec->autocfg.line_outs)
  3104. return 0; /* can't find valid BIOS pin config */
  3105. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3106. if (err < 0)
  3107. return err;
  3108. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3109. if (err < 0)
  3110. return err;
  3111. err = alc880_auto_create_extra_out(spec,
  3112. spec->autocfg.speaker_pins[0],
  3113. "Speaker");
  3114. if (err < 0)
  3115. return err;
  3116. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3117. "Headphone");
  3118. if (err < 0)
  3119. return err;
  3120. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3121. if (err < 0)
  3122. return err;
  3123. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3124. if (spec->autocfg.dig_out_pin)
  3125. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3126. if (spec->autocfg.dig_in_pin)
  3127. spec->dig_in_nid = ALC880_DIGIN_NID;
  3128. if (spec->kctl_alloc)
  3129. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3130. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3131. spec->num_mux_defs = 1;
  3132. spec->input_mux = &spec->private_imux;
  3133. return 1;
  3134. }
  3135. /* additional initialization for auto-configuration model */
  3136. static void alc880_auto_init(struct hda_codec *codec)
  3137. {
  3138. alc880_auto_init_multi_out(codec);
  3139. alc880_auto_init_extra_out(codec);
  3140. alc880_auto_init_analog_input(codec);
  3141. }
  3142. /*
  3143. * OK, here we have finally the patch for ALC880
  3144. */
  3145. static int patch_alc880(struct hda_codec *codec)
  3146. {
  3147. struct alc_spec *spec;
  3148. int board_config;
  3149. int err;
  3150. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3151. if (spec == NULL)
  3152. return -ENOMEM;
  3153. codec->spec = spec;
  3154. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3155. alc880_models,
  3156. alc880_cfg_tbl);
  3157. if (board_config < 0) {
  3158. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3159. "trying auto-probe from BIOS...\n");
  3160. board_config = ALC880_AUTO;
  3161. }
  3162. if (board_config == ALC880_AUTO) {
  3163. /* automatic parse from the BIOS config */
  3164. err = alc880_parse_auto_config(codec);
  3165. if (err < 0) {
  3166. alc_free(codec);
  3167. return err;
  3168. } else if (!err) {
  3169. printk(KERN_INFO
  3170. "hda_codec: Cannot set up configuration "
  3171. "from BIOS. Using 3-stack mode...\n");
  3172. board_config = ALC880_3ST;
  3173. }
  3174. }
  3175. if (board_config != ALC880_AUTO)
  3176. setup_preset(spec, &alc880_presets[board_config]);
  3177. spec->stream_name_analog = "ALC880 Analog";
  3178. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3179. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3180. spec->stream_name_digital = "ALC880 Digital";
  3181. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3182. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3183. if (!spec->adc_nids && spec->input_mux) {
  3184. /* check whether NID 0x07 is valid */
  3185. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3186. /* get type */
  3187. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3188. if (wcap != AC_WID_AUD_IN) {
  3189. spec->adc_nids = alc880_adc_nids_alt;
  3190. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3191. spec->mixers[spec->num_mixers] =
  3192. alc880_capture_alt_mixer;
  3193. spec->num_mixers++;
  3194. } else {
  3195. spec->adc_nids = alc880_adc_nids;
  3196. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3197. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3198. spec->num_mixers++;
  3199. }
  3200. }
  3201. codec->patch_ops = alc_patch_ops;
  3202. if (board_config == ALC880_AUTO)
  3203. spec->init_hook = alc880_auto_init;
  3204. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3205. if (!spec->loopback.amplist)
  3206. spec->loopback.amplist = alc880_loopbacks;
  3207. #endif
  3208. return 0;
  3209. }
  3210. /*
  3211. * ALC260 support
  3212. */
  3213. static hda_nid_t alc260_dac_nids[1] = {
  3214. /* front */
  3215. 0x02,
  3216. };
  3217. static hda_nid_t alc260_adc_nids[1] = {
  3218. /* ADC0 */
  3219. 0x04,
  3220. };
  3221. static hda_nid_t alc260_adc_nids_alt[1] = {
  3222. /* ADC1 */
  3223. 0x05,
  3224. };
  3225. static hda_nid_t alc260_hp_adc_nids[2] = {
  3226. /* ADC1, 0 */
  3227. 0x05, 0x04
  3228. };
  3229. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3230. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3231. */
  3232. static hda_nid_t alc260_dual_adc_nids[2] = {
  3233. /* ADC0, ADC1 */
  3234. 0x04, 0x05
  3235. };
  3236. #define ALC260_DIGOUT_NID 0x03
  3237. #define ALC260_DIGIN_NID 0x06
  3238. static struct hda_input_mux alc260_capture_source = {
  3239. .num_items = 4,
  3240. .items = {
  3241. { "Mic", 0x0 },
  3242. { "Front Mic", 0x1 },
  3243. { "Line", 0x2 },
  3244. { "CD", 0x4 },
  3245. },
  3246. };
  3247. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3248. * headphone jack and the internal CD lines since these are the only pins at
  3249. * which audio can appear. For flexibility, also allow the option of
  3250. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3251. * connection to the mixer output).
  3252. */
  3253. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3254. {
  3255. .num_items = 3,
  3256. .items = {
  3257. { "Mic/Line", 0x0 },
  3258. { "CD", 0x4 },
  3259. { "Headphone", 0x2 },
  3260. },
  3261. },
  3262. {
  3263. .num_items = 4,
  3264. .items = {
  3265. { "Mic/Line", 0x0 },
  3266. { "CD", 0x4 },
  3267. { "Headphone", 0x2 },
  3268. { "Mixer", 0x5 },
  3269. },
  3270. },
  3271. };
  3272. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3273. * the Fujitsu S702x, but jacks are marked differently.
  3274. */
  3275. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3276. {
  3277. .num_items = 4,
  3278. .items = {
  3279. { "Mic", 0x0 },
  3280. { "Line", 0x2 },
  3281. { "CD", 0x4 },
  3282. { "Headphone", 0x5 },
  3283. },
  3284. },
  3285. {
  3286. .num_items = 5,
  3287. .items = {
  3288. { "Mic", 0x0 },
  3289. { "Line", 0x2 },
  3290. { "CD", 0x4 },
  3291. { "Headphone", 0x6 },
  3292. { "Mixer", 0x5 },
  3293. },
  3294. },
  3295. };
  3296. /*
  3297. * This is just place-holder, so there's something for alc_build_pcms to look
  3298. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3299. * element which allows changing the channel mode, so the verb list is
  3300. * never used.
  3301. */
  3302. static struct hda_channel_mode alc260_modes[1] = {
  3303. { 2, NULL },
  3304. };
  3305. /* Mixer combinations
  3306. *
  3307. * basic: base_output + input + pc_beep + capture
  3308. * HP: base_output + input + capture_alt
  3309. * HP_3013: hp_3013 + input + capture
  3310. * fujitsu: fujitsu + capture
  3311. * acer: acer + capture
  3312. */
  3313. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3314. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3315. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3316. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3317. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3318. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3319. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3320. { } /* end */
  3321. };
  3322. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3323. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3324. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3325. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3326. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3327. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3328. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3329. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3331. { } /* end */
  3332. };
  3333. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3334. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3335. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3336. { } /* end */
  3337. };
  3338. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3339. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3340. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3341. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3342. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3343. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3344. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3345. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3346. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3347. { } /* end */
  3348. };
  3349. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3350. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3351. */
  3352. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3353. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3354. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3355. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3356. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3357. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3358. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3359. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3360. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3361. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3362. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3363. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3364. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3365. { } /* end */
  3366. };
  3367. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3368. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3369. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3370. * datasheet doesn't mention this restriction. At this stage it's not clear
  3371. * whether this behaviour is intentional or is a hardware bug in chip
  3372. * revisions available in early 2006. Therefore for now allow the
  3373. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3374. * that the lack of mic bias for this NID is intentional we could change the
  3375. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3376. *
  3377. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3378. * don't appear to make the mic bias available from the "line" jack, even
  3379. * though the NID used for this jack (0x14) can supply it. The theory is
  3380. * that perhaps Acer have included blocking capacitors between the ALC260
  3381. * and the output jack. If this turns out to be the case for all such
  3382. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3383. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3384. *
  3385. * The C20x Tablet series have a mono internal speaker which is controlled
  3386. * via the chip's Mono sum widget and pin complex, so include the necessary
  3387. * controls for such models. On models without a "mono speaker" the control
  3388. * won't do anything.
  3389. */
  3390. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3391. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3392. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3393. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3394. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3395. HDA_OUTPUT),
  3396. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3397. HDA_INPUT),
  3398. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3399. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3400. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3401. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3402. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3403. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3404. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3405. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3406. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3407. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3408. { } /* end */
  3409. };
  3410. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3411. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3412. */
  3413. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3414. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3415. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3416. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3417. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3418. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3419. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3420. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3421. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3422. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3423. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3424. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3425. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3426. { } /* end */
  3427. };
  3428. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3429. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3430. */
  3431. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3432. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3433. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3434. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3435. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3436. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3437. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3438. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3439. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3440. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3441. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3442. { } /* end */
  3443. };
  3444. /* capture mixer elements */
  3445. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3446. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3447. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3448. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3449. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3450. {
  3451. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3452. /* The multiple "Capture Source" controls confuse alsamixer
  3453. * So call somewhat different..
  3454. * FIXME: the controls appear in the "playback" view!
  3455. */
  3456. /* .name = "Capture Source", */
  3457. .name = "Input Source",
  3458. .count = 2,
  3459. .info = alc_mux_enum_info,
  3460. .get = alc_mux_enum_get,
  3461. .put = alc_mux_enum_put,
  3462. },
  3463. { } /* end */
  3464. };
  3465. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3466. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3467. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3468. {
  3469. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3470. /* The multiple "Capture Source" controls confuse alsamixer
  3471. * So call somewhat different..
  3472. * FIXME: the controls appear in the "playback" view!
  3473. */
  3474. /* .name = "Capture Source", */
  3475. .name = "Input Source",
  3476. .count = 1,
  3477. .info = alc_mux_enum_info,
  3478. .get = alc_mux_enum_get,
  3479. .put = alc_mux_enum_put,
  3480. },
  3481. { } /* end */
  3482. };
  3483. /*
  3484. * initialization verbs
  3485. */
  3486. static struct hda_verb alc260_init_verbs[] = {
  3487. /* Line In pin widget for input */
  3488. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3489. /* CD pin widget for input */
  3490. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3491. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3492. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3493. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3494. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3495. /* LINE-2 is used for line-out in rear */
  3496. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3497. /* select line-out */
  3498. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3499. /* LINE-OUT pin */
  3500. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3501. /* enable HP */
  3502. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3503. /* enable Mono */
  3504. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3505. /* mute capture amp left and right */
  3506. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3507. /* set connection select to line in (default select for this ADC) */
  3508. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3509. /* mute capture amp left and right */
  3510. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3511. /* set connection select to line in (default select for this ADC) */
  3512. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3513. /* set vol=0 Line-Out mixer amp left and right */
  3514. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3515. /* unmute pin widget amp left and right (no gain on this amp) */
  3516. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3517. /* set vol=0 HP mixer amp left and right */
  3518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3519. /* unmute pin widget amp left and right (no gain on this amp) */
  3520. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3521. /* set vol=0 Mono mixer amp left and right */
  3522. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3523. /* unmute pin widget amp left and right (no gain on this amp) */
  3524. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3525. /* unmute LINE-2 out pin */
  3526. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3527. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3528. * Line In 2 = 0x03
  3529. */
  3530. /* mute analog inputs */
  3531. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3533. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3534. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3536. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3537. /* mute Front out path */
  3538. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3540. /* mute Headphone out path */
  3541. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3543. /* mute Mono out path */
  3544. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3546. { }
  3547. };
  3548. #if 0 /* should be identical with alc260_init_verbs? */
  3549. static struct hda_verb alc260_hp_init_verbs[] = {
  3550. /* Headphone and output */
  3551. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3552. /* mono output */
  3553. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3554. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3555. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3556. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3557. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3558. /* Line In pin widget for input */
  3559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3560. /* Line-2 pin widget for output */
  3561. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3562. /* CD pin widget for input */
  3563. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3564. /* unmute amp left and right */
  3565. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3566. /* set connection select to line in (default select for this ADC) */
  3567. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3568. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3570. /* mute pin widget amp left and right (no gain on this amp) */
  3571. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3572. /* unmute HP mixer amp left and right (volume = 0) */
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3574. /* mute pin widget amp left and right (no gain on this amp) */
  3575. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3576. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3577. * Line In 2 = 0x03
  3578. */
  3579. /* mute analog inputs */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3582. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3583. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3584. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3585. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3586. /* Unmute Front out path */
  3587. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3588. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3589. /* Unmute Headphone out path */
  3590. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3591. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3592. /* Unmute Mono out path */
  3593. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3594. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3595. { }
  3596. };
  3597. #endif
  3598. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3599. /* Line out and output */
  3600. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3601. /* mono output */
  3602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3603. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3604. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3605. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3606. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3607. /* Line In pin widget for input */
  3608. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3609. /* Headphone pin widget for output */
  3610. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3611. /* CD pin widget for input */
  3612. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3613. /* unmute amp left and right */
  3614. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3615. /* set connection select to line in (default select for this ADC) */
  3616. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3617. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3619. /* mute pin widget amp left and right (no gain on this amp) */
  3620. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3621. /* unmute HP mixer amp left and right (volume = 0) */
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3623. /* mute pin widget amp left and right (no gain on this amp) */
  3624. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3625. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3626. * Line In 2 = 0x03
  3627. */
  3628. /* mute analog inputs */
  3629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3634. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3635. /* Unmute Front out path */
  3636. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3637. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3638. /* Unmute Headphone out path */
  3639. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3640. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3641. /* Unmute Mono out path */
  3642. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3643. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3644. { }
  3645. };
  3646. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3647. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3648. * audio = 0x16, internal speaker = 0x10.
  3649. */
  3650. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3651. /* Disable all GPIOs */
  3652. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3653. /* Internal speaker is connected to headphone pin */
  3654. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3655. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3656. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3657. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3658. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3659. /* Ensure all other unused pins are disabled and muted. */
  3660. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3661. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3662. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3663. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3664. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3665. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3666. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3667. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3668. /* Disable digital (SPDIF) pins */
  3669. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3670. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3671. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3672. * when acting as an output.
  3673. */
  3674. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3675. /* Start with output sum widgets muted and their output gains at min */
  3676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3677. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3678. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3679. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3680. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3682. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3683. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3684. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3685. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3686. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3687. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3688. * If the pin mode is changed by the user the pin mode control will
  3689. * take care of enabling the pin's input/output buffers as needed.
  3690. * Therefore there's no need to enable the input buffer at this
  3691. * stage.
  3692. */
  3693. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3694. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3695. * mixer ctrl)
  3696. */
  3697. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3698. /* Mute capture amp left and right */
  3699. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3700. /* Set ADC connection select to match default mixer setting - line
  3701. * in (on mic1 pin)
  3702. */
  3703. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3704. /* Do the same for the second ADC: mute capture input amp and
  3705. * set ADC connection to line in (on mic1 pin)
  3706. */
  3707. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3708. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3709. /* Mute all inputs to mixer widget (even unconnected ones) */
  3710. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3711. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3713. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3714. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3715. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3717. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3718. { }
  3719. };
  3720. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3721. * similar laptops (adapted from Fujitsu init verbs).
  3722. */
  3723. static struct hda_verb alc260_acer_init_verbs[] = {
  3724. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3725. * the headphone jack. Turn this on and rely on the standard mute
  3726. * methods whenever the user wants to turn these outputs off.
  3727. */
  3728. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3729. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3730. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3731. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3732. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3733. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3734. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3735. /* Line In jack is connected to Line1 pin */
  3736. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3737. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3738. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3739. /* Ensure all other unused pins are disabled and muted. */
  3740. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3741. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3742. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3743. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3744. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3746. /* Disable digital (SPDIF) pins */
  3747. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3748. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3749. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3750. * bus when acting as outputs.
  3751. */
  3752. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3753. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3754. /* Start with output sum widgets muted and their output gains at min */
  3755. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3756. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3758. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3759. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3761. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3762. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3763. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3764. /* Unmute Line-out pin widget amp left and right
  3765. * (no equiv mixer ctrl)
  3766. */
  3767. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3768. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3769. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3770. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3771. * inputs. If the pin mode is changed by the user the pin mode control
  3772. * will take care of enabling the pin's input/output buffers as needed.
  3773. * Therefore there's no need to enable the input buffer at this
  3774. * stage.
  3775. */
  3776. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3777. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3778. /* Mute capture amp left and right */
  3779. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. /* Set ADC connection select to match default mixer setting - mic
  3781. * (on mic1 pin)
  3782. */
  3783. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3784. /* Do similar with the second ADC: mute capture input amp and
  3785. * set ADC connection to mic to match ALSA's default state.
  3786. */
  3787. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3788. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3789. /* Mute all inputs to mixer widget (even unconnected ones) */
  3790. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3791. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3792. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3793. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3797. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3798. { }
  3799. };
  3800. static struct hda_verb alc260_will_verbs[] = {
  3801. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3802. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3803. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3804. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3805. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3806. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3807. {}
  3808. };
  3809. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3810. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3811. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3812. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3813. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3814. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3815. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3816. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3817. {}
  3818. };
  3819. /* toggle speaker-output according to the hp-jack state */
  3820. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3821. {
  3822. unsigned int present;
  3823. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3824. present = snd_hda_codec_read(codec, 0x0f, 0,
  3825. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3826. if (present) {
  3827. snd_hda_codec_write_cache(codec, 0x01, 0,
  3828. AC_VERB_SET_GPIO_DATA, 1);
  3829. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3830. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3831. PIN_HP);
  3832. } else {
  3833. snd_hda_codec_write_cache(codec, 0x01, 0,
  3834. AC_VERB_SET_GPIO_DATA, 0);
  3835. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3836. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3837. PIN_OUT);
  3838. }
  3839. }
  3840. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3841. unsigned int res)
  3842. {
  3843. if ((res >> 26) == ALC880_HP_EVENT)
  3844. alc260_replacer_672v_automute(codec);
  3845. }
  3846. /* Test configuration for debugging, modelled after the ALC880 test
  3847. * configuration.
  3848. */
  3849. #ifdef CONFIG_SND_DEBUG
  3850. static hda_nid_t alc260_test_dac_nids[1] = {
  3851. 0x02,
  3852. };
  3853. static hda_nid_t alc260_test_adc_nids[2] = {
  3854. 0x04, 0x05,
  3855. };
  3856. /* For testing the ALC260, each input MUX needs its own definition since
  3857. * the signal assignments are different. This assumes that the first ADC
  3858. * is NID 0x04.
  3859. */
  3860. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3861. {
  3862. .num_items = 7,
  3863. .items = {
  3864. { "MIC1 pin", 0x0 },
  3865. { "MIC2 pin", 0x1 },
  3866. { "LINE1 pin", 0x2 },
  3867. { "LINE2 pin", 0x3 },
  3868. { "CD pin", 0x4 },
  3869. { "LINE-OUT pin", 0x5 },
  3870. { "HP-OUT pin", 0x6 },
  3871. },
  3872. },
  3873. {
  3874. .num_items = 8,
  3875. .items = {
  3876. { "MIC1 pin", 0x0 },
  3877. { "MIC2 pin", 0x1 },
  3878. { "LINE1 pin", 0x2 },
  3879. { "LINE2 pin", 0x3 },
  3880. { "CD pin", 0x4 },
  3881. { "Mixer", 0x5 },
  3882. { "LINE-OUT pin", 0x6 },
  3883. { "HP-OUT pin", 0x7 },
  3884. },
  3885. },
  3886. };
  3887. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3888. /* Output driver widgets */
  3889. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3890. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3891. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3892. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3893. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3894. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3895. /* Modes for retasking pin widgets
  3896. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3897. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3898. * mention this restriction. At this stage it's not clear whether
  3899. * this behaviour is intentional or is a hardware bug in chip
  3900. * revisions available at least up until early 2006. Therefore for
  3901. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3902. * choices, but if it turns out that the lack of mic bias for these
  3903. * NIDs is intentional we could change their modes from
  3904. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3905. */
  3906. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3907. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3908. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3909. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3910. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3911. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3912. /* Loopback mixer controls */
  3913. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3914. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3915. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3916. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3917. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3918. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3919. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3920. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3921. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3922. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3923. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3924. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3925. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3926. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3927. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3928. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3929. /* Controls for GPIO pins, assuming they are configured as outputs */
  3930. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3931. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3932. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3933. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3934. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3935. * is ambigious as to which NID is which; testing on laptops which
  3936. * make this output available should provide clarification.
  3937. */
  3938. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3939. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3940. { } /* end */
  3941. };
  3942. static struct hda_verb alc260_test_init_verbs[] = {
  3943. /* Enable all GPIOs as outputs with an initial value of 0 */
  3944. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3945. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3946. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3947. /* Enable retasking pins as output, initially without power amp */
  3948. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3949. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3950. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3951. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3952. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3953. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3954. /* Disable digital (SPDIF) pins initially, but users can enable
  3955. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3956. * payload also sets the generation to 0, output to be in "consumer"
  3957. * PCM format, copyright asserted, no pre-emphasis and no validity
  3958. * control.
  3959. */
  3960. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3961. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3962. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3963. * OUT1 sum bus when acting as an output.
  3964. */
  3965. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3966. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3967. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3968. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3969. /* Start with output sum widgets muted and their output gains at min */
  3970. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3972. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3973. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3974. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3975. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3976. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3977. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3978. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3979. /* Unmute retasking pin widget output buffers since the default
  3980. * state appears to be output. As the pin mode is changed by the
  3981. * user the pin mode control will take care of enabling the pin's
  3982. * input/output buffers as needed.
  3983. */
  3984. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3985. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3986. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3987. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3988. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3989. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3990. /* Also unmute the mono-out pin widget */
  3991. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3992. /* Mute capture amp left and right */
  3993. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3994. /* Set ADC connection select to match default mixer setting (mic1
  3995. * pin)
  3996. */
  3997. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3998. /* Do the same for the second ADC: mute capture input amp and
  3999. * set ADC connection to mic1 pin
  4000. */
  4001. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4002. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4003. /* Mute all inputs to mixer widget (even unconnected ones) */
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4008. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4009. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4010. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4011. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4012. { }
  4013. };
  4014. #endif
  4015. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4016. .substreams = 1,
  4017. .channels_min = 2,
  4018. .channels_max = 2,
  4019. };
  4020. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4021. .substreams = 1,
  4022. .channels_min = 2,
  4023. .channels_max = 2,
  4024. };
  4025. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4026. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4027. /*
  4028. * for BIOS auto-configuration
  4029. */
  4030. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4031. const char *pfx)
  4032. {
  4033. hda_nid_t nid_vol;
  4034. unsigned long vol_val, sw_val;
  4035. char name[32];
  4036. int err;
  4037. if (nid >= 0x0f && nid < 0x11) {
  4038. nid_vol = nid - 0x7;
  4039. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4040. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4041. } else if (nid == 0x11) {
  4042. nid_vol = nid - 0x7;
  4043. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4044. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4045. } else if (nid >= 0x12 && nid <= 0x15) {
  4046. nid_vol = 0x08;
  4047. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4048. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4049. } else
  4050. return 0; /* N/A */
  4051. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4052. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4053. if (err < 0)
  4054. return err;
  4055. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4056. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4057. if (err < 0)
  4058. return err;
  4059. return 1;
  4060. }
  4061. /* add playback controls from the parsed DAC table */
  4062. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4063. const struct auto_pin_cfg *cfg)
  4064. {
  4065. hda_nid_t nid;
  4066. int err;
  4067. spec->multiout.num_dacs = 1;
  4068. spec->multiout.dac_nids = spec->private_dac_nids;
  4069. spec->multiout.dac_nids[0] = 0x02;
  4070. nid = cfg->line_out_pins[0];
  4071. if (nid) {
  4072. err = alc260_add_playback_controls(spec, nid, "Front");
  4073. if (err < 0)
  4074. return err;
  4075. }
  4076. nid = cfg->speaker_pins[0];
  4077. if (nid) {
  4078. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4079. if (err < 0)
  4080. return err;
  4081. }
  4082. nid = cfg->hp_pins[0];
  4083. if (nid) {
  4084. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4085. if (err < 0)
  4086. return err;
  4087. }
  4088. return 0;
  4089. }
  4090. /* create playback/capture controls for input pins */
  4091. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4092. const struct auto_pin_cfg *cfg)
  4093. {
  4094. struct hda_input_mux *imux = &spec->private_imux;
  4095. int i, err, idx;
  4096. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4097. if (cfg->input_pins[i] >= 0x12) {
  4098. idx = cfg->input_pins[i] - 0x12;
  4099. err = new_analog_input(spec, cfg->input_pins[i],
  4100. auto_pin_cfg_labels[i], idx,
  4101. 0x07);
  4102. if (err < 0)
  4103. return err;
  4104. imux->items[imux->num_items].label =
  4105. auto_pin_cfg_labels[i];
  4106. imux->items[imux->num_items].index = idx;
  4107. imux->num_items++;
  4108. }
  4109. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4110. idx = cfg->input_pins[i] - 0x09;
  4111. err = new_analog_input(spec, cfg->input_pins[i],
  4112. auto_pin_cfg_labels[i], idx,
  4113. 0x07);
  4114. if (err < 0)
  4115. return err;
  4116. imux->items[imux->num_items].label =
  4117. auto_pin_cfg_labels[i];
  4118. imux->items[imux->num_items].index = idx;
  4119. imux->num_items++;
  4120. }
  4121. }
  4122. return 0;
  4123. }
  4124. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4125. hda_nid_t nid, int pin_type,
  4126. int sel_idx)
  4127. {
  4128. /* set as output */
  4129. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4130. pin_type);
  4131. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4132. AMP_OUT_UNMUTE);
  4133. /* need the manual connection? */
  4134. if (nid >= 0x12) {
  4135. int idx = nid - 0x12;
  4136. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4137. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4138. }
  4139. }
  4140. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4141. {
  4142. struct alc_spec *spec = codec->spec;
  4143. hda_nid_t nid;
  4144. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4145. nid = spec->autocfg.line_out_pins[0];
  4146. if (nid) {
  4147. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4148. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4149. }
  4150. nid = spec->autocfg.speaker_pins[0];
  4151. if (nid)
  4152. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4153. nid = spec->autocfg.hp_pins[0];
  4154. if (nid)
  4155. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4156. }
  4157. #define ALC260_PIN_CD_NID 0x16
  4158. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4159. {
  4160. struct alc_spec *spec = codec->spec;
  4161. int i;
  4162. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4163. hda_nid_t nid = spec->autocfg.input_pins[i];
  4164. if (nid >= 0x12) {
  4165. snd_hda_codec_write(codec, nid, 0,
  4166. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4167. i <= AUTO_PIN_FRONT_MIC ?
  4168. PIN_VREF80 : PIN_IN);
  4169. if (nid != ALC260_PIN_CD_NID)
  4170. snd_hda_codec_write(codec, nid, 0,
  4171. AC_VERB_SET_AMP_GAIN_MUTE,
  4172. AMP_OUT_MUTE);
  4173. }
  4174. }
  4175. }
  4176. /*
  4177. * generic initialization of ADC, input mixers and output mixers
  4178. */
  4179. static struct hda_verb alc260_volume_init_verbs[] = {
  4180. /*
  4181. * Unmute ADC0-1 and set the default input to mic-in
  4182. */
  4183. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4184. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4185. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4186. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4187. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4188. * mixer widget
  4189. * Note: PASD motherboards uses the Line In 2 as the input for
  4190. * front panel mic (mic 2)
  4191. */
  4192. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4193. /* mute analog inputs */
  4194. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4199. /*
  4200. * Set up output mixers (0x08 - 0x0a)
  4201. */
  4202. /* set vol=0 to output mixers */
  4203. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4204. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4205. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4206. /* set up input amps for analog loopback */
  4207. /* Amp Indices: DAC = 0, mixer = 1 */
  4208. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4209. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4210. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4211. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4212. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4213. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4214. { }
  4215. };
  4216. static int alc260_parse_auto_config(struct hda_codec *codec)
  4217. {
  4218. struct alc_spec *spec = codec->spec;
  4219. unsigned int wcap;
  4220. int err;
  4221. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4222. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4223. alc260_ignore);
  4224. if (err < 0)
  4225. return err;
  4226. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4227. if (err < 0)
  4228. return err;
  4229. if (!spec->kctl_alloc)
  4230. return 0; /* can't find valid BIOS pin config */
  4231. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4232. if (err < 0)
  4233. return err;
  4234. spec->multiout.max_channels = 2;
  4235. if (spec->autocfg.dig_out_pin)
  4236. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4237. if (spec->kctl_alloc)
  4238. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4239. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4240. spec->num_mux_defs = 1;
  4241. spec->input_mux = &spec->private_imux;
  4242. /* check whether NID 0x04 is valid */
  4243. wcap = get_wcaps(codec, 0x04);
  4244. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4245. if (wcap != AC_WID_AUD_IN) {
  4246. spec->adc_nids = alc260_adc_nids_alt;
  4247. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4248. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4249. } else {
  4250. spec->adc_nids = alc260_adc_nids;
  4251. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4252. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4253. }
  4254. spec->num_mixers++;
  4255. return 1;
  4256. }
  4257. /* additional initialization for auto-configuration model */
  4258. static void alc260_auto_init(struct hda_codec *codec)
  4259. {
  4260. alc260_auto_init_multi_out(codec);
  4261. alc260_auto_init_analog_input(codec);
  4262. }
  4263. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4264. static struct hda_amp_list alc260_loopbacks[] = {
  4265. { 0x07, HDA_INPUT, 0 },
  4266. { 0x07, HDA_INPUT, 1 },
  4267. { 0x07, HDA_INPUT, 2 },
  4268. { 0x07, HDA_INPUT, 3 },
  4269. { 0x07, HDA_INPUT, 4 },
  4270. { } /* end */
  4271. };
  4272. #endif
  4273. /*
  4274. * ALC260 configurations
  4275. */
  4276. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4277. [ALC260_BASIC] = "basic",
  4278. [ALC260_HP] = "hp",
  4279. [ALC260_HP_3013] = "hp-3013",
  4280. [ALC260_FUJITSU_S702X] = "fujitsu",
  4281. [ALC260_ACER] = "acer",
  4282. [ALC260_WILL] = "will",
  4283. [ALC260_REPLACER_672V] = "replacer",
  4284. #ifdef CONFIG_SND_DEBUG
  4285. [ALC260_TEST] = "test",
  4286. #endif
  4287. [ALC260_AUTO] = "auto",
  4288. };
  4289. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4290. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4291. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4292. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4293. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4294. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4295. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4296. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4297. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4298. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4299. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4300. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4301. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4302. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4303. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4304. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4305. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4306. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4307. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4308. {}
  4309. };
  4310. static struct alc_config_preset alc260_presets[] = {
  4311. [ALC260_BASIC] = {
  4312. .mixers = { alc260_base_output_mixer,
  4313. alc260_input_mixer,
  4314. alc260_pc_beep_mixer,
  4315. alc260_capture_mixer },
  4316. .init_verbs = { alc260_init_verbs },
  4317. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4318. .dac_nids = alc260_dac_nids,
  4319. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4320. .adc_nids = alc260_adc_nids,
  4321. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4322. .channel_mode = alc260_modes,
  4323. .input_mux = &alc260_capture_source,
  4324. },
  4325. [ALC260_HP] = {
  4326. .mixers = { alc260_base_output_mixer,
  4327. alc260_input_mixer,
  4328. alc260_capture_alt_mixer },
  4329. .init_verbs = { alc260_init_verbs },
  4330. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4331. .dac_nids = alc260_dac_nids,
  4332. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4333. .adc_nids = alc260_hp_adc_nids,
  4334. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4335. .channel_mode = alc260_modes,
  4336. .input_mux = &alc260_capture_source,
  4337. },
  4338. [ALC260_HP_3013] = {
  4339. .mixers = { alc260_hp_3013_mixer,
  4340. alc260_input_mixer,
  4341. alc260_capture_alt_mixer },
  4342. .init_verbs = { alc260_hp_3013_init_verbs },
  4343. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4344. .dac_nids = alc260_dac_nids,
  4345. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4346. .adc_nids = alc260_hp_adc_nids,
  4347. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4348. .channel_mode = alc260_modes,
  4349. .input_mux = &alc260_capture_source,
  4350. },
  4351. [ALC260_FUJITSU_S702X] = {
  4352. .mixers = { alc260_fujitsu_mixer,
  4353. alc260_capture_mixer },
  4354. .init_verbs = { alc260_fujitsu_init_verbs },
  4355. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4356. .dac_nids = alc260_dac_nids,
  4357. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4358. .adc_nids = alc260_dual_adc_nids,
  4359. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4360. .channel_mode = alc260_modes,
  4361. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4362. .input_mux = alc260_fujitsu_capture_sources,
  4363. },
  4364. [ALC260_ACER] = {
  4365. .mixers = { alc260_acer_mixer,
  4366. alc260_capture_mixer },
  4367. .init_verbs = { alc260_acer_init_verbs },
  4368. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4369. .dac_nids = alc260_dac_nids,
  4370. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4371. .adc_nids = alc260_dual_adc_nids,
  4372. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4373. .channel_mode = alc260_modes,
  4374. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4375. .input_mux = alc260_acer_capture_sources,
  4376. },
  4377. [ALC260_WILL] = {
  4378. .mixers = { alc260_will_mixer,
  4379. alc260_capture_mixer },
  4380. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4381. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4382. .dac_nids = alc260_dac_nids,
  4383. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4384. .adc_nids = alc260_adc_nids,
  4385. .dig_out_nid = ALC260_DIGOUT_NID,
  4386. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4387. .channel_mode = alc260_modes,
  4388. .input_mux = &alc260_capture_source,
  4389. },
  4390. [ALC260_REPLACER_672V] = {
  4391. .mixers = { alc260_replacer_672v_mixer,
  4392. alc260_capture_mixer },
  4393. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4394. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4395. .dac_nids = alc260_dac_nids,
  4396. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4397. .adc_nids = alc260_adc_nids,
  4398. .dig_out_nid = ALC260_DIGOUT_NID,
  4399. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4400. .channel_mode = alc260_modes,
  4401. .input_mux = &alc260_capture_source,
  4402. .unsol_event = alc260_replacer_672v_unsol_event,
  4403. .init_hook = alc260_replacer_672v_automute,
  4404. },
  4405. #ifdef CONFIG_SND_DEBUG
  4406. [ALC260_TEST] = {
  4407. .mixers = { alc260_test_mixer,
  4408. alc260_capture_mixer },
  4409. .init_verbs = { alc260_test_init_verbs },
  4410. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4411. .dac_nids = alc260_test_dac_nids,
  4412. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4413. .adc_nids = alc260_test_adc_nids,
  4414. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4415. .channel_mode = alc260_modes,
  4416. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4417. .input_mux = alc260_test_capture_sources,
  4418. },
  4419. #endif
  4420. };
  4421. static int patch_alc260(struct hda_codec *codec)
  4422. {
  4423. struct alc_spec *spec;
  4424. int err, board_config;
  4425. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4426. if (spec == NULL)
  4427. return -ENOMEM;
  4428. codec->spec = spec;
  4429. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4430. alc260_models,
  4431. alc260_cfg_tbl);
  4432. if (board_config < 0) {
  4433. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4434. "trying auto-probe from BIOS...\n");
  4435. board_config = ALC260_AUTO;
  4436. }
  4437. if (board_config == ALC260_AUTO) {
  4438. /* automatic parse from the BIOS config */
  4439. err = alc260_parse_auto_config(codec);
  4440. if (err < 0) {
  4441. alc_free(codec);
  4442. return err;
  4443. } else if (!err) {
  4444. printk(KERN_INFO
  4445. "hda_codec: Cannot set up configuration "
  4446. "from BIOS. Using base mode...\n");
  4447. board_config = ALC260_BASIC;
  4448. }
  4449. }
  4450. if (board_config != ALC260_AUTO)
  4451. setup_preset(spec, &alc260_presets[board_config]);
  4452. spec->stream_name_analog = "ALC260 Analog";
  4453. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4454. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4455. spec->stream_name_digital = "ALC260 Digital";
  4456. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4457. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4458. codec->patch_ops = alc_patch_ops;
  4459. if (board_config == ALC260_AUTO)
  4460. spec->init_hook = alc260_auto_init;
  4461. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4462. if (!spec->loopback.amplist)
  4463. spec->loopback.amplist = alc260_loopbacks;
  4464. #endif
  4465. return 0;
  4466. }
  4467. /*
  4468. * ALC882 support
  4469. *
  4470. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4471. * configuration. Each pin widget can choose any input DACs and a mixer.
  4472. * Each ADC is connected from a mixer of all inputs. This makes possible
  4473. * 6-channel independent captures.
  4474. *
  4475. * In addition, an independent DAC for the multi-playback (not used in this
  4476. * driver yet).
  4477. */
  4478. #define ALC882_DIGOUT_NID 0x06
  4479. #define ALC882_DIGIN_NID 0x0a
  4480. static struct hda_channel_mode alc882_ch_modes[1] = {
  4481. { 8, NULL }
  4482. };
  4483. static hda_nid_t alc882_dac_nids[4] = {
  4484. /* front, rear, clfe, rear_surr */
  4485. 0x02, 0x03, 0x04, 0x05
  4486. };
  4487. /* identical with ALC880 */
  4488. #define alc882_adc_nids alc880_adc_nids
  4489. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4490. /* input MUX */
  4491. /* FIXME: should be a matrix-type input source selection */
  4492. static struct hda_input_mux alc882_capture_source = {
  4493. .num_items = 4,
  4494. .items = {
  4495. { "Mic", 0x0 },
  4496. { "Front Mic", 0x1 },
  4497. { "Line", 0x2 },
  4498. { "CD", 0x4 },
  4499. },
  4500. };
  4501. #define alc882_mux_enum_info alc_mux_enum_info
  4502. #define alc882_mux_enum_get alc_mux_enum_get
  4503. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4504. struct snd_ctl_elem_value *ucontrol)
  4505. {
  4506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4507. struct alc_spec *spec = codec->spec;
  4508. const struct hda_input_mux *imux = spec->input_mux;
  4509. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4510. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4511. hda_nid_t nid = capture_mixers[adc_idx];
  4512. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4513. unsigned int i, idx;
  4514. idx = ucontrol->value.enumerated.item[0];
  4515. if (idx >= imux->num_items)
  4516. idx = imux->num_items - 1;
  4517. if (*cur_val == idx)
  4518. return 0;
  4519. for (i = 0; i < imux->num_items; i++) {
  4520. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4521. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4522. imux->items[i].index,
  4523. HDA_AMP_MUTE, v);
  4524. }
  4525. *cur_val = idx;
  4526. return 1;
  4527. }
  4528. /*
  4529. * 2ch mode
  4530. */
  4531. static struct hda_verb alc882_3ST_ch2_init[] = {
  4532. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4533. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4534. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4535. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4536. { } /* end */
  4537. };
  4538. /*
  4539. * 6ch mode
  4540. */
  4541. static struct hda_verb alc882_3ST_ch6_init[] = {
  4542. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4543. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4544. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4545. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4546. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4547. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4548. { } /* end */
  4549. };
  4550. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4551. { 2, alc882_3ST_ch2_init },
  4552. { 6, alc882_3ST_ch6_init },
  4553. };
  4554. /*
  4555. * 6ch mode
  4556. */
  4557. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4558. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4559. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4560. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4561. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { } /* end */
  4563. };
  4564. /*
  4565. * 8ch mode
  4566. */
  4567. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4568. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4569. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4570. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { } /* end */
  4573. };
  4574. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4575. { 6, alc882_sixstack_ch6_init },
  4576. { 8, alc882_sixstack_ch8_init },
  4577. };
  4578. /*
  4579. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4580. */
  4581. /*
  4582. * 2ch mode
  4583. */
  4584. static struct hda_verb alc885_mbp_ch2_init[] = {
  4585. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4586. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4587. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4588. { } /* end */
  4589. };
  4590. /*
  4591. * 6ch mode
  4592. */
  4593. static struct hda_verb alc885_mbp_ch6_init[] = {
  4594. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4595. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4596. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4597. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4598. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4599. { } /* end */
  4600. };
  4601. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4602. { 2, alc885_mbp_ch2_init },
  4603. { 6, alc885_mbp_ch6_init },
  4604. };
  4605. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4606. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4607. */
  4608. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4609. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4610. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4611. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4612. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4613. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4614. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4615. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4616. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4617. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4618. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4619. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4620. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4621. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4622. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4623. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4624. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4625. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4626. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4627. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4628. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4629. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4630. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4631. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4632. { } /* end */
  4633. };
  4634. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4635. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4636. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4637. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4638. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4639. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4640. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4641. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4642. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4643. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4644. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4645. { } /* end */
  4646. };
  4647. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4648. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4649. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4650. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4651. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4652. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4653. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4654. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4656. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4657. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4658. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4659. { } /* end */
  4660. };
  4661. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4662. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4663. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4665. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4666. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4667. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4668. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4671. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4672. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4673. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4674. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4675. { } /* end */
  4676. };
  4677. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4678. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4679. */
  4680. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4681. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4682. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4683. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4684. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4685. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4686. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4687. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4688. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4689. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4690. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4691. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4692. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4693. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4694. { } /* end */
  4695. };
  4696. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4697. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4698. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4699. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4700. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4701. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4702. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4703. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4705. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4706. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4707. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4708. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4709. { } /* end */
  4710. };
  4711. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4712. {
  4713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4714. .name = "Channel Mode",
  4715. .info = alc_ch_mode_info,
  4716. .get = alc_ch_mode_get,
  4717. .put = alc_ch_mode_put,
  4718. },
  4719. { } /* end */
  4720. };
  4721. static struct hda_verb alc882_init_verbs[] = {
  4722. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4723. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4724. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4726. /* Rear mixer */
  4727. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4729. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4730. /* CLFE mixer */
  4731. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4732. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4733. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4734. /* Side mixer */
  4735. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4736. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4737. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4738. /* Front Pin: output 0 (0x0c) */
  4739. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4740. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4741. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4742. /* Rear Pin: output 1 (0x0d) */
  4743. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4744. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4745. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4746. /* CLFE Pin: output 2 (0x0e) */
  4747. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4748. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4749. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4750. /* Side Pin: output 3 (0x0f) */
  4751. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4752. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4753. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4754. /* Mic (rear) pin: input vref at 80% */
  4755. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4756. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4757. /* Front Mic pin: input vref at 80% */
  4758. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4759. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4760. /* Line In pin: input */
  4761. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4762. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4763. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4764. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4765. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4766. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4767. /* CD pin widget for input */
  4768. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4769. /* FIXME: use matrix-type input source selection */
  4770. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4771. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4772. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4773. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4774. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4775. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4776. /* Input mixer2 */
  4777. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4778. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4780. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4781. /* Input mixer3 */
  4782. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4783. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4784. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4785. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4786. /* ADC1: mute amp left and right */
  4787. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4788. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4789. /* ADC2: mute amp left and right */
  4790. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4791. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4792. /* ADC3: mute amp left and right */
  4793. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4794. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4795. { }
  4796. };
  4797. static struct hda_verb alc882_eapd_verbs[] = {
  4798. /* change to EAPD mode */
  4799. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4800. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4801. { }
  4802. };
  4803. /* Mac Pro test */
  4804. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4805. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4806. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4807. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4808. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4809. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4810. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4811. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4812. { } /* end */
  4813. };
  4814. static struct hda_verb alc882_macpro_init_verbs[] = {
  4815. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4816. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4817. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4819. /* Front Pin: output 0 (0x0c) */
  4820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4821. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4822. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4823. /* Front Mic pin: input vref at 80% */
  4824. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4825. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4826. /* Speaker: output */
  4827. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4828. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4829. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4830. /* Headphone output (output 0 - 0x0c) */
  4831. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4832. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4833. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4834. /* FIXME: use matrix-type input source selection */
  4835. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4836. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4837. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4838. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4841. /* Input mixer2 */
  4842. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4843. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4846. /* Input mixer3 */
  4847. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4848. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4851. /* ADC1: mute amp left and right */
  4852. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4853. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4854. /* ADC2: mute amp left and right */
  4855. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4856. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4857. /* ADC3: mute amp left and right */
  4858. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4859. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4860. { }
  4861. };
  4862. /* Macbook Pro rev3 */
  4863. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4864. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4865. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4866. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4868. /* Rear mixer */
  4869. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4870. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4871. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4872. /* Front Pin: output 0 (0x0c) */
  4873. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4874. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4875. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4876. /* HP Pin: output 0 (0x0d) */
  4877. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4878. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4879. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4880. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4881. /* Mic (rear) pin: input vref at 80% */
  4882. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4883. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4884. /* Front Mic pin: input vref at 80% */
  4885. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4886. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4887. /* Line In pin: use output 1 when in LineOut mode */
  4888. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4889. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4890. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4891. /* FIXME: use matrix-type input source selection */
  4892. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4893. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4894. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4895. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4897. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4898. /* Input mixer2 */
  4899. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4900. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4903. /* Input mixer3 */
  4904. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4905. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4908. /* ADC1: mute amp left and right */
  4909. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4910. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4911. /* ADC2: mute amp left and right */
  4912. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4913. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4914. /* ADC3: mute amp left and right */
  4915. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4916. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. { }
  4918. };
  4919. /* iMac 24 mixer. */
  4920. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4921. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4922. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4923. { } /* end */
  4924. };
  4925. /* iMac 24 init verbs. */
  4926. static struct hda_verb alc885_imac24_init_verbs[] = {
  4927. /* Internal speakers: output 0 (0x0c) */
  4928. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4929. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4930. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4931. /* Internal speakers: output 0 (0x0c) */
  4932. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4933. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4934. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4935. /* Headphone: output 0 (0x0c) */
  4936. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4937. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4938. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4939. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4940. /* Front Mic: input vref at 80% */
  4941. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4942. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4943. { }
  4944. };
  4945. /* Toggle speaker-output according to the hp-jack state */
  4946. static void alc885_imac24_automute(struct hda_codec *codec)
  4947. {
  4948. unsigned int present;
  4949. present = snd_hda_codec_read(codec, 0x14, 0,
  4950. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4951. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4952. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4953. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4954. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4955. }
  4956. /* Processes unsolicited events. */
  4957. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4958. unsigned int res)
  4959. {
  4960. /* Headphone insertion or removal. */
  4961. if ((res >> 26) == ALC880_HP_EVENT)
  4962. alc885_imac24_automute(codec);
  4963. }
  4964. static void alc885_mbp3_automute(struct hda_codec *codec)
  4965. {
  4966. unsigned int present;
  4967. present = snd_hda_codec_read(codec, 0x15, 0,
  4968. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4969. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4970. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4971. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4972. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4973. }
  4974. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4975. unsigned int res)
  4976. {
  4977. /* Headphone insertion or removal. */
  4978. if ((res >> 26) == ALC880_HP_EVENT)
  4979. alc885_mbp3_automute(codec);
  4980. }
  4981. static struct hda_verb alc882_targa_verbs[] = {
  4982. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4983. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4984. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4985. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4986. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4987. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4988. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4989. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4990. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4991. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4992. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4993. { } /* end */
  4994. };
  4995. /* toggle speaker-output according to the hp-jack state */
  4996. static void alc882_targa_automute(struct hda_codec *codec)
  4997. {
  4998. unsigned int present;
  4999. present = snd_hda_codec_read(codec, 0x14, 0,
  5000. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5001. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5002. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5003. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5004. present ? 1 : 3);
  5005. }
  5006. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5007. {
  5008. /* Looks like the unsol event is incompatible with the standard
  5009. * definition. 4bit tag is placed at 26 bit!
  5010. */
  5011. if (((res >> 26) == ALC880_HP_EVENT)) {
  5012. alc882_targa_automute(codec);
  5013. }
  5014. }
  5015. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5016. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5017. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5018. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5019. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5020. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5021. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5022. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5023. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5024. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5025. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5026. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5027. { } /* end */
  5028. };
  5029. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5031. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5032. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5033. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5034. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5035. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5036. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5037. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5038. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5039. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5040. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5041. { } /* end */
  5042. };
  5043. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5044. {
  5045. unsigned int gpiostate, gpiomask, gpiodir;
  5046. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5047. AC_VERB_GET_GPIO_DATA, 0);
  5048. if (!muted)
  5049. gpiostate |= (1 << pin);
  5050. else
  5051. gpiostate &= ~(1 << pin);
  5052. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5053. AC_VERB_GET_GPIO_MASK, 0);
  5054. gpiomask |= (1 << pin);
  5055. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5056. AC_VERB_GET_GPIO_DIRECTION, 0);
  5057. gpiodir |= (1 << pin);
  5058. snd_hda_codec_write(codec, codec->afg, 0,
  5059. AC_VERB_SET_GPIO_MASK, gpiomask);
  5060. snd_hda_codec_write(codec, codec->afg, 0,
  5061. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5062. msleep(1);
  5063. snd_hda_codec_write(codec, codec->afg, 0,
  5064. AC_VERB_SET_GPIO_DATA, gpiostate);
  5065. }
  5066. /* set up GPIO at initialization */
  5067. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5068. {
  5069. alc882_gpio_mute(codec, 0, 0);
  5070. alc882_gpio_mute(codec, 1, 0);
  5071. }
  5072. /* set up GPIO and update auto-muting at initialization */
  5073. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5074. {
  5075. alc885_macpro_init_hook(codec);
  5076. alc885_imac24_automute(codec);
  5077. }
  5078. /*
  5079. * generic initialization of ADC, input mixers and output mixers
  5080. */
  5081. static struct hda_verb alc882_auto_init_verbs[] = {
  5082. /*
  5083. * Unmute ADC0-2 and set the default input to mic-in
  5084. */
  5085. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5086. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5087. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5088. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5089. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5090. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5091. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5092. * mixer widget
  5093. * Note: PASD motherboards uses the Line In 2 as the input for
  5094. * front panel mic (mic 2)
  5095. */
  5096. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5097. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5098. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5099. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5102. /*
  5103. * Set up output mixers (0x0c - 0x0f)
  5104. */
  5105. /* set vol=0 to output mixers */
  5106. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5107. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5108. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5109. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5110. /* set up input amps for analog loopback */
  5111. /* Amp Indices: DAC = 0, mixer = 1 */
  5112. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5113. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5114. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5115. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5116. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5117. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5118. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5119. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5120. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5121. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5122. /* FIXME: use matrix-type input source selection */
  5123. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5124. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5125. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5126. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5128. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5129. /* Input mixer2 */
  5130. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5131. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5132. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5133. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5134. /* Input mixer3 */
  5135. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5136. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5137. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5139. { }
  5140. };
  5141. /* capture mixer elements */
  5142. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5143. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5144. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5145. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5146. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5147. {
  5148. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5149. /* The multiple "Capture Source" controls confuse alsamixer
  5150. * So call somewhat different..
  5151. * FIXME: the controls appear in the "playback" view!
  5152. */
  5153. /* .name = "Capture Source", */
  5154. .name = "Input Source",
  5155. .count = 2,
  5156. .info = alc882_mux_enum_info,
  5157. .get = alc882_mux_enum_get,
  5158. .put = alc882_mux_enum_put,
  5159. },
  5160. { } /* end */
  5161. };
  5162. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5163. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5164. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5165. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5166. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5167. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5168. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5169. {
  5170. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5171. /* The multiple "Capture Source" controls confuse alsamixer
  5172. * So call somewhat different..
  5173. * FIXME: the controls appear in the "playback" view!
  5174. */
  5175. /* .name = "Capture Source", */
  5176. .name = "Input Source",
  5177. .count = 3,
  5178. .info = alc882_mux_enum_info,
  5179. .get = alc882_mux_enum_get,
  5180. .put = alc882_mux_enum_put,
  5181. },
  5182. { } /* end */
  5183. };
  5184. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5185. #define alc882_loopbacks alc880_loopbacks
  5186. #endif
  5187. /* pcm configuration: identiacal with ALC880 */
  5188. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5189. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5190. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5191. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5192. /*
  5193. * configuration and preset
  5194. */
  5195. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5196. [ALC882_3ST_DIG] = "3stack-dig",
  5197. [ALC882_6ST_DIG] = "6stack-dig",
  5198. [ALC882_ARIMA] = "arima",
  5199. [ALC882_W2JC] = "w2jc",
  5200. [ALC882_TARGA] = "targa",
  5201. [ALC882_ASUS_A7J] = "asus-a7j",
  5202. [ALC882_ASUS_A7M] = "asus-a7m",
  5203. [ALC885_MACPRO] = "macpro",
  5204. [ALC885_MBP3] = "mbp3",
  5205. [ALC885_IMAC24] = "imac24",
  5206. [ALC882_AUTO] = "auto",
  5207. };
  5208. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5209. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5210. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5211. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5212. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5213. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5214. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5215. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5216. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5217. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5218. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5219. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5220. {}
  5221. };
  5222. static struct alc_config_preset alc882_presets[] = {
  5223. [ALC882_3ST_DIG] = {
  5224. .mixers = { alc882_base_mixer },
  5225. .init_verbs = { alc882_init_verbs },
  5226. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5227. .dac_nids = alc882_dac_nids,
  5228. .dig_out_nid = ALC882_DIGOUT_NID,
  5229. .dig_in_nid = ALC882_DIGIN_NID,
  5230. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5231. .channel_mode = alc882_ch_modes,
  5232. .need_dac_fix = 1,
  5233. .input_mux = &alc882_capture_source,
  5234. },
  5235. [ALC882_6ST_DIG] = {
  5236. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5237. .init_verbs = { alc882_init_verbs },
  5238. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5239. .dac_nids = alc882_dac_nids,
  5240. .dig_out_nid = ALC882_DIGOUT_NID,
  5241. .dig_in_nid = ALC882_DIGIN_NID,
  5242. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5243. .channel_mode = alc882_sixstack_modes,
  5244. .input_mux = &alc882_capture_source,
  5245. },
  5246. [ALC882_ARIMA] = {
  5247. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5248. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5249. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5250. .dac_nids = alc882_dac_nids,
  5251. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5252. .channel_mode = alc882_sixstack_modes,
  5253. .input_mux = &alc882_capture_source,
  5254. },
  5255. [ALC882_W2JC] = {
  5256. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5257. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5258. alc880_gpio1_init_verbs },
  5259. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5260. .dac_nids = alc882_dac_nids,
  5261. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5262. .channel_mode = alc880_threestack_modes,
  5263. .need_dac_fix = 1,
  5264. .input_mux = &alc882_capture_source,
  5265. .dig_out_nid = ALC882_DIGOUT_NID,
  5266. },
  5267. [ALC885_MBP3] = {
  5268. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5269. .init_verbs = { alc885_mbp3_init_verbs,
  5270. alc880_gpio1_init_verbs },
  5271. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5272. .dac_nids = alc882_dac_nids,
  5273. .channel_mode = alc885_mbp_6ch_modes,
  5274. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5275. .input_mux = &alc882_capture_source,
  5276. .dig_out_nid = ALC882_DIGOUT_NID,
  5277. .dig_in_nid = ALC882_DIGIN_NID,
  5278. .unsol_event = alc885_mbp3_unsol_event,
  5279. .init_hook = alc885_mbp3_automute,
  5280. },
  5281. [ALC885_MACPRO] = {
  5282. .mixers = { alc882_macpro_mixer },
  5283. .init_verbs = { alc882_macpro_init_verbs },
  5284. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5285. .dac_nids = alc882_dac_nids,
  5286. .dig_out_nid = ALC882_DIGOUT_NID,
  5287. .dig_in_nid = ALC882_DIGIN_NID,
  5288. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5289. .channel_mode = alc882_ch_modes,
  5290. .input_mux = &alc882_capture_source,
  5291. .init_hook = alc885_macpro_init_hook,
  5292. },
  5293. [ALC885_IMAC24] = {
  5294. .mixers = { alc885_imac24_mixer },
  5295. .init_verbs = { alc885_imac24_init_verbs },
  5296. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5297. .dac_nids = alc882_dac_nids,
  5298. .dig_out_nid = ALC882_DIGOUT_NID,
  5299. .dig_in_nid = ALC882_DIGIN_NID,
  5300. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5301. .channel_mode = alc882_ch_modes,
  5302. .input_mux = &alc882_capture_source,
  5303. .unsol_event = alc885_imac24_unsol_event,
  5304. .init_hook = alc885_imac24_init_hook,
  5305. },
  5306. [ALC882_TARGA] = {
  5307. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5308. alc882_capture_mixer },
  5309. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5310. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5311. .dac_nids = alc882_dac_nids,
  5312. .dig_out_nid = ALC882_DIGOUT_NID,
  5313. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5314. .adc_nids = alc882_adc_nids,
  5315. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5316. .channel_mode = alc882_3ST_6ch_modes,
  5317. .need_dac_fix = 1,
  5318. .input_mux = &alc882_capture_source,
  5319. .unsol_event = alc882_targa_unsol_event,
  5320. .init_hook = alc882_targa_automute,
  5321. },
  5322. [ALC882_ASUS_A7J] = {
  5323. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5324. alc882_capture_mixer },
  5325. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5326. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5327. .dac_nids = alc882_dac_nids,
  5328. .dig_out_nid = ALC882_DIGOUT_NID,
  5329. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5330. .adc_nids = alc882_adc_nids,
  5331. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5332. .channel_mode = alc882_3ST_6ch_modes,
  5333. .need_dac_fix = 1,
  5334. .input_mux = &alc882_capture_source,
  5335. },
  5336. [ALC882_ASUS_A7M] = {
  5337. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5338. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5339. alc880_gpio1_init_verbs,
  5340. alc882_asus_a7m_verbs },
  5341. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5342. .dac_nids = alc882_dac_nids,
  5343. .dig_out_nid = ALC882_DIGOUT_NID,
  5344. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5345. .channel_mode = alc880_threestack_modes,
  5346. .need_dac_fix = 1,
  5347. .input_mux = &alc882_capture_source,
  5348. },
  5349. };
  5350. /*
  5351. * Pin config fixes
  5352. */
  5353. enum {
  5354. PINFIX_ABIT_AW9D_MAX
  5355. };
  5356. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5357. { 0x15, 0x01080104 }, /* side */
  5358. { 0x16, 0x01011012 }, /* rear */
  5359. { 0x17, 0x01016011 }, /* clfe */
  5360. { }
  5361. };
  5362. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5363. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5364. };
  5365. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5366. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5367. {}
  5368. };
  5369. /*
  5370. * BIOS auto configuration
  5371. */
  5372. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5373. hda_nid_t nid, int pin_type,
  5374. int dac_idx)
  5375. {
  5376. /* set as output */
  5377. struct alc_spec *spec = codec->spec;
  5378. int idx;
  5379. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5380. idx = 4;
  5381. else
  5382. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5383. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5384. pin_type);
  5385. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5386. AMP_OUT_UNMUTE);
  5387. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5388. }
  5389. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5390. {
  5391. struct alc_spec *spec = codec->spec;
  5392. int i;
  5393. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5394. for (i = 0; i <= HDA_SIDE; i++) {
  5395. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5396. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5397. if (nid)
  5398. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5399. i);
  5400. }
  5401. }
  5402. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5403. {
  5404. struct alc_spec *spec = codec->spec;
  5405. hda_nid_t pin;
  5406. pin = spec->autocfg.hp_pins[0];
  5407. if (pin) /* connect to front */
  5408. /* use dac 0 */
  5409. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5410. }
  5411. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5412. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5413. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5414. {
  5415. struct alc_spec *spec = codec->spec;
  5416. int i;
  5417. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5418. hda_nid_t nid = spec->autocfg.input_pins[i];
  5419. if (alc882_is_input_pin(nid)) {
  5420. snd_hda_codec_write(codec, nid, 0,
  5421. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5422. i <= AUTO_PIN_FRONT_MIC ?
  5423. PIN_VREF80 : PIN_IN);
  5424. if (nid != ALC882_PIN_CD_NID)
  5425. snd_hda_codec_write(codec, nid, 0,
  5426. AC_VERB_SET_AMP_GAIN_MUTE,
  5427. AMP_OUT_MUTE);
  5428. }
  5429. }
  5430. }
  5431. /* add mic boosts if needed */
  5432. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5433. {
  5434. struct alc_spec *spec = codec->spec;
  5435. int err;
  5436. hda_nid_t nid;
  5437. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5438. if (nid) {
  5439. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5440. "Mic Boost",
  5441. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5442. if (err < 0)
  5443. return err;
  5444. }
  5445. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5446. if (nid) {
  5447. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5448. "Front Mic Boost",
  5449. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5450. if (err < 0)
  5451. return err;
  5452. }
  5453. return 0;
  5454. }
  5455. /* almost identical with ALC880 parser... */
  5456. static int alc882_parse_auto_config(struct hda_codec *codec)
  5457. {
  5458. struct alc_spec *spec = codec->spec;
  5459. int err = alc880_parse_auto_config(codec);
  5460. if (err < 0)
  5461. return err;
  5462. else if (!err)
  5463. return 0; /* no config found */
  5464. err = alc_auto_add_mic_boost(codec);
  5465. if (err < 0)
  5466. return err;
  5467. /* hack - override the init verbs */
  5468. spec->init_verbs[0] = alc882_auto_init_verbs;
  5469. return 1; /* config found */
  5470. }
  5471. /* additional initialization for auto-configuration model */
  5472. static void alc882_auto_init(struct hda_codec *codec)
  5473. {
  5474. alc882_auto_init_multi_out(codec);
  5475. alc882_auto_init_hp_out(codec);
  5476. alc882_auto_init_analog_input(codec);
  5477. }
  5478. static int patch_alc882(struct hda_codec *codec)
  5479. {
  5480. struct alc_spec *spec;
  5481. int err, board_config;
  5482. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5483. if (spec == NULL)
  5484. return -ENOMEM;
  5485. codec->spec = spec;
  5486. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5487. alc882_models,
  5488. alc882_cfg_tbl);
  5489. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5490. /* Pick up systems that don't supply PCI SSID */
  5491. switch (codec->subsystem_id) {
  5492. case 0x106b0c00: /* Mac Pro */
  5493. board_config = ALC885_MACPRO;
  5494. break;
  5495. case 0x106b1000: /* iMac 24 */
  5496. board_config = ALC885_IMAC24;
  5497. break;
  5498. case 0x106b2c00: /* Macbook Pro rev3 */
  5499. board_config = ALC885_MBP3;
  5500. break;
  5501. default:
  5502. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5503. "trying auto-probe from BIOS...\n");
  5504. board_config = ALC882_AUTO;
  5505. }
  5506. }
  5507. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5508. if (board_config == ALC882_AUTO) {
  5509. /* automatic parse from the BIOS config */
  5510. err = alc882_parse_auto_config(codec);
  5511. if (err < 0) {
  5512. alc_free(codec);
  5513. return err;
  5514. } else if (!err) {
  5515. printk(KERN_INFO
  5516. "hda_codec: Cannot set up configuration "
  5517. "from BIOS. Using base mode...\n");
  5518. board_config = ALC882_3ST_DIG;
  5519. }
  5520. }
  5521. if (board_config != ALC882_AUTO)
  5522. setup_preset(spec, &alc882_presets[board_config]);
  5523. spec->stream_name_analog = "ALC882 Analog";
  5524. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5525. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5526. spec->stream_name_digital = "ALC882 Digital";
  5527. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5528. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5529. if (!spec->adc_nids && spec->input_mux) {
  5530. /* check whether NID 0x07 is valid */
  5531. unsigned int wcap = get_wcaps(codec, 0x07);
  5532. /* get type */
  5533. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5534. if (wcap != AC_WID_AUD_IN) {
  5535. spec->adc_nids = alc882_adc_nids_alt;
  5536. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5537. spec->mixers[spec->num_mixers] =
  5538. alc882_capture_alt_mixer;
  5539. spec->num_mixers++;
  5540. } else {
  5541. spec->adc_nids = alc882_adc_nids;
  5542. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5543. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5544. spec->num_mixers++;
  5545. }
  5546. }
  5547. codec->patch_ops = alc_patch_ops;
  5548. if (board_config == ALC882_AUTO)
  5549. spec->init_hook = alc882_auto_init;
  5550. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5551. if (!spec->loopback.amplist)
  5552. spec->loopback.amplist = alc882_loopbacks;
  5553. #endif
  5554. return 0;
  5555. }
  5556. /*
  5557. * ALC883 support
  5558. *
  5559. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5560. * configuration. Each pin widget can choose any input DACs and a mixer.
  5561. * Each ADC is connected from a mixer of all inputs. This makes possible
  5562. * 6-channel independent captures.
  5563. *
  5564. * In addition, an independent DAC for the multi-playback (not used in this
  5565. * driver yet).
  5566. */
  5567. #define ALC883_DIGOUT_NID 0x06
  5568. #define ALC883_DIGIN_NID 0x0a
  5569. static hda_nid_t alc883_dac_nids[4] = {
  5570. /* front, rear, clfe, rear_surr */
  5571. 0x02, 0x04, 0x03, 0x05
  5572. };
  5573. static hda_nid_t alc883_adc_nids[2] = {
  5574. /* ADC1-2 */
  5575. 0x08, 0x09,
  5576. };
  5577. /* input MUX */
  5578. /* FIXME: should be a matrix-type input source selection */
  5579. static struct hda_input_mux alc883_capture_source = {
  5580. .num_items = 4,
  5581. .items = {
  5582. { "Mic", 0x0 },
  5583. { "Front Mic", 0x1 },
  5584. { "Line", 0x2 },
  5585. { "CD", 0x4 },
  5586. },
  5587. };
  5588. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5589. .num_items = 2,
  5590. .items = {
  5591. { "Mic", 0x1 },
  5592. { "Line", 0x2 },
  5593. },
  5594. };
  5595. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5596. .num_items = 4,
  5597. .items = {
  5598. { "Mic", 0x0 },
  5599. { "iMic", 0x1 },
  5600. { "Line", 0x2 },
  5601. { "CD", 0x4 },
  5602. },
  5603. };
  5604. #define alc883_mux_enum_info alc_mux_enum_info
  5605. #define alc883_mux_enum_get alc_mux_enum_get
  5606. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5607. struct snd_ctl_elem_value *ucontrol)
  5608. {
  5609. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5610. struct alc_spec *spec = codec->spec;
  5611. const struct hda_input_mux *imux = spec->input_mux;
  5612. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5613. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5614. hda_nid_t nid = capture_mixers[adc_idx];
  5615. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5616. unsigned int i, idx;
  5617. idx = ucontrol->value.enumerated.item[0];
  5618. if (idx >= imux->num_items)
  5619. idx = imux->num_items - 1;
  5620. if (*cur_val == idx)
  5621. return 0;
  5622. for (i = 0; i < imux->num_items; i++) {
  5623. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5624. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5625. imux->items[i].index,
  5626. HDA_AMP_MUTE, v);
  5627. }
  5628. *cur_val = idx;
  5629. return 1;
  5630. }
  5631. /*
  5632. * 2ch mode
  5633. */
  5634. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5635. { 2, NULL }
  5636. };
  5637. /*
  5638. * 2ch mode
  5639. */
  5640. static struct hda_verb alc883_3ST_ch2_init[] = {
  5641. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5642. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5643. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5644. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5645. { } /* end */
  5646. };
  5647. /*
  5648. * 4ch mode
  5649. */
  5650. static struct hda_verb alc883_3ST_ch4_init[] = {
  5651. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5652. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5653. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5654. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5655. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5656. { } /* end */
  5657. };
  5658. /*
  5659. * 6ch mode
  5660. */
  5661. static struct hda_verb alc883_3ST_ch6_init[] = {
  5662. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5663. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5664. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5665. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5666. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5667. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5668. { } /* end */
  5669. };
  5670. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5671. { 2, alc883_3ST_ch2_init },
  5672. { 4, alc883_3ST_ch4_init },
  5673. { 6, alc883_3ST_ch6_init },
  5674. };
  5675. /*
  5676. * 6ch mode
  5677. */
  5678. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5679. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5680. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5681. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5682. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5683. { } /* end */
  5684. };
  5685. /*
  5686. * 8ch mode
  5687. */
  5688. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5689. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5690. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5691. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5692. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5693. { } /* end */
  5694. };
  5695. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5696. { 6, alc883_sixstack_ch6_init },
  5697. { 8, alc883_sixstack_ch8_init },
  5698. };
  5699. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5700. /* eanable EAPD on medion laptop */
  5701. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5702. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5703. { }
  5704. };
  5705. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5706. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5707. */
  5708. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5709. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5710. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5711. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5712. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5713. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5714. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5715. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5716. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5717. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5718. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5719. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5726. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5728. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5729. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5731. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5734. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5735. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5736. {
  5737. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5738. /* .name = "Capture Source", */
  5739. .name = "Input Source",
  5740. .count = 2,
  5741. .info = alc883_mux_enum_info,
  5742. .get = alc883_mux_enum_get,
  5743. .put = alc883_mux_enum_put,
  5744. },
  5745. { } /* end */
  5746. };
  5747. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5748. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5749. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5750. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5751. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5752. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5753. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5754. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5755. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5757. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5758. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5759. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5760. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5761. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5762. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5763. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5764. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5765. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5766. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5767. {
  5768. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5769. /* .name = "Capture Source", */
  5770. .name = "Input Source",
  5771. .count = 2,
  5772. .info = alc883_mux_enum_info,
  5773. .get = alc883_mux_enum_get,
  5774. .put = alc883_mux_enum_put,
  5775. },
  5776. { } /* end */
  5777. };
  5778. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5779. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5780. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5781. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5782. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5783. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5784. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5785. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5786. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5787. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5788. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5789. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5790. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5791. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5792. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5796. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5797. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5799. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5801. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5802. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5803. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5804. {
  5805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5806. /* .name = "Capture Source", */
  5807. .name = "Input Source",
  5808. .count = 2,
  5809. .info = alc883_mux_enum_info,
  5810. .get = alc883_mux_enum_get,
  5811. .put = alc883_mux_enum_put,
  5812. },
  5813. { } /* end */
  5814. };
  5815. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5816. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5817. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5818. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5821. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5822. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5823. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5825. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5826. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5827. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5828. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5829. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5830. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5831. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5834. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5836. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5837. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5838. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5839. {
  5840. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5841. /* .name = "Capture Source", */
  5842. .name = "Input Source",
  5843. .count = 1,
  5844. .info = alc883_mux_enum_info,
  5845. .get = alc883_mux_enum_get,
  5846. .put = alc883_mux_enum_put,
  5847. },
  5848. { } /* end */
  5849. };
  5850. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5851. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5853. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5854. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5855. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5856. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5857. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5858. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5859. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5860. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5861. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5863. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5864. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5866. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5867. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5868. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5869. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5870. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5871. {
  5872. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5873. /* .name = "Capture Source", */
  5874. .name = "Input Source",
  5875. .count = 2,
  5876. .info = alc883_mux_enum_info,
  5877. .get = alc883_mux_enum_get,
  5878. .put = alc883_mux_enum_put,
  5879. },
  5880. { } /* end */
  5881. };
  5882. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5883. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5884. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5885. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5887. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5888. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5889. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5890. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5891. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5892. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5893. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5894. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5895. {
  5896. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5897. /* .name = "Capture Source", */
  5898. .name = "Input Source",
  5899. .count = 2,
  5900. .info = alc883_mux_enum_info,
  5901. .get = alc883_mux_enum_get,
  5902. .put = alc883_mux_enum_put,
  5903. },
  5904. { } /* end */
  5905. };
  5906. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5907. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5908. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5909. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5910. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5911. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5912. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5913. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5914. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5915. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5916. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5917. {
  5918. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5919. /* .name = "Capture Source", */
  5920. .name = "Input Source",
  5921. .count = 1,
  5922. .info = alc883_mux_enum_info,
  5923. .get = alc883_mux_enum_get,
  5924. .put = alc883_mux_enum_put,
  5925. },
  5926. { } /* end */
  5927. };
  5928. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5929. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5930. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5931. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5932. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5933. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5934. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5935. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5936. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5937. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5938. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5939. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5940. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5941. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5942. {
  5943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5944. /* .name = "Capture Source", */
  5945. .name = "Input Source",
  5946. .count = 2,
  5947. .info = alc883_mux_enum_info,
  5948. .get = alc883_mux_enum_get,
  5949. .put = alc883_mux_enum_put,
  5950. },
  5951. { } /* end */
  5952. };
  5953. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5954. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5955. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5956. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5957. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5958. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5959. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5960. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5961. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5962. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5963. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5964. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5965. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5966. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5967. {
  5968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5969. /* .name = "Capture Source", */
  5970. .name = "Input Source",
  5971. .count = 2,
  5972. .info = alc883_mux_enum_info,
  5973. .get = alc883_mux_enum_get,
  5974. .put = alc883_mux_enum_put,
  5975. },
  5976. { } /* end */
  5977. };
  5978. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5979. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5980. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5981. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5982. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5983. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5984. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5985. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5986. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5987. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5988. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5989. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5990. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5991. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5992. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5993. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5994. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5995. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5996. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5997. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5998. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5999. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6000. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6001. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6002. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6003. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6004. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6005. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6006. {
  6007. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6008. /* .name = "Capture Source", */
  6009. .name = "Input Source",
  6010. .count = 2,
  6011. .info = alc883_mux_enum_info,
  6012. .get = alc883_mux_enum_get,
  6013. .put = alc883_mux_enum_put,
  6014. },
  6015. { } /* end */
  6016. };
  6017. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6018. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6019. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6020. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6021. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6022. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6023. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6024. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6025. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6026. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6027. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6028. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6029. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6030. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6031. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6032. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6033. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6034. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6035. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6036. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6037. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6038. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6039. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6040. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6041. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6042. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6043. {
  6044. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6045. /* .name = "Capture Source", */
  6046. .name = "Input Source",
  6047. .count = 2,
  6048. .info = alc883_mux_enum_info,
  6049. .get = alc883_mux_enum_get,
  6050. .put = alc883_mux_enum_put,
  6051. },
  6052. { } /* end */
  6053. };
  6054. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6055. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6056. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6057. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6058. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6059. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6060. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6061. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6062. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6063. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6064. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6065. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6066. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6067. {
  6068. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6069. /* .name = "Capture Source", */
  6070. .name = "Input Source",
  6071. .count = 2,
  6072. .info = alc883_mux_enum_info,
  6073. .get = alc883_mux_enum_get,
  6074. .put = alc883_mux_enum_put,
  6075. },
  6076. { } /* end */
  6077. };
  6078. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6079. {
  6080. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6081. .name = "Channel Mode",
  6082. .info = alc_ch_mode_info,
  6083. .get = alc_ch_mode_get,
  6084. .put = alc_ch_mode_put,
  6085. },
  6086. { } /* end */
  6087. };
  6088. static struct hda_verb alc883_init_verbs[] = {
  6089. /* ADC1: mute amp left and right */
  6090. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6091. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6092. /* ADC2: mute amp left and right */
  6093. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6094. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6095. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6098. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6099. /* Rear mixer */
  6100. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6101. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6102. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6103. /* CLFE mixer */
  6104. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6105. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6106. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6107. /* Side mixer */
  6108. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6109. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6110. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6111. /* mute analog input loopbacks */
  6112. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6113. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6114. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6115. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6117. /* Front Pin: output 0 (0x0c) */
  6118. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6119. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6120. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6121. /* Rear Pin: output 1 (0x0d) */
  6122. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6123. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6124. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6125. /* CLFE Pin: output 2 (0x0e) */
  6126. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6127. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6128. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6129. /* Side Pin: output 3 (0x0f) */
  6130. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6131. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6132. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6133. /* Mic (rear) pin: input vref at 80% */
  6134. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6135. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6136. /* Front Mic pin: input vref at 80% */
  6137. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6138. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6139. /* Line In pin: input */
  6140. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6141. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6142. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6143. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6144. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6145. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6146. /* CD pin widget for input */
  6147. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6148. /* FIXME: use matrix-type input source selection */
  6149. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6150. /* Input mixer2 */
  6151. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6155. /* Input mixer3 */
  6156. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6157. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6158. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6159. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6160. { }
  6161. };
  6162. static struct hda_verb alc883_tagra_verbs[] = {
  6163. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6165. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6167. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6168. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6169. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6170. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6171. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6172. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6173. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6174. { } /* end */
  6175. };
  6176. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6177. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6178. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6179. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6180. { } /* end */
  6181. };
  6182. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6183. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6184. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6185. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6186. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6187. { } /* end */
  6188. };
  6189. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6192. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6193. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6194. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6195. { } /* end */
  6196. };
  6197. static struct hda_verb alc883_haier_w66_verbs[] = {
  6198. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6200. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6201. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6202. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6203. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6204. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6205. { } /* end */
  6206. };
  6207. static struct hda_verb alc888_6st_hp_verbs[] = {
  6208. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6209. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6210. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6211. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6212. { }
  6213. };
  6214. static struct hda_verb alc888_3st_hp_verbs[] = {
  6215. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6216. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6217. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6218. { }
  6219. };
  6220. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6221. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6222. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6223. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6224. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6225. { }
  6226. };
  6227. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6228. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6229. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6230. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6231. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6232. { }
  6233. };
  6234. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6235. { 2, alc888_3st_hp_2ch_init },
  6236. { 6, alc888_3st_hp_6ch_init },
  6237. };
  6238. /* toggle front-jack and RCA according to the hp-jack state */
  6239. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6240. {
  6241. unsigned int present;
  6242. present = snd_hda_codec_read(codec, 0x1b, 0,
  6243. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6244. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6245. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6246. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6247. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6248. }
  6249. /* toggle RCA according to the front-jack state */
  6250. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6251. {
  6252. unsigned int present;
  6253. present = snd_hda_codec_read(codec, 0x14, 0,
  6254. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6255. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6256. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6257. }
  6258. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6259. unsigned int res)
  6260. {
  6261. if ((res >> 26) == ALC880_HP_EVENT)
  6262. alc888_lenovo_ms7195_front_automute(codec);
  6263. if ((res >> 26) == ALC880_FRONT_EVENT)
  6264. alc888_lenovo_ms7195_rca_automute(codec);
  6265. }
  6266. static struct hda_verb alc883_medion_md2_verbs[] = {
  6267. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6268. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6269. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6270. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6271. { } /* end */
  6272. };
  6273. /* toggle speaker-output according to the hp-jack state */
  6274. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6275. {
  6276. unsigned int present;
  6277. present = snd_hda_codec_read(codec, 0x14, 0,
  6278. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6279. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6280. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6281. }
  6282. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6283. unsigned int res)
  6284. {
  6285. if ((res >> 26) == ALC880_HP_EVENT)
  6286. alc883_medion_md2_automute(codec);
  6287. }
  6288. /* toggle speaker-output according to the hp-jack state */
  6289. static void alc883_tagra_automute(struct hda_codec *codec)
  6290. {
  6291. unsigned int present;
  6292. unsigned char bits;
  6293. present = snd_hda_codec_read(codec, 0x14, 0,
  6294. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6295. bits = present ? HDA_AMP_MUTE : 0;
  6296. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6297. HDA_AMP_MUTE, bits);
  6298. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6299. present ? 1 : 3);
  6300. }
  6301. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6302. {
  6303. if ((res >> 26) == ALC880_HP_EVENT)
  6304. alc883_tagra_automute(codec);
  6305. }
  6306. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6307. {
  6308. unsigned int present;
  6309. unsigned char bits;
  6310. present = snd_hda_codec_read(codec, 0x1b, 0,
  6311. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6312. bits = present ? 0x80 : 0;
  6313. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6314. 0x80, bits);
  6315. }
  6316. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6317. unsigned int res)
  6318. {
  6319. if ((res >> 26) == ALC880_HP_EVENT)
  6320. alc883_haier_w66_automute(codec);
  6321. }
  6322. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6323. {
  6324. unsigned int present;
  6325. unsigned char bits;
  6326. present = snd_hda_codec_read(codec, 0x14, 0,
  6327. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6328. bits = present ? HDA_AMP_MUTE : 0;
  6329. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6330. HDA_AMP_MUTE, bits);
  6331. }
  6332. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6333. {
  6334. unsigned int present;
  6335. unsigned char bits;
  6336. present = snd_hda_codec_read(codec, 0x1b, 0,
  6337. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6338. bits = present ? HDA_AMP_MUTE : 0;
  6339. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6340. HDA_AMP_MUTE, bits);
  6341. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6342. HDA_AMP_MUTE, bits);
  6343. }
  6344. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6345. unsigned int res)
  6346. {
  6347. if ((res >> 26) == ALC880_HP_EVENT)
  6348. alc883_lenovo_101e_all_automute(codec);
  6349. if ((res >> 26) == ALC880_FRONT_EVENT)
  6350. alc883_lenovo_101e_ispeaker_automute(codec);
  6351. }
  6352. /* toggle speaker-output according to the hp-jack state */
  6353. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6354. {
  6355. unsigned int present;
  6356. present = snd_hda_codec_read(codec, 0x14, 0,
  6357. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6358. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6359. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6360. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6361. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6362. }
  6363. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6364. unsigned int res)
  6365. {
  6366. if ((res >> 26) == ALC880_HP_EVENT)
  6367. alc883_acer_aspire_automute(codec);
  6368. }
  6369. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6370. /* HP Pin: output 0 (0x0c) */
  6371. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6372. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6373. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6374. /* Front Pin: output 0 (0x0c) */
  6375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6376. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6378. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6379. /* eanable EAPD on medion laptop */
  6380. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6381. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6382. /* enable unsolicited event */
  6383. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6384. { }
  6385. };
  6386. /*
  6387. * generic initialization of ADC, input mixers and output mixers
  6388. */
  6389. static struct hda_verb alc883_auto_init_verbs[] = {
  6390. /*
  6391. * Unmute ADC0-2 and set the default input to mic-in
  6392. */
  6393. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6394. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6395. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6396. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6397. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6398. * mixer widget
  6399. * Note: PASD motherboards uses the Line In 2 as the input for
  6400. * front panel mic (mic 2)
  6401. */
  6402. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6403. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6404. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6405. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6406. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6407. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6408. /*
  6409. * Set up output mixers (0x0c - 0x0f)
  6410. */
  6411. /* set vol=0 to output mixers */
  6412. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6413. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6414. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6415. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6416. /* set up input amps for analog loopback */
  6417. /* Amp Indices: DAC = 0, mixer = 1 */
  6418. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6419. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6420. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6421. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6422. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6423. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6424. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6425. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6426. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6427. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6428. /* FIXME: use matrix-type input source selection */
  6429. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6430. /* Input mixer1 */
  6431. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6432. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6433. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6434. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6435. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6436. /* Input mixer2 */
  6437. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6438. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6439. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6440. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6441. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6442. { }
  6443. };
  6444. /* capture mixer elements */
  6445. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6446. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6447. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6448. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6449. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6450. {
  6451. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6452. /* The multiple "Capture Source" controls confuse alsamixer
  6453. * So call somewhat different..
  6454. * FIXME: the controls appear in the "playback" view!
  6455. */
  6456. /* .name = "Capture Source", */
  6457. .name = "Input Source",
  6458. .count = 2,
  6459. .info = alc882_mux_enum_info,
  6460. .get = alc882_mux_enum_get,
  6461. .put = alc882_mux_enum_put,
  6462. },
  6463. { } /* end */
  6464. };
  6465. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6466. #define alc883_loopbacks alc880_loopbacks
  6467. #endif
  6468. /* pcm configuration: identiacal with ALC880 */
  6469. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6470. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6471. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6472. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6473. /*
  6474. * configuration and preset
  6475. */
  6476. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6477. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6478. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6479. [ALC883_3ST_6ch] = "3stack-6ch",
  6480. [ALC883_6ST_DIG] = "6stack-dig",
  6481. [ALC883_TARGA_DIG] = "targa-dig",
  6482. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6483. [ALC883_ACER] = "acer",
  6484. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6485. [ALC883_MEDION] = "medion",
  6486. [ALC883_MEDION_MD2] = "medion-md2",
  6487. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6488. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6489. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6490. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6491. [ALC883_HAIER_W66] = "haier-w66",
  6492. [ALC888_6ST_HP] = "6stack-hp",
  6493. [ALC888_3ST_HP] = "3stack-hp",
  6494. [ALC883_AUTO] = "auto",
  6495. };
  6496. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6497. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6498. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6499. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6500. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6501. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6502. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6503. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6504. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6505. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6506. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6507. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6508. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6509. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6510. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6511. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6512. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6513. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6514. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6515. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6516. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6517. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6518. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6519. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6520. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6521. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6522. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6523. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6524. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6525. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6526. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6527. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6528. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6529. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6530. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6531. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6532. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6533. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6534. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6535. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6536. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6537. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6538. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6539. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6540. {}
  6541. };
  6542. static struct alc_config_preset alc883_presets[] = {
  6543. [ALC883_3ST_2ch_DIG] = {
  6544. .mixers = { alc883_3ST_2ch_mixer },
  6545. .init_verbs = { alc883_init_verbs },
  6546. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6547. .dac_nids = alc883_dac_nids,
  6548. .dig_out_nid = ALC883_DIGOUT_NID,
  6549. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6550. .adc_nids = alc883_adc_nids,
  6551. .dig_in_nid = ALC883_DIGIN_NID,
  6552. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6553. .channel_mode = alc883_3ST_2ch_modes,
  6554. .input_mux = &alc883_capture_source,
  6555. },
  6556. [ALC883_3ST_6ch_DIG] = {
  6557. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6558. .init_verbs = { alc883_init_verbs },
  6559. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6560. .dac_nids = alc883_dac_nids,
  6561. .dig_out_nid = ALC883_DIGOUT_NID,
  6562. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6563. .adc_nids = alc883_adc_nids,
  6564. .dig_in_nid = ALC883_DIGIN_NID,
  6565. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6566. .channel_mode = alc883_3ST_6ch_modes,
  6567. .need_dac_fix = 1,
  6568. .input_mux = &alc883_capture_source,
  6569. },
  6570. [ALC883_3ST_6ch] = {
  6571. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6572. .init_verbs = { alc883_init_verbs },
  6573. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6574. .dac_nids = alc883_dac_nids,
  6575. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6576. .adc_nids = alc883_adc_nids,
  6577. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6578. .channel_mode = alc883_3ST_6ch_modes,
  6579. .need_dac_fix = 1,
  6580. .input_mux = &alc883_capture_source,
  6581. },
  6582. [ALC883_6ST_DIG] = {
  6583. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6584. .init_verbs = { alc883_init_verbs },
  6585. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6586. .dac_nids = alc883_dac_nids,
  6587. .dig_out_nid = ALC883_DIGOUT_NID,
  6588. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6589. .adc_nids = alc883_adc_nids,
  6590. .dig_in_nid = ALC883_DIGIN_NID,
  6591. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6592. .channel_mode = alc883_sixstack_modes,
  6593. .input_mux = &alc883_capture_source,
  6594. },
  6595. [ALC883_TARGA_DIG] = {
  6596. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6597. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6598. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6599. .dac_nids = alc883_dac_nids,
  6600. .dig_out_nid = ALC883_DIGOUT_NID,
  6601. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6602. .adc_nids = alc883_adc_nids,
  6603. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6604. .channel_mode = alc883_3ST_6ch_modes,
  6605. .need_dac_fix = 1,
  6606. .input_mux = &alc883_capture_source,
  6607. .unsol_event = alc883_tagra_unsol_event,
  6608. .init_hook = alc883_tagra_automute,
  6609. },
  6610. [ALC883_TARGA_2ch_DIG] = {
  6611. .mixers = { alc883_tagra_2ch_mixer},
  6612. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6613. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6614. .dac_nids = alc883_dac_nids,
  6615. .dig_out_nid = ALC883_DIGOUT_NID,
  6616. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6617. .adc_nids = alc883_adc_nids,
  6618. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6619. .channel_mode = alc883_3ST_2ch_modes,
  6620. .input_mux = &alc883_capture_source,
  6621. .unsol_event = alc883_tagra_unsol_event,
  6622. .init_hook = alc883_tagra_automute,
  6623. },
  6624. [ALC883_ACER] = {
  6625. .mixers = { alc883_base_mixer },
  6626. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6627. * and the headphone jack. Turn this on and rely on the
  6628. * standard mute methods whenever the user wants to turn
  6629. * these outputs off.
  6630. */
  6631. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6632. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6633. .dac_nids = alc883_dac_nids,
  6634. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6635. .adc_nids = alc883_adc_nids,
  6636. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6637. .channel_mode = alc883_3ST_2ch_modes,
  6638. .input_mux = &alc883_capture_source,
  6639. },
  6640. [ALC883_ACER_ASPIRE] = {
  6641. .mixers = { alc883_acer_aspire_mixer },
  6642. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6643. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6644. .dac_nids = alc883_dac_nids,
  6645. .dig_out_nid = ALC883_DIGOUT_NID,
  6646. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6647. .adc_nids = alc883_adc_nids,
  6648. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6649. .channel_mode = alc883_3ST_2ch_modes,
  6650. .input_mux = &alc883_capture_source,
  6651. .unsol_event = alc883_acer_aspire_unsol_event,
  6652. .init_hook = alc883_acer_aspire_automute,
  6653. },
  6654. [ALC883_MEDION] = {
  6655. .mixers = { alc883_fivestack_mixer,
  6656. alc883_chmode_mixer },
  6657. .init_verbs = { alc883_init_verbs,
  6658. alc883_medion_eapd_verbs },
  6659. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6660. .dac_nids = alc883_dac_nids,
  6661. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6662. .adc_nids = alc883_adc_nids,
  6663. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6664. .channel_mode = alc883_sixstack_modes,
  6665. .input_mux = &alc883_capture_source,
  6666. },
  6667. [ALC883_MEDION_MD2] = {
  6668. .mixers = { alc883_medion_md2_mixer},
  6669. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6670. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6671. .dac_nids = alc883_dac_nids,
  6672. .dig_out_nid = ALC883_DIGOUT_NID,
  6673. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6674. .adc_nids = alc883_adc_nids,
  6675. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6676. .channel_mode = alc883_3ST_2ch_modes,
  6677. .input_mux = &alc883_capture_source,
  6678. .unsol_event = alc883_medion_md2_unsol_event,
  6679. .init_hook = alc883_medion_md2_automute,
  6680. },
  6681. [ALC883_LAPTOP_EAPD] = {
  6682. .mixers = { alc883_base_mixer },
  6683. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6684. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6685. .dac_nids = alc883_dac_nids,
  6686. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6687. .adc_nids = alc883_adc_nids,
  6688. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6689. .channel_mode = alc883_3ST_2ch_modes,
  6690. .input_mux = &alc883_capture_source,
  6691. },
  6692. [ALC883_LENOVO_101E_2ch] = {
  6693. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6694. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6695. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6696. .dac_nids = alc883_dac_nids,
  6697. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6698. .adc_nids = alc883_adc_nids,
  6699. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6700. .channel_mode = alc883_3ST_2ch_modes,
  6701. .input_mux = &alc883_lenovo_101e_capture_source,
  6702. .unsol_event = alc883_lenovo_101e_unsol_event,
  6703. .init_hook = alc883_lenovo_101e_all_automute,
  6704. },
  6705. [ALC883_LENOVO_NB0763] = {
  6706. .mixers = { alc883_lenovo_nb0763_mixer },
  6707. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6708. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6709. .dac_nids = alc883_dac_nids,
  6710. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6711. .adc_nids = alc883_adc_nids,
  6712. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6713. .channel_mode = alc883_3ST_2ch_modes,
  6714. .need_dac_fix = 1,
  6715. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6716. .unsol_event = alc883_medion_md2_unsol_event,
  6717. .init_hook = alc883_medion_md2_automute,
  6718. },
  6719. [ALC888_LENOVO_MS7195_DIG] = {
  6720. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6721. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6722. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6723. .dac_nids = alc883_dac_nids,
  6724. .dig_out_nid = ALC883_DIGOUT_NID,
  6725. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6726. .adc_nids = alc883_adc_nids,
  6727. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6728. .channel_mode = alc883_3ST_6ch_modes,
  6729. .need_dac_fix = 1,
  6730. .input_mux = &alc883_capture_source,
  6731. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6732. .init_hook = alc888_lenovo_ms7195_front_automute,
  6733. },
  6734. [ALC883_HAIER_W66] = {
  6735. .mixers = { alc883_tagra_2ch_mixer},
  6736. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6737. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6738. .dac_nids = alc883_dac_nids,
  6739. .dig_out_nid = ALC883_DIGOUT_NID,
  6740. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6741. .adc_nids = alc883_adc_nids,
  6742. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6743. .channel_mode = alc883_3ST_2ch_modes,
  6744. .input_mux = &alc883_capture_source,
  6745. .unsol_event = alc883_haier_w66_unsol_event,
  6746. .init_hook = alc883_haier_w66_automute,
  6747. },
  6748. [ALC888_6ST_HP] = {
  6749. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6750. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6751. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6752. .dac_nids = alc883_dac_nids,
  6753. .dig_out_nid = ALC883_DIGOUT_NID,
  6754. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6755. .adc_nids = alc883_adc_nids,
  6756. .dig_in_nid = ALC883_DIGIN_NID,
  6757. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6758. .channel_mode = alc883_sixstack_modes,
  6759. .input_mux = &alc883_capture_source,
  6760. },
  6761. [ALC888_3ST_HP] = {
  6762. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6763. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6764. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6765. .dac_nids = alc883_dac_nids,
  6766. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6767. .adc_nids = alc883_adc_nids,
  6768. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6769. .channel_mode = alc888_3st_hp_modes,
  6770. .need_dac_fix = 1,
  6771. .input_mux = &alc883_capture_source,
  6772. },
  6773. };
  6774. /*
  6775. * BIOS auto configuration
  6776. */
  6777. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6778. hda_nid_t nid, int pin_type,
  6779. int dac_idx)
  6780. {
  6781. /* set as output */
  6782. struct alc_spec *spec = codec->spec;
  6783. int idx;
  6784. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6785. idx = 4;
  6786. else
  6787. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6788. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6789. pin_type);
  6790. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6791. AMP_OUT_UNMUTE);
  6792. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6793. }
  6794. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6795. {
  6796. struct alc_spec *spec = codec->spec;
  6797. int i;
  6798. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6799. for (i = 0; i <= HDA_SIDE; i++) {
  6800. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6801. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6802. if (nid)
  6803. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6804. i);
  6805. }
  6806. }
  6807. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6808. {
  6809. struct alc_spec *spec = codec->spec;
  6810. hda_nid_t pin;
  6811. pin = spec->autocfg.hp_pins[0];
  6812. if (pin) /* connect to front */
  6813. /* use dac 0 */
  6814. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6815. }
  6816. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6817. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6818. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6819. {
  6820. struct alc_spec *spec = codec->spec;
  6821. int i;
  6822. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6823. hda_nid_t nid = spec->autocfg.input_pins[i];
  6824. if (alc883_is_input_pin(nid)) {
  6825. snd_hda_codec_write(codec, nid, 0,
  6826. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6827. (i <= AUTO_PIN_FRONT_MIC ?
  6828. PIN_VREF80 : PIN_IN));
  6829. if (nid != ALC883_PIN_CD_NID)
  6830. snd_hda_codec_write(codec, nid, 0,
  6831. AC_VERB_SET_AMP_GAIN_MUTE,
  6832. AMP_OUT_MUTE);
  6833. }
  6834. }
  6835. }
  6836. /* almost identical with ALC880 parser... */
  6837. static int alc883_parse_auto_config(struct hda_codec *codec)
  6838. {
  6839. struct alc_spec *spec = codec->spec;
  6840. int err = alc880_parse_auto_config(codec);
  6841. if (err < 0)
  6842. return err;
  6843. else if (!err)
  6844. return 0; /* no config found */
  6845. err = alc_auto_add_mic_boost(codec);
  6846. if (err < 0)
  6847. return err;
  6848. /* hack - override the init verbs */
  6849. spec->init_verbs[0] = alc883_auto_init_verbs;
  6850. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6851. spec->num_mixers++;
  6852. return 1; /* config found */
  6853. }
  6854. /* additional initialization for auto-configuration model */
  6855. static void alc883_auto_init(struct hda_codec *codec)
  6856. {
  6857. alc883_auto_init_multi_out(codec);
  6858. alc883_auto_init_hp_out(codec);
  6859. alc883_auto_init_analog_input(codec);
  6860. }
  6861. static int patch_alc883(struct hda_codec *codec)
  6862. {
  6863. struct alc_spec *spec;
  6864. int err, board_config;
  6865. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6866. if (spec == NULL)
  6867. return -ENOMEM;
  6868. codec->spec = spec;
  6869. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6870. alc883_models,
  6871. alc883_cfg_tbl);
  6872. if (board_config < 0) {
  6873. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6874. "trying auto-probe from BIOS...\n");
  6875. board_config = ALC883_AUTO;
  6876. }
  6877. if (board_config == ALC883_AUTO) {
  6878. /* automatic parse from the BIOS config */
  6879. err = alc883_parse_auto_config(codec);
  6880. if (err < 0) {
  6881. alc_free(codec);
  6882. return err;
  6883. } else if (!err) {
  6884. printk(KERN_INFO
  6885. "hda_codec: Cannot set up configuration "
  6886. "from BIOS. Using base mode...\n");
  6887. board_config = ALC883_3ST_2ch_DIG;
  6888. }
  6889. }
  6890. if (board_config != ALC883_AUTO)
  6891. setup_preset(spec, &alc883_presets[board_config]);
  6892. spec->stream_name_analog = "ALC883 Analog";
  6893. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6894. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6895. spec->stream_name_digital = "ALC883 Digital";
  6896. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6897. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6898. if (!spec->adc_nids && spec->input_mux) {
  6899. spec->adc_nids = alc883_adc_nids;
  6900. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6901. }
  6902. codec->patch_ops = alc_patch_ops;
  6903. if (board_config == ALC883_AUTO)
  6904. spec->init_hook = alc883_auto_init;
  6905. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6906. if (!spec->loopback.amplist)
  6907. spec->loopback.amplist = alc883_loopbacks;
  6908. #endif
  6909. return 0;
  6910. }
  6911. /*
  6912. * ALC262 support
  6913. */
  6914. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6915. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6916. #define alc262_dac_nids alc260_dac_nids
  6917. #define alc262_adc_nids alc882_adc_nids
  6918. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6919. #define alc262_modes alc260_modes
  6920. #define alc262_capture_source alc882_capture_source
  6921. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6922. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6923. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6924. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6925. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6926. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6927. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6928. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6929. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6930. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6931. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6932. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6933. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6934. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6935. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6936. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6937. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6938. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6939. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6940. { } /* end */
  6941. };
  6942. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6943. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6944. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6945. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6946. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6947. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6948. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6949. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6950. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6951. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6952. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6953. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6954. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6955. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6956. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6957. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6958. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6959. { } /* end */
  6960. };
  6961. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6962. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6963. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6964. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6965. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6966. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6969. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6970. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6971. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6972. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6973. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6974. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6975. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6976. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6977. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6978. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6979. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6980. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6981. { } /* end */
  6982. };
  6983. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6984. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6985. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6986. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6987. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6988. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6989. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6990. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6991. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6992. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6993. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6994. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6995. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6996. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6997. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6998. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6999. { } /* end */
  7000. };
  7001. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7002. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7003. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7004. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7005. { } /* end */
  7006. };
  7007. /* bind hp and internal speaker mute (with plug check) */
  7008. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7009. struct snd_ctl_elem_value *ucontrol)
  7010. {
  7011. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7012. long *valp = ucontrol->value.integer.value;
  7013. int change;
  7014. /* change hp mute */
  7015. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7016. HDA_AMP_MUTE,
  7017. valp[0] ? 0 : HDA_AMP_MUTE);
  7018. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7019. HDA_AMP_MUTE,
  7020. valp[1] ? 0 : HDA_AMP_MUTE);
  7021. if (change) {
  7022. /* change speaker according to HP jack state */
  7023. struct alc_spec *spec = codec->spec;
  7024. unsigned int mute;
  7025. if (spec->jack_present)
  7026. mute = HDA_AMP_MUTE;
  7027. else
  7028. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7029. HDA_OUTPUT, 0);
  7030. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7031. HDA_AMP_MUTE, mute);
  7032. }
  7033. return change;
  7034. }
  7035. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7036. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7037. {
  7038. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7039. .name = "Master Playback Switch",
  7040. .info = snd_hda_mixer_amp_switch_info,
  7041. .get = snd_hda_mixer_amp_switch_get,
  7042. .put = alc262_sony_master_sw_put,
  7043. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7044. },
  7045. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7046. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7047. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7048. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7049. { } /* end */
  7050. };
  7051. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7052. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7053. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7054. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7055. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7056. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7057. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7058. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7059. { } /* end */
  7060. };
  7061. #define alc262_capture_mixer alc882_capture_mixer
  7062. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7063. /*
  7064. * generic initialization of ADC, input mixers and output mixers
  7065. */
  7066. static struct hda_verb alc262_init_verbs[] = {
  7067. /*
  7068. * Unmute ADC0-2 and set the default input to mic-in
  7069. */
  7070. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7071. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7072. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7074. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7075. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7076. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7077. * mixer widget
  7078. * Note: PASD motherboards uses the Line In 2 as the input for
  7079. * front panel mic (mic 2)
  7080. */
  7081. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7082. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7083. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7084. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7085. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7086. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7087. /*
  7088. * Set up output mixers (0x0c - 0x0e)
  7089. */
  7090. /* set vol=0 to output mixers */
  7091. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7092. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7093. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7094. /* set up input amps for analog loopback */
  7095. /* Amp Indices: DAC = 0, mixer = 1 */
  7096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7098. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7099. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7100. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7101. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7102. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7103. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7104. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7105. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7106. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7107. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7108. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7109. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7110. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7111. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7112. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7113. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7114. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7115. /* FIXME: use matrix-type input source selection */
  7116. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7117. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7118. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7119. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7120. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7121. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7122. /* Input mixer2 */
  7123. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7124. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7125. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7126. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7127. /* Input mixer3 */
  7128. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7129. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7130. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7131. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7132. { }
  7133. };
  7134. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7135. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7136. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7137. {}
  7138. };
  7139. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7140. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7141. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7142. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7143. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7144. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7145. {}
  7146. };
  7147. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7148. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7149. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7150. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7151. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7152. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7153. };
  7154. /* mute/unmute internal speaker according to the hp jack and mute state */
  7155. static void alc262_hippo_automute(struct hda_codec *codec)
  7156. {
  7157. struct alc_spec *spec = codec->spec;
  7158. unsigned int mute;
  7159. unsigned int present;
  7160. /* need to execute and sync at first */
  7161. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7162. present = snd_hda_codec_read(codec, 0x15, 0,
  7163. AC_VERB_GET_PIN_SENSE, 0);
  7164. spec->jack_present = (present & 0x80000000) != 0;
  7165. if (spec->jack_present) {
  7166. /* mute internal speaker */
  7167. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7168. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7169. } else {
  7170. /* unmute internal speaker if necessary */
  7171. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7172. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7173. HDA_AMP_MUTE, mute);
  7174. }
  7175. }
  7176. /* unsolicited event for HP jack sensing */
  7177. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7178. unsigned int res)
  7179. {
  7180. if ((res >> 26) != ALC880_HP_EVENT)
  7181. return;
  7182. alc262_hippo_automute(codec);
  7183. }
  7184. static void alc262_hippo1_automute(struct hda_codec *codec)
  7185. {
  7186. unsigned int mute;
  7187. unsigned int present;
  7188. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7189. present = snd_hda_codec_read(codec, 0x1b, 0,
  7190. AC_VERB_GET_PIN_SENSE, 0);
  7191. present = (present & 0x80000000) != 0;
  7192. if (present) {
  7193. /* mute internal speaker */
  7194. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7195. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7196. } else {
  7197. /* unmute internal speaker if necessary */
  7198. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7199. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7200. HDA_AMP_MUTE, mute);
  7201. }
  7202. }
  7203. /* unsolicited event for HP jack sensing */
  7204. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7205. unsigned int res)
  7206. {
  7207. if ((res >> 26) != ALC880_HP_EVENT)
  7208. return;
  7209. alc262_hippo1_automute(codec);
  7210. }
  7211. /*
  7212. * fujitsu model
  7213. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7214. */
  7215. #define ALC_HP_EVENT 0x37
  7216. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7217. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7218. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7219. {}
  7220. };
  7221. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7222. .num_items = 3,
  7223. .items = {
  7224. { "Mic", 0x0 },
  7225. { "Int Mic", 0x1 },
  7226. { "CD", 0x4 },
  7227. },
  7228. };
  7229. static struct hda_input_mux alc262_HP_capture_source = {
  7230. .num_items = 5,
  7231. .items = {
  7232. { "Mic", 0x0 },
  7233. { "Front Mic", 0x1 },
  7234. { "Line", 0x2 },
  7235. { "CD", 0x4 },
  7236. { "AUX IN", 0x6 },
  7237. },
  7238. };
  7239. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7240. .num_items = 4,
  7241. .items = {
  7242. { "Mic", 0x0 },
  7243. { "Front Mic", 0x2 },
  7244. { "Line", 0x1 },
  7245. { "CD", 0x4 },
  7246. },
  7247. };
  7248. /* mute/unmute internal speaker according to the hp jack and mute state */
  7249. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7250. {
  7251. struct alc_spec *spec = codec->spec;
  7252. unsigned int mute;
  7253. if (force || !spec->sense_updated) {
  7254. unsigned int present;
  7255. /* need to execute and sync at first */
  7256. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7257. present = snd_hda_codec_read(codec, 0x14, 0,
  7258. AC_VERB_GET_PIN_SENSE, 0);
  7259. spec->jack_present = (present & 0x80000000) != 0;
  7260. spec->sense_updated = 1;
  7261. }
  7262. if (spec->jack_present) {
  7263. /* mute internal speaker */
  7264. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7265. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7266. } else {
  7267. /* unmute internal speaker if necessary */
  7268. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7269. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7270. HDA_AMP_MUTE, mute);
  7271. }
  7272. }
  7273. /* unsolicited event for HP jack sensing */
  7274. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7275. unsigned int res)
  7276. {
  7277. if ((res >> 26) != ALC_HP_EVENT)
  7278. return;
  7279. alc262_fujitsu_automute(codec, 1);
  7280. }
  7281. /* bind volumes of both NID 0x0c and 0x0d */
  7282. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7283. .ops = &snd_hda_bind_vol,
  7284. .values = {
  7285. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7286. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7287. 0
  7288. },
  7289. };
  7290. /* bind hp and internal speaker mute (with plug check) */
  7291. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7292. struct snd_ctl_elem_value *ucontrol)
  7293. {
  7294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7295. long *valp = ucontrol->value.integer.value;
  7296. int change;
  7297. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7298. HDA_AMP_MUTE,
  7299. valp[0] ? 0 : HDA_AMP_MUTE);
  7300. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7301. HDA_AMP_MUTE,
  7302. valp[1] ? 0 : HDA_AMP_MUTE);
  7303. if (change)
  7304. alc262_fujitsu_automute(codec, 0);
  7305. return change;
  7306. }
  7307. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7308. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7309. {
  7310. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7311. .name = "Master Playback Switch",
  7312. .info = snd_hda_mixer_amp_switch_info,
  7313. .get = snd_hda_mixer_amp_switch_get,
  7314. .put = alc262_fujitsu_master_sw_put,
  7315. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7316. },
  7317. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7318. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7319. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7320. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7321. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7322. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7323. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7324. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7325. { } /* end */
  7326. };
  7327. /* additional init verbs for Benq laptops */
  7328. static struct hda_verb alc262_EAPD_verbs[] = {
  7329. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7330. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7331. {}
  7332. };
  7333. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7334. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7335. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7336. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7337. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7338. {}
  7339. };
  7340. /* add playback controls from the parsed DAC table */
  7341. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7342. const struct auto_pin_cfg *cfg)
  7343. {
  7344. hda_nid_t nid;
  7345. int err;
  7346. spec->multiout.num_dacs = 1; /* only use one dac */
  7347. spec->multiout.dac_nids = spec->private_dac_nids;
  7348. spec->multiout.dac_nids[0] = 2;
  7349. nid = cfg->line_out_pins[0];
  7350. if (nid) {
  7351. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7352. "Front Playback Volume",
  7353. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7354. if (err < 0)
  7355. return err;
  7356. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7357. "Front Playback Switch",
  7358. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7359. if (err < 0)
  7360. return err;
  7361. }
  7362. nid = cfg->speaker_pins[0];
  7363. if (nid) {
  7364. if (nid == 0x16) {
  7365. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7366. "Speaker Playback Volume",
  7367. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7368. HDA_OUTPUT));
  7369. if (err < 0)
  7370. return err;
  7371. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7372. "Speaker Playback Switch",
  7373. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7374. HDA_OUTPUT));
  7375. if (err < 0)
  7376. return err;
  7377. } else {
  7378. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7379. "Speaker Playback Switch",
  7380. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7381. HDA_OUTPUT));
  7382. if (err < 0)
  7383. return err;
  7384. }
  7385. }
  7386. nid = cfg->hp_pins[0];
  7387. if (nid) {
  7388. /* spec->multiout.hp_nid = 2; */
  7389. if (nid == 0x16) {
  7390. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7391. "Headphone Playback Volume",
  7392. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7393. HDA_OUTPUT));
  7394. if (err < 0)
  7395. return err;
  7396. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7397. "Headphone Playback Switch",
  7398. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7399. HDA_OUTPUT));
  7400. if (err < 0)
  7401. return err;
  7402. } else {
  7403. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7404. "Headphone Playback Switch",
  7405. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7406. HDA_OUTPUT));
  7407. if (err < 0)
  7408. return err;
  7409. }
  7410. }
  7411. return 0;
  7412. }
  7413. /* identical with ALC880 */
  7414. #define alc262_auto_create_analog_input_ctls \
  7415. alc880_auto_create_analog_input_ctls
  7416. /*
  7417. * generic initialization of ADC, input mixers and output mixers
  7418. */
  7419. static struct hda_verb alc262_volume_init_verbs[] = {
  7420. /*
  7421. * Unmute ADC0-2 and set the default input to mic-in
  7422. */
  7423. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7424. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7425. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7426. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7427. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7428. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7429. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7430. * mixer widget
  7431. * Note: PASD motherboards uses the Line In 2 as the input for
  7432. * front panel mic (mic 2)
  7433. */
  7434. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7435. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7436. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7437. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7438. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7439. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7440. /*
  7441. * Set up output mixers (0x0c - 0x0f)
  7442. */
  7443. /* set vol=0 to output mixers */
  7444. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7445. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7446. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7447. /* set up input amps for analog loopback */
  7448. /* Amp Indices: DAC = 0, mixer = 1 */
  7449. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7450. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7451. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7452. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7453. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7454. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7455. /* FIXME: use matrix-type input source selection */
  7456. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7457. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7458. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7459. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7460. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7461. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7462. /* Input mixer2 */
  7463. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7464. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7465. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7466. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7467. /* Input mixer3 */
  7468. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7469. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7470. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7471. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7472. { }
  7473. };
  7474. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7475. /*
  7476. * Unmute ADC0-2 and set the default input to mic-in
  7477. */
  7478. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7480. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7482. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7483. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7484. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7485. * mixer widget
  7486. * Note: PASD motherboards uses the Line In 2 as the input for
  7487. * front panel mic (mic 2)
  7488. */
  7489. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7490. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7491. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7492. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7493. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7494. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7495. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7496. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7497. /*
  7498. * Set up output mixers (0x0c - 0x0e)
  7499. */
  7500. /* set vol=0 to output mixers */
  7501. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7502. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7503. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7504. /* set up input amps for analog loopback */
  7505. /* Amp Indices: DAC = 0, mixer = 1 */
  7506. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7507. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7508. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7509. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7510. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7511. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7512. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7513. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7514. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7515. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7516. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7517. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7518. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7520. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7521. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7522. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7524. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7525. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7526. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7527. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7528. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7529. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7530. /* FIXME: use matrix-type input source selection */
  7531. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7532. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7533. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7534. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7535. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7536. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7537. /* Input mixer2 */
  7538. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7539. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7540. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7541. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7542. /* Input mixer3 */
  7543. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7544. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7545. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7546. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7547. { }
  7548. };
  7549. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7550. /*
  7551. * Unmute ADC0-2 and set the default input to mic-in
  7552. */
  7553. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7554. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7555. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7556. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7557. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7558. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7559. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7560. * mixer widget
  7561. * Note: PASD motherboards uses the Line In 2 as the input for front
  7562. * panel mic (mic 2)
  7563. */
  7564. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7565. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7566. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7567. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7568. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7569. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7570. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7571. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7572. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7573. /*
  7574. * Set up output mixers (0x0c - 0x0e)
  7575. */
  7576. /* set vol=0 to output mixers */
  7577. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7578. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7579. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7580. /* set up input amps for analog loopback */
  7581. /* Amp Indices: DAC = 0, mixer = 1 */
  7582. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7583. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7584. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7585. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7586. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7587. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7588. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7589. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7590. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7591. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7592. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7593. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7594. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7595. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7596. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7597. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7598. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7599. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7600. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7601. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7602. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7603. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7604. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7605. /* FIXME: use matrix-type input source selection */
  7606. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7607. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7608. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7609. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7610. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7611. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7612. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7613. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7614. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7615. /* Input mixer2 */
  7616. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7617. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7618. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7619. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7620. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7621. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7623. /* Input mixer3 */
  7624. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7625. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7626. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7629. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7630. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7631. { }
  7632. };
  7633. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7634. #define alc262_loopbacks alc880_loopbacks
  7635. #endif
  7636. /* pcm configuration: identiacal with ALC880 */
  7637. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7638. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7639. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7640. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7641. /*
  7642. * BIOS auto configuration
  7643. */
  7644. static int alc262_parse_auto_config(struct hda_codec *codec)
  7645. {
  7646. struct alc_spec *spec = codec->spec;
  7647. int err;
  7648. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7649. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7650. alc262_ignore);
  7651. if (err < 0)
  7652. return err;
  7653. if (!spec->autocfg.line_outs)
  7654. return 0; /* can't find valid BIOS pin config */
  7655. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7656. if (err < 0)
  7657. return err;
  7658. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7659. if (err < 0)
  7660. return err;
  7661. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7662. if (spec->autocfg.dig_out_pin)
  7663. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7664. if (spec->autocfg.dig_in_pin)
  7665. spec->dig_in_nid = ALC262_DIGIN_NID;
  7666. if (spec->kctl_alloc)
  7667. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7668. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7669. spec->num_mux_defs = 1;
  7670. spec->input_mux = &spec->private_imux;
  7671. err = alc_auto_add_mic_boost(codec);
  7672. if (err < 0)
  7673. return err;
  7674. return 1;
  7675. }
  7676. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7677. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7678. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7679. /* init callback for auto-configuration model -- overriding the default init */
  7680. static void alc262_auto_init(struct hda_codec *codec)
  7681. {
  7682. alc262_auto_init_multi_out(codec);
  7683. alc262_auto_init_hp_out(codec);
  7684. alc262_auto_init_analog_input(codec);
  7685. }
  7686. /*
  7687. * configuration and preset
  7688. */
  7689. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7690. [ALC262_BASIC] = "basic",
  7691. [ALC262_HIPPO] = "hippo",
  7692. [ALC262_HIPPO_1] = "hippo_1",
  7693. [ALC262_FUJITSU] = "fujitsu",
  7694. [ALC262_HP_BPC] = "hp-bpc",
  7695. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7696. [ALC262_BENQ_ED8] = "benq",
  7697. [ALC262_BENQ_T31] = "benq-t31",
  7698. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7699. [ALC262_AUTO] = "auto",
  7700. };
  7701. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7702. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7703. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7704. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7705. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7706. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7707. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7708. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7709. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7710. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7711. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7712. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7713. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7714. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7715. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7716. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7717. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7718. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7719. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7720. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7721. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7722. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7723. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7724. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7725. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7726. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7727. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7728. {}
  7729. };
  7730. static struct alc_config_preset alc262_presets[] = {
  7731. [ALC262_BASIC] = {
  7732. .mixers = { alc262_base_mixer },
  7733. .init_verbs = { alc262_init_verbs },
  7734. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7735. .dac_nids = alc262_dac_nids,
  7736. .hp_nid = 0x03,
  7737. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7738. .channel_mode = alc262_modes,
  7739. .input_mux = &alc262_capture_source,
  7740. },
  7741. [ALC262_HIPPO] = {
  7742. .mixers = { alc262_base_mixer },
  7743. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7744. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7745. .dac_nids = alc262_dac_nids,
  7746. .hp_nid = 0x03,
  7747. .dig_out_nid = ALC262_DIGOUT_NID,
  7748. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7749. .channel_mode = alc262_modes,
  7750. .input_mux = &alc262_capture_source,
  7751. .unsol_event = alc262_hippo_unsol_event,
  7752. .init_hook = alc262_hippo_automute,
  7753. },
  7754. [ALC262_HIPPO_1] = {
  7755. .mixers = { alc262_hippo1_mixer },
  7756. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7757. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7758. .dac_nids = alc262_dac_nids,
  7759. .hp_nid = 0x02,
  7760. .dig_out_nid = ALC262_DIGOUT_NID,
  7761. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7762. .channel_mode = alc262_modes,
  7763. .input_mux = &alc262_capture_source,
  7764. .unsol_event = alc262_hippo1_unsol_event,
  7765. .init_hook = alc262_hippo1_automute,
  7766. },
  7767. [ALC262_FUJITSU] = {
  7768. .mixers = { alc262_fujitsu_mixer },
  7769. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7770. alc262_fujitsu_unsol_verbs },
  7771. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7772. .dac_nids = alc262_dac_nids,
  7773. .hp_nid = 0x03,
  7774. .dig_out_nid = ALC262_DIGOUT_NID,
  7775. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7776. .channel_mode = alc262_modes,
  7777. .input_mux = &alc262_fujitsu_capture_source,
  7778. .unsol_event = alc262_fujitsu_unsol_event,
  7779. },
  7780. [ALC262_HP_BPC] = {
  7781. .mixers = { alc262_HP_BPC_mixer },
  7782. .init_verbs = { alc262_HP_BPC_init_verbs },
  7783. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7784. .dac_nids = alc262_dac_nids,
  7785. .hp_nid = 0x03,
  7786. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7787. .channel_mode = alc262_modes,
  7788. .input_mux = &alc262_HP_capture_source,
  7789. },
  7790. [ALC262_HP_BPC_D7000_WF] = {
  7791. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7792. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7793. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7794. .dac_nids = alc262_dac_nids,
  7795. .hp_nid = 0x03,
  7796. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7797. .channel_mode = alc262_modes,
  7798. .input_mux = &alc262_HP_D7000_capture_source,
  7799. },
  7800. [ALC262_HP_BPC_D7000_WL] = {
  7801. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7802. alc262_HP_BPC_WildWest_option_mixer },
  7803. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7804. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7805. .dac_nids = alc262_dac_nids,
  7806. .hp_nid = 0x03,
  7807. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7808. .channel_mode = alc262_modes,
  7809. .input_mux = &alc262_HP_D7000_capture_source,
  7810. },
  7811. [ALC262_BENQ_ED8] = {
  7812. .mixers = { alc262_base_mixer },
  7813. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7814. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7815. .dac_nids = alc262_dac_nids,
  7816. .hp_nid = 0x03,
  7817. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7818. .channel_mode = alc262_modes,
  7819. .input_mux = &alc262_capture_source,
  7820. },
  7821. [ALC262_SONY_ASSAMD] = {
  7822. .mixers = { alc262_sony_mixer },
  7823. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7824. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7825. .dac_nids = alc262_dac_nids,
  7826. .hp_nid = 0x02,
  7827. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7828. .channel_mode = alc262_modes,
  7829. .input_mux = &alc262_capture_source,
  7830. .unsol_event = alc262_hippo_unsol_event,
  7831. .init_hook = alc262_hippo_automute,
  7832. },
  7833. [ALC262_BENQ_T31] = {
  7834. .mixers = { alc262_benq_t31_mixer },
  7835. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7836. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7837. .dac_nids = alc262_dac_nids,
  7838. .hp_nid = 0x03,
  7839. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7840. .channel_mode = alc262_modes,
  7841. .input_mux = &alc262_capture_source,
  7842. .unsol_event = alc262_hippo_unsol_event,
  7843. .init_hook = alc262_hippo_automute,
  7844. },
  7845. };
  7846. static int patch_alc262(struct hda_codec *codec)
  7847. {
  7848. struct alc_spec *spec;
  7849. int board_config;
  7850. int err;
  7851. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7852. if (spec == NULL)
  7853. return -ENOMEM;
  7854. codec->spec = spec;
  7855. #if 0
  7856. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7857. * under-run
  7858. */
  7859. {
  7860. int tmp;
  7861. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7862. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7863. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7864. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7865. }
  7866. #endif
  7867. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7868. alc262_models,
  7869. alc262_cfg_tbl);
  7870. if (board_config < 0) {
  7871. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7872. "trying auto-probe from BIOS...\n");
  7873. board_config = ALC262_AUTO;
  7874. }
  7875. if (board_config == ALC262_AUTO) {
  7876. /* automatic parse from the BIOS config */
  7877. err = alc262_parse_auto_config(codec);
  7878. if (err < 0) {
  7879. alc_free(codec);
  7880. return err;
  7881. } else if (!err) {
  7882. printk(KERN_INFO
  7883. "hda_codec: Cannot set up configuration "
  7884. "from BIOS. Using base mode...\n");
  7885. board_config = ALC262_BASIC;
  7886. }
  7887. }
  7888. if (board_config != ALC262_AUTO)
  7889. setup_preset(spec, &alc262_presets[board_config]);
  7890. spec->stream_name_analog = "ALC262 Analog";
  7891. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7892. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7893. spec->stream_name_digital = "ALC262 Digital";
  7894. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7895. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7896. if (!spec->adc_nids && spec->input_mux) {
  7897. /* check whether NID 0x07 is valid */
  7898. unsigned int wcap = get_wcaps(codec, 0x07);
  7899. /* get type */
  7900. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7901. if (wcap != AC_WID_AUD_IN) {
  7902. spec->adc_nids = alc262_adc_nids_alt;
  7903. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7904. spec->mixers[spec->num_mixers] =
  7905. alc262_capture_alt_mixer;
  7906. spec->num_mixers++;
  7907. } else {
  7908. spec->adc_nids = alc262_adc_nids;
  7909. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7910. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7911. spec->num_mixers++;
  7912. }
  7913. }
  7914. codec->patch_ops = alc_patch_ops;
  7915. if (board_config == ALC262_AUTO)
  7916. spec->init_hook = alc262_auto_init;
  7917. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7918. if (!spec->loopback.amplist)
  7919. spec->loopback.amplist = alc262_loopbacks;
  7920. #endif
  7921. return 0;
  7922. }
  7923. /*
  7924. * ALC268 channel source setting (2 channel)
  7925. */
  7926. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7927. #define alc268_modes alc260_modes
  7928. static hda_nid_t alc268_dac_nids[2] = {
  7929. /* front, hp */
  7930. 0x02, 0x03
  7931. };
  7932. static hda_nid_t alc268_adc_nids[2] = {
  7933. /* ADC0-1 */
  7934. 0x08, 0x07
  7935. };
  7936. static hda_nid_t alc268_adc_nids_alt[1] = {
  7937. /* ADC0 */
  7938. 0x08
  7939. };
  7940. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7941. /* output mixer control */
  7942. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7943. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7944. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7945. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7946. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7947. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7948. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7949. { }
  7950. };
  7951. static struct hda_verb alc268_eapd_verbs[] = {
  7952. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7953. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7954. { }
  7955. };
  7956. /* Toshiba specific */
  7957. #define alc268_toshiba_automute alc262_hippo_automute
  7958. static struct hda_verb alc268_toshiba_verbs[] = {
  7959. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7960. { } /* end */
  7961. };
  7962. /* Acer specific */
  7963. /* bind volumes of both NID 0x02 and 0x03 */
  7964. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7965. .ops = &snd_hda_bind_vol,
  7966. .values = {
  7967. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7968. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7969. 0
  7970. },
  7971. };
  7972. /* mute/unmute internal speaker according to the hp jack and mute state */
  7973. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7974. {
  7975. struct alc_spec *spec = codec->spec;
  7976. unsigned int mute;
  7977. if (force || !spec->sense_updated) {
  7978. unsigned int present;
  7979. present = snd_hda_codec_read(codec, 0x14, 0,
  7980. AC_VERB_GET_PIN_SENSE, 0);
  7981. spec->jack_present = (present & 0x80000000) != 0;
  7982. spec->sense_updated = 1;
  7983. }
  7984. if (spec->jack_present)
  7985. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7986. else /* unmute internal speaker if necessary */
  7987. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7988. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7989. HDA_AMP_MUTE, mute);
  7990. }
  7991. /* bind hp and internal speaker mute (with plug check) */
  7992. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7993. struct snd_ctl_elem_value *ucontrol)
  7994. {
  7995. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7996. long *valp = ucontrol->value.integer.value;
  7997. int change;
  7998. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7999. HDA_AMP_MUTE,
  8000. valp[0] ? 0 : HDA_AMP_MUTE);
  8001. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8002. HDA_AMP_MUTE,
  8003. valp[1] ? 0 : HDA_AMP_MUTE);
  8004. if (change)
  8005. alc268_acer_automute(codec, 0);
  8006. return change;
  8007. }
  8008. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8009. /* output mixer control */
  8010. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8011. {
  8012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8013. .name = "Master Playback Switch",
  8014. .info = snd_hda_mixer_amp_switch_info,
  8015. .get = snd_hda_mixer_amp_switch_get,
  8016. .put = alc268_acer_master_sw_put,
  8017. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8018. },
  8019. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8020. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8021. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8022. { }
  8023. };
  8024. static struct hda_verb alc268_acer_verbs[] = {
  8025. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8026. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8027. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8028. { }
  8029. };
  8030. /* unsolicited event for HP jack sensing */
  8031. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8032. unsigned int res)
  8033. {
  8034. if ((res >> 26) != ALC880_HP_EVENT)
  8035. return;
  8036. alc268_toshiba_automute(codec);
  8037. }
  8038. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8039. unsigned int res)
  8040. {
  8041. if ((res >> 26) != ALC880_HP_EVENT)
  8042. return;
  8043. alc268_acer_automute(codec, 1);
  8044. }
  8045. static void alc268_acer_init_hook(struct hda_codec *codec)
  8046. {
  8047. alc268_acer_automute(codec, 1);
  8048. }
  8049. /*
  8050. * generic initialization of ADC, input mixers and output mixers
  8051. */
  8052. static struct hda_verb alc268_base_init_verbs[] = {
  8053. /* Unmute DAC0-1 and set vol = 0 */
  8054. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8055. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8056. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8057. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8058. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8059. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8060. /*
  8061. * Set up output mixers (0x0c - 0x0e)
  8062. */
  8063. /* set vol=0 to output mixers */
  8064. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8065. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8066. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8067. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8068. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8069. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8071. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8072. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8073. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8074. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8075. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8076. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8077. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8078. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8079. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8080. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8081. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8082. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8083. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8084. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8085. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8086. /* FIXME: use matrix-type input source selection */
  8087. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  8088. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8089. /* Input mixer2 */
  8090. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8091. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8092. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8093. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8094. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8095. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8096. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8097. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8098. { }
  8099. };
  8100. /*
  8101. * generic initialization of ADC, input mixers and output mixers
  8102. */
  8103. static struct hda_verb alc268_volume_init_verbs[] = {
  8104. /* set output DAC */
  8105. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8106. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8107. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8108. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8109. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8110. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8111. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8112. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8113. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8114. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8115. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8116. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8117. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8118. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8119. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8120. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8121. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8122. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8123. /* set PCBEEP vol = 0 */
  8124. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8125. { }
  8126. };
  8127. #define alc268_mux_enum_info alc_mux_enum_info
  8128. #define alc268_mux_enum_get alc_mux_enum_get
  8129. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8130. struct snd_ctl_elem_value *ucontrol)
  8131. {
  8132. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8133. struct alc_spec *spec = codec->spec;
  8134. const struct hda_input_mux *imux = spec->input_mux;
  8135. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8136. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8137. hda_nid_t nid = capture_mixers[adc_idx];
  8138. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8139. unsigned int i, idx;
  8140. idx = ucontrol->value.enumerated.item[0];
  8141. if (idx >= imux->num_items)
  8142. idx = imux->num_items - 1;
  8143. if (*cur_val == idx)
  8144. return 0;
  8145. for (i = 0; i < imux->num_items; i++) {
  8146. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8147. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8148. imux->items[i].index,
  8149. HDA_AMP_MUTE, v);
  8150. snd_hda_codec_write_cache(codec, nid, 0,
  8151. AC_VERB_SET_CONNECT_SEL,
  8152. idx );
  8153. }
  8154. *cur_val = idx;
  8155. return 1;
  8156. }
  8157. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8158. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8159. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8160. {
  8161. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8162. /* The multiple "Capture Source" controls confuse alsamixer
  8163. * So call somewhat different..
  8164. * FIXME: the controls appear in the "playback" view!
  8165. */
  8166. /* .name = "Capture Source", */
  8167. .name = "Input Source",
  8168. .count = 1,
  8169. .info = alc268_mux_enum_info,
  8170. .get = alc268_mux_enum_get,
  8171. .put = alc268_mux_enum_put,
  8172. },
  8173. { } /* end */
  8174. };
  8175. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8176. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8177. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8178. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8179. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8180. {
  8181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8182. /* The multiple "Capture Source" controls confuse alsamixer
  8183. * So call somewhat different..
  8184. * FIXME: the controls appear in the "playback" view!
  8185. */
  8186. /* .name = "Capture Source", */
  8187. .name = "Input Source",
  8188. .count = 2,
  8189. .info = alc268_mux_enum_info,
  8190. .get = alc268_mux_enum_get,
  8191. .put = alc268_mux_enum_put,
  8192. },
  8193. { } /* end */
  8194. };
  8195. static struct hda_input_mux alc268_capture_source = {
  8196. .num_items = 4,
  8197. .items = {
  8198. { "Mic", 0x0 },
  8199. { "Front Mic", 0x1 },
  8200. { "Line", 0x2 },
  8201. { "CD", 0x3 },
  8202. },
  8203. };
  8204. /* create input playback/capture controls for the given pin */
  8205. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8206. const char *ctlname, int idx)
  8207. {
  8208. char name[32];
  8209. int err;
  8210. sprintf(name, "%s Playback Volume", ctlname);
  8211. if (nid == 0x14) {
  8212. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8213. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8214. HDA_OUTPUT));
  8215. if (err < 0)
  8216. return err;
  8217. } else if (nid == 0x15) {
  8218. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8219. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8220. HDA_OUTPUT));
  8221. if (err < 0)
  8222. return err;
  8223. } else
  8224. return -1;
  8225. sprintf(name, "%s Playback Switch", ctlname);
  8226. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8227. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8228. if (err < 0)
  8229. return err;
  8230. return 0;
  8231. }
  8232. /* add playback controls from the parsed DAC table */
  8233. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8234. const struct auto_pin_cfg *cfg)
  8235. {
  8236. hda_nid_t nid;
  8237. int err;
  8238. spec->multiout.num_dacs = 2; /* only use one dac */
  8239. spec->multiout.dac_nids = spec->private_dac_nids;
  8240. spec->multiout.dac_nids[0] = 2;
  8241. spec->multiout.dac_nids[1] = 3;
  8242. nid = cfg->line_out_pins[0];
  8243. if (nid)
  8244. alc268_new_analog_output(spec, nid, "Front", 0);
  8245. nid = cfg->speaker_pins[0];
  8246. if (nid == 0x1d) {
  8247. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8248. "Speaker Playback Volume",
  8249. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8250. if (err < 0)
  8251. return err;
  8252. }
  8253. nid = cfg->hp_pins[0];
  8254. if (nid)
  8255. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8256. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8257. if (nid == 0x16) {
  8258. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8259. "Mono Playback Switch",
  8260. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8261. if (err < 0)
  8262. return err;
  8263. }
  8264. return 0;
  8265. }
  8266. /* create playback/capture controls for input pins */
  8267. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8268. const struct auto_pin_cfg *cfg)
  8269. {
  8270. struct hda_input_mux *imux = &spec->private_imux;
  8271. int i, idx1;
  8272. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8273. switch(cfg->input_pins[i]) {
  8274. case 0x18:
  8275. idx1 = 0; /* Mic 1 */
  8276. break;
  8277. case 0x19:
  8278. idx1 = 1; /* Mic 2 */
  8279. break;
  8280. case 0x1a:
  8281. idx1 = 2; /* Line In */
  8282. break;
  8283. case 0x1c:
  8284. idx1 = 3; /* CD */
  8285. break;
  8286. default:
  8287. continue;
  8288. }
  8289. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8290. imux->items[imux->num_items].index = idx1;
  8291. imux->num_items++;
  8292. }
  8293. return 0;
  8294. }
  8295. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8296. {
  8297. struct alc_spec *spec = codec->spec;
  8298. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8299. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8300. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8301. unsigned int dac_vol1, dac_vol2;
  8302. if (speaker_nid) {
  8303. snd_hda_codec_write(codec, speaker_nid, 0,
  8304. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8305. snd_hda_codec_write(codec, 0x0f, 0,
  8306. AC_VERB_SET_AMP_GAIN_MUTE,
  8307. AMP_IN_UNMUTE(1));
  8308. snd_hda_codec_write(codec, 0x10, 0,
  8309. AC_VERB_SET_AMP_GAIN_MUTE,
  8310. AMP_IN_UNMUTE(1));
  8311. } else {
  8312. snd_hda_codec_write(codec, 0x0f, 0,
  8313. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8314. snd_hda_codec_write(codec, 0x10, 0,
  8315. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8316. }
  8317. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8318. if (line_nid == 0x14)
  8319. dac_vol2 = AMP_OUT_ZERO;
  8320. else if (line_nid == 0x15)
  8321. dac_vol1 = AMP_OUT_ZERO;
  8322. if (hp_nid == 0x14)
  8323. dac_vol2 = AMP_OUT_ZERO;
  8324. else if (hp_nid == 0x15)
  8325. dac_vol1 = AMP_OUT_ZERO;
  8326. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8327. spec->autocfg.line_out_pins[1] != 0x16 ||
  8328. spec->autocfg.line_out_pins[2] != 0x16)
  8329. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8330. snd_hda_codec_write(codec, 0x02, 0,
  8331. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8332. snd_hda_codec_write(codec, 0x03, 0,
  8333. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8334. }
  8335. /* pcm configuration: identiacal with ALC880 */
  8336. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8337. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8338. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8339. /*
  8340. * BIOS auto configuration
  8341. */
  8342. static int alc268_parse_auto_config(struct hda_codec *codec)
  8343. {
  8344. struct alc_spec *spec = codec->spec;
  8345. int err;
  8346. static hda_nid_t alc268_ignore[] = { 0 };
  8347. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8348. alc268_ignore);
  8349. if (err < 0)
  8350. return err;
  8351. if (!spec->autocfg.line_outs)
  8352. return 0; /* can't find valid BIOS pin config */
  8353. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8354. if (err < 0)
  8355. return err;
  8356. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8357. if (err < 0)
  8358. return err;
  8359. spec->multiout.max_channels = 2;
  8360. /* digital only support output */
  8361. if (spec->autocfg.dig_out_pin)
  8362. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8363. if (spec->kctl_alloc)
  8364. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8365. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8366. spec->num_mux_defs = 1;
  8367. spec->input_mux = &spec->private_imux;
  8368. err = alc_auto_add_mic_boost(codec);
  8369. if (err < 0)
  8370. return err;
  8371. return 1;
  8372. }
  8373. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8374. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8375. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8376. /* init callback for auto-configuration model -- overriding the default init */
  8377. static void alc268_auto_init(struct hda_codec *codec)
  8378. {
  8379. alc268_auto_init_multi_out(codec);
  8380. alc268_auto_init_hp_out(codec);
  8381. alc268_auto_init_mono_speaker_out(codec);
  8382. alc268_auto_init_analog_input(codec);
  8383. }
  8384. /*
  8385. * configuration and preset
  8386. */
  8387. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8388. [ALC268_3ST] = "3stack",
  8389. [ALC268_TOSHIBA] = "toshiba",
  8390. [ALC268_ACER] = "acer",
  8391. [ALC268_AUTO] = "auto",
  8392. };
  8393. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8394. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8395. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8396. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8397. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8398. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8399. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8400. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8401. {}
  8402. };
  8403. static struct alc_config_preset alc268_presets[] = {
  8404. [ALC268_3ST] = {
  8405. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8406. .init_verbs = { alc268_base_init_verbs },
  8407. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8408. .dac_nids = alc268_dac_nids,
  8409. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8410. .adc_nids = alc268_adc_nids_alt,
  8411. .hp_nid = 0x03,
  8412. .dig_out_nid = ALC268_DIGOUT_NID,
  8413. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8414. .channel_mode = alc268_modes,
  8415. .input_mux = &alc268_capture_source,
  8416. },
  8417. [ALC268_TOSHIBA] = {
  8418. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8419. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8420. alc268_toshiba_verbs },
  8421. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8422. .dac_nids = alc268_dac_nids,
  8423. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8424. .adc_nids = alc268_adc_nids_alt,
  8425. .hp_nid = 0x03,
  8426. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8427. .channel_mode = alc268_modes,
  8428. .input_mux = &alc268_capture_source,
  8429. .unsol_event = alc268_toshiba_unsol_event,
  8430. .init_hook = alc268_toshiba_automute,
  8431. },
  8432. [ALC268_ACER] = {
  8433. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8434. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8435. alc268_acer_verbs },
  8436. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8437. .dac_nids = alc268_dac_nids,
  8438. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8439. .adc_nids = alc268_adc_nids_alt,
  8440. .hp_nid = 0x02,
  8441. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8442. .channel_mode = alc268_modes,
  8443. .input_mux = &alc268_capture_source,
  8444. .unsol_event = alc268_acer_unsol_event,
  8445. .init_hook = alc268_acer_init_hook,
  8446. },
  8447. };
  8448. static int patch_alc268(struct hda_codec *codec)
  8449. {
  8450. struct alc_spec *spec;
  8451. int board_config;
  8452. int err;
  8453. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8454. if (spec == NULL)
  8455. return -ENOMEM;
  8456. codec->spec = spec;
  8457. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8458. alc268_models,
  8459. alc268_cfg_tbl);
  8460. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8461. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8462. "trying auto-probe from BIOS...\n");
  8463. board_config = ALC268_AUTO;
  8464. }
  8465. if (board_config == ALC268_AUTO) {
  8466. /* automatic parse from the BIOS config */
  8467. err = alc268_parse_auto_config(codec);
  8468. if (err < 0) {
  8469. alc_free(codec);
  8470. return err;
  8471. } else if (!err) {
  8472. printk(KERN_INFO
  8473. "hda_codec: Cannot set up configuration "
  8474. "from BIOS. Using base mode...\n");
  8475. board_config = ALC268_3ST;
  8476. }
  8477. }
  8478. if (board_config != ALC268_AUTO)
  8479. setup_preset(spec, &alc268_presets[board_config]);
  8480. spec->stream_name_analog = "ALC268 Analog";
  8481. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8482. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8483. spec->stream_name_digital = "ALC268 Digital";
  8484. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8485. if (board_config == ALC268_AUTO) {
  8486. if (!spec->adc_nids && spec->input_mux) {
  8487. /* check whether NID 0x07 is valid */
  8488. unsigned int wcap = get_wcaps(codec, 0x07);
  8489. /* get type */
  8490. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8491. if (wcap != AC_WID_AUD_IN) {
  8492. spec->adc_nids = alc268_adc_nids_alt;
  8493. spec->num_adc_nids =
  8494. ARRAY_SIZE(alc268_adc_nids_alt);
  8495. spec->mixers[spec->num_mixers] =
  8496. alc268_capture_alt_mixer;
  8497. spec->num_mixers++;
  8498. } else {
  8499. spec->adc_nids = alc268_adc_nids;
  8500. spec->num_adc_nids =
  8501. ARRAY_SIZE(alc268_adc_nids);
  8502. spec->mixers[spec->num_mixers] =
  8503. alc268_capture_mixer;
  8504. spec->num_mixers++;
  8505. }
  8506. }
  8507. }
  8508. codec->patch_ops = alc_patch_ops;
  8509. if (board_config == ALC268_AUTO)
  8510. spec->init_hook = alc268_auto_init;
  8511. return 0;
  8512. }
  8513. /*
  8514. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8515. */
  8516. /*
  8517. * set the path ways for 2 channel output
  8518. * need to set the codec line out and mic 1 pin widgets to inputs
  8519. */
  8520. static struct hda_verb alc861_threestack_ch2_init[] = {
  8521. /* set pin widget 1Ah (line in) for input */
  8522. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8523. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8524. * the vref
  8525. */
  8526. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8527. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8528. #if 0
  8529. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8530. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8531. #endif
  8532. { } /* end */
  8533. };
  8534. /*
  8535. * 6ch mode
  8536. * need to set the codec line out and mic 1 pin widgets to outputs
  8537. */
  8538. static struct hda_verb alc861_threestack_ch6_init[] = {
  8539. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8540. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8541. /* set pin widget 18h (mic1) for output (CLFE)*/
  8542. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8543. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8544. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8545. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8546. #if 0
  8547. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8548. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8549. #endif
  8550. { } /* end */
  8551. };
  8552. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8553. { 2, alc861_threestack_ch2_init },
  8554. { 6, alc861_threestack_ch6_init },
  8555. };
  8556. /* Set mic1 as input and unmute the mixer */
  8557. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8558. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8559. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8560. { } /* end */
  8561. };
  8562. /* Set mic1 as output and mute mixer */
  8563. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8564. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8565. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8566. { } /* end */
  8567. };
  8568. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8569. { 2, alc861_uniwill_m31_ch2_init },
  8570. { 4, alc861_uniwill_m31_ch4_init },
  8571. };
  8572. /* Set mic1 and line-in as input and unmute the mixer */
  8573. static struct hda_verb alc861_asus_ch2_init[] = {
  8574. /* set pin widget 1Ah (line in) for input */
  8575. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8576. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8577. * the vref
  8578. */
  8579. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8580. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8581. #if 0
  8582. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8583. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8584. #endif
  8585. { } /* end */
  8586. };
  8587. /* Set mic1 nad line-in as output and mute mixer */
  8588. static struct hda_verb alc861_asus_ch6_init[] = {
  8589. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8590. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8591. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8592. /* set pin widget 18h (mic1) for output (CLFE)*/
  8593. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8594. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8595. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8596. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8597. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8598. #if 0
  8599. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8600. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8601. #endif
  8602. { } /* end */
  8603. };
  8604. static struct hda_channel_mode alc861_asus_modes[2] = {
  8605. { 2, alc861_asus_ch2_init },
  8606. { 6, alc861_asus_ch6_init },
  8607. };
  8608. /* patch-ALC861 */
  8609. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8610. /* output mixer control */
  8611. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8612. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8613. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8614. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8615. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8616. /*Input mixer control */
  8617. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8618. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8619. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8620. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8621. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8622. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8623. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8624. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8625. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8626. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8627. /* Capture mixer control */
  8628. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8629. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8630. {
  8631. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8632. .name = "Capture Source",
  8633. .count = 1,
  8634. .info = alc_mux_enum_info,
  8635. .get = alc_mux_enum_get,
  8636. .put = alc_mux_enum_put,
  8637. },
  8638. { } /* end */
  8639. };
  8640. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8641. /* output mixer control */
  8642. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8643. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8644. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8645. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8646. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8647. /* Input mixer control */
  8648. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8649. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8650. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8651. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8652. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8653. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8654. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8655. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8656. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8657. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8658. /* Capture mixer control */
  8659. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8660. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8661. {
  8662. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8663. .name = "Capture Source",
  8664. .count = 1,
  8665. .info = alc_mux_enum_info,
  8666. .get = alc_mux_enum_get,
  8667. .put = alc_mux_enum_put,
  8668. },
  8669. {
  8670. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8671. .name = "Channel Mode",
  8672. .info = alc_ch_mode_info,
  8673. .get = alc_ch_mode_get,
  8674. .put = alc_ch_mode_put,
  8675. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8676. },
  8677. { } /* end */
  8678. };
  8679. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8680. /* output mixer control */
  8681. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8682. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8683. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8684. /*Capture mixer control */
  8685. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8686. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8687. {
  8688. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8689. .name = "Capture Source",
  8690. .count = 1,
  8691. .info = alc_mux_enum_info,
  8692. .get = alc_mux_enum_get,
  8693. .put = alc_mux_enum_put,
  8694. },
  8695. { } /* end */
  8696. };
  8697. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8698. /* output mixer control */
  8699. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8700. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8701. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8702. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8703. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8704. /* Input mixer control */
  8705. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8706. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8707. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8708. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8709. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8710. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8711. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8712. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8713. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8714. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8715. /* Capture mixer control */
  8716. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8717. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8718. {
  8719. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8720. .name = "Capture Source",
  8721. .count = 1,
  8722. .info = alc_mux_enum_info,
  8723. .get = alc_mux_enum_get,
  8724. .put = alc_mux_enum_put,
  8725. },
  8726. {
  8727. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8728. .name = "Channel Mode",
  8729. .info = alc_ch_mode_info,
  8730. .get = alc_ch_mode_get,
  8731. .put = alc_ch_mode_put,
  8732. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8733. },
  8734. { } /* end */
  8735. };
  8736. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8737. /* output mixer control */
  8738. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8739. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8740. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8741. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8742. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8743. /* Input mixer control */
  8744. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8745. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8746. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8747. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8748. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8749. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8750. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8751. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8752. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8753. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8754. /* Capture mixer control */
  8755. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8756. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8757. {
  8758. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8759. .name = "Capture Source",
  8760. .count = 1,
  8761. .info = alc_mux_enum_info,
  8762. .get = alc_mux_enum_get,
  8763. .put = alc_mux_enum_put,
  8764. },
  8765. {
  8766. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8767. .name = "Channel Mode",
  8768. .info = alc_ch_mode_info,
  8769. .get = alc_ch_mode_get,
  8770. .put = alc_ch_mode_put,
  8771. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8772. },
  8773. { }
  8774. };
  8775. /* additional mixer */
  8776. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8777. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8778. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8779. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8780. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8781. { }
  8782. };
  8783. /*
  8784. * generic initialization of ADC, input mixers and output mixers
  8785. */
  8786. static struct hda_verb alc861_base_init_verbs[] = {
  8787. /*
  8788. * Unmute ADC0 and set the default input to mic-in
  8789. */
  8790. /* port-A for surround (rear panel) */
  8791. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8792. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8793. /* port-B for mic-in (rear panel) with vref */
  8794. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8795. /* port-C for line-in (rear panel) */
  8796. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8797. /* port-D for Front */
  8798. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8799. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8800. /* port-E for HP out (front panel) */
  8801. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8802. /* route front PCM to HP */
  8803. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8804. /* port-F for mic-in (front panel) with vref */
  8805. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8806. /* port-G for CLFE (rear panel) */
  8807. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8808. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8809. /* port-H for side (rear panel) */
  8810. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8811. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8812. /* CD-in */
  8813. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8814. /* route front mic to ADC1*/
  8815. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8816. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8817. /* Unmute DAC0~3 & spdif out*/
  8818. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8819. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8820. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8821. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8822. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8823. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8824. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8825. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8826. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8827. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8828. /* Unmute Stereo Mixer 15 */
  8829. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8830. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8831. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8832. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8833. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8834. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8835. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8836. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8837. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8838. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8839. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8840. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8841. /* hp used DAC 3 (Front) */
  8842. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8843. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8844. { }
  8845. };
  8846. static struct hda_verb alc861_threestack_init_verbs[] = {
  8847. /*
  8848. * Unmute ADC0 and set the default input to mic-in
  8849. */
  8850. /* port-A for surround (rear panel) */
  8851. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8852. /* port-B for mic-in (rear panel) with vref */
  8853. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8854. /* port-C for line-in (rear panel) */
  8855. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8856. /* port-D for Front */
  8857. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8858. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8859. /* port-E for HP out (front panel) */
  8860. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8861. /* route front PCM to HP */
  8862. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8863. /* port-F for mic-in (front panel) with vref */
  8864. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8865. /* port-G for CLFE (rear panel) */
  8866. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8867. /* port-H for side (rear panel) */
  8868. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8869. /* CD-in */
  8870. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8871. /* route front mic to ADC1*/
  8872. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8873. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8874. /* Unmute DAC0~3 & spdif out*/
  8875. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8876. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8877. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8878. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8879. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8880. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8881. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8882. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8883. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8884. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8885. /* Unmute Stereo Mixer 15 */
  8886. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8887. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8888. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8889. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8890. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8891. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8892. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8893. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8894. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8895. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8896. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8897. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8898. /* hp used DAC 3 (Front) */
  8899. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8900. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8901. { }
  8902. };
  8903. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8904. /*
  8905. * Unmute ADC0 and set the default input to mic-in
  8906. */
  8907. /* port-A for surround (rear panel) */
  8908. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8909. /* port-B for mic-in (rear panel) with vref */
  8910. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8911. /* port-C for line-in (rear panel) */
  8912. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8913. /* port-D for Front */
  8914. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8915. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8916. /* port-E for HP out (front panel) */
  8917. /* this has to be set to VREF80 */
  8918. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8919. /* route front PCM to HP */
  8920. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8921. /* port-F for mic-in (front panel) with vref */
  8922. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8923. /* port-G for CLFE (rear panel) */
  8924. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8925. /* port-H for side (rear panel) */
  8926. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8927. /* CD-in */
  8928. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8929. /* route front mic to ADC1*/
  8930. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8931. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8932. /* Unmute DAC0~3 & spdif out*/
  8933. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8934. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8935. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8936. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8937. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8938. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8939. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8940. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8941. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8942. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8943. /* Unmute Stereo Mixer 15 */
  8944. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8945. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8946. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8947. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8948. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8949. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8950. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8951. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8952. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8953. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8954. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8955. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8956. /* hp used DAC 3 (Front) */
  8957. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8958. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8959. { }
  8960. };
  8961. static struct hda_verb alc861_asus_init_verbs[] = {
  8962. /*
  8963. * Unmute ADC0 and set the default input to mic-in
  8964. */
  8965. /* port-A for surround (rear panel)
  8966. * according to codec#0 this is the HP jack
  8967. */
  8968. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8969. /* route front PCM to HP */
  8970. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8971. /* port-B for mic-in (rear panel) with vref */
  8972. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8973. /* port-C for line-in (rear panel) */
  8974. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8975. /* port-D for Front */
  8976. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8977. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8978. /* port-E for HP out (front panel) */
  8979. /* this has to be set to VREF80 */
  8980. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8981. /* route front PCM to HP */
  8982. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8983. /* port-F for mic-in (front panel) with vref */
  8984. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8985. /* port-G for CLFE (rear panel) */
  8986. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8987. /* port-H for side (rear panel) */
  8988. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8989. /* CD-in */
  8990. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8991. /* route front mic to ADC1*/
  8992. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8993. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8994. /* Unmute DAC0~3 & spdif out*/
  8995. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8996. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8997. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8998. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8999. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9000. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9001. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9002. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9003. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9004. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9005. /* Unmute Stereo Mixer 15 */
  9006. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9007. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9008. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9009. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9010. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9011. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9012. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9013. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9014. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9015. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9016. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9017. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9018. /* hp used DAC 3 (Front) */
  9019. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9020. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9021. { }
  9022. };
  9023. /* additional init verbs for ASUS laptops */
  9024. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9025. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9026. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9027. { }
  9028. };
  9029. /*
  9030. * generic initialization of ADC, input mixers and output mixers
  9031. */
  9032. static struct hda_verb alc861_auto_init_verbs[] = {
  9033. /*
  9034. * Unmute ADC0 and set the default input to mic-in
  9035. */
  9036. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9037. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9038. /* Unmute DAC0~3 & spdif out*/
  9039. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9040. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9041. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9042. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9043. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9044. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9045. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9046. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9047. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9048. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9049. /* Unmute Stereo Mixer 15 */
  9050. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9051. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9052. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9053. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9054. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9055. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9056. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9057. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9058. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9059. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9060. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9061. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9062. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9063. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9064. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9065. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9066. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9067. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9068. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9069. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9070. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9071. { }
  9072. };
  9073. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9074. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9075. { }
  9076. };
  9077. /* toggle speaker-output according to the hp-jack state */
  9078. static void alc861_toshiba_automute(struct hda_codec *codec)
  9079. {
  9080. unsigned int present;
  9081. present = snd_hda_codec_read(codec, 0x0f, 0,
  9082. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9083. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9084. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9085. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9086. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9087. }
  9088. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9089. unsigned int res)
  9090. {
  9091. if ((res >> 26) == ALC880_HP_EVENT)
  9092. alc861_toshiba_automute(codec);
  9093. }
  9094. /* pcm configuration: identiacal with ALC880 */
  9095. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9096. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9097. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9098. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9099. #define ALC861_DIGOUT_NID 0x07
  9100. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9101. { 8, NULL }
  9102. };
  9103. static hda_nid_t alc861_dac_nids[4] = {
  9104. /* front, surround, clfe, side */
  9105. 0x03, 0x06, 0x05, 0x04
  9106. };
  9107. static hda_nid_t alc660_dac_nids[3] = {
  9108. /* front, clfe, surround */
  9109. 0x03, 0x05, 0x06
  9110. };
  9111. static hda_nid_t alc861_adc_nids[1] = {
  9112. /* ADC0-2 */
  9113. 0x08,
  9114. };
  9115. static struct hda_input_mux alc861_capture_source = {
  9116. .num_items = 5,
  9117. .items = {
  9118. { "Mic", 0x0 },
  9119. { "Front Mic", 0x3 },
  9120. { "Line", 0x1 },
  9121. { "CD", 0x4 },
  9122. { "Mixer", 0x5 },
  9123. },
  9124. };
  9125. /* fill in the dac_nids table from the parsed pin configuration */
  9126. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9127. const struct auto_pin_cfg *cfg)
  9128. {
  9129. int i;
  9130. hda_nid_t nid;
  9131. spec->multiout.dac_nids = spec->private_dac_nids;
  9132. for (i = 0; i < cfg->line_outs; i++) {
  9133. nid = cfg->line_out_pins[i];
  9134. if (nid) {
  9135. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9136. continue;
  9137. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9138. }
  9139. }
  9140. spec->multiout.num_dacs = cfg->line_outs;
  9141. return 0;
  9142. }
  9143. /* add playback controls from the parsed DAC table */
  9144. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9145. const struct auto_pin_cfg *cfg)
  9146. {
  9147. char name[32];
  9148. static const char *chname[4] = {
  9149. "Front", "Surround", NULL /*CLFE*/, "Side"
  9150. };
  9151. hda_nid_t nid;
  9152. int i, idx, err;
  9153. for (i = 0; i < cfg->line_outs; i++) {
  9154. nid = spec->multiout.dac_nids[i];
  9155. if (!nid)
  9156. continue;
  9157. if (nid == 0x05) {
  9158. /* Center/LFE */
  9159. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9160. "Center Playback Switch",
  9161. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9162. HDA_OUTPUT));
  9163. if (err < 0)
  9164. return err;
  9165. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9166. "LFE Playback Switch",
  9167. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9168. HDA_OUTPUT));
  9169. if (err < 0)
  9170. return err;
  9171. } else {
  9172. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9173. idx++)
  9174. if (nid == alc861_dac_nids[idx])
  9175. break;
  9176. sprintf(name, "%s Playback Switch", chname[idx]);
  9177. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9178. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9179. HDA_OUTPUT));
  9180. if (err < 0)
  9181. return err;
  9182. }
  9183. }
  9184. return 0;
  9185. }
  9186. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9187. {
  9188. int err;
  9189. hda_nid_t nid;
  9190. if (!pin)
  9191. return 0;
  9192. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9193. nid = 0x03;
  9194. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9195. "Headphone Playback Switch",
  9196. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9197. if (err < 0)
  9198. return err;
  9199. spec->multiout.hp_nid = nid;
  9200. }
  9201. return 0;
  9202. }
  9203. /* create playback/capture controls for input pins */
  9204. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9205. const struct auto_pin_cfg *cfg)
  9206. {
  9207. struct hda_input_mux *imux = &spec->private_imux;
  9208. int i, err, idx, idx1;
  9209. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9210. switch (cfg->input_pins[i]) {
  9211. case 0x0c:
  9212. idx1 = 1;
  9213. idx = 2; /* Line In */
  9214. break;
  9215. case 0x0f:
  9216. idx1 = 2;
  9217. idx = 2; /* Line In */
  9218. break;
  9219. case 0x0d:
  9220. idx1 = 0;
  9221. idx = 1; /* Mic In */
  9222. break;
  9223. case 0x10:
  9224. idx1 = 3;
  9225. idx = 1; /* Mic In */
  9226. break;
  9227. case 0x11:
  9228. idx1 = 4;
  9229. idx = 0; /* CD */
  9230. break;
  9231. default:
  9232. continue;
  9233. }
  9234. err = new_analog_input(spec, cfg->input_pins[i],
  9235. auto_pin_cfg_labels[i], idx, 0x15);
  9236. if (err < 0)
  9237. return err;
  9238. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9239. imux->items[imux->num_items].index = idx1;
  9240. imux->num_items++;
  9241. }
  9242. return 0;
  9243. }
  9244. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9245. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9246. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9247. {
  9248. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9249. /* The multiple "Capture Source" controls confuse alsamixer
  9250. * So call somewhat different..
  9251. *FIXME: the controls appear in the "playback" view!
  9252. */
  9253. /* .name = "Capture Source", */
  9254. .name = "Input Source",
  9255. .count = 1,
  9256. .info = alc_mux_enum_info,
  9257. .get = alc_mux_enum_get,
  9258. .put = alc_mux_enum_put,
  9259. },
  9260. { } /* end */
  9261. };
  9262. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9263. hda_nid_t nid,
  9264. int pin_type, int dac_idx)
  9265. {
  9266. /* set as output */
  9267. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9268. pin_type);
  9269. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9270. AMP_OUT_UNMUTE);
  9271. }
  9272. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9273. {
  9274. struct alc_spec *spec = codec->spec;
  9275. int i;
  9276. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9277. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9278. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9279. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9280. if (nid)
  9281. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9282. spec->multiout.dac_nids[i]);
  9283. }
  9284. }
  9285. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9286. {
  9287. struct alc_spec *spec = codec->spec;
  9288. hda_nid_t pin;
  9289. pin = spec->autocfg.hp_pins[0];
  9290. if (pin) /* connect to front */
  9291. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9292. spec->multiout.dac_nids[0]);
  9293. }
  9294. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9295. {
  9296. struct alc_spec *spec = codec->spec;
  9297. int i;
  9298. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9299. hda_nid_t nid = spec->autocfg.input_pins[i];
  9300. if (nid >= 0x0c && nid <= 0x11) {
  9301. snd_hda_codec_write(codec, nid, 0,
  9302. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9303. i <= AUTO_PIN_FRONT_MIC ?
  9304. PIN_VREF80 : PIN_IN);
  9305. }
  9306. }
  9307. }
  9308. /* parse the BIOS configuration and set up the alc_spec */
  9309. /* return 1 if successful, 0 if the proper config is not found,
  9310. * or a negative error code
  9311. */
  9312. static int alc861_parse_auto_config(struct hda_codec *codec)
  9313. {
  9314. struct alc_spec *spec = codec->spec;
  9315. int err;
  9316. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9317. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9318. alc861_ignore);
  9319. if (err < 0)
  9320. return err;
  9321. if (!spec->autocfg.line_outs)
  9322. return 0; /* can't find valid BIOS pin config */
  9323. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9324. if (err < 0)
  9325. return err;
  9326. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9327. if (err < 0)
  9328. return err;
  9329. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9330. if (err < 0)
  9331. return err;
  9332. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9333. if (err < 0)
  9334. return err;
  9335. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9336. if (spec->autocfg.dig_out_pin)
  9337. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9338. if (spec->kctl_alloc)
  9339. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9340. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9341. spec->num_mux_defs = 1;
  9342. spec->input_mux = &spec->private_imux;
  9343. spec->adc_nids = alc861_adc_nids;
  9344. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9345. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9346. spec->num_mixers++;
  9347. return 1;
  9348. }
  9349. /* additional initialization for auto-configuration model */
  9350. static void alc861_auto_init(struct hda_codec *codec)
  9351. {
  9352. alc861_auto_init_multi_out(codec);
  9353. alc861_auto_init_hp_out(codec);
  9354. alc861_auto_init_analog_input(codec);
  9355. }
  9356. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9357. static struct hda_amp_list alc861_loopbacks[] = {
  9358. { 0x15, HDA_INPUT, 0 },
  9359. { 0x15, HDA_INPUT, 1 },
  9360. { 0x15, HDA_INPUT, 2 },
  9361. { 0x15, HDA_INPUT, 3 },
  9362. { } /* end */
  9363. };
  9364. #endif
  9365. /*
  9366. * configuration and preset
  9367. */
  9368. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9369. [ALC861_3ST] = "3stack",
  9370. [ALC660_3ST] = "3stack-660",
  9371. [ALC861_3ST_DIG] = "3stack-dig",
  9372. [ALC861_6ST_DIG] = "6stack-dig",
  9373. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9374. [ALC861_TOSHIBA] = "toshiba",
  9375. [ALC861_ASUS] = "asus",
  9376. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9377. [ALC861_AUTO] = "auto",
  9378. };
  9379. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9380. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9381. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9382. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9383. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9384. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9385. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9386. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9387. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9388. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9389. * Any other models that need this preset?
  9390. */
  9391. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9392. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9393. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9394. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9395. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9396. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9397. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9398. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9399. {}
  9400. };
  9401. static struct alc_config_preset alc861_presets[] = {
  9402. [ALC861_3ST] = {
  9403. .mixers = { alc861_3ST_mixer },
  9404. .init_verbs = { alc861_threestack_init_verbs },
  9405. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9406. .dac_nids = alc861_dac_nids,
  9407. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9408. .channel_mode = alc861_threestack_modes,
  9409. .need_dac_fix = 1,
  9410. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9411. .adc_nids = alc861_adc_nids,
  9412. .input_mux = &alc861_capture_source,
  9413. },
  9414. [ALC861_3ST_DIG] = {
  9415. .mixers = { alc861_base_mixer },
  9416. .init_verbs = { alc861_threestack_init_verbs },
  9417. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9418. .dac_nids = alc861_dac_nids,
  9419. .dig_out_nid = ALC861_DIGOUT_NID,
  9420. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9421. .channel_mode = alc861_threestack_modes,
  9422. .need_dac_fix = 1,
  9423. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9424. .adc_nids = alc861_adc_nids,
  9425. .input_mux = &alc861_capture_source,
  9426. },
  9427. [ALC861_6ST_DIG] = {
  9428. .mixers = { alc861_base_mixer },
  9429. .init_verbs = { alc861_base_init_verbs },
  9430. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9431. .dac_nids = alc861_dac_nids,
  9432. .dig_out_nid = ALC861_DIGOUT_NID,
  9433. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9434. .channel_mode = alc861_8ch_modes,
  9435. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9436. .adc_nids = alc861_adc_nids,
  9437. .input_mux = &alc861_capture_source,
  9438. },
  9439. [ALC660_3ST] = {
  9440. .mixers = { alc861_3ST_mixer },
  9441. .init_verbs = { alc861_threestack_init_verbs },
  9442. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9443. .dac_nids = alc660_dac_nids,
  9444. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9445. .channel_mode = alc861_threestack_modes,
  9446. .need_dac_fix = 1,
  9447. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9448. .adc_nids = alc861_adc_nids,
  9449. .input_mux = &alc861_capture_source,
  9450. },
  9451. [ALC861_UNIWILL_M31] = {
  9452. .mixers = { alc861_uniwill_m31_mixer },
  9453. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9454. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9455. .dac_nids = alc861_dac_nids,
  9456. .dig_out_nid = ALC861_DIGOUT_NID,
  9457. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9458. .channel_mode = alc861_uniwill_m31_modes,
  9459. .need_dac_fix = 1,
  9460. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9461. .adc_nids = alc861_adc_nids,
  9462. .input_mux = &alc861_capture_source,
  9463. },
  9464. [ALC861_TOSHIBA] = {
  9465. .mixers = { alc861_toshiba_mixer },
  9466. .init_verbs = { alc861_base_init_verbs,
  9467. alc861_toshiba_init_verbs },
  9468. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9469. .dac_nids = alc861_dac_nids,
  9470. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9471. .channel_mode = alc883_3ST_2ch_modes,
  9472. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9473. .adc_nids = alc861_adc_nids,
  9474. .input_mux = &alc861_capture_source,
  9475. .unsol_event = alc861_toshiba_unsol_event,
  9476. .init_hook = alc861_toshiba_automute,
  9477. },
  9478. [ALC861_ASUS] = {
  9479. .mixers = { alc861_asus_mixer },
  9480. .init_verbs = { alc861_asus_init_verbs },
  9481. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9482. .dac_nids = alc861_dac_nids,
  9483. .dig_out_nid = ALC861_DIGOUT_NID,
  9484. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9485. .channel_mode = alc861_asus_modes,
  9486. .need_dac_fix = 1,
  9487. .hp_nid = 0x06,
  9488. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9489. .adc_nids = alc861_adc_nids,
  9490. .input_mux = &alc861_capture_source,
  9491. },
  9492. [ALC861_ASUS_LAPTOP] = {
  9493. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9494. .init_verbs = { alc861_asus_init_verbs,
  9495. alc861_asus_laptop_init_verbs },
  9496. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9497. .dac_nids = alc861_dac_nids,
  9498. .dig_out_nid = ALC861_DIGOUT_NID,
  9499. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9500. .channel_mode = alc883_3ST_2ch_modes,
  9501. .need_dac_fix = 1,
  9502. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9503. .adc_nids = alc861_adc_nids,
  9504. .input_mux = &alc861_capture_source,
  9505. },
  9506. };
  9507. static int patch_alc861(struct hda_codec *codec)
  9508. {
  9509. struct alc_spec *spec;
  9510. int board_config;
  9511. int err;
  9512. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9513. if (spec == NULL)
  9514. return -ENOMEM;
  9515. codec->spec = spec;
  9516. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9517. alc861_models,
  9518. alc861_cfg_tbl);
  9519. if (board_config < 0) {
  9520. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9521. "trying auto-probe from BIOS...\n");
  9522. board_config = ALC861_AUTO;
  9523. }
  9524. if (board_config == ALC861_AUTO) {
  9525. /* automatic parse from the BIOS config */
  9526. err = alc861_parse_auto_config(codec);
  9527. if (err < 0) {
  9528. alc_free(codec);
  9529. return err;
  9530. } else if (!err) {
  9531. printk(KERN_INFO
  9532. "hda_codec: Cannot set up configuration "
  9533. "from BIOS. Using base mode...\n");
  9534. board_config = ALC861_3ST_DIG;
  9535. }
  9536. }
  9537. if (board_config != ALC861_AUTO)
  9538. setup_preset(spec, &alc861_presets[board_config]);
  9539. spec->stream_name_analog = "ALC861 Analog";
  9540. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9541. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9542. spec->stream_name_digital = "ALC861 Digital";
  9543. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9544. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9545. codec->patch_ops = alc_patch_ops;
  9546. if (board_config == ALC861_AUTO)
  9547. spec->init_hook = alc861_auto_init;
  9548. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9549. if (!spec->loopback.amplist)
  9550. spec->loopback.amplist = alc861_loopbacks;
  9551. #endif
  9552. return 0;
  9553. }
  9554. /*
  9555. * ALC861-VD support
  9556. *
  9557. * Based on ALC882
  9558. *
  9559. * In addition, an independent DAC
  9560. */
  9561. #define ALC861VD_DIGOUT_NID 0x06
  9562. static hda_nid_t alc861vd_dac_nids[4] = {
  9563. /* front, surr, clfe, side surr */
  9564. 0x02, 0x03, 0x04, 0x05
  9565. };
  9566. /* dac_nids for ALC660vd are in a different order - according to
  9567. * Realtek's driver.
  9568. * This should probably tesult in a different mixer for 6stack models
  9569. * of ALC660vd codecs, but for now there is only 3stack mixer
  9570. * - and it is the same as in 861vd.
  9571. * adc_nids in ALC660vd are (is) the same as in 861vd
  9572. */
  9573. static hda_nid_t alc660vd_dac_nids[3] = {
  9574. /* front, rear, clfe, rear_surr */
  9575. 0x02, 0x04, 0x03
  9576. };
  9577. static hda_nid_t alc861vd_adc_nids[1] = {
  9578. /* ADC0 */
  9579. 0x09,
  9580. };
  9581. /* input MUX */
  9582. /* FIXME: should be a matrix-type input source selection */
  9583. static struct hda_input_mux alc861vd_capture_source = {
  9584. .num_items = 4,
  9585. .items = {
  9586. { "Mic", 0x0 },
  9587. { "Front Mic", 0x1 },
  9588. { "Line", 0x2 },
  9589. { "CD", 0x4 },
  9590. },
  9591. };
  9592. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9593. .num_items = 3,
  9594. .items = {
  9595. { "Front Mic", 0x0 },
  9596. { "ATAPI Mic", 0x1 },
  9597. { "Line In", 0x5 },
  9598. },
  9599. };
  9600. static struct hda_input_mux alc861vd_hp_capture_source = {
  9601. .num_items = 2,
  9602. .items = {
  9603. { "Front Mic", 0x0 },
  9604. { "ATAPI Mic", 0x1 },
  9605. },
  9606. };
  9607. #define alc861vd_mux_enum_info alc_mux_enum_info
  9608. #define alc861vd_mux_enum_get alc_mux_enum_get
  9609. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9610. struct snd_ctl_elem_value *ucontrol)
  9611. {
  9612. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9613. struct alc_spec *spec = codec->spec;
  9614. const struct hda_input_mux *imux = spec->input_mux;
  9615. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9616. static hda_nid_t capture_mixers[1] = { 0x22 };
  9617. hda_nid_t nid = capture_mixers[adc_idx];
  9618. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9619. unsigned int i, idx;
  9620. idx = ucontrol->value.enumerated.item[0];
  9621. if (idx >= imux->num_items)
  9622. idx = imux->num_items - 1;
  9623. if (*cur_val == idx)
  9624. return 0;
  9625. for (i = 0; i < imux->num_items; i++) {
  9626. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9627. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9628. imux->items[i].index,
  9629. HDA_AMP_MUTE, v);
  9630. }
  9631. *cur_val = idx;
  9632. return 1;
  9633. }
  9634. /*
  9635. * 2ch mode
  9636. */
  9637. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9638. { 2, NULL }
  9639. };
  9640. /*
  9641. * 6ch mode
  9642. */
  9643. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9644. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9645. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9646. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9647. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9648. { } /* end */
  9649. };
  9650. /*
  9651. * 8ch mode
  9652. */
  9653. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9654. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9655. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9656. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9657. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9658. { } /* end */
  9659. };
  9660. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9661. { 6, alc861vd_6stack_ch6_init },
  9662. { 8, alc861vd_6stack_ch8_init },
  9663. };
  9664. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9665. {
  9666. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9667. .name = "Channel Mode",
  9668. .info = alc_ch_mode_info,
  9669. .get = alc_ch_mode_get,
  9670. .put = alc_ch_mode_put,
  9671. },
  9672. { } /* end */
  9673. };
  9674. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9675. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9676. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9677. {
  9678. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9679. /* The multiple "Capture Source" controls confuse alsamixer
  9680. * So call somewhat different..
  9681. *FIXME: the controls appear in the "playback" view!
  9682. */
  9683. /* .name = "Capture Source", */
  9684. .name = "Input Source",
  9685. .count = 1,
  9686. .info = alc861vd_mux_enum_info,
  9687. .get = alc861vd_mux_enum_get,
  9688. .put = alc861vd_mux_enum_put,
  9689. },
  9690. { } /* end */
  9691. };
  9692. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9693. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9694. */
  9695. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9696. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9697. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9698. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9699. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9700. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9701. HDA_OUTPUT),
  9702. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9703. HDA_OUTPUT),
  9704. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9705. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9706. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9707. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9708. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9709. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9710. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9711. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9712. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9713. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9714. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9715. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9716. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9717. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9718. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9719. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9720. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9721. { } /* end */
  9722. };
  9723. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9724. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9725. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9726. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9727. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9728. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9729. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9730. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9731. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9732. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9733. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9734. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9735. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9736. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9737. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9738. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9739. { } /* end */
  9740. };
  9741. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9742. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9743. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9744. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9745. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9746. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9747. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9748. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9749. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9750. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9751. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9752. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9753. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9754. { } /* end */
  9755. };
  9756. /* Pin assignment: Front=0x14, HP = 0x15,
  9757. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9758. */
  9759. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9760. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9761. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9762. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9763. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9764. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9765. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9766. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9767. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9768. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9769. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9770. { } /* end */
  9771. };
  9772. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9773. * Front Mic=0x18, ATAPI Mic = 0x19,
  9774. */
  9775. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9776. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9777. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9778. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9779. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9780. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9781. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9782. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9783. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9784. { } /* end */
  9785. };
  9786. /*
  9787. * generic initialization of ADC, input mixers and output mixers
  9788. */
  9789. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9790. /*
  9791. * Unmute ADC0 and set the default input to mic-in
  9792. */
  9793. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9794. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9795. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9796. * the analog-loopback mixer widget
  9797. */
  9798. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9799. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9800. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9801. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9802. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9803. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9804. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9805. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9806. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9807. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9808. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9809. /*
  9810. * Set up output mixers (0x02 - 0x05)
  9811. */
  9812. /* set vol=0 to output mixers */
  9813. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9814. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9815. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9816. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9817. /* set up input amps for analog loopback */
  9818. /* Amp Indices: DAC = 0, mixer = 1 */
  9819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9821. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9822. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9823. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9824. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9825. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9826. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9827. { }
  9828. };
  9829. /*
  9830. * 3-stack pin configuration:
  9831. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9832. */
  9833. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9834. /*
  9835. * Set pin mode and muting
  9836. */
  9837. /* set front pin widgets 0x14 for output */
  9838. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9839. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9840. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9841. /* Mic (rear) pin: input vref at 80% */
  9842. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9843. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9844. /* Front Mic pin: input vref at 80% */
  9845. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9846. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9847. /* Line In pin: input */
  9848. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9849. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9850. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9851. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9852. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9853. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9854. /* CD pin widget for input */
  9855. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9856. { }
  9857. };
  9858. /*
  9859. * 6-stack pin configuration:
  9860. */
  9861. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9862. /*
  9863. * Set pin mode and muting
  9864. */
  9865. /* set front pin widgets 0x14 for output */
  9866. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9867. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9868. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9869. /* Rear Pin: output 1 (0x0d) */
  9870. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9871. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9872. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9873. /* CLFE Pin: output 2 (0x0e) */
  9874. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9875. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9876. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9877. /* Side Pin: output 3 (0x0f) */
  9878. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9879. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9880. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9881. /* Mic (rear) pin: input vref at 80% */
  9882. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9883. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9884. /* Front Mic pin: input vref at 80% */
  9885. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9886. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9887. /* Line In pin: input */
  9888. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9889. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9890. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9891. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9892. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9893. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9894. /* CD pin widget for input */
  9895. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9896. { }
  9897. };
  9898. static struct hda_verb alc861vd_eapd_verbs[] = {
  9899. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9900. { }
  9901. };
  9902. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9903. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9904. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9905. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9906. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9907. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9908. {}
  9909. };
  9910. /* toggle speaker-output according to the hp-jack state */
  9911. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9912. {
  9913. unsigned int present;
  9914. unsigned char bits;
  9915. present = snd_hda_codec_read(codec, 0x1b, 0,
  9916. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9917. bits = present ? HDA_AMP_MUTE : 0;
  9918. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9919. HDA_AMP_MUTE, bits);
  9920. }
  9921. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9922. {
  9923. unsigned int present;
  9924. unsigned char bits;
  9925. present = snd_hda_codec_read(codec, 0x18, 0,
  9926. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9927. bits = present ? HDA_AMP_MUTE : 0;
  9928. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9929. HDA_AMP_MUTE, bits);
  9930. }
  9931. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9932. {
  9933. alc861vd_lenovo_hp_automute(codec);
  9934. alc861vd_lenovo_mic_automute(codec);
  9935. }
  9936. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9937. unsigned int res)
  9938. {
  9939. switch (res >> 26) {
  9940. case ALC880_HP_EVENT:
  9941. alc861vd_lenovo_hp_automute(codec);
  9942. break;
  9943. case ALC880_MIC_EVENT:
  9944. alc861vd_lenovo_mic_automute(codec);
  9945. break;
  9946. }
  9947. }
  9948. static struct hda_verb alc861vd_dallas_verbs[] = {
  9949. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9950. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9951. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9952. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9953. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9954. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9955. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9956. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9957. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9958. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9959. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9960. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9961. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9962. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9963. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9964. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9965. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9966. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9967. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9968. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9969. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9970. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9971. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9972. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9973. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9974. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9975. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9976. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9977. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9981. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9982. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9983. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9984. { } /* end */
  9985. };
  9986. /* toggle speaker-output according to the hp-jack state */
  9987. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9988. {
  9989. unsigned int present;
  9990. present = snd_hda_codec_read(codec, 0x15, 0,
  9991. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9992. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9993. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9994. }
  9995. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9996. {
  9997. if ((res >> 26) == ALC880_HP_EVENT)
  9998. alc861vd_dallas_automute(codec);
  9999. }
  10000. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10001. #define alc861vd_loopbacks alc880_loopbacks
  10002. #endif
  10003. /* pcm configuration: identiacal with ALC880 */
  10004. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10005. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10006. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10007. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10008. /*
  10009. * configuration and preset
  10010. */
  10011. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10012. [ALC660VD_3ST] = "3stack-660",
  10013. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10014. [ALC861VD_3ST] = "3stack",
  10015. [ALC861VD_3ST_DIG] = "3stack-digout",
  10016. [ALC861VD_6ST_DIG] = "6stack-digout",
  10017. [ALC861VD_LENOVO] = "lenovo",
  10018. [ALC861VD_DALLAS] = "dallas",
  10019. [ALC861VD_HP] = "hp",
  10020. [ALC861VD_AUTO] = "auto",
  10021. };
  10022. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10023. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10024. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10025. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10026. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10027. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10028. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10029. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10030. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10031. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10032. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10033. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10034. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10035. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10036. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10037. {}
  10038. };
  10039. static struct alc_config_preset alc861vd_presets[] = {
  10040. [ALC660VD_3ST] = {
  10041. .mixers = { alc861vd_3st_mixer },
  10042. .init_verbs = { alc861vd_volume_init_verbs,
  10043. alc861vd_3stack_init_verbs },
  10044. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10045. .dac_nids = alc660vd_dac_nids,
  10046. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10047. .adc_nids = alc861vd_adc_nids,
  10048. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10049. .channel_mode = alc861vd_3stack_2ch_modes,
  10050. .input_mux = &alc861vd_capture_source,
  10051. },
  10052. [ALC660VD_3ST_DIG] = {
  10053. .mixers = { alc861vd_3st_mixer },
  10054. .init_verbs = { alc861vd_volume_init_verbs,
  10055. alc861vd_3stack_init_verbs },
  10056. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10057. .dac_nids = alc660vd_dac_nids,
  10058. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10059. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10060. .adc_nids = alc861vd_adc_nids,
  10061. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10062. .channel_mode = alc861vd_3stack_2ch_modes,
  10063. .input_mux = &alc861vd_capture_source,
  10064. },
  10065. [ALC861VD_3ST] = {
  10066. .mixers = { alc861vd_3st_mixer },
  10067. .init_verbs = { alc861vd_volume_init_verbs,
  10068. alc861vd_3stack_init_verbs },
  10069. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10070. .dac_nids = alc861vd_dac_nids,
  10071. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10072. .channel_mode = alc861vd_3stack_2ch_modes,
  10073. .input_mux = &alc861vd_capture_source,
  10074. },
  10075. [ALC861VD_3ST_DIG] = {
  10076. .mixers = { alc861vd_3st_mixer },
  10077. .init_verbs = { alc861vd_volume_init_verbs,
  10078. alc861vd_3stack_init_verbs },
  10079. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10080. .dac_nids = alc861vd_dac_nids,
  10081. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10082. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10083. .channel_mode = alc861vd_3stack_2ch_modes,
  10084. .input_mux = &alc861vd_capture_source,
  10085. },
  10086. [ALC861VD_6ST_DIG] = {
  10087. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10088. .init_verbs = { alc861vd_volume_init_verbs,
  10089. alc861vd_6stack_init_verbs },
  10090. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10091. .dac_nids = alc861vd_dac_nids,
  10092. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10093. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10094. .channel_mode = alc861vd_6stack_modes,
  10095. .input_mux = &alc861vd_capture_source,
  10096. },
  10097. [ALC861VD_LENOVO] = {
  10098. .mixers = { alc861vd_lenovo_mixer },
  10099. .init_verbs = { alc861vd_volume_init_verbs,
  10100. alc861vd_3stack_init_verbs,
  10101. alc861vd_eapd_verbs,
  10102. alc861vd_lenovo_unsol_verbs },
  10103. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10104. .dac_nids = alc660vd_dac_nids,
  10105. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10106. .adc_nids = alc861vd_adc_nids,
  10107. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10108. .channel_mode = alc861vd_3stack_2ch_modes,
  10109. .input_mux = &alc861vd_capture_source,
  10110. .unsol_event = alc861vd_lenovo_unsol_event,
  10111. .init_hook = alc861vd_lenovo_automute,
  10112. },
  10113. [ALC861VD_DALLAS] = {
  10114. .mixers = { alc861vd_dallas_mixer },
  10115. .init_verbs = { alc861vd_dallas_verbs },
  10116. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10117. .dac_nids = alc861vd_dac_nids,
  10118. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10119. .adc_nids = alc861vd_adc_nids,
  10120. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10121. .channel_mode = alc861vd_3stack_2ch_modes,
  10122. .input_mux = &alc861vd_dallas_capture_source,
  10123. .unsol_event = alc861vd_dallas_unsol_event,
  10124. .init_hook = alc861vd_dallas_automute,
  10125. },
  10126. [ALC861VD_HP] = {
  10127. .mixers = { alc861vd_hp_mixer },
  10128. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10129. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10130. .dac_nids = alc861vd_dac_nids,
  10131. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10132. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10133. .adc_nids = alc861vd_adc_nids,
  10134. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10135. .channel_mode = alc861vd_3stack_2ch_modes,
  10136. .input_mux = &alc861vd_hp_capture_source,
  10137. .unsol_event = alc861vd_dallas_unsol_event,
  10138. .init_hook = alc861vd_dallas_automute,
  10139. },
  10140. };
  10141. /*
  10142. * BIOS auto configuration
  10143. */
  10144. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10145. hda_nid_t nid, int pin_type, int dac_idx)
  10146. {
  10147. /* set as output */
  10148. snd_hda_codec_write(codec, nid, 0,
  10149. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10150. snd_hda_codec_write(codec, nid, 0,
  10151. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10152. }
  10153. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10154. {
  10155. struct alc_spec *spec = codec->spec;
  10156. int i;
  10157. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10158. for (i = 0; i <= HDA_SIDE; i++) {
  10159. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10160. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10161. if (nid)
  10162. alc861vd_auto_set_output_and_unmute(codec, nid,
  10163. pin_type, i);
  10164. }
  10165. }
  10166. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10167. {
  10168. struct alc_spec *spec = codec->spec;
  10169. hda_nid_t pin;
  10170. pin = spec->autocfg.hp_pins[0];
  10171. if (pin) /* connect to front and use dac 0 */
  10172. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10173. }
  10174. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10175. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10176. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10177. {
  10178. struct alc_spec *spec = codec->spec;
  10179. int i;
  10180. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10181. hda_nid_t nid = spec->autocfg.input_pins[i];
  10182. if (alc861vd_is_input_pin(nid)) {
  10183. snd_hda_codec_write(codec, nid, 0,
  10184. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10185. i <= AUTO_PIN_FRONT_MIC ?
  10186. PIN_VREF80 : PIN_IN);
  10187. if (nid != ALC861VD_PIN_CD_NID)
  10188. snd_hda_codec_write(codec, nid, 0,
  10189. AC_VERB_SET_AMP_GAIN_MUTE,
  10190. AMP_OUT_MUTE);
  10191. }
  10192. }
  10193. }
  10194. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10195. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10196. /* add playback controls from the parsed DAC table */
  10197. /* Based on ALC880 version. But ALC861VD has separate,
  10198. * different NIDs for mute/unmute switch and volume control */
  10199. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10200. const struct auto_pin_cfg *cfg)
  10201. {
  10202. char name[32];
  10203. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10204. hda_nid_t nid_v, nid_s;
  10205. int i, err;
  10206. for (i = 0; i < cfg->line_outs; i++) {
  10207. if (!spec->multiout.dac_nids[i])
  10208. continue;
  10209. nid_v = alc861vd_idx_to_mixer_vol(
  10210. alc880_dac_to_idx(
  10211. spec->multiout.dac_nids[i]));
  10212. nid_s = alc861vd_idx_to_mixer_switch(
  10213. alc880_dac_to_idx(
  10214. spec->multiout.dac_nids[i]));
  10215. if (i == 2) {
  10216. /* Center/LFE */
  10217. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10218. "Center Playback Volume",
  10219. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10220. HDA_OUTPUT));
  10221. if (err < 0)
  10222. return err;
  10223. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10224. "LFE Playback Volume",
  10225. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10226. HDA_OUTPUT));
  10227. if (err < 0)
  10228. return err;
  10229. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10230. "Center Playback Switch",
  10231. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10232. HDA_INPUT));
  10233. if (err < 0)
  10234. return err;
  10235. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10236. "LFE Playback Switch",
  10237. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10238. HDA_INPUT));
  10239. if (err < 0)
  10240. return err;
  10241. } else {
  10242. sprintf(name, "%s Playback Volume", chname[i]);
  10243. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10244. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10245. HDA_OUTPUT));
  10246. if (err < 0)
  10247. return err;
  10248. sprintf(name, "%s Playback Switch", chname[i]);
  10249. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10250. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10251. HDA_INPUT));
  10252. if (err < 0)
  10253. return err;
  10254. }
  10255. }
  10256. return 0;
  10257. }
  10258. /* add playback controls for speaker and HP outputs */
  10259. /* Based on ALC880 version. But ALC861VD has separate,
  10260. * different NIDs for mute/unmute switch and volume control */
  10261. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10262. hda_nid_t pin, const char *pfx)
  10263. {
  10264. hda_nid_t nid_v, nid_s;
  10265. int err;
  10266. char name[32];
  10267. if (!pin)
  10268. return 0;
  10269. if (alc880_is_fixed_pin(pin)) {
  10270. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10271. /* specify the DAC as the extra output */
  10272. if (!spec->multiout.hp_nid)
  10273. spec->multiout.hp_nid = nid_v;
  10274. else
  10275. spec->multiout.extra_out_nid[0] = nid_v;
  10276. /* control HP volume/switch on the output mixer amp */
  10277. nid_v = alc861vd_idx_to_mixer_vol(
  10278. alc880_fixed_pin_idx(pin));
  10279. nid_s = alc861vd_idx_to_mixer_switch(
  10280. alc880_fixed_pin_idx(pin));
  10281. sprintf(name, "%s Playback Volume", pfx);
  10282. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10283. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10284. if (err < 0)
  10285. return err;
  10286. sprintf(name, "%s Playback Switch", pfx);
  10287. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10288. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10289. if (err < 0)
  10290. return err;
  10291. } else if (alc880_is_multi_pin(pin)) {
  10292. /* set manual connection */
  10293. /* we have only a switch on HP-out PIN */
  10294. sprintf(name, "%s Playback Switch", pfx);
  10295. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10296. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10297. if (err < 0)
  10298. return err;
  10299. }
  10300. return 0;
  10301. }
  10302. /* parse the BIOS configuration and set up the alc_spec
  10303. * return 1 if successful, 0 if the proper config is not found,
  10304. * or a negative error code
  10305. * Based on ALC880 version - had to change it to override
  10306. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10307. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10308. {
  10309. struct alc_spec *spec = codec->spec;
  10310. int err;
  10311. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10312. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10313. alc861vd_ignore);
  10314. if (err < 0)
  10315. return err;
  10316. if (!spec->autocfg.line_outs)
  10317. return 0; /* can't find valid BIOS pin config */
  10318. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10319. if (err < 0)
  10320. return err;
  10321. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10322. if (err < 0)
  10323. return err;
  10324. err = alc861vd_auto_create_extra_out(spec,
  10325. spec->autocfg.speaker_pins[0],
  10326. "Speaker");
  10327. if (err < 0)
  10328. return err;
  10329. err = alc861vd_auto_create_extra_out(spec,
  10330. spec->autocfg.hp_pins[0],
  10331. "Headphone");
  10332. if (err < 0)
  10333. return err;
  10334. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10335. if (err < 0)
  10336. return err;
  10337. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10338. if (spec->autocfg.dig_out_pin)
  10339. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10340. if (spec->kctl_alloc)
  10341. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10342. spec->init_verbs[spec->num_init_verbs++]
  10343. = alc861vd_volume_init_verbs;
  10344. spec->num_mux_defs = 1;
  10345. spec->input_mux = &spec->private_imux;
  10346. err = alc_auto_add_mic_boost(codec);
  10347. if (err < 0)
  10348. return err;
  10349. return 1;
  10350. }
  10351. /* additional initialization for auto-configuration model */
  10352. static void alc861vd_auto_init(struct hda_codec *codec)
  10353. {
  10354. alc861vd_auto_init_multi_out(codec);
  10355. alc861vd_auto_init_hp_out(codec);
  10356. alc861vd_auto_init_analog_input(codec);
  10357. }
  10358. static int patch_alc861vd(struct hda_codec *codec)
  10359. {
  10360. struct alc_spec *spec;
  10361. int err, board_config;
  10362. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10363. if (spec == NULL)
  10364. return -ENOMEM;
  10365. codec->spec = spec;
  10366. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10367. alc861vd_models,
  10368. alc861vd_cfg_tbl);
  10369. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10370. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10371. "ALC861VD, trying auto-probe from BIOS...\n");
  10372. board_config = ALC861VD_AUTO;
  10373. }
  10374. if (board_config == ALC861VD_AUTO) {
  10375. /* automatic parse from the BIOS config */
  10376. err = alc861vd_parse_auto_config(codec);
  10377. if (err < 0) {
  10378. alc_free(codec);
  10379. return err;
  10380. } else if (!err) {
  10381. printk(KERN_INFO
  10382. "hda_codec: Cannot set up configuration "
  10383. "from BIOS. Using base mode...\n");
  10384. board_config = ALC861VD_3ST;
  10385. }
  10386. }
  10387. if (board_config != ALC861VD_AUTO)
  10388. setup_preset(spec, &alc861vd_presets[board_config]);
  10389. spec->stream_name_analog = "ALC861VD Analog";
  10390. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10391. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10392. spec->stream_name_digital = "ALC861VD Digital";
  10393. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10394. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10395. spec->adc_nids = alc861vd_adc_nids;
  10396. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10397. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10398. spec->num_mixers++;
  10399. codec->patch_ops = alc_patch_ops;
  10400. if (board_config == ALC861VD_AUTO)
  10401. spec->init_hook = alc861vd_auto_init;
  10402. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10403. if (!spec->loopback.amplist)
  10404. spec->loopback.amplist = alc861vd_loopbacks;
  10405. #endif
  10406. return 0;
  10407. }
  10408. /*
  10409. * ALC662 support
  10410. *
  10411. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10412. * configuration. Each pin widget can choose any input DACs and a mixer.
  10413. * Each ADC is connected from a mixer of all inputs. This makes possible
  10414. * 6-channel independent captures.
  10415. *
  10416. * In addition, an independent DAC for the multi-playback (not used in this
  10417. * driver yet).
  10418. */
  10419. #define ALC662_DIGOUT_NID 0x06
  10420. #define ALC662_DIGIN_NID 0x0a
  10421. static hda_nid_t alc662_dac_nids[4] = {
  10422. /* front, rear, clfe, rear_surr */
  10423. 0x02, 0x03, 0x04
  10424. };
  10425. static hda_nid_t alc662_adc_nids[1] = {
  10426. /* ADC1-2 */
  10427. 0x09,
  10428. };
  10429. /* input MUX */
  10430. /* FIXME: should be a matrix-type input source selection */
  10431. static struct hda_input_mux alc662_capture_source = {
  10432. .num_items = 4,
  10433. .items = {
  10434. { "Mic", 0x0 },
  10435. { "Front Mic", 0x1 },
  10436. { "Line", 0x2 },
  10437. { "CD", 0x4 },
  10438. },
  10439. };
  10440. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10441. .num_items = 2,
  10442. .items = {
  10443. { "Mic", 0x1 },
  10444. { "Line", 0x2 },
  10445. },
  10446. };
  10447. static struct hda_input_mux alc662_eeepc_capture_source = {
  10448. .num_items = 2,
  10449. .items = {
  10450. { "i-Mic", 0x1 },
  10451. { "e-Mic", 0x0 },
  10452. },
  10453. };
  10454. #define alc662_mux_enum_info alc_mux_enum_info
  10455. #define alc662_mux_enum_get alc_mux_enum_get
  10456. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10457. struct snd_ctl_elem_value *ucontrol)
  10458. {
  10459. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10460. struct alc_spec *spec = codec->spec;
  10461. const struct hda_input_mux *imux = spec->input_mux;
  10462. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10463. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10464. hda_nid_t nid = capture_mixers[adc_idx];
  10465. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10466. unsigned int i, idx;
  10467. idx = ucontrol->value.enumerated.item[0];
  10468. if (idx >= imux->num_items)
  10469. idx = imux->num_items - 1;
  10470. if (*cur_val == idx)
  10471. return 0;
  10472. for (i = 0; i < imux->num_items; i++) {
  10473. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10474. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10475. imux->items[i].index,
  10476. HDA_AMP_MUTE, v);
  10477. }
  10478. *cur_val = idx;
  10479. return 1;
  10480. }
  10481. /*
  10482. * 2ch mode
  10483. */
  10484. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10485. { 2, NULL }
  10486. };
  10487. /*
  10488. * 2ch mode
  10489. */
  10490. static struct hda_verb alc662_3ST_ch2_init[] = {
  10491. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10492. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10493. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10494. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10495. { } /* end */
  10496. };
  10497. /*
  10498. * 6ch mode
  10499. */
  10500. static struct hda_verb alc662_3ST_ch6_init[] = {
  10501. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10502. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10503. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10504. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10505. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10506. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10507. { } /* end */
  10508. };
  10509. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10510. { 2, alc662_3ST_ch2_init },
  10511. { 6, alc662_3ST_ch6_init },
  10512. };
  10513. /*
  10514. * 2ch mode
  10515. */
  10516. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10517. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10518. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10519. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10520. { } /* end */
  10521. };
  10522. /*
  10523. * 6ch mode
  10524. */
  10525. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10526. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10527. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10528. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10529. { } /* end */
  10530. };
  10531. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10532. { 2, alc662_sixstack_ch6_init },
  10533. { 6, alc662_sixstack_ch8_init },
  10534. };
  10535. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10536. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10537. */
  10538. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10539. /* output mixer control */
  10540. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10541. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10542. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10543. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10544. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10545. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10546. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10547. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10548. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10549. /*Input mixer control */
  10550. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10551. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10552. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10553. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10554. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10555. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10556. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10557. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10558. /* Capture mixer control */
  10559. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10560. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10561. {
  10562. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10563. .name = "Capture Source",
  10564. .count = 1,
  10565. .info = alc_mux_enum_info,
  10566. .get = alc_mux_enum_get,
  10567. .put = alc_mux_enum_put,
  10568. },
  10569. { } /* end */
  10570. };
  10571. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10572. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10573. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10574. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10575. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10576. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10577. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10578. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10579. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10580. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10581. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10582. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10583. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10584. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10585. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10586. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10587. {
  10588. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10589. /* .name = "Capture Source", */
  10590. .name = "Input Source",
  10591. .count = 1,
  10592. .info = alc662_mux_enum_info,
  10593. .get = alc662_mux_enum_get,
  10594. .put = alc662_mux_enum_put,
  10595. },
  10596. { } /* end */
  10597. };
  10598. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10599. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10600. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10601. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10602. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10603. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10604. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10605. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10606. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10607. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10608. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10609. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10610. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10611. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10612. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10613. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10614. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10615. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10616. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10617. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10618. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10619. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10620. {
  10621. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10622. /* .name = "Capture Source", */
  10623. .name = "Input Source",
  10624. .count = 1,
  10625. .info = alc662_mux_enum_info,
  10626. .get = alc662_mux_enum_get,
  10627. .put = alc662_mux_enum_put,
  10628. },
  10629. { } /* end */
  10630. };
  10631. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10632. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10633. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10634. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10635. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10636. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10637. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10638. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10639. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10640. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10641. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10642. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10643. {
  10644. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10645. /* .name = "Capture Source", */
  10646. .name = "Input Source",
  10647. .count = 1,
  10648. .info = alc662_mux_enum_info,
  10649. .get = alc662_mux_enum_get,
  10650. .put = alc662_mux_enum_put,
  10651. },
  10652. { } /* end */
  10653. };
  10654. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  10655. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10656. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10657. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10658. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  10659. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10660. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10661. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  10662. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10663. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10664. { } /* end */
  10665. };
  10666. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10667. {
  10668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10669. .name = "Channel Mode",
  10670. .info = alc_ch_mode_info,
  10671. .get = alc_ch_mode_get,
  10672. .put = alc_ch_mode_put,
  10673. },
  10674. { } /* end */
  10675. };
  10676. static struct hda_verb alc662_init_verbs[] = {
  10677. /* ADC: mute amp left and right */
  10678. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10679. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10680. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10686. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10687. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10688. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10689. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10690. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10692. /* Front Pin: output 0 (0x0c) */
  10693. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10694. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10695. /* Rear Pin: output 1 (0x0d) */
  10696. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10697. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10698. /* CLFE Pin: output 2 (0x0e) */
  10699. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10700. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10701. /* Mic (rear) pin: input vref at 80% */
  10702. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10703. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10704. /* Front Mic pin: input vref at 80% */
  10705. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10706. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10707. /* Line In pin: input */
  10708. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10709. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10710. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10711. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10712. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10713. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10714. /* CD pin widget for input */
  10715. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10716. /* FIXME: use matrix-type input source selection */
  10717. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10718. /* Input mixer */
  10719. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10720. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10721. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10722. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10726. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10727. { }
  10728. };
  10729. static struct hda_verb alc662_sue_init_verbs[] = {
  10730. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10731. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10732. {}
  10733. };
  10734. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  10735. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10736. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10737. {}
  10738. };
  10739. /*
  10740. * generic initialization of ADC, input mixers and output mixers
  10741. */
  10742. static struct hda_verb alc662_auto_init_verbs[] = {
  10743. /*
  10744. * Unmute ADC and set the default input to mic-in
  10745. */
  10746. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10747. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10748. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10749. * mixer widget
  10750. * Note: PASD motherboards uses the Line In 2 as the input for front
  10751. * panel mic (mic 2)
  10752. */
  10753. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10754. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10755. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10756. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10759. /*
  10760. * Set up output mixers (0x0c - 0x0f)
  10761. */
  10762. /* set vol=0 to output mixers */
  10763. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10764. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10765. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10766. /* set up input amps for analog loopback */
  10767. /* Amp Indices: DAC = 0, mixer = 1 */
  10768. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10769. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10770. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10771. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10772. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10773. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10774. /* FIXME: use matrix-type input source selection */
  10775. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10776. /* Input mixer */
  10777. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10778. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10779. { }
  10780. };
  10781. /* capture mixer elements */
  10782. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10783. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10784. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10785. {
  10786. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10787. /* The multiple "Capture Source" controls confuse alsamixer
  10788. * So call somewhat different..
  10789. * FIXME: the controls appear in the "playback" view!
  10790. */
  10791. /* .name = "Capture Source", */
  10792. .name = "Input Source",
  10793. .count = 1,
  10794. .info = alc882_mux_enum_info,
  10795. .get = alc882_mux_enum_get,
  10796. .put = alc882_mux_enum_put,
  10797. },
  10798. { } /* end */
  10799. };
  10800. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10801. {
  10802. unsigned int present;
  10803. unsigned char bits;
  10804. present = snd_hda_codec_read(codec, 0x14, 0,
  10805. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10806. bits = present ? HDA_AMP_MUTE : 0;
  10807. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10808. HDA_AMP_MUTE, bits);
  10809. }
  10810. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10811. {
  10812. unsigned int present;
  10813. unsigned char bits;
  10814. present = snd_hda_codec_read(codec, 0x1b, 0,
  10815. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10816. bits = present ? HDA_AMP_MUTE : 0;
  10817. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10818. HDA_AMP_MUTE, bits);
  10819. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10820. HDA_AMP_MUTE, bits);
  10821. }
  10822. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10823. unsigned int res)
  10824. {
  10825. if ((res >> 26) == ALC880_HP_EVENT)
  10826. alc662_lenovo_101e_all_automute(codec);
  10827. if ((res >> 26) == ALC880_FRONT_EVENT)
  10828. alc662_lenovo_101e_ispeaker_automute(codec);
  10829. }
  10830. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  10831. {
  10832. unsigned int present;
  10833. present = snd_hda_codec_read(codec, 0x18, 0,
  10834. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10835. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10836. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10837. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10838. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10839. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10840. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10841. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10842. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10843. }
  10844. /* unsolicited event for HP jack sensing */
  10845. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  10846. unsigned int res)
  10847. {
  10848. if ((res >> 26) == ALC880_HP_EVENT)
  10849. alc262_hippo1_automute( codec );
  10850. if ((res >> 26) == ALC880_MIC_EVENT)
  10851. alc662_eeepc_mic_automute(codec);
  10852. }
  10853. static void alc662_eeepc_inithook(struct hda_codec *codec)
  10854. {
  10855. alc262_hippo1_automute( codec );
  10856. alc662_eeepc_mic_automute(codec);
  10857. }
  10858. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10859. #define alc662_loopbacks alc880_loopbacks
  10860. #endif
  10861. /* pcm configuration: identiacal with ALC880 */
  10862. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10863. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10864. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10865. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10866. /*
  10867. * configuration and preset
  10868. */
  10869. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10870. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10871. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10872. [ALC662_3ST_6ch] = "3stack-6ch",
  10873. [ALC662_5ST_DIG] = "6stack-dig",
  10874. [ALC662_LENOVO_101E] = "lenovo-101e",
  10875. [ALC662_AUTO] = "auto",
  10876. };
  10877. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10878. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10879. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  10880. {}
  10881. };
  10882. static struct alc_config_preset alc662_presets[] = {
  10883. [ALC662_3ST_2ch_DIG] = {
  10884. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  10885. .init_verbs = { alc662_init_verbs },
  10886. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10887. .dac_nids = alc662_dac_nids,
  10888. .dig_out_nid = ALC662_DIGOUT_NID,
  10889. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10890. .adc_nids = alc662_adc_nids,
  10891. .dig_in_nid = ALC662_DIGIN_NID,
  10892. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10893. .channel_mode = alc662_3ST_2ch_modes,
  10894. .input_mux = &alc662_capture_source,
  10895. },
  10896. [ALC662_3ST_6ch_DIG] = {
  10897. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10898. alc662_capture_mixer },
  10899. .init_verbs = { alc662_init_verbs },
  10900. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10901. .dac_nids = alc662_dac_nids,
  10902. .dig_out_nid = ALC662_DIGOUT_NID,
  10903. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10904. .adc_nids = alc662_adc_nids,
  10905. .dig_in_nid = ALC662_DIGIN_NID,
  10906. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10907. .channel_mode = alc662_3ST_6ch_modes,
  10908. .need_dac_fix = 1,
  10909. .input_mux = &alc662_capture_source,
  10910. },
  10911. [ALC662_3ST_6ch] = {
  10912. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10913. alc662_capture_mixer },
  10914. .init_verbs = { alc662_init_verbs },
  10915. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10916. .dac_nids = alc662_dac_nids,
  10917. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10918. .adc_nids = alc662_adc_nids,
  10919. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10920. .channel_mode = alc662_3ST_6ch_modes,
  10921. .need_dac_fix = 1,
  10922. .input_mux = &alc662_capture_source,
  10923. },
  10924. [ALC662_5ST_DIG] = {
  10925. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  10926. alc662_capture_mixer },
  10927. .init_verbs = { alc662_init_verbs },
  10928. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10929. .dac_nids = alc662_dac_nids,
  10930. .dig_out_nid = ALC662_DIGOUT_NID,
  10931. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10932. .adc_nids = alc662_adc_nids,
  10933. .dig_in_nid = ALC662_DIGIN_NID,
  10934. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10935. .channel_mode = alc662_5stack_modes,
  10936. .input_mux = &alc662_capture_source,
  10937. },
  10938. [ALC662_LENOVO_101E] = {
  10939. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  10940. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10941. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10942. .dac_nids = alc662_dac_nids,
  10943. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10944. .adc_nids = alc662_adc_nids,
  10945. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10946. .channel_mode = alc662_3ST_2ch_modes,
  10947. .input_mux = &alc662_lenovo_101e_capture_source,
  10948. .unsol_event = alc662_lenovo_101e_unsol_event,
  10949. .init_hook = alc662_lenovo_101e_all_automute,
  10950. },
  10951. [ALC662_ASUS_EEEPC_P701] = {
  10952. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  10953. .init_verbs = { alc662_init_verbs,
  10954. alc662_eeepc_sue_init_verbs },
  10955. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10956. .dac_nids = alc662_dac_nids,
  10957. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10958. .adc_nids = alc662_adc_nids,
  10959. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10960. .channel_mode = alc662_3ST_2ch_modes,
  10961. .input_mux = &alc662_eeepc_capture_source,
  10962. .unsol_event = alc662_eeepc_unsol_event,
  10963. .init_hook = alc662_eeepc_inithook,
  10964. },
  10965. };
  10966. /*
  10967. * BIOS auto configuration
  10968. */
  10969. /* add playback controls from the parsed DAC table */
  10970. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10971. const struct auto_pin_cfg *cfg)
  10972. {
  10973. char name[32];
  10974. static const char *chname[4] = {
  10975. "Front", "Surround", NULL /*CLFE*/, "Side"
  10976. };
  10977. hda_nid_t nid;
  10978. int i, err;
  10979. for (i = 0; i < cfg->line_outs; i++) {
  10980. if (!spec->multiout.dac_nids[i])
  10981. continue;
  10982. nid = alc880_idx_to_dac(i);
  10983. if (i == 2) {
  10984. /* Center/LFE */
  10985. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10986. "Center Playback Volume",
  10987. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10988. HDA_OUTPUT));
  10989. if (err < 0)
  10990. return err;
  10991. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10992. "LFE Playback Volume",
  10993. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10994. HDA_OUTPUT));
  10995. if (err < 0)
  10996. return err;
  10997. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10998. "Center Playback Switch",
  10999. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11000. HDA_INPUT));
  11001. if (err < 0)
  11002. return err;
  11003. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11004. "LFE Playback Switch",
  11005. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11006. HDA_INPUT));
  11007. if (err < 0)
  11008. return err;
  11009. } else {
  11010. sprintf(name, "%s Playback Volume", chname[i]);
  11011. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11012. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11013. HDA_OUTPUT));
  11014. if (err < 0)
  11015. return err;
  11016. sprintf(name, "%s Playback Switch", chname[i]);
  11017. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11018. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11019. HDA_INPUT));
  11020. if (err < 0)
  11021. return err;
  11022. }
  11023. }
  11024. return 0;
  11025. }
  11026. /* add playback controls for speaker and HP outputs */
  11027. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11028. const char *pfx)
  11029. {
  11030. hda_nid_t nid;
  11031. int err;
  11032. char name[32];
  11033. if (!pin)
  11034. return 0;
  11035. if (alc880_is_fixed_pin(pin)) {
  11036. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11037. /* printk("DAC nid=%x\n",nid); */
  11038. /* specify the DAC as the extra output */
  11039. if (!spec->multiout.hp_nid)
  11040. spec->multiout.hp_nid = nid;
  11041. else
  11042. spec->multiout.extra_out_nid[0] = nid;
  11043. /* control HP volume/switch on the output mixer amp */
  11044. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11045. sprintf(name, "%s Playback Volume", pfx);
  11046. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11047. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11048. if (err < 0)
  11049. return err;
  11050. sprintf(name, "%s Playback Switch", pfx);
  11051. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11052. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11053. if (err < 0)
  11054. return err;
  11055. } else if (alc880_is_multi_pin(pin)) {
  11056. /* set manual connection */
  11057. /* we have only a switch on HP-out PIN */
  11058. sprintf(name, "%s Playback Switch", pfx);
  11059. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11060. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11061. if (err < 0)
  11062. return err;
  11063. }
  11064. return 0;
  11065. }
  11066. /* create playback/capture controls for input pins */
  11067. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11068. const struct auto_pin_cfg *cfg)
  11069. {
  11070. struct hda_input_mux *imux = &spec->private_imux;
  11071. int i, err, idx;
  11072. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11073. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11074. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11075. err = new_analog_input(spec, cfg->input_pins[i],
  11076. auto_pin_cfg_labels[i],
  11077. idx, 0x0b);
  11078. if (err < 0)
  11079. return err;
  11080. imux->items[imux->num_items].label =
  11081. auto_pin_cfg_labels[i];
  11082. imux->items[imux->num_items].index =
  11083. alc880_input_pin_idx(cfg->input_pins[i]);
  11084. imux->num_items++;
  11085. }
  11086. }
  11087. return 0;
  11088. }
  11089. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11090. hda_nid_t nid, int pin_type,
  11091. int dac_idx)
  11092. {
  11093. /* set as output */
  11094. snd_hda_codec_write(codec, nid, 0,
  11095. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11096. snd_hda_codec_write(codec, nid, 0,
  11097. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11098. /* need the manual connection? */
  11099. if (alc880_is_multi_pin(nid)) {
  11100. struct alc_spec *spec = codec->spec;
  11101. int idx = alc880_multi_pin_idx(nid);
  11102. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11103. AC_VERB_SET_CONNECT_SEL,
  11104. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11105. }
  11106. }
  11107. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11108. {
  11109. struct alc_spec *spec = codec->spec;
  11110. int i;
  11111. for (i = 0; i <= HDA_SIDE; i++) {
  11112. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11113. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11114. if (nid)
  11115. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11116. i);
  11117. }
  11118. }
  11119. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11120. {
  11121. struct alc_spec *spec = codec->spec;
  11122. hda_nid_t pin;
  11123. pin = spec->autocfg.hp_pins[0];
  11124. if (pin) /* connect to front */
  11125. /* use dac 0 */
  11126. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11127. }
  11128. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11129. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11130. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11131. {
  11132. struct alc_spec *spec = codec->spec;
  11133. int i;
  11134. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11135. hda_nid_t nid = spec->autocfg.input_pins[i];
  11136. if (alc662_is_input_pin(nid)) {
  11137. snd_hda_codec_write(codec, nid, 0,
  11138. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11139. (i <= AUTO_PIN_FRONT_MIC ?
  11140. PIN_VREF80 : PIN_IN));
  11141. if (nid != ALC662_PIN_CD_NID)
  11142. snd_hda_codec_write(codec, nid, 0,
  11143. AC_VERB_SET_AMP_GAIN_MUTE,
  11144. AMP_OUT_MUTE);
  11145. }
  11146. }
  11147. }
  11148. static int alc662_parse_auto_config(struct hda_codec *codec)
  11149. {
  11150. struct alc_spec *spec = codec->spec;
  11151. int err;
  11152. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11153. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11154. alc662_ignore);
  11155. if (err < 0)
  11156. return err;
  11157. if (!spec->autocfg.line_outs)
  11158. return 0; /* can't find valid BIOS pin config */
  11159. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11160. if (err < 0)
  11161. return err;
  11162. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11163. if (err < 0)
  11164. return err;
  11165. err = alc662_auto_create_extra_out(spec,
  11166. spec->autocfg.speaker_pins[0],
  11167. "Speaker");
  11168. if (err < 0)
  11169. return err;
  11170. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11171. "Headphone");
  11172. if (err < 0)
  11173. return err;
  11174. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11175. if (err < 0)
  11176. return err;
  11177. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11178. if (spec->autocfg.dig_out_pin)
  11179. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11180. if (spec->kctl_alloc)
  11181. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11182. spec->num_mux_defs = 1;
  11183. spec->input_mux = &spec->private_imux;
  11184. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11185. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11186. spec->num_mixers++;
  11187. return 1;
  11188. }
  11189. /* additional initialization for auto-configuration model */
  11190. static void alc662_auto_init(struct hda_codec *codec)
  11191. {
  11192. alc662_auto_init_multi_out(codec);
  11193. alc662_auto_init_hp_out(codec);
  11194. alc662_auto_init_analog_input(codec);
  11195. }
  11196. static int patch_alc662(struct hda_codec *codec)
  11197. {
  11198. struct alc_spec *spec;
  11199. int err, board_config;
  11200. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11201. if (!spec)
  11202. return -ENOMEM;
  11203. codec->spec = spec;
  11204. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11205. alc662_models,
  11206. alc662_cfg_tbl);
  11207. if (board_config < 0) {
  11208. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11209. "trying auto-probe from BIOS...\n");
  11210. board_config = ALC662_AUTO;
  11211. }
  11212. if (board_config == ALC662_AUTO) {
  11213. /* automatic parse from the BIOS config */
  11214. err = alc662_parse_auto_config(codec);
  11215. if (err < 0) {
  11216. alc_free(codec);
  11217. return err;
  11218. } else if (!err) {
  11219. printk(KERN_INFO
  11220. "hda_codec: Cannot set up configuration "
  11221. "from BIOS. Using base mode...\n");
  11222. board_config = ALC662_3ST_2ch_DIG;
  11223. }
  11224. }
  11225. if (board_config != ALC662_AUTO)
  11226. setup_preset(spec, &alc662_presets[board_config]);
  11227. spec->stream_name_analog = "ALC662 Analog";
  11228. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11229. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11230. spec->stream_name_digital = "ALC662 Digital";
  11231. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11232. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11233. if (!spec->adc_nids && spec->input_mux) {
  11234. spec->adc_nids = alc662_adc_nids;
  11235. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11236. }
  11237. codec->patch_ops = alc_patch_ops;
  11238. if (board_config == ALC662_AUTO)
  11239. spec->init_hook = alc662_auto_init;
  11240. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11241. if (!spec->loopback.amplist)
  11242. spec->loopback.amplist = alc662_loopbacks;
  11243. #endif
  11244. return 0;
  11245. }
  11246. /*
  11247. * patch entries
  11248. */
  11249. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11250. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11251. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11252. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11253. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11254. .patch = patch_alc861 },
  11255. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11256. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11257. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11258. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11259. .patch = patch_alc883 },
  11260. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11261. .patch = patch_alc662 },
  11262. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11263. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11264. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11265. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11266. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11267. {} /* terminator */
  11268. };