patch_realtek.c 432 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127
  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_HP_TC_T5735,
  91. ALC262_BENQ_ED8,
  92. ALC262_SONY_ASSAMD,
  93. ALC262_BENQ_T31,
  94. ALC262_ULTRA,
  95. ALC262_AUTO,
  96. ALC262_MODEL_LAST /* last tag */
  97. };
  98. /* ALC268 models */
  99. enum {
  100. ALC268_3ST,
  101. ALC268_TOSHIBA,
  102. ALC268_ACER,
  103. ALC268_AUTO,
  104. ALC268_MODEL_LAST /* last tag */
  105. };
  106. /* ALC269 models */
  107. enum {
  108. ALC269_BASIC,
  109. ALC269_AUTO,
  110. ALC269_MODEL_LAST /* last tag */
  111. };
  112. /* ALC861 models */
  113. enum {
  114. ALC861_3ST,
  115. ALC660_3ST,
  116. ALC861_3ST_DIG,
  117. ALC861_6ST_DIG,
  118. ALC861_UNIWILL_M31,
  119. ALC861_TOSHIBA,
  120. ALC861_ASUS,
  121. ALC861_ASUS_LAPTOP,
  122. ALC861_AUTO,
  123. ALC861_MODEL_LAST,
  124. };
  125. /* ALC861-VD models */
  126. enum {
  127. ALC660VD_3ST,
  128. ALC660VD_3ST_DIG,
  129. ALC861VD_3ST,
  130. ALC861VD_3ST_DIG,
  131. ALC861VD_6ST_DIG,
  132. ALC861VD_LENOVO,
  133. ALC861VD_DALLAS,
  134. ALC861VD_HP,
  135. ALC861VD_AUTO,
  136. ALC861VD_MODEL_LAST,
  137. };
  138. /* ALC662 models */
  139. enum {
  140. ALC662_3ST_2ch_DIG,
  141. ALC662_3ST_6ch_DIG,
  142. ALC662_3ST_6ch,
  143. ALC662_5ST_DIG,
  144. ALC662_LENOVO_101E,
  145. ALC662_ASUS_EEEPC_P701,
  146. ALC662_AUTO,
  147. ALC662_MODEL_LAST,
  148. };
  149. /* ALC882 models */
  150. enum {
  151. ALC882_3ST_DIG,
  152. ALC882_6ST_DIG,
  153. ALC882_ARIMA,
  154. ALC882_W2JC,
  155. ALC882_TARGA,
  156. ALC882_ASUS_A7J,
  157. ALC882_ASUS_A7M,
  158. ALC885_MACPRO,
  159. ALC885_MBP3,
  160. ALC885_IMAC24,
  161. ALC882_AUTO,
  162. ALC882_MODEL_LAST,
  163. };
  164. /* ALC883 models */
  165. enum {
  166. ALC883_3ST_2ch_DIG,
  167. ALC883_3ST_6ch_DIG,
  168. ALC883_3ST_6ch,
  169. ALC883_6ST_DIG,
  170. ALC883_TARGA_DIG,
  171. ALC883_TARGA_2ch_DIG,
  172. ALC883_ACER,
  173. ALC883_ACER_ASPIRE,
  174. ALC883_MEDION,
  175. ALC883_MEDION_MD2,
  176. ALC883_LAPTOP_EAPD,
  177. ALC883_LENOVO_101E_2ch,
  178. ALC883_LENOVO_NB0763,
  179. ALC888_LENOVO_MS7195_DIG,
  180. ALC883_HAIER_W66,
  181. ALC888_6ST_HP,
  182. ALC888_3ST_HP,
  183. ALC883_MITAC,
  184. ALC883_AUTO,
  185. ALC883_MODEL_LAST,
  186. };
  187. /* for GPIO Poll */
  188. #define GPIO_MASK 0x03
  189. struct alc_spec {
  190. /* codec parameterization */
  191. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  192. unsigned int num_mixers;
  193. const struct hda_verb *init_verbs[5]; /* initialization verbs
  194. * don't forget NULL
  195. * termination!
  196. */
  197. unsigned int num_init_verbs;
  198. char *stream_name_analog; /* analog PCM stream */
  199. struct hda_pcm_stream *stream_analog_playback;
  200. struct hda_pcm_stream *stream_analog_capture;
  201. char *stream_name_digital; /* digital PCM stream */
  202. struct hda_pcm_stream *stream_digital_playback;
  203. struct hda_pcm_stream *stream_digital_capture;
  204. /* playback */
  205. struct hda_multi_out multiout; /* playback set-up
  206. * max_channels, dacs must be set
  207. * dig_out_nid and hp_nid are optional
  208. */
  209. /* capture */
  210. unsigned int num_adc_nids;
  211. hda_nid_t *adc_nids;
  212. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  213. /* capture source */
  214. unsigned int num_mux_defs;
  215. const struct hda_input_mux *input_mux;
  216. unsigned int cur_mux[3];
  217. /* channel model */
  218. const struct hda_channel_mode *channel_mode;
  219. int num_channel_mode;
  220. int need_dac_fix;
  221. /* PCM information */
  222. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  223. /* dynamic controls, init_verbs and input_mux */
  224. struct auto_pin_cfg autocfg;
  225. unsigned int num_kctl_alloc, num_kctl_used;
  226. struct snd_kcontrol_new *kctl_alloc;
  227. struct hda_input_mux private_imux;
  228. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  229. /* hooks */
  230. void (*init_hook)(struct hda_codec *codec);
  231. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  232. /* for pin sensing */
  233. unsigned int sense_updated: 1;
  234. unsigned int jack_present: 1;
  235. #ifdef CONFIG_SND_HDA_POWER_SAVE
  236. struct hda_loopback_check loopback;
  237. #endif
  238. };
  239. /*
  240. * configuration template - to be copied to the spec instance
  241. */
  242. struct alc_config_preset {
  243. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  244. * with spec
  245. */
  246. const struct hda_verb *init_verbs[5];
  247. unsigned int num_dacs;
  248. hda_nid_t *dac_nids;
  249. hda_nid_t dig_out_nid; /* optional */
  250. hda_nid_t hp_nid; /* optional */
  251. unsigned int num_adc_nids;
  252. hda_nid_t *adc_nids;
  253. hda_nid_t dig_in_nid;
  254. unsigned int num_channel_mode;
  255. const struct hda_channel_mode *channel_mode;
  256. int need_dac_fix;
  257. unsigned int num_mux_defs;
  258. const struct hda_input_mux *input_mux;
  259. void (*unsol_event)(struct hda_codec *, unsigned int);
  260. void (*init_hook)(struct hda_codec *);
  261. #ifdef CONFIG_SND_HDA_POWER_SAVE
  262. struct hda_amp_list *loopbacks;
  263. #endif
  264. };
  265. /*
  266. * input MUX handling
  267. */
  268. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  269. struct snd_ctl_elem_info *uinfo)
  270. {
  271. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  272. struct alc_spec *spec = codec->spec;
  273. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  274. if (mux_idx >= spec->num_mux_defs)
  275. mux_idx = 0;
  276. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  277. }
  278. static int alc_mux_enum_get(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. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  285. return 0;
  286. }
  287. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  288. struct snd_ctl_elem_value *ucontrol)
  289. {
  290. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  291. struct alc_spec *spec = codec->spec;
  292. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  293. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  294. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  295. spec->adc_nids[adc_idx],
  296. &spec->cur_mux[adc_idx]);
  297. }
  298. /*
  299. * channel mode setting
  300. */
  301. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  302. struct snd_ctl_elem_info *uinfo)
  303. {
  304. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  305. struct alc_spec *spec = codec->spec;
  306. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  307. spec->num_channel_mode);
  308. }
  309. static int alc_ch_mode_get(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. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  315. spec->num_channel_mode,
  316. spec->multiout.max_channels);
  317. }
  318. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  319. struct snd_ctl_elem_value *ucontrol)
  320. {
  321. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  322. struct alc_spec *spec = codec->spec;
  323. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  324. spec->num_channel_mode,
  325. &spec->multiout.max_channels);
  326. if (err >= 0 && spec->need_dac_fix)
  327. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  328. return err;
  329. }
  330. /*
  331. * Control the mode of pin widget settings via the mixer. "pc" is used
  332. * instead of "%" to avoid consequences of accidently treating the % as
  333. * being part of a format specifier. Maximum allowed length of a value is
  334. * 63 characters plus NULL terminator.
  335. *
  336. * Note: some retasking pin complexes seem to ignore requests for input
  337. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  338. * are requested. Therefore order this list so that this behaviour will not
  339. * cause problems when mixer clients move through the enum sequentially.
  340. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  341. * March 2006.
  342. */
  343. static char *alc_pin_mode_names[] = {
  344. "Mic 50pc bias", "Mic 80pc bias",
  345. "Line in", "Line out", "Headphone out",
  346. };
  347. static unsigned char alc_pin_mode_values[] = {
  348. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  349. };
  350. /* The control can present all 5 options, or it can limit the options based
  351. * in the pin being assumed to be exclusively an input or an output pin. In
  352. * addition, "input" pins may or may not process the mic bias option
  353. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  354. * accept requests for bias as of chip versions up to March 2006) and/or
  355. * wiring in the computer.
  356. */
  357. #define ALC_PIN_DIR_IN 0x00
  358. #define ALC_PIN_DIR_OUT 0x01
  359. #define ALC_PIN_DIR_INOUT 0x02
  360. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  361. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  362. /* Info about the pin modes supported by the different pin direction modes.
  363. * For each direction the minimum and maximum values are given.
  364. */
  365. static signed char alc_pin_mode_dir_info[5][2] = {
  366. { 0, 2 }, /* ALC_PIN_DIR_IN */
  367. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  368. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  369. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  370. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  371. };
  372. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  373. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  374. #define alc_pin_mode_n_items(_dir) \
  375. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  376. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  377. struct snd_ctl_elem_info *uinfo)
  378. {
  379. unsigned int item_num = uinfo->value.enumerated.item;
  380. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  381. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  382. uinfo->count = 1;
  383. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  384. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  385. item_num = alc_pin_mode_min(dir);
  386. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  387. return 0;
  388. }
  389. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  390. struct snd_ctl_elem_value *ucontrol)
  391. {
  392. unsigned int i;
  393. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  394. hda_nid_t nid = kcontrol->private_value & 0xffff;
  395. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  396. long *valp = ucontrol->value.integer.value;
  397. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  398. AC_VERB_GET_PIN_WIDGET_CONTROL,
  399. 0x00);
  400. /* Find enumerated value for current pinctl setting */
  401. i = alc_pin_mode_min(dir);
  402. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  403. i++;
  404. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  405. return 0;
  406. }
  407. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  408. struct snd_ctl_elem_value *ucontrol)
  409. {
  410. signed int change;
  411. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  412. hda_nid_t nid = kcontrol->private_value & 0xffff;
  413. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  414. long val = *ucontrol->value.integer.value;
  415. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  416. AC_VERB_GET_PIN_WIDGET_CONTROL,
  417. 0x00);
  418. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  419. val = alc_pin_mode_min(dir);
  420. change = pinctl != alc_pin_mode_values[val];
  421. if (change) {
  422. /* Set pin mode to that requested */
  423. snd_hda_codec_write_cache(codec, nid, 0,
  424. AC_VERB_SET_PIN_WIDGET_CONTROL,
  425. alc_pin_mode_values[val]);
  426. /* Also enable the retasking pin's input/output as required
  427. * for the requested pin mode. Enum values of 2 or less are
  428. * input modes.
  429. *
  430. * Dynamically switching the input/output buffers probably
  431. * reduces noise slightly (particularly on input) so we'll
  432. * do it. However, having both input and output buffers
  433. * enabled simultaneously doesn't seem to be problematic if
  434. * this turns out to be necessary in the future.
  435. */
  436. if (val <= 2) {
  437. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  438. HDA_AMP_MUTE, HDA_AMP_MUTE);
  439. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  440. HDA_AMP_MUTE, 0);
  441. } else {
  442. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  443. HDA_AMP_MUTE, HDA_AMP_MUTE);
  444. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  445. HDA_AMP_MUTE, 0);
  446. }
  447. }
  448. return change;
  449. }
  450. #define ALC_PIN_MODE(xname, nid, dir) \
  451. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  452. .info = alc_pin_mode_info, \
  453. .get = alc_pin_mode_get, \
  454. .put = alc_pin_mode_put, \
  455. .private_value = nid | (dir<<16) }
  456. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  457. * together using a mask with more than one bit set. This control is
  458. * currently used only by the ALC260 test model. At this stage they are not
  459. * needed for any "production" models.
  460. */
  461. #ifdef CONFIG_SND_DEBUG
  462. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  463. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  464. struct snd_ctl_elem_value *ucontrol)
  465. {
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long *valp = ucontrol->value.integer.value;
  470. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_GPIO_DATA, 0x00);
  472. *valp = (val & mask) != 0;
  473. return 0;
  474. }
  475. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  476. struct snd_ctl_elem_value *ucontrol)
  477. {
  478. signed int change;
  479. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  480. hda_nid_t nid = kcontrol->private_value & 0xffff;
  481. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  482. long val = *ucontrol->value.integer.value;
  483. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  484. AC_VERB_GET_GPIO_DATA,
  485. 0x00);
  486. /* Set/unset the masked GPIO bit(s) as needed */
  487. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  488. if (val == 0)
  489. gpio_data &= ~mask;
  490. else
  491. gpio_data |= mask;
  492. snd_hda_codec_write_cache(codec, nid, 0,
  493. AC_VERB_SET_GPIO_DATA, gpio_data);
  494. return change;
  495. }
  496. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  497. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  498. .info = alc_gpio_data_info, \
  499. .get = alc_gpio_data_get, \
  500. .put = alc_gpio_data_put, \
  501. .private_value = nid | (mask<<16) }
  502. #endif /* CONFIG_SND_DEBUG */
  503. /* A switch control to allow the enabling of the digital IO pins on the
  504. * ALC260. This is incredibly simplistic; the intention of this control is
  505. * to provide something in the test model allowing digital outputs to be
  506. * identified if present. If models are found which can utilise these
  507. * outputs a more complete mixer control can be devised for those models if
  508. * necessary.
  509. */
  510. #ifdef CONFIG_SND_DEBUG
  511. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  512. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  513. struct snd_ctl_elem_value *ucontrol)
  514. {
  515. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  516. hda_nid_t nid = kcontrol->private_value & 0xffff;
  517. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  518. long *valp = ucontrol->value.integer.value;
  519. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  520. AC_VERB_GET_DIGI_CONVERT_1, 0x00);
  521. *valp = (val & mask) != 0;
  522. return 0;
  523. }
  524. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  525. struct snd_ctl_elem_value *ucontrol)
  526. {
  527. signed int change;
  528. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  529. hda_nid_t nid = kcontrol->private_value & 0xffff;
  530. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  531. long val = *ucontrol->value.integer.value;
  532. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  533. AC_VERB_GET_DIGI_CONVERT_1,
  534. 0x00);
  535. /* Set/unset the masked control bit(s) as needed */
  536. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  537. if (val==0)
  538. ctrl_data &= ~mask;
  539. else
  540. ctrl_data |= mask;
  541. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  542. ctrl_data);
  543. return change;
  544. }
  545. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  546. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  547. .info = alc_spdif_ctrl_info, \
  548. .get = alc_spdif_ctrl_get, \
  549. .put = alc_spdif_ctrl_put, \
  550. .private_value = nid | (mask<<16) }
  551. #endif /* CONFIG_SND_DEBUG */
  552. /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
  553. * Again, this is only used in the ALC26x test models to help identify when
  554. * the EAPD line must be asserted for features to work.
  555. */
  556. #ifdef CONFIG_SND_DEBUG
  557. #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
  558. static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
  559. struct snd_ctl_elem_value *ucontrol)
  560. {
  561. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  562. hda_nid_t nid = kcontrol->private_value & 0xffff;
  563. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  564. long *valp = ucontrol->value.integer.value;
  565. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  566. AC_VERB_GET_EAPD_BTLENABLE, 0x00);
  567. *valp = (val & mask) != 0;
  568. return 0;
  569. }
  570. static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
  571. struct snd_ctl_elem_value *ucontrol)
  572. {
  573. int change;
  574. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  575. hda_nid_t nid = kcontrol->private_value & 0xffff;
  576. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  577. long val = *ucontrol->value.integer.value;
  578. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  579. AC_VERB_GET_EAPD_BTLENABLE,
  580. 0x00);
  581. /* Set/unset the masked control bit(s) as needed */
  582. change = (!val ? 0 : mask) != (ctrl_data & mask);
  583. if (!val)
  584. ctrl_data &= ~mask;
  585. else
  586. ctrl_data |= mask;
  587. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
  588. ctrl_data);
  589. return change;
  590. }
  591. #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
  592. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  593. .info = alc_eapd_ctrl_info, \
  594. .get = alc_eapd_ctrl_get, \
  595. .put = alc_eapd_ctrl_put, \
  596. .private_value = nid | (mask<<16) }
  597. #endif /* CONFIG_SND_DEBUG */
  598. /*
  599. * set up from the preset table
  600. */
  601. static void setup_preset(struct alc_spec *spec,
  602. const struct alc_config_preset *preset)
  603. {
  604. int i;
  605. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  606. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  607. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  608. i++)
  609. spec->init_verbs[spec->num_init_verbs++] =
  610. preset->init_verbs[i];
  611. spec->channel_mode = preset->channel_mode;
  612. spec->num_channel_mode = preset->num_channel_mode;
  613. spec->need_dac_fix = preset->need_dac_fix;
  614. spec->multiout.max_channels = spec->channel_mode[0].channels;
  615. spec->multiout.num_dacs = preset->num_dacs;
  616. spec->multiout.dac_nids = preset->dac_nids;
  617. spec->multiout.dig_out_nid = preset->dig_out_nid;
  618. spec->multiout.hp_nid = preset->hp_nid;
  619. spec->num_mux_defs = preset->num_mux_defs;
  620. if (!spec->num_mux_defs)
  621. spec->num_mux_defs = 1;
  622. spec->input_mux = preset->input_mux;
  623. spec->num_adc_nids = preset->num_adc_nids;
  624. spec->adc_nids = preset->adc_nids;
  625. spec->dig_in_nid = preset->dig_in_nid;
  626. spec->unsol_event = preset->unsol_event;
  627. spec->init_hook = preset->init_hook;
  628. #ifdef CONFIG_SND_HDA_POWER_SAVE
  629. spec->loopback.amplist = preset->loopbacks;
  630. #endif
  631. }
  632. /* Enable GPIO mask and set output */
  633. static struct hda_verb alc_gpio1_init_verbs[] = {
  634. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  635. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  636. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  637. { }
  638. };
  639. static struct hda_verb alc_gpio2_init_verbs[] = {
  640. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  641. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  642. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  643. { }
  644. };
  645. static struct hda_verb alc_gpio3_init_verbs[] = {
  646. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  647. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  648. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  649. { }
  650. };
  651. static void alc_sku_automute(struct hda_codec *codec)
  652. {
  653. struct alc_spec *spec = codec->spec;
  654. unsigned int mute;
  655. unsigned int present;
  656. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  657. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  658. /* need to execute and sync at first */
  659. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  660. present = snd_hda_codec_read(codec, hp_nid, 0,
  661. AC_VERB_GET_PIN_SENSE, 0);
  662. spec->jack_present = (present & 0x80000000) != 0;
  663. if (spec->jack_present) {
  664. /* mute internal speaker */
  665. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  666. HDA_AMP_MUTE, HDA_AMP_MUTE);
  667. } else {
  668. /* unmute internal speaker if necessary */
  669. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  670. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  671. HDA_AMP_MUTE, mute);
  672. }
  673. }
  674. /* unsolicited event for HP jack sensing */
  675. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  676. {
  677. if (codec->vendor_id == 0x10ec0880)
  678. res >>= 28;
  679. else
  680. res >>= 26;
  681. if (res != ALC880_HP_EVENT)
  682. return;
  683. alc_sku_automute(codec);
  684. }
  685. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  686. * 31 ~ 16 : Manufacture ID
  687. * 15 ~ 8 : SKU ID
  688. * 7 ~ 0 : Assembly ID
  689. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  690. */
  691. static void alc_subsystem_id(struct hda_codec *codec,
  692. unsigned int porta, unsigned int porte,
  693. unsigned int portd)
  694. {
  695. unsigned int ass, tmp, i;
  696. unsigned nid;
  697. struct alc_spec *spec = codec->spec;
  698. ass = codec->subsystem_id & 0xffff;
  699. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  700. goto do_sku;
  701. /*
  702. * 31~30 : port conetcivity
  703. * 29~21 : reserve
  704. * 20 : PCBEEP input
  705. * 19~16 : Check sum (15:1)
  706. * 15~1 : Custom
  707. * 0 : override
  708. */
  709. nid = 0x1d;
  710. if (codec->vendor_id == 0x10ec0260)
  711. nid = 0x17;
  712. ass = snd_hda_codec_read(codec, nid, 0,
  713. AC_VERB_GET_CONFIG_DEFAULT, 0);
  714. if (!(ass & 1) && !(ass & 0x100000))
  715. return;
  716. if ((ass >> 30) != 1) /* no physical connection */
  717. return;
  718. /* check sum */
  719. tmp = 0;
  720. for (i = 1; i < 16; i++) {
  721. if ((ass >> i) && 1)
  722. tmp++;
  723. }
  724. if (((ass >> 16) & 0xf) != tmp)
  725. return;
  726. do_sku:
  727. /*
  728. * 0 : override
  729. * 1 : Swap Jack
  730. * 2 : 0 --> Desktop, 1 --> Laptop
  731. * 3~5 : External Amplifier control
  732. * 7~6 : Reserved
  733. */
  734. tmp = (ass & 0x38) >> 3; /* external Amp control */
  735. switch (tmp) {
  736. case 1:
  737. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  738. break;
  739. case 3:
  740. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  741. break;
  742. case 7:
  743. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  744. break;
  745. case 5: /* set EAPD output high */
  746. switch (codec->vendor_id) {
  747. case 0x10ec0260:
  748. snd_hda_codec_write(codec, 0x0f, 0,
  749. AC_VERB_SET_EAPD_BTLENABLE, 2);
  750. snd_hda_codec_write(codec, 0x10, 0,
  751. AC_VERB_SET_EAPD_BTLENABLE, 2);
  752. break;
  753. case 0x10ec0262:
  754. case 0x10ec0267:
  755. case 0x10ec0268:
  756. case 0x10ec0269:
  757. case 0x10ec0862:
  758. case 0x10ec0662:
  759. snd_hda_codec_write(codec, 0x14, 0,
  760. AC_VERB_SET_EAPD_BTLENABLE, 2);
  761. snd_hda_codec_write(codec, 0x15, 0,
  762. AC_VERB_SET_EAPD_BTLENABLE, 2);
  763. break;
  764. }
  765. switch (codec->vendor_id) {
  766. case 0x10ec0260:
  767. snd_hda_codec_write(codec, 0x1a, 0,
  768. AC_VERB_SET_COEF_INDEX, 7);
  769. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  770. AC_VERB_GET_PROC_COEF, 0);
  771. snd_hda_codec_write(codec, 0x1a, 0,
  772. AC_VERB_SET_COEF_INDEX, 7);
  773. snd_hda_codec_write(codec, 0x1a, 0,
  774. AC_VERB_SET_PROC_COEF,
  775. tmp | 0x2010);
  776. break;
  777. case 0x10ec0262:
  778. case 0x10ec0880:
  779. case 0x10ec0882:
  780. case 0x10ec0883:
  781. case 0x10ec0885:
  782. case 0x10ec0888:
  783. snd_hda_codec_write(codec, 0x20, 0,
  784. AC_VERB_SET_COEF_INDEX, 7);
  785. tmp = snd_hda_codec_read(codec, 0x20, 0,
  786. AC_VERB_GET_PROC_COEF, 0);
  787. snd_hda_codec_write(codec, 0x20, 0,
  788. AC_VERB_SET_COEF_INDEX, 7);
  789. snd_hda_codec_write(codec, 0x20, 0,
  790. AC_VERB_SET_PROC_COEF,
  791. tmp | 0x2010);
  792. break;
  793. case 0x10ec0267:
  794. case 0x10ec0268:
  795. snd_hda_codec_write(codec, 0x20, 0,
  796. AC_VERB_SET_COEF_INDEX, 7);
  797. tmp = snd_hda_codec_read(codec, 0x20, 0,
  798. AC_VERB_GET_PROC_COEF, 0);
  799. snd_hda_codec_write(codec, 0x20, 0,
  800. AC_VERB_SET_COEF_INDEX, 7);
  801. snd_hda_codec_write(codec, 0x20, 0,
  802. AC_VERB_SET_PROC_COEF,
  803. tmp | 0x3000);
  804. break;
  805. }
  806. default:
  807. break;
  808. }
  809. /* is laptop and enable the function "Mute internal speaker
  810. * when the external headphone out jack is plugged"
  811. */
  812. if (!(ass & 0x4) || !(ass & 0x8000))
  813. return;
  814. /*
  815. * 10~8 : Jack location
  816. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  817. * 14~13: Resvered
  818. * 15 : 1 --> enable the function "Mute internal speaker
  819. * when the external headphone out jack is plugged"
  820. */
  821. if (!spec->autocfg.speaker_pins[0]) {
  822. if (spec->multiout.dac_nids[0])
  823. spec->autocfg.speaker_pins[0] =
  824. spec->multiout.dac_nids[0];
  825. else
  826. return;
  827. }
  828. if (!spec->autocfg.hp_pins[0]) {
  829. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  830. if (tmp == 0)
  831. spec->autocfg.hp_pins[0] = porta;
  832. else if (tmp == 1)
  833. spec->autocfg.hp_pins[0] = porte;
  834. else if (tmp == 2)
  835. spec->autocfg.hp_pins[0] = portd;
  836. else
  837. return;
  838. }
  839. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  840. AC_VERB_SET_UNSOLICITED_ENABLE,
  841. AC_USRSP_EN | ALC880_HP_EVENT);
  842. spec->unsol_event = alc_sku_unsol_event;
  843. spec->init_hook = alc_sku_automute;
  844. }
  845. /*
  846. * Fix-up pin default configurations
  847. */
  848. struct alc_pincfg {
  849. hda_nid_t nid;
  850. u32 val;
  851. };
  852. static void alc_fix_pincfg(struct hda_codec *codec,
  853. const struct snd_pci_quirk *quirk,
  854. const struct alc_pincfg **pinfix)
  855. {
  856. const struct alc_pincfg *cfg;
  857. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  858. if (!quirk)
  859. return;
  860. cfg = pinfix[quirk->value];
  861. for (; cfg->nid; cfg++) {
  862. int i;
  863. u32 val = cfg->val;
  864. for (i = 0; i < 4; i++) {
  865. snd_hda_codec_write(codec, cfg->nid, 0,
  866. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  867. val & 0xff);
  868. val >>= 8;
  869. }
  870. }
  871. }
  872. /*
  873. * ALC880 3-stack model
  874. *
  875. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  876. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  877. * F-Mic = 0x1b, HP = 0x19
  878. */
  879. static hda_nid_t alc880_dac_nids[4] = {
  880. /* front, rear, clfe, rear_surr */
  881. 0x02, 0x05, 0x04, 0x03
  882. };
  883. static hda_nid_t alc880_adc_nids[3] = {
  884. /* ADC0-2 */
  885. 0x07, 0x08, 0x09,
  886. };
  887. /* The datasheet says the node 0x07 is connected from inputs,
  888. * but it shows zero connection in the real implementation on some devices.
  889. * Note: this is a 915GAV bug, fixed on 915GLV
  890. */
  891. static hda_nid_t alc880_adc_nids_alt[2] = {
  892. /* ADC1-2 */
  893. 0x08, 0x09,
  894. };
  895. #define ALC880_DIGOUT_NID 0x06
  896. #define ALC880_DIGIN_NID 0x0a
  897. static struct hda_input_mux alc880_capture_source = {
  898. .num_items = 4,
  899. .items = {
  900. { "Mic", 0x0 },
  901. { "Front Mic", 0x3 },
  902. { "Line", 0x2 },
  903. { "CD", 0x4 },
  904. },
  905. };
  906. /* channel source setting (2/6 channel selection for 3-stack) */
  907. /* 2ch mode */
  908. static struct hda_verb alc880_threestack_ch2_init[] = {
  909. /* set line-in to input, mute it */
  910. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  911. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  912. /* set mic-in to input vref 80%, mute it */
  913. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  914. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  915. { } /* end */
  916. };
  917. /* 6ch mode */
  918. static struct hda_verb alc880_threestack_ch6_init[] = {
  919. /* set line-in to output, unmute it */
  920. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  921. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  922. /* set mic-in to output, unmute it */
  923. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  924. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  925. { } /* end */
  926. };
  927. static struct hda_channel_mode alc880_threestack_modes[2] = {
  928. { 2, alc880_threestack_ch2_init },
  929. { 6, alc880_threestack_ch6_init },
  930. };
  931. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  932. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  933. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  934. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  937. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  938. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  939. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  940. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  941. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  942. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  943. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  944. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  945. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  946. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  947. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  948. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  949. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  950. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  951. {
  952. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  953. .name = "Channel Mode",
  954. .info = alc_ch_mode_info,
  955. .get = alc_ch_mode_get,
  956. .put = alc_ch_mode_put,
  957. },
  958. { } /* end */
  959. };
  960. /* capture mixer elements */
  961. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  962. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  963. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  964. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  965. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  966. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  967. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  968. {
  969. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  970. /* The multiple "Capture Source" controls confuse alsamixer
  971. * So call somewhat different..
  972. * FIXME: the controls appear in the "playback" view!
  973. */
  974. /* .name = "Capture Source", */
  975. .name = "Input Source",
  976. .count = 3,
  977. .info = alc_mux_enum_info,
  978. .get = alc_mux_enum_get,
  979. .put = alc_mux_enum_put,
  980. },
  981. { } /* end */
  982. };
  983. /* capture mixer elements (in case NID 0x07 not available) */
  984. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  985. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  986. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  987. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  988. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  989. {
  990. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  991. /* The multiple "Capture Source" controls confuse alsamixer
  992. * So call somewhat different..
  993. * FIXME: the controls appear in the "playback" view!
  994. */
  995. /* .name = "Capture Source", */
  996. .name = "Input Source",
  997. .count = 2,
  998. .info = alc_mux_enum_info,
  999. .get = alc_mux_enum_get,
  1000. .put = alc_mux_enum_put,
  1001. },
  1002. { } /* end */
  1003. };
  1004. /*
  1005. * ALC880 5-stack model
  1006. *
  1007. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  1008. * Side = 0x02 (0xd)
  1009. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  1010. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  1011. */
  1012. /* additional mixers to alc880_three_stack_mixer */
  1013. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  1014. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1015. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  1016. { } /* end */
  1017. };
  1018. /* channel source setting (6/8 channel selection for 5-stack) */
  1019. /* 6ch mode */
  1020. static struct hda_verb alc880_fivestack_ch6_init[] = {
  1021. /* set line-in to input, mute it */
  1022. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1023. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  1024. { } /* end */
  1025. };
  1026. /* 8ch mode */
  1027. static struct hda_verb alc880_fivestack_ch8_init[] = {
  1028. /* set line-in to output, unmute it */
  1029. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  1030. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  1031. { } /* end */
  1032. };
  1033. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  1034. { 6, alc880_fivestack_ch6_init },
  1035. { 8, alc880_fivestack_ch8_init },
  1036. };
  1037. /*
  1038. * ALC880 6-stack model
  1039. *
  1040. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  1041. * Side = 0x05 (0x0f)
  1042. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  1043. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  1044. */
  1045. static hda_nid_t alc880_6st_dac_nids[4] = {
  1046. /* front, rear, clfe, rear_surr */
  1047. 0x02, 0x03, 0x04, 0x05
  1048. };
  1049. static struct hda_input_mux alc880_6stack_capture_source = {
  1050. .num_items = 4,
  1051. .items = {
  1052. { "Mic", 0x0 },
  1053. { "Front Mic", 0x1 },
  1054. { "Line", 0x2 },
  1055. { "CD", 0x4 },
  1056. },
  1057. };
  1058. /* fixed 8-channels */
  1059. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1060. { 8, NULL },
  1061. };
  1062. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1063. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1064. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1065. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1066. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1067. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1068. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1069. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1070. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1071. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1072. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1073. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1074. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1075. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1076. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1078. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1080. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1082. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1083. {
  1084. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1085. .name = "Channel Mode",
  1086. .info = alc_ch_mode_info,
  1087. .get = alc_ch_mode_get,
  1088. .put = alc_ch_mode_put,
  1089. },
  1090. { } /* end */
  1091. };
  1092. /*
  1093. * ALC880 W810 model
  1094. *
  1095. * W810 has rear IO for:
  1096. * Front (DAC 02)
  1097. * Surround (DAC 03)
  1098. * Center/LFE (DAC 04)
  1099. * Digital out (06)
  1100. *
  1101. * The system also has a pair of internal speakers, and a headphone jack.
  1102. * These are both connected to Line2 on the codec, hence to DAC 02.
  1103. *
  1104. * There is a variable resistor to control the speaker or headphone
  1105. * volume. This is a hardware-only device without a software API.
  1106. *
  1107. * Plugging headphones in will disable the internal speakers. This is
  1108. * implemented in hardware, not via the driver using jack sense. In
  1109. * a similar fashion, plugging into the rear socket marked "front" will
  1110. * disable both the speakers and headphones.
  1111. *
  1112. * For input, there's a microphone jack, and an "audio in" jack.
  1113. * These may not do anything useful with this driver yet, because I
  1114. * haven't setup any initialization verbs for these yet...
  1115. */
  1116. static hda_nid_t alc880_w810_dac_nids[3] = {
  1117. /* front, rear/surround, clfe */
  1118. 0x02, 0x03, 0x04
  1119. };
  1120. /* fixed 6 channels */
  1121. static struct hda_channel_mode alc880_w810_modes[1] = {
  1122. { 6, NULL }
  1123. };
  1124. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1125. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1126. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1127. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1128. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1129. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1130. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1131. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1132. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1133. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1134. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1135. { } /* end */
  1136. };
  1137. /*
  1138. * Z710V model
  1139. *
  1140. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1141. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1142. * Line = 0x1a
  1143. */
  1144. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1145. 0x02
  1146. };
  1147. #define ALC880_Z71V_HP_DAC 0x03
  1148. /* fixed 2 channels */
  1149. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1150. { 2, NULL }
  1151. };
  1152. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1153. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1154. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1155. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1156. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1157. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1158. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1159. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1160. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1161. { } /* end */
  1162. };
  1163. /* FIXME! */
  1164. /*
  1165. * ALC880 F1734 model
  1166. *
  1167. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1168. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1169. */
  1170. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1171. 0x03
  1172. };
  1173. #define ALC880_F1734_HP_DAC 0x02
  1174. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1175. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1176. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1177. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1178. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1179. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1180. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1181. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1182. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1183. { } /* end */
  1184. };
  1185. /* FIXME! */
  1186. /*
  1187. * ALC880 ASUS model
  1188. *
  1189. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1190. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1191. * Mic = 0x18, Line = 0x1a
  1192. */
  1193. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1194. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1195. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1196. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1197. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1198. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1199. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1200. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1201. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1202. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1203. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1204. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1205. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1206. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1207. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1208. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1209. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1210. {
  1211. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1212. .name = "Channel Mode",
  1213. .info = alc_ch_mode_info,
  1214. .get = alc_ch_mode_get,
  1215. .put = alc_ch_mode_put,
  1216. },
  1217. { } /* end */
  1218. };
  1219. /* FIXME! */
  1220. /*
  1221. * ALC880 ASUS W1V model
  1222. *
  1223. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1224. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1225. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1226. */
  1227. /* additional mixers to alc880_asus_mixer */
  1228. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1229. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1230. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1231. { } /* end */
  1232. };
  1233. /* additional mixers to alc880_asus_mixer */
  1234. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1235. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1236. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1237. { } /* end */
  1238. };
  1239. /* TCL S700 */
  1240. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1241. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1242. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1243. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  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("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1247. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1248. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1249. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1250. {
  1251. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1252. /* The multiple "Capture Source" controls confuse alsamixer
  1253. * So call somewhat different..
  1254. * FIXME: the controls appear in the "playback" view!
  1255. */
  1256. /* .name = "Capture Source", */
  1257. .name = "Input Source",
  1258. .count = 1,
  1259. .info = alc_mux_enum_info,
  1260. .get = alc_mux_enum_get,
  1261. .put = alc_mux_enum_put,
  1262. },
  1263. { } /* end */
  1264. };
  1265. /* Uniwill */
  1266. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1267. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1268. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1269. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1270. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1271. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1272. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1273. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1274. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1275. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1276. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1277. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1278. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1280. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1281. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1282. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1283. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1284. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1285. {
  1286. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1287. .name = "Channel Mode",
  1288. .info = alc_ch_mode_info,
  1289. .get = alc_ch_mode_get,
  1290. .put = alc_ch_mode_put,
  1291. },
  1292. { } /* end */
  1293. };
  1294. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1295. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1296. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1297. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1298. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1299. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1300. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1301. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1302. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1303. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1304. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1305. { } /* end */
  1306. };
  1307. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1308. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1309. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1310. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1311. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1312. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1313. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1314. { } /* end */
  1315. };
  1316. /*
  1317. * build control elements
  1318. */
  1319. static int alc_build_controls(struct hda_codec *codec)
  1320. {
  1321. struct alc_spec *spec = codec->spec;
  1322. int err;
  1323. int i;
  1324. for (i = 0; i < spec->num_mixers; i++) {
  1325. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1326. if (err < 0)
  1327. return err;
  1328. }
  1329. if (spec->multiout.dig_out_nid) {
  1330. err = snd_hda_create_spdif_out_ctls(codec,
  1331. spec->multiout.dig_out_nid);
  1332. if (err < 0)
  1333. return err;
  1334. }
  1335. if (spec->dig_in_nid) {
  1336. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1337. if (err < 0)
  1338. return err;
  1339. }
  1340. return 0;
  1341. }
  1342. /*
  1343. * initialize the codec volumes, etc
  1344. */
  1345. /*
  1346. * generic initialization of ADC, input mixers and output mixers
  1347. */
  1348. static struct hda_verb alc880_volume_init_verbs[] = {
  1349. /*
  1350. * Unmute ADC0-2 and set the default input to mic-in
  1351. */
  1352. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1353. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1354. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1355. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1356. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1357. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1358. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1359. * mixer widget
  1360. * Note: PASD motherboards uses the Line In 2 as the input for front
  1361. * panel mic (mic 2)
  1362. */
  1363. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1364. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1365. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1366. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1367. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1368. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1369. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1370. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1371. /*
  1372. * Set up output mixers (0x0c - 0x0f)
  1373. */
  1374. /* set vol=0 to output mixers */
  1375. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1376. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1377. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1378. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1379. /* set up input amps for analog loopback */
  1380. /* Amp Indices: DAC = 0, mixer = 1 */
  1381. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1382. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1383. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1384. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1385. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1386. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1387. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1388. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1389. { }
  1390. };
  1391. /*
  1392. * 3-stack pin configuration:
  1393. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1394. */
  1395. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1396. /*
  1397. * preset connection lists of input pins
  1398. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1399. */
  1400. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1401. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1402. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1403. /*
  1404. * Set pin mode and muting
  1405. */
  1406. /* set front pin widgets 0x14 for output */
  1407. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1408. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1409. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1410. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1411. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1412. /* Mic2 (as headphone out) for HP output */
  1413. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1414. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1415. /* Line In pin widget for input */
  1416. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1417. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1418. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1419. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1420. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1421. /* CD pin widget for input */
  1422. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1423. { }
  1424. };
  1425. /*
  1426. * 5-stack pin configuration:
  1427. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1428. * line-in/side = 0x1a, f-mic = 0x1b
  1429. */
  1430. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1431. /*
  1432. * preset connection lists of input pins
  1433. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1434. */
  1435. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1436. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1437. /*
  1438. * Set pin mode and muting
  1439. */
  1440. /* set pin widgets 0x14-0x17 for output */
  1441. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1442. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1443. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1444. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1445. /* unmute pins for output (no gain on this amp) */
  1446. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1447. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1448. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1449. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1450. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1451. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1452. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1453. /* Mic2 (as headphone out) for HP output */
  1454. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1455. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1456. /* Line In pin widget for input */
  1457. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1458. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1459. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1460. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1461. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1462. /* CD pin widget for input */
  1463. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1464. { }
  1465. };
  1466. /*
  1467. * W810 pin configuration:
  1468. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1469. */
  1470. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1471. /* hphone/speaker input selector: front DAC */
  1472. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1473. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1474. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1475. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1476. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1477. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1478. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1479. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1480. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1481. { }
  1482. };
  1483. /*
  1484. * Z71V pin configuration:
  1485. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1486. */
  1487. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1488. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1489. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1490. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1491. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1493. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1494. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1495. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. { }
  1497. };
  1498. /*
  1499. * 6-stack pin configuration:
  1500. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1501. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1502. */
  1503. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1504. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1505. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1508. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1514. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1515. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1518. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1520. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1522. { }
  1523. };
  1524. /*
  1525. * Uniwill pin configuration:
  1526. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1527. * line = 0x1a
  1528. */
  1529. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1530. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1531. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1532. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1533. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1534. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1535. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1536. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1538. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1539. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1540. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1541. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1542. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1543. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1544. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1545. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1546. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1547. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1548. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1549. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1550. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1551. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1552. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1554. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1555. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1556. { }
  1557. };
  1558. /*
  1559. * Uniwill P53
  1560. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1561. */
  1562. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1563. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1564. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1565. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1566. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1567. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1568. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1569. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1570. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1571. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1573. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1574. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1575. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1576. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1577. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1578. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1579. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1580. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1581. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1582. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1583. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1584. { }
  1585. };
  1586. static struct hda_verb alc880_beep_init_verbs[] = {
  1587. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1588. { }
  1589. };
  1590. /* toggle speaker-output according to the hp-jack state */
  1591. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1592. {
  1593. unsigned int present;
  1594. unsigned char bits;
  1595. present = snd_hda_codec_read(codec, 0x14, 0,
  1596. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1597. bits = present ? HDA_AMP_MUTE : 0;
  1598. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1599. HDA_AMP_MUTE, bits);
  1600. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1601. HDA_AMP_MUTE, bits);
  1602. }
  1603. /* auto-toggle front mic */
  1604. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1605. {
  1606. unsigned int present;
  1607. unsigned char bits;
  1608. present = snd_hda_codec_read(codec, 0x18, 0,
  1609. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1610. bits = present ? HDA_AMP_MUTE : 0;
  1611. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1612. }
  1613. static void alc880_uniwill_automute(struct hda_codec *codec)
  1614. {
  1615. alc880_uniwill_hp_automute(codec);
  1616. alc880_uniwill_mic_automute(codec);
  1617. }
  1618. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1619. unsigned int res)
  1620. {
  1621. /* Looks like the unsol event is incompatible with the standard
  1622. * definition. 4bit tag is placed at 28 bit!
  1623. */
  1624. switch (res >> 28) {
  1625. case ALC880_HP_EVENT:
  1626. alc880_uniwill_hp_automute(codec);
  1627. break;
  1628. case ALC880_MIC_EVENT:
  1629. alc880_uniwill_mic_automute(codec);
  1630. break;
  1631. }
  1632. }
  1633. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1634. {
  1635. unsigned int present;
  1636. unsigned char bits;
  1637. present = snd_hda_codec_read(codec, 0x14, 0,
  1638. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1639. bits = present ? HDA_AMP_MUTE : 0;
  1640. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1641. }
  1642. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1643. {
  1644. unsigned int present;
  1645. present = snd_hda_codec_read(codec, 0x21, 0,
  1646. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1647. present &= HDA_AMP_VOLMASK;
  1648. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1649. HDA_AMP_VOLMASK, present);
  1650. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1651. HDA_AMP_VOLMASK, present);
  1652. }
  1653. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1654. unsigned int res)
  1655. {
  1656. /* Looks like the unsol event is incompatible with the standard
  1657. * definition. 4bit tag is placed at 28 bit!
  1658. */
  1659. if ((res >> 28) == ALC880_HP_EVENT)
  1660. alc880_uniwill_p53_hp_automute(codec);
  1661. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1662. alc880_uniwill_p53_dcvol_automute(codec);
  1663. }
  1664. /* FIXME! */
  1665. /*
  1666. * F1734 pin configuration:
  1667. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1668. */
  1669. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1670. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1671. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1672. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1673. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1674. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1675. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1676. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1677. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1678. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1679. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1680. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1681. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1682. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1683. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1684. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1685. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1686. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1687. { }
  1688. };
  1689. /* FIXME! */
  1690. /*
  1691. * ASUS pin configuration:
  1692. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1693. */
  1694. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1695. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1696. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1697. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1698. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1699. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1700. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1701. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1702. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1703. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1704. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1705. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1706. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1707. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1708. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1709. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1710. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1711. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1712. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1713. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1714. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1715. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1716. { }
  1717. };
  1718. /* Enable GPIO mask and set output */
  1719. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1720. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1721. /* Clevo m520g init */
  1722. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1723. /* headphone output */
  1724. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1725. /* line-out */
  1726. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1727. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1728. /* Line-in */
  1729. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1730. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1731. /* CD */
  1732. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1733. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1734. /* Mic1 (rear panel) */
  1735. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1736. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1737. /* Mic2 (front panel) */
  1738. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1739. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1740. /* headphone */
  1741. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1742. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1743. /* change to EAPD mode */
  1744. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1745. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1746. { }
  1747. };
  1748. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1749. /* change to EAPD mode */
  1750. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1751. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1752. /* Headphone output */
  1753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1754. /* Front output*/
  1755. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1756. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1757. /* Line In pin widget for input */
  1758. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1759. /* CD pin widget for input */
  1760. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1761. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1762. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1763. /* change to EAPD mode */
  1764. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1765. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1766. { }
  1767. };
  1768. /*
  1769. * LG m1 express dual
  1770. *
  1771. * Pin assignment:
  1772. * Rear Line-In/Out (blue): 0x14
  1773. * Build-in Mic-In: 0x15
  1774. * Speaker-out: 0x17
  1775. * HP-Out (green): 0x1b
  1776. * Mic-In/Out (red): 0x19
  1777. * SPDIF-Out: 0x1e
  1778. */
  1779. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1780. static hda_nid_t alc880_lg_dac_nids[3] = {
  1781. 0x05, 0x02, 0x03
  1782. };
  1783. /* seems analog CD is not working */
  1784. static struct hda_input_mux alc880_lg_capture_source = {
  1785. .num_items = 3,
  1786. .items = {
  1787. { "Mic", 0x1 },
  1788. { "Line", 0x5 },
  1789. { "Internal Mic", 0x6 },
  1790. },
  1791. };
  1792. /* 2,4,6 channel modes */
  1793. static struct hda_verb alc880_lg_ch2_init[] = {
  1794. /* set line-in and mic-in to input */
  1795. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1796. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1797. { }
  1798. };
  1799. static struct hda_verb alc880_lg_ch4_init[] = {
  1800. /* set line-in to out and mic-in to input */
  1801. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1802. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1803. { }
  1804. };
  1805. static struct hda_verb alc880_lg_ch6_init[] = {
  1806. /* set line-in and mic-in to output */
  1807. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1808. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1809. { }
  1810. };
  1811. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1812. { 2, alc880_lg_ch2_init },
  1813. { 4, alc880_lg_ch4_init },
  1814. { 6, alc880_lg_ch6_init },
  1815. };
  1816. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1817. /* FIXME: it's not really "master" but front channels */
  1818. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1819. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1820. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1821. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1822. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1823. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1824. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1825. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1826. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1827. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1828. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1829. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1830. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1831. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1832. {
  1833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1834. .name = "Channel Mode",
  1835. .info = alc_ch_mode_info,
  1836. .get = alc_ch_mode_get,
  1837. .put = alc_ch_mode_put,
  1838. },
  1839. { } /* end */
  1840. };
  1841. static struct hda_verb alc880_lg_init_verbs[] = {
  1842. /* set capture source to mic-in */
  1843. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1844. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1845. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1846. /* mute all amp mixer inputs */
  1847. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1848. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1849. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1850. /* line-in to input */
  1851. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1852. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1853. /* built-in mic */
  1854. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1855. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1856. /* speaker-out */
  1857. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1858. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1859. /* mic-in to input */
  1860. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1861. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1862. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1863. /* HP-out */
  1864. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1865. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1866. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1867. /* jack sense */
  1868. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1869. { }
  1870. };
  1871. /* toggle speaker-output according to the hp-jack state */
  1872. static void alc880_lg_automute(struct hda_codec *codec)
  1873. {
  1874. unsigned int present;
  1875. unsigned char bits;
  1876. present = snd_hda_codec_read(codec, 0x1b, 0,
  1877. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1878. bits = present ? HDA_AMP_MUTE : 0;
  1879. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1880. HDA_AMP_MUTE, bits);
  1881. }
  1882. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1883. {
  1884. /* Looks like the unsol event is incompatible with the standard
  1885. * definition. 4bit tag is placed at 28 bit!
  1886. */
  1887. if ((res >> 28) == 0x01)
  1888. alc880_lg_automute(codec);
  1889. }
  1890. /*
  1891. * LG LW20
  1892. *
  1893. * Pin assignment:
  1894. * Speaker-out: 0x14
  1895. * Mic-In: 0x18
  1896. * Built-in Mic-In: 0x19
  1897. * Line-In: 0x1b
  1898. * HP-Out: 0x1a
  1899. * SPDIF-Out: 0x1e
  1900. */
  1901. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1902. .num_items = 3,
  1903. .items = {
  1904. { "Mic", 0x0 },
  1905. { "Internal Mic", 0x1 },
  1906. { "Line In", 0x2 },
  1907. },
  1908. };
  1909. #define alc880_lg_lw_modes alc880_threestack_modes
  1910. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1911. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1912. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1913. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1914. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1915. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1916. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1917. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1918. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1919. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1920. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1921. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1922. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1923. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1924. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1925. {
  1926. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1927. .name = "Channel Mode",
  1928. .info = alc_ch_mode_info,
  1929. .get = alc_ch_mode_get,
  1930. .put = alc_ch_mode_put,
  1931. },
  1932. { } /* end */
  1933. };
  1934. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1935. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1936. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1937. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1938. /* set capture source to mic-in */
  1939. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1940. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1941. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1942. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1943. /* speaker-out */
  1944. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1945. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1946. /* HP-out */
  1947. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1948. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1949. /* mic-in to input */
  1950. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1951. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1952. /* built-in mic */
  1953. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1954. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1955. /* jack sense */
  1956. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1957. { }
  1958. };
  1959. /* toggle speaker-output according to the hp-jack state */
  1960. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1961. {
  1962. unsigned int present;
  1963. unsigned char bits;
  1964. present = snd_hda_codec_read(codec, 0x1b, 0,
  1965. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1966. bits = present ? HDA_AMP_MUTE : 0;
  1967. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1968. HDA_AMP_MUTE, bits);
  1969. }
  1970. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1971. {
  1972. /* Looks like the unsol event is incompatible with the standard
  1973. * definition. 4bit tag is placed at 28 bit!
  1974. */
  1975. if ((res >> 28) == 0x01)
  1976. alc880_lg_lw_automute(codec);
  1977. }
  1978. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1979. static struct hda_amp_list alc880_loopbacks[] = {
  1980. { 0x0b, HDA_INPUT, 0 },
  1981. { 0x0b, HDA_INPUT, 1 },
  1982. { 0x0b, HDA_INPUT, 2 },
  1983. { 0x0b, HDA_INPUT, 3 },
  1984. { 0x0b, HDA_INPUT, 4 },
  1985. { } /* end */
  1986. };
  1987. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1988. { 0x0b, HDA_INPUT, 1 },
  1989. { 0x0b, HDA_INPUT, 6 },
  1990. { 0x0b, HDA_INPUT, 7 },
  1991. { } /* end */
  1992. };
  1993. #endif
  1994. /*
  1995. * Common callbacks
  1996. */
  1997. static int alc_init(struct hda_codec *codec)
  1998. {
  1999. struct alc_spec *spec = codec->spec;
  2000. unsigned int i;
  2001. for (i = 0; i < spec->num_init_verbs; i++)
  2002. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  2003. if (spec->init_hook)
  2004. spec->init_hook(codec);
  2005. return 0;
  2006. }
  2007. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  2008. {
  2009. struct alc_spec *spec = codec->spec;
  2010. if (spec->unsol_event)
  2011. spec->unsol_event(codec, res);
  2012. }
  2013. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2014. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  2015. {
  2016. struct alc_spec *spec = codec->spec;
  2017. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  2018. }
  2019. #endif
  2020. /*
  2021. * Analog playback callbacks
  2022. */
  2023. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2024. struct hda_codec *codec,
  2025. struct snd_pcm_substream *substream)
  2026. {
  2027. struct alc_spec *spec = codec->spec;
  2028. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  2029. }
  2030. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2031. struct hda_codec *codec,
  2032. unsigned int stream_tag,
  2033. unsigned int format,
  2034. struct snd_pcm_substream *substream)
  2035. {
  2036. struct alc_spec *spec = codec->spec;
  2037. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  2038. stream_tag, format, substream);
  2039. }
  2040. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2041. struct hda_codec *codec,
  2042. struct snd_pcm_substream *substream)
  2043. {
  2044. struct alc_spec *spec = codec->spec;
  2045. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  2046. }
  2047. /*
  2048. * Digital out
  2049. */
  2050. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2051. struct hda_codec *codec,
  2052. struct snd_pcm_substream *substream)
  2053. {
  2054. struct alc_spec *spec = codec->spec;
  2055. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2056. }
  2057. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2058. struct hda_codec *codec,
  2059. unsigned int stream_tag,
  2060. unsigned int format,
  2061. struct snd_pcm_substream *substream)
  2062. {
  2063. struct alc_spec *spec = codec->spec;
  2064. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2065. stream_tag, format, substream);
  2066. }
  2067. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2068. struct hda_codec *codec,
  2069. struct snd_pcm_substream *substream)
  2070. {
  2071. struct alc_spec *spec = codec->spec;
  2072. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2073. }
  2074. /*
  2075. * Analog capture
  2076. */
  2077. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2078. struct hda_codec *codec,
  2079. unsigned int stream_tag,
  2080. unsigned int format,
  2081. struct snd_pcm_substream *substream)
  2082. {
  2083. struct alc_spec *spec = codec->spec;
  2084. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2085. stream_tag, 0, format);
  2086. return 0;
  2087. }
  2088. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2089. struct hda_codec *codec,
  2090. struct snd_pcm_substream *substream)
  2091. {
  2092. struct alc_spec *spec = codec->spec;
  2093. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2094. 0, 0, 0);
  2095. return 0;
  2096. }
  2097. /*
  2098. */
  2099. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2100. .substreams = 1,
  2101. .channels_min = 2,
  2102. .channels_max = 8,
  2103. /* NID is set in alc_build_pcms */
  2104. .ops = {
  2105. .open = alc880_playback_pcm_open,
  2106. .prepare = alc880_playback_pcm_prepare,
  2107. .cleanup = alc880_playback_pcm_cleanup
  2108. },
  2109. };
  2110. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2111. .substreams = 2,
  2112. .channels_min = 2,
  2113. .channels_max = 2,
  2114. /* NID is set in alc_build_pcms */
  2115. .ops = {
  2116. .prepare = alc880_capture_pcm_prepare,
  2117. .cleanup = alc880_capture_pcm_cleanup
  2118. },
  2119. };
  2120. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2121. .substreams = 1,
  2122. .channels_min = 2,
  2123. .channels_max = 2,
  2124. /* NID is set in alc_build_pcms */
  2125. .ops = {
  2126. .open = alc880_dig_playback_pcm_open,
  2127. .close = alc880_dig_playback_pcm_close,
  2128. .prepare = alc880_dig_playback_pcm_prepare
  2129. },
  2130. };
  2131. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2132. .substreams = 1,
  2133. .channels_min = 2,
  2134. .channels_max = 2,
  2135. /* NID is set in alc_build_pcms */
  2136. };
  2137. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2138. static struct hda_pcm_stream alc_pcm_null_playback = {
  2139. .substreams = 0,
  2140. .channels_min = 0,
  2141. .channels_max = 0,
  2142. };
  2143. static int alc_build_pcms(struct hda_codec *codec)
  2144. {
  2145. struct alc_spec *spec = codec->spec;
  2146. struct hda_pcm *info = spec->pcm_rec;
  2147. int i;
  2148. codec->num_pcms = 1;
  2149. codec->pcm_info = info;
  2150. info->name = spec->stream_name_analog;
  2151. if (spec->stream_analog_playback) {
  2152. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2153. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2154. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2155. }
  2156. if (spec->stream_analog_capture) {
  2157. snd_assert(spec->adc_nids, return -EINVAL);
  2158. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2159. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2160. }
  2161. if (spec->channel_mode) {
  2162. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2163. for (i = 0; i < spec->num_channel_mode; i++) {
  2164. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2165. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2166. }
  2167. }
  2168. }
  2169. /* SPDIF for stream index #1 */
  2170. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2171. codec->num_pcms = 2;
  2172. info = spec->pcm_rec + 1;
  2173. info->name = spec->stream_name_digital;
  2174. if (spec->multiout.dig_out_nid &&
  2175. spec->stream_digital_playback) {
  2176. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2177. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2178. }
  2179. if (spec->dig_in_nid &&
  2180. spec->stream_digital_capture) {
  2181. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2182. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2183. }
  2184. }
  2185. /* If the use of more than one ADC is requested for the current
  2186. * model, configure a second analog capture-only PCM.
  2187. */
  2188. /* Additional Analaog capture for index #2 */
  2189. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2190. spec->adc_nids) {
  2191. codec->num_pcms = 3;
  2192. info = spec->pcm_rec + 2;
  2193. info->name = spec->stream_name_analog;
  2194. /* No playback stream for second PCM */
  2195. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2196. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2197. if (spec->stream_analog_capture) {
  2198. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2199. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2200. }
  2201. }
  2202. return 0;
  2203. }
  2204. static void alc_free(struct hda_codec *codec)
  2205. {
  2206. struct alc_spec *spec = codec->spec;
  2207. unsigned int i;
  2208. if (!spec)
  2209. return;
  2210. if (spec->kctl_alloc) {
  2211. for (i = 0; i < spec->num_kctl_used; i++)
  2212. kfree(spec->kctl_alloc[i].name);
  2213. kfree(spec->kctl_alloc);
  2214. }
  2215. kfree(spec);
  2216. }
  2217. /*
  2218. */
  2219. static struct hda_codec_ops alc_patch_ops = {
  2220. .build_controls = alc_build_controls,
  2221. .build_pcms = alc_build_pcms,
  2222. .init = alc_init,
  2223. .free = alc_free,
  2224. .unsol_event = alc_unsol_event,
  2225. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2226. .check_power_status = alc_check_power_status,
  2227. #endif
  2228. };
  2229. /*
  2230. * Test configuration for debugging
  2231. *
  2232. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2233. * enum controls.
  2234. */
  2235. #ifdef CONFIG_SND_DEBUG
  2236. static hda_nid_t alc880_test_dac_nids[4] = {
  2237. 0x02, 0x03, 0x04, 0x05
  2238. };
  2239. static struct hda_input_mux alc880_test_capture_source = {
  2240. .num_items = 7,
  2241. .items = {
  2242. { "In-1", 0x0 },
  2243. { "In-2", 0x1 },
  2244. { "In-3", 0x2 },
  2245. { "In-4", 0x3 },
  2246. { "CD", 0x4 },
  2247. { "Front", 0x5 },
  2248. { "Surround", 0x6 },
  2249. },
  2250. };
  2251. static struct hda_channel_mode alc880_test_modes[4] = {
  2252. { 2, NULL },
  2253. { 4, NULL },
  2254. { 6, NULL },
  2255. { 8, NULL },
  2256. };
  2257. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2258. struct snd_ctl_elem_info *uinfo)
  2259. {
  2260. static char *texts[] = {
  2261. "N/A", "Line Out", "HP Out",
  2262. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2263. };
  2264. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2265. uinfo->count = 1;
  2266. uinfo->value.enumerated.items = 8;
  2267. if (uinfo->value.enumerated.item >= 8)
  2268. uinfo->value.enumerated.item = 7;
  2269. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2270. return 0;
  2271. }
  2272. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2273. struct snd_ctl_elem_value *ucontrol)
  2274. {
  2275. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2276. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2277. unsigned int pin_ctl, item = 0;
  2278. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2279. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2280. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2281. if (pin_ctl & AC_PINCTL_HP_EN)
  2282. item = 2;
  2283. else
  2284. item = 1;
  2285. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2286. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2287. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2288. case AC_PINCTL_VREF_50: item = 4; break;
  2289. case AC_PINCTL_VREF_GRD: item = 5; break;
  2290. case AC_PINCTL_VREF_80: item = 6; break;
  2291. case AC_PINCTL_VREF_100: item = 7; break;
  2292. }
  2293. }
  2294. ucontrol->value.enumerated.item[0] = item;
  2295. return 0;
  2296. }
  2297. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2298. struct snd_ctl_elem_value *ucontrol)
  2299. {
  2300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2301. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2302. static unsigned int ctls[] = {
  2303. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2304. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2305. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2306. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2307. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2308. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2309. };
  2310. unsigned int old_ctl, new_ctl;
  2311. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2312. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2313. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2314. if (old_ctl != new_ctl) {
  2315. int val;
  2316. snd_hda_codec_write_cache(codec, nid, 0,
  2317. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2318. new_ctl);
  2319. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2320. HDA_AMP_MUTE : 0;
  2321. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2322. HDA_AMP_MUTE, val);
  2323. return 1;
  2324. }
  2325. return 0;
  2326. }
  2327. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2328. struct snd_ctl_elem_info *uinfo)
  2329. {
  2330. static char *texts[] = {
  2331. "Front", "Surround", "CLFE", "Side"
  2332. };
  2333. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2334. uinfo->count = 1;
  2335. uinfo->value.enumerated.items = 4;
  2336. if (uinfo->value.enumerated.item >= 4)
  2337. uinfo->value.enumerated.item = 3;
  2338. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2339. return 0;
  2340. }
  2341. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2342. struct snd_ctl_elem_value *ucontrol)
  2343. {
  2344. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2345. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2346. unsigned int sel;
  2347. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2348. ucontrol->value.enumerated.item[0] = sel & 3;
  2349. return 0;
  2350. }
  2351. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2352. struct snd_ctl_elem_value *ucontrol)
  2353. {
  2354. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2355. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2356. unsigned int sel;
  2357. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2358. if (ucontrol->value.enumerated.item[0] != sel) {
  2359. sel = ucontrol->value.enumerated.item[0] & 3;
  2360. snd_hda_codec_write_cache(codec, nid, 0,
  2361. AC_VERB_SET_CONNECT_SEL, sel);
  2362. return 1;
  2363. }
  2364. return 0;
  2365. }
  2366. #define PIN_CTL_TEST(xname,nid) { \
  2367. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2368. .name = xname, \
  2369. .info = alc_test_pin_ctl_info, \
  2370. .get = alc_test_pin_ctl_get, \
  2371. .put = alc_test_pin_ctl_put, \
  2372. .private_value = nid \
  2373. }
  2374. #define PIN_SRC_TEST(xname,nid) { \
  2375. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2376. .name = xname, \
  2377. .info = alc_test_pin_src_info, \
  2378. .get = alc_test_pin_src_get, \
  2379. .put = alc_test_pin_src_put, \
  2380. .private_value = nid \
  2381. }
  2382. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2383. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2384. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2385. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2386. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2387. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2388. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2389. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2390. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2391. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2392. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2393. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2394. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2395. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2396. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2397. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2398. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2399. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2400. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2401. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2402. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2403. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2404. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2405. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2406. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2407. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2408. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2409. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2410. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2411. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2412. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2413. {
  2414. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2415. .name = "Channel Mode",
  2416. .info = alc_ch_mode_info,
  2417. .get = alc_ch_mode_get,
  2418. .put = alc_ch_mode_put,
  2419. },
  2420. { } /* end */
  2421. };
  2422. static struct hda_verb alc880_test_init_verbs[] = {
  2423. /* Unmute inputs of 0x0c - 0x0f */
  2424. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2425. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2426. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2427. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2428. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2429. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2430. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2431. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2432. /* Vol output for 0x0c-0x0f */
  2433. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2434. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2435. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2436. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2437. /* Set output pins 0x14-0x17 */
  2438. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2439. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2440. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2441. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2442. /* Unmute output pins 0x14-0x17 */
  2443. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2444. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2445. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2446. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2447. /* Set input pins 0x18-0x1c */
  2448. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2449. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2450. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2451. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2452. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2453. /* Mute input pins 0x18-0x1b */
  2454. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2455. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2456. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2457. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2458. /* ADC set up */
  2459. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2460. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2461. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2462. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2463. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2464. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2465. /* Analog input/passthru */
  2466. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2467. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2468. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2469. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2470. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2471. { }
  2472. };
  2473. #endif
  2474. /*
  2475. */
  2476. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2477. [ALC880_3ST] = "3stack",
  2478. [ALC880_TCL_S700] = "tcl",
  2479. [ALC880_3ST_DIG] = "3stack-digout",
  2480. [ALC880_CLEVO] = "clevo",
  2481. [ALC880_5ST] = "5stack",
  2482. [ALC880_5ST_DIG] = "5stack-digout",
  2483. [ALC880_W810] = "w810",
  2484. [ALC880_Z71V] = "z71v",
  2485. [ALC880_6ST] = "6stack",
  2486. [ALC880_6ST_DIG] = "6stack-digout",
  2487. [ALC880_ASUS] = "asus",
  2488. [ALC880_ASUS_W1V] = "asus-w1v",
  2489. [ALC880_ASUS_DIG] = "asus-dig",
  2490. [ALC880_ASUS_DIG2] = "asus-dig2",
  2491. [ALC880_UNIWILL_DIG] = "uniwill",
  2492. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2493. [ALC880_FUJITSU] = "fujitsu",
  2494. [ALC880_F1734] = "F1734",
  2495. [ALC880_LG] = "lg",
  2496. [ALC880_LG_LW] = "lg-lw",
  2497. #ifdef CONFIG_SND_DEBUG
  2498. [ALC880_TEST] = "test",
  2499. #endif
  2500. [ALC880_AUTO] = "auto",
  2501. };
  2502. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2503. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2504. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2505. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2506. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2507. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2508. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2509. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2510. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2511. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2512. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2513. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2514. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2515. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2516. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2517. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2518. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2519. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2520. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2521. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2522. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2523. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2524. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2525. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2526. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2527. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2528. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
  2529. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2530. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2531. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2532. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2533. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2534. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2535. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2536. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2537. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2538. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2539. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2540. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2541. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2542. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2543. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2544. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2545. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2546. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2547. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2548. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2549. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2550. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2551. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2552. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2553. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2554. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2555. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2556. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2557. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
  2558. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2559. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2560. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2561. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2562. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2563. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2564. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2565. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2566. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2567. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2568. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2569. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
  2570. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2571. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2572. {}
  2573. };
  2574. /*
  2575. * ALC880 codec presets
  2576. */
  2577. static struct alc_config_preset alc880_presets[] = {
  2578. [ALC880_3ST] = {
  2579. .mixers = { alc880_three_stack_mixer },
  2580. .init_verbs = { alc880_volume_init_verbs,
  2581. alc880_pin_3stack_init_verbs },
  2582. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2583. .dac_nids = alc880_dac_nids,
  2584. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2585. .channel_mode = alc880_threestack_modes,
  2586. .need_dac_fix = 1,
  2587. .input_mux = &alc880_capture_source,
  2588. },
  2589. [ALC880_3ST_DIG] = {
  2590. .mixers = { alc880_three_stack_mixer },
  2591. .init_verbs = { alc880_volume_init_verbs,
  2592. alc880_pin_3stack_init_verbs },
  2593. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2594. .dac_nids = alc880_dac_nids,
  2595. .dig_out_nid = ALC880_DIGOUT_NID,
  2596. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2597. .channel_mode = alc880_threestack_modes,
  2598. .need_dac_fix = 1,
  2599. .input_mux = &alc880_capture_source,
  2600. },
  2601. [ALC880_TCL_S700] = {
  2602. .mixers = { alc880_tcl_s700_mixer },
  2603. .init_verbs = { alc880_volume_init_verbs,
  2604. alc880_pin_tcl_S700_init_verbs,
  2605. alc880_gpio2_init_verbs },
  2606. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2607. .dac_nids = alc880_dac_nids,
  2608. .hp_nid = 0x03,
  2609. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2610. .channel_mode = alc880_2_jack_modes,
  2611. .input_mux = &alc880_capture_source,
  2612. },
  2613. [ALC880_5ST] = {
  2614. .mixers = { alc880_three_stack_mixer,
  2615. alc880_five_stack_mixer},
  2616. .init_verbs = { alc880_volume_init_verbs,
  2617. alc880_pin_5stack_init_verbs },
  2618. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2619. .dac_nids = alc880_dac_nids,
  2620. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2621. .channel_mode = alc880_fivestack_modes,
  2622. .input_mux = &alc880_capture_source,
  2623. },
  2624. [ALC880_5ST_DIG] = {
  2625. .mixers = { alc880_three_stack_mixer,
  2626. alc880_five_stack_mixer },
  2627. .init_verbs = { alc880_volume_init_verbs,
  2628. alc880_pin_5stack_init_verbs },
  2629. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2630. .dac_nids = alc880_dac_nids,
  2631. .dig_out_nid = ALC880_DIGOUT_NID,
  2632. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2633. .channel_mode = alc880_fivestack_modes,
  2634. .input_mux = &alc880_capture_source,
  2635. },
  2636. [ALC880_6ST] = {
  2637. .mixers = { alc880_six_stack_mixer },
  2638. .init_verbs = { alc880_volume_init_verbs,
  2639. alc880_pin_6stack_init_verbs },
  2640. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2641. .dac_nids = alc880_6st_dac_nids,
  2642. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2643. .channel_mode = alc880_sixstack_modes,
  2644. .input_mux = &alc880_6stack_capture_source,
  2645. },
  2646. [ALC880_6ST_DIG] = {
  2647. .mixers = { alc880_six_stack_mixer },
  2648. .init_verbs = { alc880_volume_init_verbs,
  2649. alc880_pin_6stack_init_verbs },
  2650. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2651. .dac_nids = alc880_6st_dac_nids,
  2652. .dig_out_nid = ALC880_DIGOUT_NID,
  2653. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2654. .channel_mode = alc880_sixstack_modes,
  2655. .input_mux = &alc880_6stack_capture_source,
  2656. },
  2657. [ALC880_W810] = {
  2658. .mixers = { alc880_w810_base_mixer },
  2659. .init_verbs = { alc880_volume_init_verbs,
  2660. alc880_pin_w810_init_verbs,
  2661. alc880_gpio2_init_verbs },
  2662. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2663. .dac_nids = alc880_w810_dac_nids,
  2664. .dig_out_nid = ALC880_DIGOUT_NID,
  2665. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2666. .channel_mode = alc880_w810_modes,
  2667. .input_mux = &alc880_capture_source,
  2668. },
  2669. [ALC880_Z71V] = {
  2670. .mixers = { alc880_z71v_mixer },
  2671. .init_verbs = { alc880_volume_init_verbs,
  2672. alc880_pin_z71v_init_verbs },
  2673. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2674. .dac_nids = alc880_z71v_dac_nids,
  2675. .dig_out_nid = ALC880_DIGOUT_NID,
  2676. .hp_nid = 0x03,
  2677. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2678. .channel_mode = alc880_2_jack_modes,
  2679. .input_mux = &alc880_capture_source,
  2680. },
  2681. [ALC880_F1734] = {
  2682. .mixers = { alc880_f1734_mixer },
  2683. .init_verbs = { alc880_volume_init_verbs,
  2684. alc880_pin_f1734_init_verbs },
  2685. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2686. .dac_nids = alc880_f1734_dac_nids,
  2687. .hp_nid = 0x02,
  2688. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2689. .channel_mode = alc880_2_jack_modes,
  2690. .input_mux = &alc880_capture_source,
  2691. },
  2692. [ALC880_ASUS] = {
  2693. .mixers = { alc880_asus_mixer },
  2694. .init_verbs = { alc880_volume_init_verbs,
  2695. alc880_pin_asus_init_verbs,
  2696. alc880_gpio1_init_verbs },
  2697. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2698. .dac_nids = alc880_asus_dac_nids,
  2699. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2700. .channel_mode = alc880_asus_modes,
  2701. .need_dac_fix = 1,
  2702. .input_mux = &alc880_capture_source,
  2703. },
  2704. [ALC880_ASUS_DIG] = {
  2705. .mixers = { alc880_asus_mixer },
  2706. .init_verbs = { alc880_volume_init_verbs,
  2707. alc880_pin_asus_init_verbs,
  2708. alc880_gpio1_init_verbs },
  2709. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2710. .dac_nids = alc880_asus_dac_nids,
  2711. .dig_out_nid = ALC880_DIGOUT_NID,
  2712. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2713. .channel_mode = alc880_asus_modes,
  2714. .need_dac_fix = 1,
  2715. .input_mux = &alc880_capture_source,
  2716. },
  2717. [ALC880_ASUS_DIG2] = {
  2718. .mixers = { alc880_asus_mixer },
  2719. .init_verbs = { alc880_volume_init_verbs,
  2720. alc880_pin_asus_init_verbs,
  2721. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2722. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2723. .dac_nids = alc880_asus_dac_nids,
  2724. .dig_out_nid = ALC880_DIGOUT_NID,
  2725. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2726. .channel_mode = alc880_asus_modes,
  2727. .need_dac_fix = 1,
  2728. .input_mux = &alc880_capture_source,
  2729. },
  2730. [ALC880_ASUS_W1V] = {
  2731. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2732. .init_verbs = { alc880_volume_init_verbs,
  2733. alc880_pin_asus_init_verbs,
  2734. alc880_gpio1_init_verbs },
  2735. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2736. .dac_nids = alc880_asus_dac_nids,
  2737. .dig_out_nid = ALC880_DIGOUT_NID,
  2738. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2739. .channel_mode = alc880_asus_modes,
  2740. .need_dac_fix = 1,
  2741. .input_mux = &alc880_capture_source,
  2742. },
  2743. [ALC880_UNIWILL_DIG] = {
  2744. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2745. .init_verbs = { alc880_volume_init_verbs,
  2746. alc880_pin_asus_init_verbs },
  2747. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2748. .dac_nids = alc880_asus_dac_nids,
  2749. .dig_out_nid = ALC880_DIGOUT_NID,
  2750. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2751. .channel_mode = alc880_asus_modes,
  2752. .need_dac_fix = 1,
  2753. .input_mux = &alc880_capture_source,
  2754. },
  2755. [ALC880_UNIWILL] = {
  2756. .mixers = { alc880_uniwill_mixer },
  2757. .init_verbs = { alc880_volume_init_verbs,
  2758. alc880_uniwill_init_verbs },
  2759. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2760. .dac_nids = alc880_asus_dac_nids,
  2761. .dig_out_nid = ALC880_DIGOUT_NID,
  2762. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2763. .channel_mode = alc880_threestack_modes,
  2764. .need_dac_fix = 1,
  2765. .input_mux = &alc880_capture_source,
  2766. .unsol_event = alc880_uniwill_unsol_event,
  2767. .init_hook = alc880_uniwill_automute,
  2768. },
  2769. [ALC880_UNIWILL_P53] = {
  2770. .mixers = { alc880_uniwill_p53_mixer },
  2771. .init_verbs = { alc880_volume_init_verbs,
  2772. alc880_uniwill_p53_init_verbs },
  2773. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2774. .dac_nids = alc880_asus_dac_nids,
  2775. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2776. .channel_mode = alc880_threestack_modes,
  2777. .input_mux = &alc880_capture_source,
  2778. .unsol_event = alc880_uniwill_p53_unsol_event,
  2779. .init_hook = alc880_uniwill_p53_hp_automute,
  2780. },
  2781. [ALC880_FUJITSU] = {
  2782. .mixers = { alc880_fujitsu_mixer,
  2783. alc880_pcbeep_mixer, },
  2784. .init_verbs = { alc880_volume_init_verbs,
  2785. alc880_uniwill_p53_init_verbs,
  2786. alc880_beep_init_verbs },
  2787. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2788. .dac_nids = alc880_dac_nids,
  2789. .dig_out_nid = ALC880_DIGOUT_NID,
  2790. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2791. .channel_mode = alc880_2_jack_modes,
  2792. .input_mux = &alc880_capture_source,
  2793. .unsol_event = alc880_uniwill_p53_unsol_event,
  2794. .init_hook = alc880_uniwill_p53_hp_automute,
  2795. },
  2796. [ALC880_CLEVO] = {
  2797. .mixers = { alc880_three_stack_mixer },
  2798. .init_verbs = { alc880_volume_init_verbs,
  2799. alc880_pin_clevo_init_verbs },
  2800. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2801. .dac_nids = alc880_dac_nids,
  2802. .hp_nid = 0x03,
  2803. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2804. .channel_mode = alc880_threestack_modes,
  2805. .need_dac_fix = 1,
  2806. .input_mux = &alc880_capture_source,
  2807. },
  2808. [ALC880_LG] = {
  2809. .mixers = { alc880_lg_mixer },
  2810. .init_verbs = { alc880_volume_init_verbs,
  2811. alc880_lg_init_verbs },
  2812. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2813. .dac_nids = alc880_lg_dac_nids,
  2814. .dig_out_nid = ALC880_DIGOUT_NID,
  2815. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2816. .channel_mode = alc880_lg_ch_modes,
  2817. .need_dac_fix = 1,
  2818. .input_mux = &alc880_lg_capture_source,
  2819. .unsol_event = alc880_lg_unsol_event,
  2820. .init_hook = alc880_lg_automute,
  2821. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2822. .loopbacks = alc880_lg_loopbacks,
  2823. #endif
  2824. },
  2825. [ALC880_LG_LW] = {
  2826. .mixers = { alc880_lg_lw_mixer },
  2827. .init_verbs = { alc880_volume_init_verbs,
  2828. alc880_lg_lw_init_verbs },
  2829. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2830. .dac_nids = alc880_dac_nids,
  2831. .dig_out_nid = ALC880_DIGOUT_NID,
  2832. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2833. .channel_mode = alc880_lg_lw_modes,
  2834. .input_mux = &alc880_lg_lw_capture_source,
  2835. .unsol_event = alc880_lg_lw_unsol_event,
  2836. .init_hook = alc880_lg_lw_automute,
  2837. },
  2838. #ifdef CONFIG_SND_DEBUG
  2839. [ALC880_TEST] = {
  2840. .mixers = { alc880_test_mixer },
  2841. .init_verbs = { alc880_test_init_verbs },
  2842. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2843. .dac_nids = alc880_test_dac_nids,
  2844. .dig_out_nid = ALC880_DIGOUT_NID,
  2845. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2846. .channel_mode = alc880_test_modes,
  2847. .input_mux = &alc880_test_capture_source,
  2848. },
  2849. #endif
  2850. };
  2851. /*
  2852. * Automatic parse of I/O pins from the BIOS configuration
  2853. */
  2854. #define NUM_CONTROL_ALLOC 32
  2855. #define NUM_VERB_ALLOC 32
  2856. enum {
  2857. ALC_CTL_WIDGET_VOL,
  2858. ALC_CTL_WIDGET_MUTE,
  2859. ALC_CTL_BIND_MUTE,
  2860. };
  2861. static struct snd_kcontrol_new alc880_control_templates[] = {
  2862. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2863. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2864. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2865. };
  2866. /* add dynamic controls */
  2867. static int add_control(struct alc_spec *spec, int type, const char *name,
  2868. unsigned long val)
  2869. {
  2870. struct snd_kcontrol_new *knew;
  2871. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2872. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2873. /* array + terminator */
  2874. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2875. if (!knew)
  2876. return -ENOMEM;
  2877. if (spec->kctl_alloc) {
  2878. memcpy(knew, spec->kctl_alloc,
  2879. sizeof(*knew) * spec->num_kctl_alloc);
  2880. kfree(spec->kctl_alloc);
  2881. }
  2882. spec->kctl_alloc = knew;
  2883. spec->num_kctl_alloc = num;
  2884. }
  2885. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2886. *knew = alc880_control_templates[type];
  2887. knew->name = kstrdup(name, GFP_KERNEL);
  2888. if (!knew->name)
  2889. return -ENOMEM;
  2890. knew->private_value = val;
  2891. spec->num_kctl_used++;
  2892. return 0;
  2893. }
  2894. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2895. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2896. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2897. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2898. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2899. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2900. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2901. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2902. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2903. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2904. #define ALC880_PIN_CD_NID 0x1c
  2905. /* fill in the dac_nids table from the parsed pin configuration */
  2906. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2907. const struct auto_pin_cfg *cfg)
  2908. {
  2909. hda_nid_t nid;
  2910. int assigned[4];
  2911. int i, j;
  2912. memset(assigned, 0, sizeof(assigned));
  2913. spec->multiout.dac_nids = spec->private_dac_nids;
  2914. /* check the pins hardwired to audio widget */
  2915. for (i = 0; i < cfg->line_outs; i++) {
  2916. nid = cfg->line_out_pins[i];
  2917. if (alc880_is_fixed_pin(nid)) {
  2918. int idx = alc880_fixed_pin_idx(nid);
  2919. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2920. assigned[idx] = 1;
  2921. }
  2922. }
  2923. /* left pins can be connect to any audio widget */
  2924. for (i = 0; i < cfg->line_outs; i++) {
  2925. nid = cfg->line_out_pins[i];
  2926. if (alc880_is_fixed_pin(nid))
  2927. continue;
  2928. /* search for an empty channel */
  2929. for (j = 0; j < cfg->line_outs; j++) {
  2930. if (!assigned[j]) {
  2931. spec->multiout.dac_nids[i] =
  2932. alc880_idx_to_dac(j);
  2933. assigned[j] = 1;
  2934. break;
  2935. }
  2936. }
  2937. }
  2938. spec->multiout.num_dacs = cfg->line_outs;
  2939. return 0;
  2940. }
  2941. /* add playback controls from the parsed DAC table */
  2942. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2943. const struct auto_pin_cfg *cfg)
  2944. {
  2945. char name[32];
  2946. static const char *chname[4] = {
  2947. "Front", "Surround", NULL /*CLFE*/, "Side"
  2948. };
  2949. hda_nid_t nid;
  2950. int i, err;
  2951. for (i = 0; i < cfg->line_outs; i++) {
  2952. if (!spec->multiout.dac_nids[i])
  2953. continue;
  2954. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2955. if (i == 2) {
  2956. /* Center/LFE */
  2957. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2958. "Center Playback Volume",
  2959. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2960. HDA_OUTPUT));
  2961. if (err < 0)
  2962. return err;
  2963. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2964. "LFE Playback Volume",
  2965. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2966. HDA_OUTPUT));
  2967. if (err < 0)
  2968. return err;
  2969. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2970. "Center Playback Switch",
  2971. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2972. HDA_INPUT));
  2973. if (err < 0)
  2974. return err;
  2975. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2976. "LFE Playback Switch",
  2977. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2978. HDA_INPUT));
  2979. if (err < 0)
  2980. return err;
  2981. } else {
  2982. sprintf(name, "%s Playback Volume", chname[i]);
  2983. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2984. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2985. HDA_OUTPUT));
  2986. if (err < 0)
  2987. return err;
  2988. sprintf(name, "%s Playback Switch", chname[i]);
  2989. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2990. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2991. HDA_INPUT));
  2992. if (err < 0)
  2993. return err;
  2994. }
  2995. }
  2996. return 0;
  2997. }
  2998. /* add playback controls for speaker and HP outputs */
  2999. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  3000. const char *pfx)
  3001. {
  3002. hda_nid_t nid;
  3003. int err;
  3004. char name[32];
  3005. if (!pin)
  3006. return 0;
  3007. if (alc880_is_fixed_pin(pin)) {
  3008. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  3009. /* specify the DAC as the extra output */
  3010. if (!spec->multiout.hp_nid)
  3011. spec->multiout.hp_nid = nid;
  3012. else
  3013. spec->multiout.extra_out_nid[0] = nid;
  3014. /* control HP volume/switch on the output mixer amp */
  3015. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  3016. sprintf(name, "%s Playback Volume", pfx);
  3017. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  3018. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  3019. if (err < 0)
  3020. return err;
  3021. sprintf(name, "%s Playback Switch", pfx);
  3022. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  3023. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  3024. if (err < 0)
  3025. return err;
  3026. } else if (alc880_is_multi_pin(pin)) {
  3027. /* set manual connection */
  3028. /* we have only a switch on HP-out PIN */
  3029. sprintf(name, "%s Playback Switch", pfx);
  3030. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  3031. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  3032. if (err < 0)
  3033. return err;
  3034. }
  3035. return 0;
  3036. }
  3037. /* create input playback/capture controls for the given pin */
  3038. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  3039. const char *ctlname,
  3040. int idx, hda_nid_t mix_nid)
  3041. {
  3042. char name[32];
  3043. int err;
  3044. sprintf(name, "%s Playback Volume", ctlname);
  3045. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  3046. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  3047. if (err < 0)
  3048. return err;
  3049. sprintf(name, "%s Playback Switch", ctlname);
  3050. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  3051. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  3052. if (err < 0)
  3053. return err;
  3054. return 0;
  3055. }
  3056. /* create playback/capture controls for input pins */
  3057. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3058. const struct auto_pin_cfg *cfg)
  3059. {
  3060. struct hda_input_mux *imux = &spec->private_imux;
  3061. int i, err, idx;
  3062. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3063. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3064. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3065. err = new_analog_input(spec, cfg->input_pins[i],
  3066. auto_pin_cfg_labels[i],
  3067. idx, 0x0b);
  3068. if (err < 0)
  3069. return err;
  3070. imux->items[imux->num_items].label =
  3071. auto_pin_cfg_labels[i];
  3072. imux->items[imux->num_items].index =
  3073. alc880_input_pin_idx(cfg->input_pins[i]);
  3074. imux->num_items++;
  3075. }
  3076. }
  3077. return 0;
  3078. }
  3079. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3080. hda_nid_t nid, int pin_type,
  3081. int dac_idx)
  3082. {
  3083. /* set as output */
  3084. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3085. pin_type);
  3086. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3087. AMP_OUT_UNMUTE);
  3088. /* need the manual connection? */
  3089. if (alc880_is_multi_pin(nid)) {
  3090. struct alc_spec *spec = codec->spec;
  3091. int idx = alc880_multi_pin_idx(nid);
  3092. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3093. AC_VERB_SET_CONNECT_SEL,
  3094. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3095. }
  3096. }
  3097. static int get_pin_type(int line_out_type)
  3098. {
  3099. if (line_out_type == AUTO_PIN_HP_OUT)
  3100. return PIN_HP;
  3101. else
  3102. return PIN_OUT;
  3103. }
  3104. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3105. {
  3106. struct alc_spec *spec = codec->spec;
  3107. int i;
  3108. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3109. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3110. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3111. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3112. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3113. }
  3114. }
  3115. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3116. {
  3117. struct alc_spec *spec = codec->spec;
  3118. hda_nid_t pin;
  3119. pin = spec->autocfg.speaker_pins[0];
  3120. if (pin) /* connect to front */
  3121. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3122. pin = spec->autocfg.hp_pins[0];
  3123. if (pin) /* connect to front */
  3124. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3125. }
  3126. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3127. {
  3128. struct alc_spec *spec = codec->spec;
  3129. int i;
  3130. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3131. hda_nid_t nid = spec->autocfg.input_pins[i];
  3132. if (alc880_is_input_pin(nid)) {
  3133. snd_hda_codec_write(codec, nid, 0,
  3134. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3135. i <= AUTO_PIN_FRONT_MIC ?
  3136. PIN_VREF80 : PIN_IN);
  3137. if (nid != ALC880_PIN_CD_NID)
  3138. snd_hda_codec_write(codec, nid, 0,
  3139. AC_VERB_SET_AMP_GAIN_MUTE,
  3140. AMP_OUT_MUTE);
  3141. }
  3142. }
  3143. }
  3144. /* parse the BIOS configuration and set up the alc_spec */
  3145. /* return 1 if successful, 0 if the proper config is not found,
  3146. * or a negative error code
  3147. */
  3148. static int alc880_parse_auto_config(struct hda_codec *codec)
  3149. {
  3150. struct alc_spec *spec = codec->spec;
  3151. int err;
  3152. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3153. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3154. alc880_ignore);
  3155. if (err < 0)
  3156. return err;
  3157. if (!spec->autocfg.line_outs)
  3158. return 0; /* can't find valid BIOS pin config */
  3159. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3160. if (err < 0)
  3161. return err;
  3162. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3163. if (err < 0)
  3164. return err;
  3165. err = alc880_auto_create_extra_out(spec,
  3166. spec->autocfg.speaker_pins[0],
  3167. "Speaker");
  3168. if (err < 0)
  3169. return err;
  3170. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3171. "Headphone");
  3172. if (err < 0)
  3173. return err;
  3174. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3175. if (err < 0)
  3176. return err;
  3177. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3178. if (spec->autocfg.dig_out_pin)
  3179. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3180. if (spec->autocfg.dig_in_pin)
  3181. spec->dig_in_nid = ALC880_DIGIN_NID;
  3182. if (spec->kctl_alloc)
  3183. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3184. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3185. spec->num_mux_defs = 1;
  3186. spec->input_mux = &spec->private_imux;
  3187. return 1;
  3188. }
  3189. /* additional initialization for auto-configuration model */
  3190. static void alc880_auto_init(struct hda_codec *codec)
  3191. {
  3192. alc880_auto_init_multi_out(codec);
  3193. alc880_auto_init_extra_out(codec);
  3194. alc880_auto_init_analog_input(codec);
  3195. }
  3196. /*
  3197. * OK, here we have finally the patch for ALC880
  3198. */
  3199. static int patch_alc880(struct hda_codec *codec)
  3200. {
  3201. struct alc_spec *spec;
  3202. int board_config;
  3203. int err;
  3204. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3205. if (spec == NULL)
  3206. return -ENOMEM;
  3207. codec->spec = spec;
  3208. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3209. alc880_models,
  3210. alc880_cfg_tbl);
  3211. if (board_config < 0) {
  3212. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3213. "trying auto-probe from BIOS...\n");
  3214. board_config = ALC880_AUTO;
  3215. }
  3216. if (board_config == ALC880_AUTO) {
  3217. /* automatic parse from the BIOS config */
  3218. err = alc880_parse_auto_config(codec);
  3219. if (err < 0) {
  3220. alc_free(codec);
  3221. return err;
  3222. } else if (!err) {
  3223. printk(KERN_INFO
  3224. "hda_codec: Cannot set up configuration "
  3225. "from BIOS. Using 3-stack mode...\n");
  3226. board_config = ALC880_3ST;
  3227. }
  3228. }
  3229. if (board_config != ALC880_AUTO)
  3230. setup_preset(spec, &alc880_presets[board_config]);
  3231. spec->stream_name_analog = "ALC880 Analog";
  3232. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3233. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3234. spec->stream_name_digital = "ALC880 Digital";
  3235. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3236. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3237. if (!spec->adc_nids && spec->input_mux) {
  3238. /* check whether NID 0x07 is valid */
  3239. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3240. /* get type */
  3241. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3242. if (wcap != AC_WID_AUD_IN) {
  3243. spec->adc_nids = alc880_adc_nids_alt;
  3244. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3245. spec->mixers[spec->num_mixers] =
  3246. alc880_capture_alt_mixer;
  3247. spec->num_mixers++;
  3248. } else {
  3249. spec->adc_nids = alc880_adc_nids;
  3250. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3251. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3252. spec->num_mixers++;
  3253. }
  3254. }
  3255. codec->patch_ops = alc_patch_ops;
  3256. if (board_config == ALC880_AUTO)
  3257. spec->init_hook = alc880_auto_init;
  3258. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3259. if (!spec->loopback.amplist)
  3260. spec->loopback.amplist = alc880_loopbacks;
  3261. #endif
  3262. return 0;
  3263. }
  3264. /*
  3265. * ALC260 support
  3266. */
  3267. static hda_nid_t alc260_dac_nids[1] = {
  3268. /* front */
  3269. 0x02,
  3270. };
  3271. static hda_nid_t alc260_adc_nids[1] = {
  3272. /* ADC0 */
  3273. 0x04,
  3274. };
  3275. static hda_nid_t alc260_adc_nids_alt[1] = {
  3276. /* ADC1 */
  3277. 0x05,
  3278. };
  3279. static hda_nid_t alc260_hp_adc_nids[2] = {
  3280. /* ADC1, 0 */
  3281. 0x05, 0x04
  3282. };
  3283. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3284. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3285. */
  3286. static hda_nid_t alc260_dual_adc_nids[2] = {
  3287. /* ADC0, ADC1 */
  3288. 0x04, 0x05
  3289. };
  3290. #define ALC260_DIGOUT_NID 0x03
  3291. #define ALC260_DIGIN_NID 0x06
  3292. static struct hda_input_mux alc260_capture_source = {
  3293. .num_items = 4,
  3294. .items = {
  3295. { "Mic", 0x0 },
  3296. { "Front Mic", 0x1 },
  3297. { "Line", 0x2 },
  3298. { "CD", 0x4 },
  3299. },
  3300. };
  3301. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3302. * headphone jack and the internal CD lines since these are the only pins at
  3303. * which audio can appear. For flexibility, also allow the option of
  3304. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3305. * connection to the mixer output).
  3306. */
  3307. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3308. {
  3309. .num_items = 3,
  3310. .items = {
  3311. { "Mic/Line", 0x0 },
  3312. { "CD", 0x4 },
  3313. { "Headphone", 0x2 },
  3314. },
  3315. },
  3316. {
  3317. .num_items = 4,
  3318. .items = {
  3319. { "Mic/Line", 0x0 },
  3320. { "CD", 0x4 },
  3321. { "Headphone", 0x2 },
  3322. { "Mixer", 0x5 },
  3323. },
  3324. },
  3325. };
  3326. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3327. * the Fujitsu S702x, but jacks are marked differently.
  3328. */
  3329. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3330. {
  3331. .num_items = 4,
  3332. .items = {
  3333. { "Mic", 0x0 },
  3334. { "Line", 0x2 },
  3335. { "CD", 0x4 },
  3336. { "Headphone", 0x5 },
  3337. },
  3338. },
  3339. {
  3340. .num_items = 5,
  3341. .items = {
  3342. { "Mic", 0x0 },
  3343. { "Line", 0x2 },
  3344. { "CD", 0x4 },
  3345. { "Headphone", 0x6 },
  3346. { "Mixer", 0x5 },
  3347. },
  3348. },
  3349. };
  3350. /*
  3351. * This is just place-holder, so there's something for alc_build_pcms to look
  3352. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3353. * element which allows changing the channel mode, so the verb list is
  3354. * never used.
  3355. */
  3356. static struct hda_channel_mode alc260_modes[1] = {
  3357. { 2, NULL },
  3358. };
  3359. /* Mixer combinations
  3360. *
  3361. * basic: base_output + input + pc_beep + capture
  3362. * HP: base_output + input + capture_alt
  3363. * HP_3013: hp_3013 + input + capture
  3364. * fujitsu: fujitsu + capture
  3365. * acer: acer + capture
  3366. */
  3367. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3368. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3369. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3370. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3371. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3372. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3373. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3374. { } /* end */
  3375. };
  3376. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3377. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3378. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3379. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3380. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3381. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3382. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3383. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3384. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3385. { } /* end */
  3386. };
  3387. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3388. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3389. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3390. { } /* end */
  3391. };
  3392. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3393. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3394. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3395. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3396. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3397. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3398. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3399. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3400. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3401. { } /* end */
  3402. };
  3403. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3404. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3405. */
  3406. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3407. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3408. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3409. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3410. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3411. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3412. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3413. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3414. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3415. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3416. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3417. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3418. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3419. { } /* end */
  3420. };
  3421. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3422. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3423. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3424. * datasheet doesn't mention this restriction. At this stage it's not clear
  3425. * whether this behaviour is intentional or is a hardware bug in chip
  3426. * revisions available in early 2006. Therefore for now allow the
  3427. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3428. * that the lack of mic bias for this NID is intentional we could change the
  3429. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3430. *
  3431. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3432. * don't appear to make the mic bias available from the "line" jack, even
  3433. * though the NID used for this jack (0x14) can supply it. The theory is
  3434. * that perhaps Acer have included blocking capacitors between the ALC260
  3435. * and the output jack. If this turns out to be the case for all such
  3436. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3437. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3438. *
  3439. * The C20x Tablet series have a mono internal speaker which is controlled
  3440. * via the chip's Mono sum widget and pin complex, so include the necessary
  3441. * controls for such models. On models without a "mono speaker" the control
  3442. * won't do anything.
  3443. */
  3444. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3445. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3446. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3447. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3448. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3449. HDA_OUTPUT),
  3450. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3451. HDA_INPUT),
  3452. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3453. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3454. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3455. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3456. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3457. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3458. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3459. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3460. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3461. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3462. { } /* end */
  3463. };
  3464. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3465. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3466. */
  3467. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3468. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3469. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3470. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3471. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3472. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3473. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3474. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3475. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3476. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3477. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3478. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3479. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3480. { } /* end */
  3481. };
  3482. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3483. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3484. */
  3485. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3486. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3487. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3488. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3489. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3490. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3491. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3492. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3493. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3494. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3495. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3496. { } /* end */
  3497. };
  3498. /* capture mixer elements */
  3499. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3500. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3501. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3502. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3503. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3504. {
  3505. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3506. /* The multiple "Capture Source" controls confuse alsamixer
  3507. * So call somewhat different..
  3508. * FIXME: the controls appear in the "playback" view!
  3509. */
  3510. /* .name = "Capture Source", */
  3511. .name = "Input Source",
  3512. .count = 2,
  3513. .info = alc_mux_enum_info,
  3514. .get = alc_mux_enum_get,
  3515. .put = alc_mux_enum_put,
  3516. },
  3517. { } /* end */
  3518. };
  3519. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3520. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3521. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3522. {
  3523. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3524. /* The multiple "Capture Source" controls confuse alsamixer
  3525. * So call somewhat different..
  3526. * FIXME: the controls appear in the "playback" view!
  3527. */
  3528. /* .name = "Capture Source", */
  3529. .name = "Input Source",
  3530. .count = 1,
  3531. .info = alc_mux_enum_info,
  3532. .get = alc_mux_enum_get,
  3533. .put = alc_mux_enum_put,
  3534. },
  3535. { } /* end */
  3536. };
  3537. /*
  3538. * initialization verbs
  3539. */
  3540. static struct hda_verb alc260_init_verbs[] = {
  3541. /* Line In pin widget for input */
  3542. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3543. /* CD pin widget for input */
  3544. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3545. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3546. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3547. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3548. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3549. /* LINE-2 is used for line-out in rear */
  3550. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3551. /* select line-out */
  3552. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3553. /* LINE-OUT pin */
  3554. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3555. /* enable HP */
  3556. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3557. /* enable Mono */
  3558. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3559. /* mute capture amp left and right */
  3560. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* set connection select to line in (default select for this ADC) */
  3562. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3563. /* mute capture amp left and right */
  3564. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3565. /* set connection select to line in (default select for this ADC) */
  3566. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3567. /* set vol=0 Line-Out mixer amp left and right */
  3568. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3569. /* unmute pin widget amp left and right (no gain on this amp) */
  3570. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3571. /* set vol=0 HP mixer amp left and right */
  3572. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3573. /* unmute pin widget amp left and right (no gain on this amp) */
  3574. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3575. /* set vol=0 Mono mixer amp left and right */
  3576. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3577. /* unmute pin widget amp left and right (no gain on this amp) */
  3578. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3579. /* unmute LINE-2 out pin */
  3580. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3581. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3582. * Line In 2 = 0x03
  3583. */
  3584. /* mute analog inputs */
  3585. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3586. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3587. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3588. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3589. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3590. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3591. /* mute Front out path */
  3592. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3593. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3594. /* mute Headphone out path */
  3595. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3596. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3597. /* mute Mono out path */
  3598. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3599. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3600. { }
  3601. };
  3602. #if 0 /* should be identical with alc260_init_verbs? */
  3603. static struct hda_verb alc260_hp_init_verbs[] = {
  3604. /* Headphone and output */
  3605. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3606. /* mono output */
  3607. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3608. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3609. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3610. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3611. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3612. /* Line In pin widget for input */
  3613. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3614. /* Line-2 pin widget for output */
  3615. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3616. /* CD pin widget for input */
  3617. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3618. /* unmute amp left and right */
  3619. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3620. /* set connection select to line in (default select for this ADC) */
  3621. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3622. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3623. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3624. /* mute pin widget amp left and right (no gain on this amp) */
  3625. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3626. /* unmute HP mixer amp left and right (volume = 0) */
  3627. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3628. /* mute pin widget amp left and right (no gain on this amp) */
  3629. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3630. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3631. * Line In 2 = 0x03
  3632. */
  3633. /* mute analog inputs */
  3634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3635. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3636. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3638. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3639. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3640. /* Unmute Front out path */
  3641. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3642. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3643. /* Unmute Headphone out path */
  3644. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3645. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3646. /* Unmute Mono out path */
  3647. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3648. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3649. { }
  3650. };
  3651. #endif
  3652. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3653. /* Line out and output */
  3654. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3655. /* mono output */
  3656. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3657. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3658. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3659. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3660. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3661. /* Line In pin widget for input */
  3662. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3663. /* Headphone pin widget for output */
  3664. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3665. /* CD pin widget for input */
  3666. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3667. /* unmute amp left and right */
  3668. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3669. /* set connection select to line in (default select for this ADC) */
  3670. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3671. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3672. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3673. /* mute pin widget amp left and right (no gain on this amp) */
  3674. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3675. /* unmute HP mixer amp left and right (volume = 0) */
  3676. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3677. /* mute pin widget amp left and right (no gain on this amp) */
  3678. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3679. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3680. * Line In 2 = 0x03
  3681. */
  3682. /* mute analog inputs */
  3683. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3684. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3685. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3686. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3687. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3688. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3689. /* Unmute Front out path */
  3690. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3692. /* Unmute Headphone out path */
  3693. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3694. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3695. /* Unmute Mono out path */
  3696. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3697. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3698. { }
  3699. };
  3700. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3701. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3702. * audio = 0x16, internal speaker = 0x10.
  3703. */
  3704. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3705. /* Disable all GPIOs */
  3706. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3707. /* Internal speaker is connected to headphone pin */
  3708. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3709. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3710. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3711. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3712. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3713. /* Ensure all other unused pins are disabled and muted. */
  3714. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3715. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3716. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3717. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3718. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3719. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3720. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3721. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3722. /* Disable digital (SPDIF) pins */
  3723. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3724. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3725. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3726. * when acting as an output.
  3727. */
  3728. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3729. /* Start with output sum widgets muted and their output gains at min */
  3730. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3731. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3733. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3734. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3735. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3736. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3737. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3738. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3739. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3740. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3741. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3742. * If the pin mode is changed by the user the pin mode control will
  3743. * take care of enabling the pin's input/output buffers as needed.
  3744. * Therefore there's no need to enable the input buffer at this
  3745. * stage.
  3746. */
  3747. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3748. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3749. * mixer ctrl)
  3750. */
  3751. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3752. /* Mute capture amp left and right */
  3753. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3754. /* Set ADC connection select to match default mixer setting - line
  3755. * in (on mic1 pin)
  3756. */
  3757. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3758. /* Do the same for the second ADC: mute capture input amp and
  3759. * set ADC connection to line in (on mic1 pin)
  3760. */
  3761. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3762. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3763. /* Mute all inputs to mixer widget (even unconnected ones) */
  3764. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3765. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3766. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3767. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3768. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3769. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3770. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3771. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3772. { }
  3773. };
  3774. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3775. * similar laptops (adapted from Fujitsu init verbs).
  3776. */
  3777. static struct hda_verb alc260_acer_init_verbs[] = {
  3778. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3779. * the headphone jack. Turn this on and rely on the standard mute
  3780. * methods whenever the user wants to turn these outputs off.
  3781. */
  3782. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3783. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3784. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3785. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3786. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3787. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3788. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3789. /* Line In jack is connected to Line1 pin */
  3790. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3791. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3792. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3793. /* Ensure all other unused pins are disabled and muted. */
  3794. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3795. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3796. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3797. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3798. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3799. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3800. /* Disable digital (SPDIF) pins */
  3801. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3802. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3803. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3804. * bus when acting as outputs.
  3805. */
  3806. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3807. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3808. /* Start with output sum widgets muted and their output gains at min */
  3809. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3810. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3811. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3812. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3813. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3814. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3815. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3816. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3817. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3818. /* Unmute Line-out pin widget amp left and right
  3819. * (no equiv mixer ctrl)
  3820. */
  3821. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3822. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3823. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3824. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3825. * inputs. If the pin mode is changed by the user the pin mode control
  3826. * will take care of enabling the pin's input/output buffers as needed.
  3827. * Therefore there's no need to enable the input buffer at this
  3828. * stage.
  3829. */
  3830. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3831. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3832. /* Mute capture amp left and right */
  3833. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. /* Set ADC connection select to match default mixer setting - mic
  3835. * (on mic1 pin)
  3836. */
  3837. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3838. /* Do similar with the second ADC: mute capture input amp and
  3839. * set ADC connection to mic to match ALSA's default state.
  3840. */
  3841. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3842. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3843. /* Mute all inputs to mixer widget (even unconnected ones) */
  3844. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3845. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3846. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3847. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3848. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3849. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3850. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3851. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3852. { }
  3853. };
  3854. static struct hda_verb alc260_will_verbs[] = {
  3855. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3856. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3857. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3858. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3859. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3860. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3861. {}
  3862. };
  3863. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3864. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3865. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3866. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3867. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3868. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3869. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3870. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3871. {}
  3872. };
  3873. /* toggle speaker-output according to the hp-jack state */
  3874. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3875. {
  3876. unsigned int present;
  3877. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3878. present = snd_hda_codec_read(codec, 0x0f, 0,
  3879. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3880. if (present) {
  3881. snd_hda_codec_write_cache(codec, 0x01, 0,
  3882. AC_VERB_SET_GPIO_DATA, 1);
  3883. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3884. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3885. PIN_HP);
  3886. } else {
  3887. snd_hda_codec_write_cache(codec, 0x01, 0,
  3888. AC_VERB_SET_GPIO_DATA, 0);
  3889. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3890. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3891. PIN_OUT);
  3892. }
  3893. }
  3894. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3895. unsigned int res)
  3896. {
  3897. if ((res >> 26) == ALC880_HP_EVENT)
  3898. alc260_replacer_672v_automute(codec);
  3899. }
  3900. /* Test configuration for debugging, modelled after the ALC880 test
  3901. * configuration.
  3902. */
  3903. #ifdef CONFIG_SND_DEBUG
  3904. static hda_nid_t alc260_test_dac_nids[1] = {
  3905. 0x02,
  3906. };
  3907. static hda_nid_t alc260_test_adc_nids[2] = {
  3908. 0x04, 0x05,
  3909. };
  3910. /* For testing the ALC260, each input MUX needs its own definition since
  3911. * the signal assignments are different. This assumes that the first ADC
  3912. * is NID 0x04.
  3913. */
  3914. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3915. {
  3916. .num_items = 7,
  3917. .items = {
  3918. { "MIC1 pin", 0x0 },
  3919. { "MIC2 pin", 0x1 },
  3920. { "LINE1 pin", 0x2 },
  3921. { "LINE2 pin", 0x3 },
  3922. { "CD pin", 0x4 },
  3923. { "LINE-OUT pin", 0x5 },
  3924. { "HP-OUT pin", 0x6 },
  3925. },
  3926. },
  3927. {
  3928. .num_items = 8,
  3929. .items = {
  3930. { "MIC1 pin", 0x0 },
  3931. { "MIC2 pin", 0x1 },
  3932. { "LINE1 pin", 0x2 },
  3933. { "LINE2 pin", 0x3 },
  3934. { "CD pin", 0x4 },
  3935. { "Mixer", 0x5 },
  3936. { "LINE-OUT pin", 0x6 },
  3937. { "HP-OUT pin", 0x7 },
  3938. },
  3939. },
  3940. };
  3941. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3942. /* Output driver widgets */
  3943. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3944. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3945. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3946. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3947. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3948. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3949. /* Modes for retasking pin widgets
  3950. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3951. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3952. * mention this restriction. At this stage it's not clear whether
  3953. * this behaviour is intentional or is a hardware bug in chip
  3954. * revisions available at least up until early 2006. Therefore for
  3955. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3956. * choices, but if it turns out that the lack of mic bias for these
  3957. * NIDs is intentional we could change their modes from
  3958. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3959. */
  3960. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3961. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3962. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3963. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3964. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3965. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3966. /* Loopback mixer controls */
  3967. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3968. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3969. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3970. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3971. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3972. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3973. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3974. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3975. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3976. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3977. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3978. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3979. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3980. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3981. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3982. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3983. /* Controls for GPIO pins, assuming they are configured as outputs */
  3984. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3985. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3986. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3987. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3988. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3989. * is ambigious as to which NID is which; testing on laptops which
  3990. * make this output available should provide clarification.
  3991. */
  3992. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3993. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3994. /* A switch allowing EAPD to be enabled. Some laptops seem to use
  3995. * this output to turn on an external amplifier.
  3996. */
  3997. ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
  3998. ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
  3999. { } /* end */
  4000. };
  4001. static struct hda_verb alc260_test_init_verbs[] = {
  4002. /* Enable all GPIOs as outputs with an initial value of 0 */
  4003. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  4004. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  4005. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  4006. /* Enable retasking pins as output, initially without power amp */
  4007. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4008. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4009. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4010. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4011. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4012. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4013. /* Disable digital (SPDIF) pins initially, but users can enable
  4014. * them via a mixer switch. In the case of SPDIF-out, this initverb
  4015. * payload also sets the generation to 0, output to be in "consumer"
  4016. * PCM format, copyright asserted, no pre-emphasis and no validity
  4017. * control.
  4018. */
  4019. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  4020. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  4021. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  4022. * OUT1 sum bus when acting as an output.
  4023. */
  4024. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  4025. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  4026. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  4027. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  4028. /* Start with output sum widgets muted and their output gains at min */
  4029. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4030. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4031. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4032. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4033. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4034. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4035. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4036. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4037. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4038. /* Unmute retasking pin widget output buffers since the default
  4039. * state appears to be output. As the pin mode is changed by the
  4040. * user the pin mode control will take care of enabling the pin's
  4041. * input/output buffers as needed.
  4042. */
  4043. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4044. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4045. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4046. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4047. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4048. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4049. /* Also unmute the mono-out pin widget */
  4050. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4051. /* Mute capture amp left and right */
  4052. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4053. /* Set ADC connection select to match default mixer setting (mic1
  4054. * pin)
  4055. */
  4056. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4057. /* Do the same for the second ADC: mute capture input amp and
  4058. * set ADC connection to mic1 pin
  4059. */
  4060. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4061. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4062. /* Mute all inputs to mixer widget (even unconnected ones) */
  4063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4064. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4065. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4066. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4067. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4068. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4069. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4070. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4071. { }
  4072. };
  4073. #endif
  4074. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4075. .substreams = 1,
  4076. .channels_min = 2,
  4077. .channels_max = 2,
  4078. };
  4079. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4080. .substreams = 1,
  4081. .channels_min = 2,
  4082. .channels_max = 2,
  4083. };
  4084. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4085. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4086. /*
  4087. * for BIOS auto-configuration
  4088. */
  4089. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4090. const char *pfx)
  4091. {
  4092. hda_nid_t nid_vol;
  4093. unsigned long vol_val, sw_val;
  4094. char name[32];
  4095. int err;
  4096. if (nid >= 0x0f && nid < 0x11) {
  4097. nid_vol = nid - 0x7;
  4098. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4099. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4100. } else if (nid == 0x11) {
  4101. nid_vol = nid - 0x7;
  4102. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4103. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4104. } else if (nid >= 0x12 && nid <= 0x15) {
  4105. nid_vol = 0x08;
  4106. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4107. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4108. } else
  4109. return 0; /* N/A */
  4110. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4111. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4112. if (err < 0)
  4113. return err;
  4114. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4115. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4116. if (err < 0)
  4117. return err;
  4118. return 1;
  4119. }
  4120. /* add playback controls from the parsed DAC table */
  4121. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4122. const struct auto_pin_cfg *cfg)
  4123. {
  4124. hda_nid_t nid;
  4125. int err;
  4126. spec->multiout.num_dacs = 1;
  4127. spec->multiout.dac_nids = spec->private_dac_nids;
  4128. spec->multiout.dac_nids[0] = 0x02;
  4129. nid = cfg->line_out_pins[0];
  4130. if (nid) {
  4131. err = alc260_add_playback_controls(spec, nid, "Front");
  4132. if (err < 0)
  4133. return err;
  4134. }
  4135. nid = cfg->speaker_pins[0];
  4136. if (nid) {
  4137. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4138. if (err < 0)
  4139. return err;
  4140. }
  4141. nid = cfg->hp_pins[0];
  4142. if (nid) {
  4143. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4144. if (err < 0)
  4145. return err;
  4146. }
  4147. return 0;
  4148. }
  4149. /* create playback/capture controls for input pins */
  4150. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4151. const struct auto_pin_cfg *cfg)
  4152. {
  4153. struct hda_input_mux *imux = &spec->private_imux;
  4154. int i, err, idx;
  4155. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4156. if (cfg->input_pins[i] >= 0x12) {
  4157. idx = cfg->input_pins[i] - 0x12;
  4158. err = new_analog_input(spec, cfg->input_pins[i],
  4159. auto_pin_cfg_labels[i], idx,
  4160. 0x07);
  4161. if (err < 0)
  4162. return err;
  4163. imux->items[imux->num_items].label =
  4164. auto_pin_cfg_labels[i];
  4165. imux->items[imux->num_items].index = idx;
  4166. imux->num_items++;
  4167. }
  4168. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4169. idx = cfg->input_pins[i] - 0x09;
  4170. err = new_analog_input(spec, cfg->input_pins[i],
  4171. auto_pin_cfg_labels[i], idx,
  4172. 0x07);
  4173. if (err < 0)
  4174. return err;
  4175. imux->items[imux->num_items].label =
  4176. auto_pin_cfg_labels[i];
  4177. imux->items[imux->num_items].index = idx;
  4178. imux->num_items++;
  4179. }
  4180. }
  4181. return 0;
  4182. }
  4183. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4184. hda_nid_t nid, int pin_type,
  4185. int sel_idx)
  4186. {
  4187. /* set as output */
  4188. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4189. pin_type);
  4190. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4191. AMP_OUT_UNMUTE);
  4192. /* need the manual connection? */
  4193. if (nid >= 0x12) {
  4194. int idx = nid - 0x12;
  4195. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4196. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4197. }
  4198. }
  4199. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4200. {
  4201. struct alc_spec *spec = codec->spec;
  4202. hda_nid_t nid;
  4203. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4204. nid = spec->autocfg.line_out_pins[0];
  4205. if (nid) {
  4206. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4207. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4208. }
  4209. nid = spec->autocfg.speaker_pins[0];
  4210. if (nid)
  4211. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4212. nid = spec->autocfg.hp_pins[0];
  4213. if (nid)
  4214. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4215. }
  4216. #define ALC260_PIN_CD_NID 0x16
  4217. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4218. {
  4219. struct alc_spec *spec = codec->spec;
  4220. int i;
  4221. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4222. hda_nid_t nid = spec->autocfg.input_pins[i];
  4223. if (nid >= 0x12) {
  4224. snd_hda_codec_write(codec, nid, 0,
  4225. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4226. i <= AUTO_PIN_FRONT_MIC ?
  4227. PIN_VREF80 : PIN_IN);
  4228. if (nid != ALC260_PIN_CD_NID)
  4229. snd_hda_codec_write(codec, nid, 0,
  4230. AC_VERB_SET_AMP_GAIN_MUTE,
  4231. AMP_OUT_MUTE);
  4232. }
  4233. }
  4234. }
  4235. /*
  4236. * generic initialization of ADC, input mixers and output mixers
  4237. */
  4238. static struct hda_verb alc260_volume_init_verbs[] = {
  4239. /*
  4240. * Unmute ADC0-1 and set the default input to mic-in
  4241. */
  4242. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4243. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4244. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4245. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4246. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4247. * mixer widget
  4248. * Note: PASD motherboards uses the Line In 2 as the input for
  4249. * front panel mic (mic 2)
  4250. */
  4251. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4252. /* mute analog inputs */
  4253. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4254. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4255. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4256. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4257. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4258. /*
  4259. * Set up output mixers (0x08 - 0x0a)
  4260. */
  4261. /* set vol=0 to output mixers */
  4262. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4263. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4264. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4265. /* set up input amps for analog loopback */
  4266. /* Amp Indices: DAC = 0, mixer = 1 */
  4267. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4268. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4269. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4270. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4271. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4272. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4273. { }
  4274. };
  4275. static int alc260_parse_auto_config(struct hda_codec *codec)
  4276. {
  4277. struct alc_spec *spec = codec->spec;
  4278. unsigned int wcap;
  4279. int err;
  4280. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4281. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4282. alc260_ignore);
  4283. if (err < 0)
  4284. return err;
  4285. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4286. if (err < 0)
  4287. return err;
  4288. if (!spec->kctl_alloc)
  4289. return 0; /* can't find valid BIOS pin config */
  4290. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4291. if (err < 0)
  4292. return err;
  4293. spec->multiout.max_channels = 2;
  4294. if (spec->autocfg.dig_out_pin)
  4295. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4296. if (spec->kctl_alloc)
  4297. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4298. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4299. spec->num_mux_defs = 1;
  4300. spec->input_mux = &spec->private_imux;
  4301. /* check whether NID 0x04 is valid */
  4302. wcap = get_wcaps(codec, 0x04);
  4303. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4304. if (wcap != AC_WID_AUD_IN) {
  4305. spec->adc_nids = alc260_adc_nids_alt;
  4306. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4307. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4308. } else {
  4309. spec->adc_nids = alc260_adc_nids;
  4310. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4311. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4312. }
  4313. spec->num_mixers++;
  4314. return 1;
  4315. }
  4316. /* additional initialization for auto-configuration model */
  4317. static void alc260_auto_init(struct hda_codec *codec)
  4318. {
  4319. alc260_auto_init_multi_out(codec);
  4320. alc260_auto_init_analog_input(codec);
  4321. }
  4322. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4323. static struct hda_amp_list alc260_loopbacks[] = {
  4324. { 0x07, HDA_INPUT, 0 },
  4325. { 0x07, HDA_INPUT, 1 },
  4326. { 0x07, HDA_INPUT, 2 },
  4327. { 0x07, HDA_INPUT, 3 },
  4328. { 0x07, HDA_INPUT, 4 },
  4329. { } /* end */
  4330. };
  4331. #endif
  4332. /*
  4333. * ALC260 configurations
  4334. */
  4335. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4336. [ALC260_BASIC] = "basic",
  4337. [ALC260_HP] = "hp",
  4338. [ALC260_HP_3013] = "hp-3013",
  4339. [ALC260_FUJITSU_S702X] = "fujitsu",
  4340. [ALC260_ACER] = "acer",
  4341. [ALC260_WILL] = "will",
  4342. [ALC260_REPLACER_672V] = "replacer",
  4343. #ifdef CONFIG_SND_DEBUG
  4344. [ALC260_TEST] = "test",
  4345. #endif
  4346. [ALC260_AUTO] = "auto",
  4347. };
  4348. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4349. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4350. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4351. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4352. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4353. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4354. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4355. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4356. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4357. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4358. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4359. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4360. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4361. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4362. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4363. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4364. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4365. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4366. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4367. {}
  4368. };
  4369. static struct alc_config_preset alc260_presets[] = {
  4370. [ALC260_BASIC] = {
  4371. .mixers = { alc260_base_output_mixer,
  4372. alc260_input_mixer,
  4373. alc260_pc_beep_mixer,
  4374. alc260_capture_mixer },
  4375. .init_verbs = { alc260_init_verbs },
  4376. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4377. .dac_nids = alc260_dac_nids,
  4378. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4379. .adc_nids = alc260_adc_nids,
  4380. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4381. .channel_mode = alc260_modes,
  4382. .input_mux = &alc260_capture_source,
  4383. },
  4384. [ALC260_HP] = {
  4385. .mixers = { alc260_base_output_mixer,
  4386. alc260_input_mixer,
  4387. alc260_capture_alt_mixer },
  4388. .init_verbs = { alc260_init_verbs },
  4389. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4390. .dac_nids = alc260_dac_nids,
  4391. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4392. .adc_nids = alc260_hp_adc_nids,
  4393. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4394. .channel_mode = alc260_modes,
  4395. .input_mux = &alc260_capture_source,
  4396. },
  4397. [ALC260_HP_3013] = {
  4398. .mixers = { alc260_hp_3013_mixer,
  4399. alc260_input_mixer,
  4400. alc260_capture_alt_mixer },
  4401. .init_verbs = { alc260_hp_3013_init_verbs },
  4402. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4403. .dac_nids = alc260_dac_nids,
  4404. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4405. .adc_nids = alc260_hp_adc_nids,
  4406. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4407. .channel_mode = alc260_modes,
  4408. .input_mux = &alc260_capture_source,
  4409. },
  4410. [ALC260_FUJITSU_S702X] = {
  4411. .mixers = { alc260_fujitsu_mixer,
  4412. alc260_capture_mixer },
  4413. .init_verbs = { alc260_fujitsu_init_verbs },
  4414. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4415. .dac_nids = alc260_dac_nids,
  4416. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4417. .adc_nids = alc260_dual_adc_nids,
  4418. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4419. .channel_mode = alc260_modes,
  4420. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4421. .input_mux = alc260_fujitsu_capture_sources,
  4422. },
  4423. [ALC260_ACER] = {
  4424. .mixers = { alc260_acer_mixer,
  4425. alc260_capture_mixer },
  4426. .init_verbs = { alc260_acer_init_verbs },
  4427. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4428. .dac_nids = alc260_dac_nids,
  4429. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4430. .adc_nids = alc260_dual_adc_nids,
  4431. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4432. .channel_mode = alc260_modes,
  4433. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4434. .input_mux = alc260_acer_capture_sources,
  4435. },
  4436. [ALC260_WILL] = {
  4437. .mixers = { alc260_will_mixer,
  4438. alc260_capture_mixer },
  4439. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4440. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4441. .dac_nids = alc260_dac_nids,
  4442. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4443. .adc_nids = alc260_adc_nids,
  4444. .dig_out_nid = ALC260_DIGOUT_NID,
  4445. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4446. .channel_mode = alc260_modes,
  4447. .input_mux = &alc260_capture_source,
  4448. },
  4449. [ALC260_REPLACER_672V] = {
  4450. .mixers = { alc260_replacer_672v_mixer,
  4451. alc260_capture_mixer },
  4452. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4453. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4454. .dac_nids = alc260_dac_nids,
  4455. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4456. .adc_nids = alc260_adc_nids,
  4457. .dig_out_nid = ALC260_DIGOUT_NID,
  4458. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4459. .channel_mode = alc260_modes,
  4460. .input_mux = &alc260_capture_source,
  4461. .unsol_event = alc260_replacer_672v_unsol_event,
  4462. .init_hook = alc260_replacer_672v_automute,
  4463. },
  4464. #ifdef CONFIG_SND_DEBUG
  4465. [ALC260_TEST] = {
  4466. .mixers = { alc260_test_mixer,
  4467. alc260_capture_mixer },
  4468. .init_verbs = { alc260_test_init_verbs },
  4469. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4470. .dac_nids = alc260_test_dac_nids,
  4471. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4472. .adc_nids = alc260_test_adc_nids,
  4473. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4474. .channel_mode = alc260_modes,
  4475. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4476. .input_mux = alc260_test_capture_sources,
  4477. },
  4478. #endif
  4479. };
  4480. static int patch_alc260(struct hda_codec *codec)
  4481. {
  4482. struct alc_spec *spec;
  4483. int err, board_config;
  4484. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4485. if (spec == NULL)
  4486. return -ENOMEM;
  4487. codec->spec = spec;
  4488. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4489. alc260_models,
  4490. alc260_cfg_tbl);
  4491. if (board_config < 0) {
  4492. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4493. "trying auto-probe from BIOS...\n");
  4494. board_config = ALC260_AUTO;
  4495. }
  4496. if (board_config == ALC260_AUTO) {
  4497. /* automatic parse from the BIOS config */
  4498. err = alc260_parse_auto_config(codec);
  4499. if (err < 0) {
  4500. alc_free(codec);
  4501. return err;
  4502. } else if (!err) {
  4503. printk(KERN_INFO
  4504. "hda_codec: Cannot set up configuration "
  4505. "from BIOS. Using base mode...\n");
  4506. board_config = ALC260_BASIC;
  4507. }
  4508. }
  4509. if (board_config != ALC260_AUTO)
  4510. setup_preset(spec, &alc260_presets[board_config]);
  4511. spec->stream_name_analog = "ALC260 Analog";
  4512. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4513. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4514. spec->stream_name_digital = "ALC260 Digital";
  4515. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4516. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4517. codec->patch_ops = alc_patch_ops;
  4518. if (board_config == ALC260_AUTO)
  4519. spec->init_hook = alc260_auto_init;
  4520. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4521. if (!spec->loopback.amplist)
  4522. spec->loopback.amplist = alc260_loopbacks;
  4523. #endif
  4524. return 0;
  4525. }
  4526. /*
  4527. * ALC882 support
  4528. *
  4529. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4530. * configuration. Each pin widget can choose any input DACs and a mixer.
  4531. * Each ADC is connected from a mixer of all inputs. This makes possible
  4532. * 6-channel independent captures.
  4533. *
  4534. * In addition, an independent DAC for the multi-playback (not used in this
  4535. * driver yet).
  4536. */
  4537. #define ALC882_DIGOUT_NID 0x06
  4538. #define ALC882_DIGIN_NID 0x0a
  4539. static struct hda_channel_mode alc882_ch_modes[1] = {
  4540. { 8, NULL }
  4541. };
  4542. static hda_nid_t alc882_dac_nids[4] = {
  4543. /* front, rear, clfe, rear_surr */
  4544. 0x02, 0x03, 0x04, 0x05
  4545. };
  4546. /* identical with ALC880 */
  4547. #define alc882_adc_nids alc880_adc_nids
  4548. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4549. /* input MUX */
  4550. /* FIXME: should be a matrix-type input source selection */
  4551. static struct hda_input_mux alc882_capture_source = {
  4552. .num_items = 4,
  4553. .items = {
  4554. { "Mic", 0x0 },
  4555. { "Front Mic", 0x1 },
  4556. { "Line", 0x2 },
  4557. { "CD", 0x4 },
  4558. },
  4559. };
  4560. #define alc882_mux_enum_info alc_mux_enum_info
  4561. #define alc882_mux_enum_get alc_mux_enum_get
  4562. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4563. struct snd_ctl_elem_value *ucontrol)
  4564. {
  4565. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4566. struct alc_spec *spec = codec->spec;
  4567. const struct hda_input_mux *imux = spec->input_mux;
  4568. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4569. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4570. hda_nid_t nid = capture_mixers[adc_idx];
  4571. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4572. unsigned int i, idx;
  4573. idx = ucontrol->value.enumerated.item[0];
  4574. if (idx >= imux->num_items)
  4575. idx = imux->num_items - 1;
  4576. if (*cur_val == idx)
  4577. return 0;
  4578. for (i = 0; i < imux->num_items; i++) {
  4579. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4580. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4581. imux->items[i].index,
  4582. HDA_AMP_MUTE, v);
  4583. }
  4584. *cur_val = idx;
  4585. return 1;
  4586. }
  4587. /*
  4588. * 2ch mode
  4589. */
  4590. static struct hda_verb alc882_3ST_ch2_init[] = {
  4591. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4592. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4593. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4594. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4595. { } /* end */
  4596. };
  4597. /*
  4598. * 6ch mode
  4599. */
  4600. static struct hda_verb alc882_3ST_ch6_init[] = {
  4601. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4602. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4603. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4604. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4605. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4606. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4607. { } /* end */
  4608. };
  4609. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4610. { 2, alc882_3ST_ch2_init },
  4611. { 6, alc882_3ST_ch6_init },
  4612. };
  4613. /*
  4614. * 6ch mode
  4615. */
  4616. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4617. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4618. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4619. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4620. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4621. { } /* end */
  4622. };
  4623. /*
  4624. * 8ch mode
  4625. */
  4626. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4627. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4628. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4629. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4630. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4631. { } /* end */
  4632. };
  4633. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4634. { 6, alc882_sixstack_ch6_init },
  4635. { 8, alc882_sixstack_ch8_init },
  4636. };
  4637. /*
  4638. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4639. */
  4640. /*
  4641. * 2ch mode
  4642. */
  4643. static struct hda_verb alc885_mbp_ch2_init[] = {
  4644. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4645. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4646. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4647. { } /* end */
  4648. };
  4649. /*
  4650. * 6ch mode
  4651. */
  4652. static struct hda_verb alc885_mbp_ch6_init[] = {
  4653. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4654. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4655. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4656. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4657. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4658. { } /* end */
  4659. };
  4660. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4661. { 2, alc885_mbp_ch2_init },
  4662. { 6, alc885_mbp_ch6_init },
  4663. };
  4664. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4665. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4666. */
  4667. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4668. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4669. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4670. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4671. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4672. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4673. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4674. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4675. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4676. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4677. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4678. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4679. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4680. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4681. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4682. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4683. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4684. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4685. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4686. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4687. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4688. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4689. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4690. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4691. { } /* end */
  4692. };
  4693. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4694. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4695. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4696. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4697. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4698. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4699. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4700. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4701. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4702. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4703. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4704. { } /* end */
  4705. };
  4706. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4707. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4708. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4709. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4710. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4711. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4712. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4713. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4714. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4715. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4716. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4717. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4718. { } /* end */
  4719. };
  4720. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4721. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4722. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4723. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4724. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4725. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4726. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4727. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4728. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4729. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4730. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4731. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4732. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4733. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4734. { } /* end */
  4735. };
  4736. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4737. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4738. */
  4739. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4740. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4741. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4742. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4743. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4744. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4745. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4746. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4747. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4748. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4749. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4750. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4751. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4752. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4753. { } /* end */
  4754. };
  4755. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4756. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4757. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4759. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4760. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4761. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4762. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4763. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4764. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4765. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4766. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4767. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4768. { } /* end */
  4769. };
  4770. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4771. {
  4772. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4773. .name = "Channel Mode",
  4774. .info = alc_ch_mode_info,
  4775. .get = alc_ch_mode_get,
  4776. .put = alc_ch_mode_put,
  4777. },
  4778. { } /* end */
  4779. };
  4780. static struct hda_verb alc882_init_verbs[] = {
  4781. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4782. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4783. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4784. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4785. /* Rear mixer */
  4786. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4787. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4788. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4789. /* CLFE mixer */
  4790. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4791. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4792. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4793. /* Side mixer */
  4794. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4795. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4796. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4797. /* Front Pin: output 0 (0x0c) */
  4798. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4799. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4800. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4801. /* Rear Pin: output 1 (0x0d) */
  4802. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4804. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4805. /* CLFE Pin: output 2 (0x0e) */
  4806. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4807. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4808. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4809. /* Side Pin: output 3 (0x0f) */
  4810. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4811. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4812. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4813. /* Mic (rear) pin: input vref at 80% */
  4814. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4815. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4816. /* Front Mic pin: input vref at 80% */
  4817. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4818. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4819. /* Line In pin: input */
  4820. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4821. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4822. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4823. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4824. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4825. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4826. /* CD pin widget for input */
  4827. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4828. /* FIXME: use matrix-type input source selection */
  4829. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4830. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4831. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4832. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4833. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4834. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4835. /* Input mixer2 */
  4836. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4837. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4838. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4839. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4840. /* Input mixer3 */
  4841. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4842. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4843. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4844. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4845. /* ADC1: mute amp left and right */
  4846. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4847. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4848. /* ADC2: mute amp left and right */
  4849. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4850. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4851. /* ADC3: mute amp left and right */
  4852. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4853. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4854. { }
  4855. };
  4856. static struct hda_verb alc882_eapd_verbs[] = {
  4857. /* change to EAPD mode */
  4858. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4859. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4860. { }
  4861. };
  4862. /* Mac Pro test */
  4863. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4864. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4865. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4866. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4867. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4868. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4869. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4870. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4871. { } /* end */
  4872. };
  4873. static struct hda_verb alc882_macpro_init_verbs[] = {
  4874. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4875. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4876. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4877. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4878. /* Front Pin: output 0 (0x0c) */
  4879. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4880. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4881. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4882. /* Front Mic pin: input vref at 80% */
  4883. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4884. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4885. /* Speaker: output */
  4886. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4887. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4888. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4889. /* Headphone output (output 0 - 0x0c) */
  4890. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4891. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4892. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4893. /* FIXME: use matrix-type input source selection */
  4894. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4895. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4897. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4898. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4899. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4900. /* Input mixer2 */
  4901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4903. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4905. /* Input mixer3 */
  4906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4910. /* ADC1: mute amp left and right */
  4911. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4912. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4913. /* ADC2: mute amp left and right */
  4914. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4915. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4916. /* ADC3: mute amp left and right */
  4917. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4918. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. { }
  4920. };
  4921. /* Macbook Pro rev3 */
  4922. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4923. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4924. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4925. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4926. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4927. /* Rear mixer */
  4928. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4929. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4930. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4931. /* Front Pin: output 0 (0x0c) */
  4932. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4933. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4934. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4935. /* HP Pin: output 0 (0x0d) */
  4936. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4937. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4938. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4939. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4940. /* Mic (rear) pin: input vref at 80% */
  4941. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4942. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4943. /* Front Mic pin: input vref at 80% */
  4944. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4945. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4946. /* Line In pin: use output 1 when in LineOut mode */
  4947. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4948. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4949. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4950. /* FIXME: use matrix-type input source selection */
  4951. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4952. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4953. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4954. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4955. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4956. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4957. /* Input mixer2 */
  4958. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4959. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4960. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4962. /* Input mixer3 */
  4963. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4964. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4965. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4967. /* ADC1: mute amp left and right */
  4968. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4969. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4970. /* ADC2: mute amp left and right */
  4971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4972. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4973. /* ADC3: mute amp left and right */
  4974. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4975. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4976. { }
  4977. };
  4978. /* iMac 24 mixer. */
  4979. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4980. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4981. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4982. { } /* end */
  4983. };
  4984. /* iMac 24 init verbs. */
  4985. static struct hda_verb alc885_imac24_init_verbs[] = {
  4986. /* Internal speakers: output 0 (0x0c) */
  4987. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4988. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4989. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4990. /* Internal speakers: output 0 (0x0c) */
  4991. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4992. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4993. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4994. /* Headphone: output 0 (0x0c) */
  4995. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4996. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4997. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4998. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4999. /* Front Mic: input vref at 80% */
  5000. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5001. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5002. { }
  5003. };
  5004. /* Toggle speaker-output according to the hp-jack state */
  5005. static void alc885_imac24_automute(struct hda_codec *codec)
  5006. {
  5007. unsigned int present;
  5008. present = snd_hda_codec_read(codec, 0x14, 0,
  5009. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5010. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  5011. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5012. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  5013. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5014. }
  5015. /* Processes unsolicited events. */
  5016. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  5017. unsigned int res)
  5018. {
  5019. /* Headphone insertion or removal. */
  5020. if ((res >> 26) == ALC880_HP_EVENT)
  5021. alc885_imac24_automute(codec);
  5022. }
  5023. static void alc885_mbp3_automute(struct hda_codec *codec)
  5024. {
  5025. unsigned int present;
  5026. present = snd_hda_codec_read(codec, 0x15, 0,
  5027. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5028. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  5029. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5030. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5031. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  5032. }
  5033. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  5034. unsigned int res)
  5035. {
  5036. /* Headphone insertion or removal. */
  5037. if ((res >> 26) == ALC880_HP_EVENT)
  5038. alc885_mbp3_automute(codec);
  5039. }
  5040. static struct hda_verb alc882_targa_verbs[] = {
  5041. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5042. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5043. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5044. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5045. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5046. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5047. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5048. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5049. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5050. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5051. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5052. { } /* end */
  5053. };
  5054. /* toggle speaker-output according to the hp-jack state */
  5055. static void alc882_targa_automute(struct hda_codec *codec)
  5056. {
  5057. unsigned int present;
  5058. present = snd_hda_codec_read(codec, 0x14, 0,
  5059. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5060. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5061. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5062. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5063. present ? 1 : 3);
  5064. }
  5065. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5066. {
  5067. /* Looks like the unsol event is incompatible with the standard
  5068. * definition. 4bit tag is placed at 26 bit!
  5069. */
  5070. if (((res >> 26) == ALC880_HP_EVENT)) {
  5071. alc882_targa_automute(codec);
  5072. }
  5073. }
  5074. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5075. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5076. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5077. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5078. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5079. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5080. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5081. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5082. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5083. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5084. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5085. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5086. { } /* end */
  5087. };
  5088. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5089. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5090. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5091. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5092. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5093. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5094. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5095. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5096. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5097. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5098. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5099. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5100. { } /* end */
  5101. };
  5102. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5103. {
  5104. unsigned int gpiostate, gpiomask, gpiodir;
  5105. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5106. AC_VERB_GET_GPIO_DATA, 0);
  5107. if (!muted)
  5108. gpiostate |= (1 << pin);
  5109. else
  5110. gpiostate &= ~(1 << pin);
  5111. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5112. AC_VERB_GET_GPIO_MASK, 0);
  5113. gpiomask |= (1 << pin);
  5114. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5115. AC_VERB_GET_GPIO_DIRECTION, 0);
  5116. gpiodir |= (1 << pin);
  5117. snd_hda_codec_write(codec, codec->afg, 0,
  5118. AC_VERB_SET_GPIO_MASK, gpiomask);
  5119. snd_hda_codec_write(codec, codec->afg, 0,
  5120. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5121. msleep(1);
  5122. snd_hda_codec_write(codec, codec->afg, 0,
  5123. AC_VERB_SET_GPIO_DATA, gpiostate);
  5124. }
  5125. /* set up GPIO at initialization */
  5126. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5127. {
  5128. alc882_gpio_mute(codec, 0, 0);
  5129. alc882_gpio_mute(codec, 1, 0);
  5130. }
  5131. /* set up GPIO and update auto-muting at initialization */
  5132. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5133. {
  5134. alc885_macpro_init_hook(codec);
  5135. alc885_imac24_automute(codec);
  5136. }
  5137. /*
  5138. * generic initialization of ADC, input mixers and output mixers
  5139. */
  5140. static struct hda_verb alc882_auto_init_verbs[] = {
  5141. /*
  5142. * Unmute ADC0-2 and set the default input to mic-in
  5143. */
  5144. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5145. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5146. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5147. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5148. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5149. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5150. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5151. * mixer widget
  5152. * Note: PASD motherboards uses the Line In 2 as the input for
  5153. * front panel mic (mic 2)
  5154. */
  5155. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5156. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5157. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5158. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5159. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5160. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5161. /*
  5162. * Set up output mixers (0x0c - 0x0f)
  5163. */
  5164. /* set vol=0 to output mixers */
  5165. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5166. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5167. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5168. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5169. /* set up input amps for analog loopback */
  5170. /* Amp Indices: DAC = 0, mixer = 1 */
  5171. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5172. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5173. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5174. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5175. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5176. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5177. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5178. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5179. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5180. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5181. /* FIXME: use matrix-type input source selection */
  5182. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5183. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5184. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5185. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5186. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5187. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5188. /* Input mixer2 */
  5189. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5190. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5191. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5192. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5193. /* Input mixer3 */
  5194. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5195. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5196. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5197. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5198. { }
  5199. };
  5200. /* capture mixer elements */
  5201. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5202. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5203. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5204. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5205. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5206. {
  5207. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5208. /* The multiple "Capture Source" controls confuse alsamixer
  5209. * So call somewhat different..
  5210. * FIXME: the controls appear in the "playback" view!
  5211. */
  5212. /* .name = "Capture Source", */
  5213. .name = "Input Source",
  5214. .count = 2,
  5215. .info = alc882_mux_enum_info,
  5216. .get = alc882_mux_enum_get,
  5217. .put = alc882_mux_enum_put,
  5218. },
  5219. { } /* end */
  5220. };
  5221. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5222. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5224. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5225. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5226. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5227. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5228. {
  5229. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5230. /* The multiple "Capture Source" controls confuse alsamixer
  5231. * So call somewhat different..
  5232. * FIXME: the controls appear in the "playback" view!
  5233. */
  5234. /* .name = "Capture Source", */
  5235. .name = "Input Source",
  5236. .count = 3,
  5237. .info = alc882_mux_enum_info,
  5238. .get = alc882_mux_enum_get,
  5239. .put = alc882_mux_enum_put,
  5240. },
  5241. { } /* end */
  5242. };
  5243. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5244. #define alc882_loopbacks alc880_loopbacks
  5245. #endif
  5246. /* pcm configuration: identiacal with ALC880 */
  5247. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5248. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5249. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5250. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5251. /*
  5252. * configuration and preset
  5253. */
  5254. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5255. [ALC882_3ST_DIG] = "3stack-dig",
  5256. [ALC882_6ST_DIG] = "6stack-dig",
  5257. [ALC882_ARIMA] = "arima",
  5258. [ALC882_W2JC] = "w2jc",
  5259. [ALC882_TARGA] = "targa",
  5260. [ALC882_ASUS_A7J] = "asus-a7j",
  5261. [ALC882_ASUS_A7M] = "asus-a7m",
  5262. [ALC885_MACPRO] = "macpro",
  5263. [ALC885_MBP3] = "mbp3",
  5264. [ALC885_IMAC24] = "imac24",
  5265. [ALC882_AUTO] = "auto",
  5266. };
  5267. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5268. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5269. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5270. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5271. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5272. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5273. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5274. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5275. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5276. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5277. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5278. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5279. {}
  5280. };
  5281. static struct alc_config_preset alc882_presets[] = {
  5282. [ALC882_3ST_DIG] = {
  5283. .mixers = { alc882_base_mixer },
  5284. .init_verbs = { alc882_init_verbs },
  5285. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5286. .dac_nids = alc882_dac_nids,
  5287. .dig_out_nid = ALC882_DIGOUT_NID,
  5288. .dig_in_nid = ALC882_DIGIN_NID,
  5289. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5290. .channel_mode = alc882_ch_modes,
  5291. .need_dac_fix = 1,
  5292. .input_mux = &alc882_capture_source,
  5293. },
  5294. [ALC882_6ST_DIG] = {
  5295. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5296. .init_verbs = { alc882_init_verbs },
  5297. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5298. .dac_nids = alc882_dac_nids,
  5299. .dig_out_nid = ALC882_DIGOUT_NID,
  5300. .dig_in_nid = ALC882_DIGIN_NID,
  5301. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5302. .channel_mode = alc882_sixstack_modes,
  5303. .input_mux = &alc882_capture_source,
  5304. },
  5305. [ALC882_ARIMA] = {
  5306. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5307. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5308. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5309. .dac_nids = alc882_dac_nids,
  5310. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5311. .channel_mode = alc882_sixstack_modes,
  5312. .input_mux = &alc882_capture_source,
  5313. },
  5314. [ALC882_W2JC] = {
  5315. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5316. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5317. alc880_gpio1_init_verbs },
  5318. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5319. .dac_nids = alc882_dac_nids,
  5320. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5321. .channel_mode = alc880_threestack_modes,
  5322. .need_dac_fix = 1,
  5323. .input_mux = &alc882_capture_source,
  5324. .dig_out_nid = ALC882_DIGOUT_NID,
  5325. },
  5326. [ALC885_MBP3] = {
  5327. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5328. .init_verbs = { alc885_mbp3_init_verbs,
  5329. alc880_gpio1_init_verbs },
  5330. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5331. .dac_nids = alc882_dac_nids,
  5332. .channel_mode = alc885_mbp_6ch_modes,
  5333. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5334. .input_mux = &alc882_capture_source,
  5335. .dig_out_nid = ALC882_DIGOUT_NID,
  5336. .dig_in_nid = ALC882_DIGIN_NID,
  5337. .unsol_event = alc885_mbp3_unsol_event,
  5338. .init_hook = alc885_mbp3_automute,
  5339. },
  5340. [ALC885_MACPRO] = {
  5341. .mixers = { alc882_macpro_mixer },
  5342. .init_verbs = { alc882_macpro_init_verbs },
  5343. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5344. .dac_nids = alc882_dac_nids,
  5345. .dig_out_nid = ALC882_DIGOUT_NID,
  5346. .dig_in_nid = ALC882_DIGIN_NID,
  5347. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5348. .channel_mode = alc882_ch_modes,
  5349. .input_mux = &alc882_capture_source,
  5350. .init_hook = alc885_macpro_init_hook,
  5351. },
  5352. [ALC885_IMAC24] = {
  5353. .mixers = { alc885_imac24_mixer },
  5354. .init_verbs = { alc885_imac24_init_verbs },
  5355. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5356. .dac_nids = alc882_dac_nids,
  5357. .dig_out_nid = ALC882_DIGOUT_NID,
  5358. .dig_in_nid = ALC882_DIGIN_NID,
  5359. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5360. .channel_mode = alc882_ch_modes,
  5361. .input_mux = &alc882_capture_source,
  5362. .unsol_event = alc885_imac24_unsol_event,
  5363. .init_hook = alc885_imac24_init_hook,
  5364. },
  5365. [ALC882_TARGA] = {
  5366. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5367. alc882_capture_mixer },
  5368. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5369. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5370. .dac_nids = alc882_dac_nids,
  5371. .dig_out_nid = ALC882_DIGOUT_NID,
  5372. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5373. .adc_nids = alc882_adc_nids,
  5374. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5375. .channel_mode = alc882_3ST_6ch_modes,
  5376. .need_dac_fix = 1,
  5377. .input_mux = &alc882_capture_source,
  5378. .unsol_event = alc882_targa_unsol_event,
  5379. .init_hook = alc882_targa_automute,
  5380. },
  5381. [ALC882_ASUS_A7J] = {
  5382. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5383. alc882_capture_mixer },
  5384. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5385. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5386. .dac_nids = alc882_dac_nids,
  5387. .dig_out_nid = ALC882_DIGOUT_NID,
  5388. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5389. .adc_nids = alc882_adc_nids,
  5390. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5391. .channel_mode = alc882_3ST_6ch_modes,
  5392. .need_dac_fix = 1,
  5393. .input_mux = &alc882_capture_source,
  5394. },
  5395. [ALC882_ASUS_A7M] = {
  5396. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5397. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5398. alc880_gpio1_init_verbs,
  5399. alc882_asus_a7m_verbs },
  5400. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5401. .dac_nids = alc882_dac_nids,
  5402. .dig_out_nid = ALC882_DIGOUT_NID,
  5403. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5404. .channel_mode = alc880_threestack_modes,
  5405. .need_dac_fix = 1,
  5406. .input_mux = &alc882_capture_source,
  5407. },
  5408. };
  5409. /*
  5410. * Pin config fixes
  5411. */
  5412. enum {
  5413. PINFIX_ABIT_AW9D_MAX
  5414. };
  5415. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5416. { 0x15, 0x01080104 }, /* side */
  5417. { 0x16, 0x01011012 }, /* rear */
  5418. { 0x17, 0x01016011 }, /* clfe */
  5419. { }
  5420. };
  5421. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5422. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5423. };
  5424. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5425. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5426. {}
  5427. };
  5428. /*
  5429. * BIOS auto configuration
  5430. */
  5431. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5432. hda_nid_t nid, int pin_type,
  5433. int dac_idx)
  5434. {
  5435. /* set as output */
  5436. struct alc_spec *spec = codec->spec;
  5437. int idx;
  5438. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5439. idx = 4;
  5440. else
  5441. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5442. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5443. pin_type);
  5444. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5445. AMP_OUT_UNMUTE);
  5446. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5447. }
  5448. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5449. {
  5450. struct alc_spec *spec = codec->spec;
  5451. int i;
  5452. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5453. for (i = 0; i <= HDA_SIDE; i++) {
  5454. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5455. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5456. if (nid)
  5457. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5458. i);
  5459. }
  5460. }
  5461. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5462. {
  5463. struct alc_spec *spec = codec->spec;
  5464. hda_nid_t pin;
  5465. pin = spec->autocfg.hp_pins[0];
  5466. if (pin) /* connect to front */
  5467. /* use dac 0 */
  5468. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5469. }
  5470. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5471. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5472. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5473. {
  5474. struct alc_spec *spec = codec->spec;
  5475. int i;
  5476. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5477. hda_nid_t nid = spec->autocfg.input_pins[i];
  5478. if (alc882_is_input_pin(nid)) {
  5479. snd_hda_codec_write(codec, nid, 0,
  5480. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5481. i <= AUTO_PIN_FRONT_MIC ?
  5482. PIN_VREF80 : PIN_IN);
  5483. if (nid != ALC882_PIN_CD_NID)
  5484. snd_hda_codec_write(codec, nid, 0,
  5485. AC_VERB_SET_AMP_GAIN_MUTE,
  5486. AMP_OUT_MUTE);
  5487. }
  5488. }
  5489. }
  5490. /* add mic boosts if needed */
  5491. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5492. {
  5493. struct alc_spec *spec = codec->spec;
  5494. int err;
  5495. hda_nid_t nid;
  5496. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5497. if (nid) {
  5498. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5499. "Mic Boost",
  5500. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5501. if (err < 0)
  5502. return err;
  5503. }
  5504. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5505. if (nid) {
  5506. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5507. "Front Mic Boost",
  5508. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5509. if (err < 0)
  5510. return err;
  5511. }
  5512. return 0;
  5513. }
  5514. /* almost identical with ALC880 parser... */
  5515. static int alc882_parse_auto_config(struct hda_codec *codec)
  5516. {
  5517. struct alc_spec *spec = codec->spec;
  5518. int err = alc880_parse_auto_config(codec);
  5519. if (err < 0)
  5520. return err;
  5521. else if (!err)
  5522. return 0; /* no config found */
  5523. err = alc_auto_add_mic_boost(codec);
  5524. if (err < 0)
  5525. return err;
  5526. /* hack - override the init verbs */
  5527. spec->init_verbs[0] = alc882_auto_init_verbs;
  5528. return 1; /* config found */
  5529. }
  5530. /* additional initialization for auto-configuration model */
  5531. static void alc882_auto_init(struct hda_codec *codec)
  5532. {
  5533. alc882_auto_init_multi_out(codec);
  5534. alc882_auto_init_hp_out(codec);
  5535. alc882_auto_init_analog_input(codec);
  5536. }
  5537. static int patch_alc882(struct hda_codec *codec)
  5538. {
  5539. struct alc_spec *spec;
  5540. int err, board_config;
  5541. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5542. if (spec == NULL)
  5543. return -ENOMEM;
  5544. codec->spec = spec;
  5545. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5546. alc882_models,
  5547. alc882_cfg_tbl);
  5548. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5549. /* Pick up systems that don't supply PCI SSID */
  5550. switch (codec->subsystem_id) {
  5551. case 0x106b0c00: /* Mac Pro */
  5552. board_config = ALC885_MACPRO;
  5553. break;
  5554. case 0x106b1000: /* iMac 24 */
  5555. board_config = ALC885_IMAC24;
  5556. break;
  5557. case 0x106b2c00: /* Macbook Pro rev3 */
  5558. board_config = ALC885_MBP3;
  5559. break;
  5560. default:
  5561. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5562. "trying auto-probe from BIOS...\n");
  5563. board_config = ALC882_AUTO;
  5564. }
  5565. }
  5566. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5567. if (board_config == ALC882_AUTO) {
  5568. /* automatic parse from the BIOS config */
  5569. err = alc882_parse_auto_config(codec);
  5570. if (err < 0) {
  5571. alc_free(codec);
  5572. return err;
  5573. } else if (!err) {
  5574. printk(KERN_INFO
  5575. "hda_codec: Cannot set up configuration "
  5576. "from BIOS. Using base mode...\n");
  5577. board_config = ALC882_3ST_DIG;
  5578. }
  5579. }
  5580. if (board_config != ALC882_AUTO)
  5581. setup_preset(spec, &alc882_presets[board_config]);
  5582. spec->stream_name_analog = "ALC882 Analog";
  5583. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5584. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5585. spec->stream_name_digital = "ALC882 Digital";
  5586. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5587. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5588. if (!spec->adc_nids && spec->input_mux) {
  5589. /* check whether NID 0x07 is valid */
  5590. unsigned int wcap = get_wcaps(codec, 0x07);
  5591. /* get type */
  5592. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5593. if (wcap != AC_WID_AUD_IN) {
  5594. spec->adc_nids = alc882_adc_nids_alt;
  5595. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5596. spec->mixers[spec->num_mixers] =
  5597. alc882_capture_alt_mixer;
  5598. spec->num_mixers++;
  5599. } else {
  5600. spec->adc_nids = alc882_adc_nids;
  5601. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5602. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5603. spec->num_mixers++;
  5604. }
  5605. }
  5606. codec->patch_ops = alc_patch_ops;
  5607. if (board_config == ALC882_AUTO)
  5608. spec->init_hook = alc882_auto_init;
  5609. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5610. if (!spec->loopback.amplist)
  5611. spec->loopback.amplist = alc882_loopbacks;
  5612. #endif
  5613. return 0;
  5614. }
  5615. /*
  5616. * ALC883 support
  5617. *
  5618. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5619. * configuration. Each pin widget can choose any input DACs and a mixer.
  5620. * Each ADC is connected from a mixer of all inputs. This makes possible
  5621. * 6-channel independent captures.
  5622. *
  5623. * In addition, an independent DAC for the multi-playback (not used in this
  5624. * driver yet).
  5625. */
  5626. #define ALC883_DIGOUT_NID 0x06
  5627. #define ALC883_DIGIN_NID 0x0a
  5628. static hda_nid_t alc883_dac_nids[4] = {
  5629. /* front, rear, clfe, rear_surr */
  5630. 0x02, 0x04, 0x03, 0x05
  5631. };
  5632. static hda_nid_t alc883_adc_nids[2] = {
  5633. /* ADC1-2 */
  5634. 0x08, 0x09,
  5635. };
  5636. /* input MUX */
  5637. /* FIXME: should be a matrix-type input source selection */
  5638. static struct hda_input_mux alc883_capture_source = {
  5639. .num_items = 4,
  5640. .items = {
  5641. { "Mic", 0x0 },
  5642. { "Front Mic", 0x1 },
  5643. { "Line", 0x2 },
  5644. { "CD", 0x4 },
  5645. },
  5646. };
  5647. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5648. .num_items = 2,
  5649. .items = {
  5650. { "Mic", 0x1 },
  5651. { "Line", 0x2 },
  5652. },
  5653. };
  5654. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5655. .num_items = 4,
  5656. .items = {
  5657. { "Mic", 0x0 },
  5658. { "iMic", 0x1 },
  5659. { "Line", 0x2 },
  5660. { "CD", 0x4 },
  5661. },
  5662. };
  5663. #define alc883_mux_enum_info alc_mux_enum_info
  5664. #define alc883_mux_enum_get alc_mux_enum_get
  5665. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5666. struct snd_ctl_elem_value *ucontrol)
  5667. {
  5668. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5669. struct alc_spec *spec = codec->spec;
  5670. const struct hda_input_mux *imux = spec->input_mux;
  5671. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5672. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5673. hda_nid_t nid = capture_mixers[adc_idx];
  5674. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5675. unsigned int i, idx;
  5676. idx = ucontrol->value.enumerated.item[0];
  5677. if (idx >= imux->num_items)
  5678. idx = imux->num_items - 1;
  5679. if (*cur_val == idx)
  5680. return 0;
  5681. for (i = 0; i < imux->num_items; i++) {
  5682. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5683. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5684. imux->items[i].index,
  5685. HDA_AMP_MUTE, v);
  5686. }
  5687. *cur_val = idx;
  5688. return 1;
  5689. }
  5690. /*
  5691. * 2ch mode
  5692. */
  5693. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5694. { 2, NULL }
  5695. };
  5696. /*
  5697. * 2ch mode
  5698. */
  5699. static struct hda_verb alc883_3ST_ch2_init[] = {
  5700. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5701. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5702. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5703. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5704. { } /* end */
  5705. };
  5706. /*
  5707. * 4ch mode
  5708. */
  5709. static struct hda_verb alc883_3ST_ch4_init[] = {
  5710. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5711. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5712. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5713. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5714. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5715. { } /* end */
  5716. };
  5717. /*
  5718. * 6ch mode
  5719. */
  5720. static struct hda_verb alc883_3ST_ch6_init[] = {
  5721. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5722. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5723. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5724. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5725. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5726. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5727. { } /* end */
  5728. };
  5729. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5730. { 2, alc883_3ST_ch2_init },
  5731. { 4, alc883_3ST_ch4_init },
  5732. { 6, alc883_3ST_ch6_init },
  5733. };
  5734. /*
  5735. * 6ch mode
  5736. */
  5737. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5738. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5739. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5740. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5741. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5742. { } /* end */
  5743. };
  5744. /*
  5745. * 8ch mode
  5746. */
  5747. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5748. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5749. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5750. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5751. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5752. { } /* end */
  5753. };
  5754. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5755. { 6, alc883_sixstack_ch6_init },
  5756. { 8, alc883_sixstack_ch8_init },
  5757. };
  5758. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5759. /* eanable EAPD on medion laptop */
  5760. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5761. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5762. { }
  5763. };
  5764. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5765. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5766. */
  5767. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5768. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5769. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5770. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5771. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5772. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5773. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5774. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5775. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5776. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5777. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5778. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5779. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5780. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5781. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5782. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5783. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5784. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5785. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5786. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5787. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5788. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5789. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5790. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5791. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5792. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5793. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5794. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5795. {
  5796. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5797. /* .name = "Capture Source", */
  5798. .name = "Input Source",
  5799. .count = 2,
  5800. .info = alc883_mux_enum_info,
  5801. .get = alc883_mux_enum_get,
  5802. .put = alc883_mux_enum_put,
  5803. },
  5804. { } /* end */
  5805. };
  5806. static struct snd_kcontrol_new alc883_mitac_mixer[] = {
  5807. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5808. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5809. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5810. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5811. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5812. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5813. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5814. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5815. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5816. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5817. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5818. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5819. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5820. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5821. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5822. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5823. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5824. {
  5825. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5826. /* .name = "Capture Source", */
  5827. .name = "Input Source",
  5828. .count = 2,
  5829. .info = alc883_mux_enum_info,
  5830. .get = alc883_mux_enum_get,
  5831. .put = alc883_mux_enum_put,
  5832. },
  5833. { } /* end */
  5834. };
  5835. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5836. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5837. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5838. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5839. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5840. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5841. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5842. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5844. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5845. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5846. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5847. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5848. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5849. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5850. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5851. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5852. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5853. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5854. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5855. {
  5856. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5857. /* .name = "Capture Source", */
  5858. .name = "Input Source",
  5859. .count = 2,
  5860. .info = alc883_mux_enum_info,
  5861. .get = alc883_mux_enum_get,
  5862. .put = alc883_mux_enum_put,
  5863. },
  5864. { } /* end */
  5865. };
  5866. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5867. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5868. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5869. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5870. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5871. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5872. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5873. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5874. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5875. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5876. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5877. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5878. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5879. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5880. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5881. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5882. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5883. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5884. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5885. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5886. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5887. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5888. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5889. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5890. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5891. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5892. {
  5893. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5894. /* .name = "Capture Source", */
  5895. .name = "Input Source",
  5896. .count = 2,
  5897. .info = alc883_mux_enum_info,
  5898. .get = alc883_mux_enum_get,
  5899. .put = alc883_mux_enum_put,
  5900. },
  5901. { } /* end */
  5902. };
  5903. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5904. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5905. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5906. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5907. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5908. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5909. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5910. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5911. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5912. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5913. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5914. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5915. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5916. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5917. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5918. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5919. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5920. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5921. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5922. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5923. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5924. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5925. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5926. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5927. {
  5928. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5929. /* .name = "Capture Source", */
  5930. .name = "Input Source",
  5931. .count = 1,
  5932. .info = alc883_mux_enum_info,
  5933. .get = alc883_mux_enum_get,
  5934. .put = alc883_mux_enum_put,
  5935. },
  5936. { } /* end */
  5937. };
  5938. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5939. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5940. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5941. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5942. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5943. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5944. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5945. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5946. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5947. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5948. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5949. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5950. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5951. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5952. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5953. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5954. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5955. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5956. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5957. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5958. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5959. {
  5960. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5961. /* .name = "Capture Source", */
  5962. .name = "Input Source",
  5963. .count = 2,
  5964. .info = alc883_mux_enum_info,
  5965. .get = alc883_mux_enum_get,
  5966. .put = alc883_mux_enum_put,
  5967. },
  5968. { } /* end */
  5969. };
  5970. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5971. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5972. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5973. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5974. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5975. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5977. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5978. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5979. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5980. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5981. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5982. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5983. {
  5984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5985. /* .name = "Capture Source", */
  5986. .name = "Input Source",
  5987. .count = 2,
  5988. .info = alc883_mux_enum_info,
  5989. .get = alc883_mux_enum_get,
  5990. .put = alc883_mux_enum_put,
  5991. },
  5992. { } /* end */
  5993. };
  5994. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5995. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5996. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5997. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5998. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5999. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6000. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6001. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6002. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6003. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6004. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6005. {
  6006. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6007. /* .name = "Capture Source", */
  6008. .name = "Input Source",
  6009. .count = 1,
  6010. .info = alc883_mux_enum_info,
  6011. .get = alc883_mux_enum_get,
  6012. .put = alc883_mux_enum_put,
  6013. },
  6014. { } /* end */
  6015. };
  6016. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  6017. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6018. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  6019. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6020. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6021. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6022. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6023. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6024. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6025. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6026. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6027. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6028. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6029. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6030. {
  6031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6032. /* .name = "Capture Source", */
  6033. .name = "Input Source",
  6034. .count = 2,
  6035. .info = alc883_mux_enum_info,
  6036. .get = alc883_mux_enum_get,
  6037. .put = alc883_mux_enum_put,
  6038. },
  6039. { } /* end */
  6040. };
  6041. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  6042. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6043. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6044. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6045. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6046. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6047. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6048. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6049. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6050. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6051. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6052. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6053. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6054. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6055. {
  6056. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6057. /* .name = "Capture Source", */
  6058. .name = "Input Source",
  6059. .count = 2,
  6060. .info = alc883_mux_enum_info,
  6061. .get = alc883_mux_enum_get,
  6062. .put = alc883_mux_enum_put,
  6063. },
  6064. { } /* end */
  6065. };
  6066. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  6067. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6068. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6069. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6070. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6071. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6072. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6073. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6074. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6075. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  6076. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  6077. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6078. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6079. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6080. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6081. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6082. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6083. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6084. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6085. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6086. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6087. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6088. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6089. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6090. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6091. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6092. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6093. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6094. {
  6095. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6096. /* .name = "Capture Source", */
  6097. .name = "Input Source",
  6098. .count = 2,
  6099. .info = alc883_mux_enum_info,
  6100. .get = alc883_mux_enum_get,
  6101. .put = alc883_mux_enum_put,
  6102. },
  6103. { } /* end */
  6104. };
  6105. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6106. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6107. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6108. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6109. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6110. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6111. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6112. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6113. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6114. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6115. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6116. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6117. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6118. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6119. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6120. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6122. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6123. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6124. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6125. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6126. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6127. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6128. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6129. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6130. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6131. {
  6132. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6133. /* .name = "Capture Source", */
  6134. .name = "Input Source",
  6135. .count = 2,
  6136. .info = alc883_mux_enum_info,
  6137. .get = alc883_mux_enum_get,
  6138. .put = alc883_mux_enum_put,
  6139. },
  6140. { } /* end */
  6141. };
  6142. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6143. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6144. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6145. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6146. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6147. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6148. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6149. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6150. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6151. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6152. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6153. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6154. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6155. {
  6156. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6157. /* .name = "Capture Source", */
  6158. .name = "Input Source",
  6159. .count = 2,
  6160. .info = alc883_mux_enum_info,
  6161. .get = alc883_mux_enum_get,
  6162. .put = alc883_mux_enum_put,
  6163. },
  6164. { } /* end */
  6165. };
  6166. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6167. {
  6168. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6169. .name = "Channel Mode",
  6170. .info = alc_ch_mode_info,
  6171. .get = alc_ch_mode_get,
  6172. .put = alc_ch_mode_put,
  6173. },
  6174. { } /* end */
  6175. };
  6176. static struct hda_verb alc883_init_verbs[] = {
  6177. /* ADC1: mute amp left and right */
  6178. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6179. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6180. /* ADC2: mute amp left and right */
  6181. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6182. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6183. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6187. /* Rear mixer */
  6188. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6191. /* CLFE mixer */
  6192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6195. /* Side mixer */
  6196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6199. /* mute analog input loopbacks */
  6200. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6201. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6202. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6203. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6204. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6205. /* Front Pin: output 0 (0x0c) */
  6206. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6207. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6208. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6209. /* Rear Pin: output 1 (0x0d) */
  6210. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6212. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6213. /* CLFE Pin: output 2 (0x0e) */
  6214. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6215. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6216. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6217. /* Side Pin: output 3 (0x0f) */
  6218. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6219. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6220. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6221. /* Mic (rear) pin: input vref at 80% */
  6222. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6223. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6224. /* Front Mic pin: input vref at 80% */
  6225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6226. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6227. /* Line In pin: input */
  6228. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6229. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6230. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6231. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6232. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6233. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6234. /* CD pin widget for input */
  6235. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6236. /* FIXME: use matrix-type input source selection */
  6237. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6238. /* Input mixer2 */
  6239. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6240. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6241. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6242. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6243. /* Input mixer3 */
  6244. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6245. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6246. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6247. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6248. { }
  6249. };
  6250. /* toggle speaker-output according to the hp-jack state */
  6251. static void alc883_mitac_hp_automute(struct hda_codec *codec)
  6252. {
  6253. unsigned int present;
  6254. present = snd_hda_codec_read(codec, 0x15, 0,
  6255. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6256. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6257. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6258. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  6259. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6260. }
  6261. /* auto-toggle front mic */
  6262. /*
  6263. static void alc883_mitac_mic_automute(struct hda_codec *codec)
  6264. {
  6265. unsigned int present;
  6266. unsigned char bits;
  6267. present = snd_hda_codec_read(codec, 0x18, 0,
  6268. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6269. bits = present ? HDA_AMP_MUTE : 0;
  6270. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  6271. }
  6272. */
  6273. static void alc883_mitac_automute(struct hda_codec *codec)
  6274. {
  6275. alc883_mitac_hp_automute(codec);
  6276. /* alc883_mitac_mic_automute(codec); */
  6277. }
  6278. static void alc883_mitac_unsol_event(struct hda_codec *codec,
  6279. unsigned int res)
  6280. {
  6281. switch (res >> 26) {
  6282. case ALC880_HP_EVENT:
  6283. alc883_mitac_hp_automute(codec);
  6284. break;
  6285. case ALC880_MIC_EVENT:
  6286. /* alc883_mitac_mic_automute(codec); */
  6287. break;
  6288. }
  6289. }
  6290. static struct hda_verb alc883_mitac_verbs[] = {
  6291. /* HP */
  6292. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6293. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6294. /* Subwoofer */
  6295. {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
  6296. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6297. /* enable unsolicited event */
  6298. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6299. /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
  6300. { } /* end */
  6301. };
  6302. static struct hda_verb alc883_tagra_verbs[] = {
  6303. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6304. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6305. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6306. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6307. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6308. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6309. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6310. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6311. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6312. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6313. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6314. { } /* end */
  6315. };
  6316. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6317. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6318. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6319. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6320. { } /* end */
  6321. };
  6322. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6323. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6324. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6325. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6326. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6327. { } /* end */
  6328. };
  6329. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6330. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6331. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6332. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6333. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6334. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6335. { } /* end */
  6336. };
  6337. static struct hda_verb alc883_haier_w66_verbs[] = {
  6338. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6339. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6341. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6342. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6343. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6344. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6345. { } /* end */
  6346. };
  6347. static struct hda_verb alc888_6st_hp_verbs[] = {
  6348. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6349. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6350. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6351. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6352. { }
  6353. };
  6354. static struct hda_verb alc888_3st_hp_verbs[] = {
  6355. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6356. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6357. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6358. { }
  6359. };
  6360. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6361. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6362. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6363. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6364. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6365. { }
  6366. };
  6367. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6368. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6369. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6370. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6371. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6372. { }
  6373. };
  6374. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6375. { 2, alc888_3st_hp_2ch_init },
  6376. { 6, alc888_3st_hp_6ch_init },
  6377. };
  6378. /* toggle front-jack and RCA according to the hp-jack state */
  6379. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6380. {
  6381. unsigned int present;
  6382. present = snd_hda_codec_read(codec, 0x1b, 0,
  6383. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6384. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6385. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6386. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6387. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6388. }
  6389. /* toggle RCA according to the front-jack state */
  6390. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6391. {
  6392. unsigned int present;
  6393. present = snd_hda_codec_read(codec, 0x14, 0,
  6394. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6395. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6396. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6397. }
  6398. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6399. unsigned int res)
  6400. {
  6401. if ((res >> 26) == ALC880_HP_EVENT)
  6402. alc888_lenovo_ms7195_front_automute(codec);
  6403. if ((res >> 26) == ALC880_FRONT_EVENT)
  6404. alc888_lenovo_ms7195_rca_automute(codec);
  6405. }
  6406. static struct hda_verb alc883_medion_md2_verbs[] = {
  6407. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6408. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6409. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6410. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6411. { } /* end */
  6412. };
  6413. /* toggle speaker-output according to the hp-jack state */
  6414. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6415. {
  6416. unsigned int present;
  6417. present = snd_hda_codec_read(codec, 0x14, 0,
  6418. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6419. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6420. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6421. }
  6422. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6423. unsigned int res)
  6424. {
  6425. if ((res >> 26) == ALC880_HP_EVENT)
  6426. alc883_medion_md2_automute(codec);
  6427. }
  6428. /* toggle speaker-output according to the hp-jack state */
  6429. static void alc883_tagra_automute(struct hda_codec *codec)
  6430. {
  6431. unsigned int present;
  6432. unsigned char bits;
  6433. present = snd_hda_codec_read(codec, 0x14, 0,
  6434. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6435. bits = present ? HDA_AMP_MUTE : 0;
  6436. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6437. HDA_AMP_MUTE, bits);
  6438. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6439. present ? 1 : 3);
  6440. }
  6441. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6442. {
  6443. if ((res >> 26) == ALC880_HP_EVENT)
  6444. alc883_tagra_automute(codec);
  6445. }
  6446. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6447. {
  6448. unsigned int present;
  6449. unsigned char bits;
  6450. present = snd_hda_codec_read(codec, 0x1b, 0,
  6451. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6452. bits = present ? 0x80 : 0;
  6453. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6454. 0x80, bits);
  6455. }
  6456. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6457. unsigned int res)
  6458. {
  6459. if ((res >> 26) == ALC880_HP_EVENT)
  6460. alc883_haier_w66_automute(codec);
  6461. }
  6462. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6463. {
  6464. unsigned int present;
  6465. unsigned char bits;
  6466. present = snd_hda_codec_read(codec, 0x14, 0,
  6467. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6468. bits = present ? HDA_AMP_MUTE : 0;
  6469. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6470. HDA_AMP_MUTE, bits);
  6471. }
  6472. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6473. {
  6474. unsigned int present;
  6475. unsigned char bits;
  6476. present = snd_hda_codec_read(codec, 0x1b, 0,
  6477. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6478. bits = present ? HDA_AMP_MUTE : 0;
  6479. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6480. HDA_AMP_MUTE, bits);
  6481. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6482. HDA_AMP_MUTE, bits);
  6483. }
  6484. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6485. unsigned int res)
  6486. {
  6487. if ((res >> 26) == ALC880_HP_EVENT)
  6488. alc883_lenovo_101e_all_automute(codec);
  6489. if ((res >> 26) == ALC880_FRONT_EVENT)
  6490. alc883_lenovo_101e_ispeaker_automute(codec);
  6491. }
  6492. /* toggle speaker-output according to the hp-jack state */
  6493. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6494. {
  6495. unsigned int present;
  6496. present = snd_hda_codec_read(codec, 0x14, 0,
  6497. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6498. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6499. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6500. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6501. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6502. }
  6503. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6504. unsigned int res)
  6505. {
  6506. if ((res >> 26) == ALC880_HP_EVENT)
  6507. alc883_acer_aspire_automute(codec);
  6508. }
  6509. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6510. /* HP Pin: output 0 (0x0c) */
  6511. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6513. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6514. /* Front Pin: output 0 (0x0c) */
  6515. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6516. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6517. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6518. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6519. /* eanable EAPD on medion laptop */
  6520. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6521. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6522. /* enable unsolicited event */
  6523. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6524. { }
  6525. };
  6526. /*
  6527. * generic initialization of ADC, input mixers and output mixers
  6528. */
  6529. static struct hda_verb alc883_auto_init_verbs[] = {
  6530. /*
  6531. * Unmute ADC0-2 and set the default input to mic-in
  6532. */
  6533. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6534. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6535. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6536. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6537. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6538. * mixer widget
  6539. * Note: PASD motherboards uses the Line In 2 as the input for
  6540. * front panel mic (mic 2)
  6541. */
  6542. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6543. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6544. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6546. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6548. /*
  6549. * Set up output mixers (0x0c - 0x0f)
  6550. */
  6551. /* set vol=0 to output mixers */
  6552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6553. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6554. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6555. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6556. /* set up input amps for analog loopback */
  6557. /* Amp Indices: DAC = 0, mixer = 1 */
  6558. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6559. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6560. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6561. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6562. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6563. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6564. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6565. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6566. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6567. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6568. /* FIXME: use matrix-type input source selection */
  6569. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6570. /* Input mixer1 */
  6571. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6572. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6573. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6574. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6575. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6576. /* Input mixer2 */
  6577. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6578. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6579. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6580. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6581. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6582. { }
  6583. };
  6584. /* capture mixer elements */
  6585. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6586. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6587. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6588. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6589. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6590. {
  6591. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6592. /* The multiple "Capture Source" controls confuse alsamixer
  6593. * So call somewhat different..
  6594. * FIXME: the controls appear in the "playback" view!
  6595. */
  6596. /* .name = "Capture Source", */
  6597. .name = "Input Source",
  6598. .count = 2,
  6599. .info = alc882_mux_enum_info,
  6600. .get = alc882_mux_enum_get,
  6601. .put = alc882_mux_enum_put,
  6602. },
  6603. { } /* end */
  6604. };
  6605. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6606. #define alc883_loopbacks alc880_loopbacks
  6607. #endif
  6608. /* pcm configuration: identiacal with ALC880 */
  6609. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6610. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6611. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6612. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6613. /*
  6614. * configuration and preset
  6615. */
  6616. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6617. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6618. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6619. [ALC883_3ST_6ch] = "3stack-6ch",
  6620. [ALC883_6ST_DIG] = "6stack-dig",
  6621. [ALC883_TARGA_DIG] = "targa-dig",
  6622. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6623. [ALC883_ACER] = "acer",
  6624. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6625. [ALC883_MEDION] = "medion",
  6626. [ALC883_MEDION_MD2] = "medion-md2",
  6627. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6628. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6629. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6630. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6631. [ALC883_HAIER_W66] = "haier-w66",
  6632. [ALC888_6ST_HP] = "6stack-hp",
  6633. [ALC888_3ST_HP] = "3stack-hp",
  6634. [ALC883_MITAC] = "mitac",
  6635. [ALC883_AUTO] = "auto",
  6636. };
  6637. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6638. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6639. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6640. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6641. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6642. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
  6643. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6644. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6645. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6646. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6647. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6648. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6649. SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
  6650. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6651. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6652. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6653. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6654. SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
  6655. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6656. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6657. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6658. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6659. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6660. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6661. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6662. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6663. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6664. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6665. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6666. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6667. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6668. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6669. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6670. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6671. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6672. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6673. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6674. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6675. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6676. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6677. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6678. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6679. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6680. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6681. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6682. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6683. {}
  6684. };
  6685. static struct alc_config_preset alc883_presets[] = {
  6686. [ALC883_3ST_2ch_DIG] = {
  6687. .mixers = { alc883_3ST_2ch_mixer },
  6688. .init_verbs = { alc883_init_verbs },
  6689. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6690. .dac_nids = alc883_dac_nids,
  6691. .dig_out_nid = ALC883_DIGOUT_NID,
  6692. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6693. .adc_nids = alc883_adc_nids,
  6694. .dig_in_nid = ALC883_DIGIN_NID,
  6695. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6696. .channel_mode = alc883_3ST_2ch_modes,
  6697. .input_mux = &alc883_capture_source,
  6698. },
  6699. [ALC883_3ST_6ch_DIG] = {
  6700. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6701. .init_verbs = { alc883_init_verbs },
  6702. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6703. .dac_nids = alc883_dac_nids,
  6704. .dig_out_nid = ALC883_DIGOUT_NID,
  6705. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6706. .adc_nids = alc883_adc_nids,
  6707. .dig_in_nid = ALC883_DIGIN_NID,
  6708. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6709. .channel_mode = alc883_3ST_6ch_modes,
  6710. .need_dac_fix = 1,
  6711. .input_mux = &alc883_capture_source,
  6712. },
  6713. [ALC883_3ST_6ch] = {
  6714. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6715. .init_verbs = { alc883_init_verbs },
  6716. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6717. .dac_nids = alc883_dac_nids,
  6718. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6719. .adc_nids = alc883_adc_nids,
  6720. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6721. .channel_mode = alc883_3ST_6ch_modes,
  6722. .need_dac_fix = 1,
  6723. .input_mux = &alc883_capture_source,
  6724. },
  6725. [ALC883_6ST_DIG] = {
  6726. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6727. .init_verbs = { alc883_init_verbs },
  6728. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6729. .dac_nids = alc883_dac_nids,
  6730. .dig_out_nid = ALC883_DIGOUT_NID,
  6731. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6732. .adc_nids = alc883_adc_nids,
  6733. .dig_in_nid = ALC883_DIGIN_NID,
  6734. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6735. .channel_mode = alc883_sixstack_modes,
  6736. .input_mux = &alc883_capture_source,
  6737. },
  6738. [ALC883_TARGA_DIG] = {
  6739. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6740. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6741. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6742. .dac_nids = alc883_dac_nids,
  6743. .dig_out_nid = ALC883_DIGOUT_NID,
  6744. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6745. .adc_nids = alc883_adc_nids,
  6746. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6747. .channel_mode = alc883_3ST_6ch_modes,
  6748. .need_dac_fix = 1,
  6749. .input_mux = &alc883_capture_source,
  6750. .unsol_event = alc883_tagra_unsol_event,
  6751. .init_hook = alc883_tagra_automute,
  6752. },
  6753. [ALC883_TARGA_2ch_DIG] = {
  6754. .mixers = { alc883_tagra_2ch_mixer},
  6755. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6756. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6757. .dac_nids = alc883_dac_nids,
  6758. .dig_out_nid = ALC883_DIGOUT_NID,
  6759. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6760. .adc_nids = alc883_adc_nids,
  6761. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6762. .channel_mode = alc883_3ST_2ch_modes,
  6763. .input_mux = &alc883_capture_source,
  6764. .unsol_event = alc883_tagra_unsol_event,
  6765. .init_hook = alc883_tagra_automute,
  6766. },
  6767. [ALC883_ACER] = {
  6768. .mixers = { alc883_base_mixer },
  6769. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6770. * and the headphone jack. Turn this on and rely on the
  6771. * standard mute methods whenever the user wants to turn
  6772. * these outputs off.
  6773. */
  6774. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6775. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6776. .dac_nids = alc883_dac_nids,
  6777. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6778. .adc_nids = alc883_adc_nids,
  6779. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6780. .channel_mode = alc883_3ST_2ch_modes,
  6781. .input_mux = &alc883_capture_source,
  6782. },
  6783. [ALC883_ACER_ASPIRE] = {
  6784. .mixers = { alc883_acer_aspire_mixer },
  6785. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6786. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6787. .dac_nids = alc883_dac_nids,
  6788. .dig_out_nid = ALC883_DIGOUT_NID,
  6789. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6790. .adc_nids = alc883_adc_nids,
  6791. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6792. .channel_mode = alc883_3ST_2ch_modes,
  6793. .input_mux = &alc883_capture_source,
  6794. .unsol_event = alc883_acer_aspire_unsol_event,
  6795. .init_hook = alc883_acer_aspire_automute,
  6796. },
  6797. [ALC883_MEDION] = {
  6798. .mixers = { alc883_fivestack_mixer,
  6799. alc883_chmode_mixer },
  6800. .init_verbs = { alc883_init_verbs,
  6801. alc883_medion_eapd_verbs },
  6802. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6803. .dac_nids = alc883_dac_nids,
  6804. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6805. .adc_nids = alc883_adc_nids,
  6806. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6807. .channel_mode = alc883_sixstack_modes,
  6808. .input_mux = &alc883_capture_source,
  6809. },
  6810. [ALC883_MEDION_MD2] = {
  6811. .mixers = { alc883_medion_md2_mixer},
  6812. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6813. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6814. .dac_nids = alc883_dac_nids,
  6815. .dig_out_nid = ALC883_DIGOUT_NID,
  6816. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6817. .adc_nids = alc883_adc_nids,
  6818. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6819. .channel_mode = alc883_3ST_2ch_modes,
  6820. .input_mux = &alc883_capture_source,
  6821. .unsol_event = alc883_medion_md2_unsol_event,
  6822. .init_hook = alc883_medion_md2_automute,
  6823. },
  6824. [ALC883_LAPTOP_EAPD] = {
  6825. .mixers = { alc883_base_mixer },
  6826. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6827. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6828. .dac_nids = alc883_dac_nids,
  6829. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6830. .adc_nids = alc883_adc_nids,
  6831. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6832. .channel_mode = alc883_3ST_2ch_modes,
  6833. .input_mux = &alc883_capture_source,
  6834. },
  6835. [ALC883_LENOVO_101E_2ch] = {
  6836. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6837. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6838. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6839. .dac_nids = alc883_dac_nids,
  6840. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6841. .adc_nids = alc883_adc_nids,
  6842. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6843. .channel_mode = alc883_3ST_2ch_modes,
  6844. .input_mux = &alc883_lenovo_101e_capture_source,
  6845. .unsol_event = alc883_lenovo_101e_unsol_event,
  6846. .init_hook = alc883_lenovo_101e_all_automute,
  6847. },
  6848. [ALC883_LENOVO_NB0763] = {
  6849. .mixers = { alc883_lenovo_nb0763_mixer },
  6850. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6851. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6852. .dac_nids = alc883_dac_nids,
  6853. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6854. .adc_nids = alc883_adc_nids,
  6855. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6856. .channel_mode = alc883_3ST_2ch_modes,
  6857. .need_dac_fix = 1,
  6858. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6859. .unsol_event = alc883_medion_md2_unsol_event,
  6860. .init_hook = alc883_medion_md2_automute,
  6861. },
  6862. [ALC888_LENOVO_MS7195_DIG] = {
  6863. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6864. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6865. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6866. .dac_nids = alc883_dac_nids,
  6867. .dig_out_nid = ALC883_DIGOUT_NID,
  6868. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6869. .adc_nids = alc883_adc_nids,
  6870. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6871. .channel_mode = alc883_3ST_6ch_modes,
  6872. .need_dac_fix = 1,
  6873. .input_mux = &alc883_capture_source,
  6874. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6875. .init_hook = alc888_lenovo_ms7195_front_automute,
  6876. },
  6877. [ALC883_HAIER_W66] = {
  6878. .mixers = { alc883_tagra_2ch_mixer},
  6879. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6880. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6881. .dac_nids = alc883_dac_nids,
  6882. .dig_out_nid = ALC883_DIGOUT_NID,
  6883. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6884. .adc_nids = alc883_adc_nids,
  6885. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6886. .channel_mode = alc883_3ST_2ch_modes,
  6887. .input_mux = &alc883_capture_source,
  6888. .unsol_event = alc883_haier_w66_unsol_event,
  6889. .init_hook = alc883_haier_w66_automute,
  6890. },
  6891. [ALC888_6ST_HP] = {
  6892. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6893. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6894. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6895. .dac_nids = alc883_dac_nids,
  6896. .dig_out_nid = ALC883_DIGOUT_NID,
  6897. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6898. .adc_nids = alc883_adc_nids,
  6899. .dig_in_nid = ALC883_DIGIN_NID,
  6900. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6901. .channel_mode = alc883_sixstack_modes,
  6902. .input_mux = &alc883_capture_source,
  6903. },
  6904. [ALC888_3ST_HP] = {
  6905. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6906. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6907. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6908. .dac_nids = alc883_dac_nids,
  6909. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6910. .adc_nids = alc883_adc_nids,
  6911. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6912. .channel_mode = alc888_3st_hp_modes,
  6913. .need_dac_fix = 1,
  6914. .input_mux = &alc883_capture_source,
  6915. },
  6916. [ALC883_MITAC] = {
  6917. .mixers = { alc883_mitac_mixer },
  6918. .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
  6919. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6920. .dac_nids = alc883_dac_nids,
  6921. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6922. .adc_nids = alc883_adc_nids,
  6923. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6924. .channel_mode = alc883_3ST_2ch_modes,
  6925. .input_mux = &alc883_capture_source,
  6926. .unsol_event = alc883_mitac_unsol_event,
  6927. .init_hook = alc883_mitac_automute,
  6928. },
  6929. };
  6930. /*
  6931. * BIOS auto configuration
  6932. */
  6933. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6934. hda_nid_t nid, int pin_type,
  6935. int dac_idx)
  6936. {
  6937. /* set as output */
  6938. struct alc_spec *spec = codec->spec;
  6939. int idx;
  6940. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6941. idx = 4;
  6942. else
  6943. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6944. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6945. pin_type);
  6946. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6947. AMP_OUT_UNMUTE);
  6948. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6949. }
  6950. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6951. {
  6952. struct alc_spec *spec = codec->spec;
  6953. int i;
  6954. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6955. for (i = 0; i <= HDA_SIDE; i++) {
  6956. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6957. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6958. if (nid)
  6959. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6960. i);
  6961. }
  6962. }
  6963. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6964. {
  6965. struct alc_spec *spec = codec->spec;
  6966. hda_nid_t pin;
  6967. pin = spec->autocfg.hp_pins[0];
  6968. if (pin) /* connect to front */
  6969. /* use dac 0 */
  6970. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6971. }
  6972. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6973. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6974. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6975. {
  6976. struct alc_spec *spec = codec->spec;
  6977. int i;
  6978. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6979. hda_nid_t nid = spec->autocfg.input_pins[i];
  6980. if (alc883_is_input_pin(nid)) {
  6981. snd_hda_codec_write(codec, nid, 0,
  6982. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6983. (i <= AUTO_PIN_FRONT_MIC ?
  6984. PIN_VREF80 : PIN_IN));
  6985. if (nid != ALC883_PIN_CD_NID)
  6986. snd_hda_codec_write(codec, nid, 0,
  6987. AC_VERB_SET_AMP_GAIN_MUTE,
  6988. AMP_OUT_MUTE);
  6989. }
  6990. }
  6991. }
  6992. /* almost identical with ALC880 parser... */
  6993. static int alc883_parse_auto_config(struct hda_codec *codec)
  6994. {
  6995. struct alc_spec *spec = codec->spec;
  6996. int err = alc880_parse_auto_config(codec);
  6997. if (err < 0)
  6998. return err;
  6999. else if (!err)
  7000. return 0; /* no config found */
  7001. err = alc_auto_add_mic_boost(codec);
  7002. if (err < 0)
  7003. return err;
  7004. /* hack - override the init verbs */
  7005. spec->init_verbs[0] = alc883_auto_init_verbs;
  7006. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  7007. spec->num_mixers++;
  7008. return 1; /* config found */
  7009. }
  7010. /* additional initialization for auto-configuration model */
  7011. static void alc883_auto_init(struct hda_codec *codec)
  7012. {
  7013. alc883_auto_init_multi_out(codec);
  7014. alc883_auto_init_hp_out(codec);
  7015. alc883_auto_init_analog_input(codec);
  7016. }
  7017. static int patch_alc883(struct hda_codec *codec)
  7018. {
  7019. struct alc_spec *spec;
  7020. int err, board_config;
  7021. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7022. if (spec == NULL)
  7023. return -ENOMEM;
  7024. codec->spec = spec;
  7025. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  7026. alc883_models,
  7027. alc883_cfg_tbl);
  7028. if (board_config < 0) {
  7029. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  7030. "trying auto-probe from BIOS...\n");
  7031. board_config = ALC883_AUTO;
  7032. }
  7033. if (board_config == ALC883_AUTO) {
  7034. /* automatic parse from the BIOS config */
  7035. err = alc883_parse_auto_config(codec);
  7036. if (err < 0) {
  7037. alc_free(codec);
  7038. return err;
  7039. } else if (!err) {
  7040. printk(KERN_INFO
  7041. "hda_codec: Cannot set up configuration "
  7042. "from BIOS. Using base mode...\n");
  7043. board_config = ALC883_3ST_2ch_DIG;
  7044. }
  7045. }
  7046. if (board_config != ALC883_AUTO)
  7047. setup_preset(spec, &alc883_presets[board_config]);
  7048. spec->stream_name_analog = "ALC883 Analog";
  7049. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  7050. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  7051. spec->stream_name_digital = "ALC883 Digital";
  7052. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  7053. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  7054. if (!spec->adc_nids && spec->input_mux) {
  7055. spec->adc_nids = alc883_adc_nids;
  7056. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  7057. }
  7058. codec->patch_ops = alc_patch_ops;
  7059. if (board_config == ALC883_AUTO)
  7060. spec->init_hook = alc883_auto_init;
  7061. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7062. if (!spec->loopback.amplist)
  7063. spec->loopback.amplist = alc883_loopbacks;
  7064. #endif
  7065. return 0;
  7066. }
  7067. /*
  7068. * ALC262 support
  7069. */
  7070. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  7071. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  7072. #define alc262_dac_nids alc260_dac_nids
  7073. #define alc262_adc_nids alc882_adc_nids
  7074. #define alc262_adc_nids_alt alc882_adc_nids_alt
  7075. #define alc262_modes alc260_modes
  7076. #define alc262_capture_source alc882_capture_source
  7077. static struct snd_kcontrol_new alc262_base_mixer[] = {
  7078. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7079. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7080. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7081. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7082. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7083. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7084. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7085. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7086. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7087. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7088. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7089. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7090. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7091. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  7092. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  7093. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7094. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  7095. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  7096. { } /* end */
  7097. };
  7098. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  7099. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7100. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7101. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7102. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7103. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7104. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7105. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7106. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7107. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7108. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7109. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7110. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7111. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7112. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  7113. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  7114. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7115. { } /* end */
  7116. };
  7117. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  7118. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7119. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7120. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7121. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  7122. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  7123. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7124. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7125. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7126. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7127. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7128. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7129. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7130. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7131. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7132. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7133. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7134. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7135. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  7136. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  7137. { } /* end */
  7138. };
  7139. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  7140. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7141. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7142. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  7143. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7144. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  7145. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  7146. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7147. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7148. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  7149. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7150. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7151. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7152. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7153. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7154. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7155. { } /* end */
  7156. };
  7157. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7158. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7159. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7160. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7161. { } /* end */
  7162. };
  7163. static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
  7164. .ops = &snd_hda_bind_vol,
  7165. .values = {
  7166. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7167. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7168. 0
  7169. },
  7170. };
  7171. static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
  7172. .ops = &snd_hda_bind_sw,
  7173. .values = {
  7174. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7175. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7176. 0
  7177. },
  7178. };
  7179. /* mute/unmute internal speaker according to the hp jack and mute state */
  7180. static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
  7181. {
  7182. struct alc_spec *spec = codec->spec;
  7183. unsigned int mute;
  7184. if (force || !spec->sense_updated) {
  7185. unsigned int present;
  7186. present = snd_hda_codec_read(codec, 0x15, 0,
  7187. AC_VERB_GET_PIN_SENSE, 0);
  7188. spec->jack_present = (present & 0x80000000) != 0;
  7189. spec->sense_updated = 1;
  7190. }
  7191. if (spec->jack_present)
  7192. mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
  7193. else /* unmute internal speaker if necessary */
  7194. mute = (0x7000 | ((0)<<8));
  7195. snd_hda_codec_write(codec, 0x0c, 0,
  7196. AC_VERB_SET_AMP_GAIN_MUTE, mute );
  7197. }
  7198. static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
  7199. unsigned int res)
  7200. {
  7201. if ((res >> 26) != ALC880_HP_EVENT)
  7202. return;
  7203. alc262_hp_t5735_automute(codec, 1);
  7204. }
  7205. static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
  7206. {
  7207. alc262_hp_t5735_automute(codec, 1);
  7208. }
  7209. static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
  7210. HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
  7211. HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
  7212. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7213. HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7214. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7215. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  7217. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7218. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7219. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7220. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7221. { } /* end */
  7222. };
  7223. static struct hda_verb alc262_hp_t5735_verbs[] = {
  7224. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7225. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7226. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7227. { }
  7228. };
  7229. /* bind hp and internal speaker mute (with plug check) */
  7230. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7231. struct snd_ctl_elem_value *ucontrol)
  7232. {
  7233. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7234. long *valp = ucontrol->value.integer.value;
  7235. int change;
  7236. /* change hp mute */
  7237. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7238. HDA_AMP_MUTE,
  7239. valp[0] ? 0 : HDA_AMP_MUTE);
  7240. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7241. HDA_AMP_MUTE,
  7242. valp[1] ? 0 : HDA_AMP_MUTE);
  7243. if (change) {
  7244. /* change speaker according to HP jack state */
  7245. struct alc_spec *spec = codec->spec;
  7246. unsigned int mute;
  7247. if (spec->jack_present)
  7248. mute = HDA_AMP_MUTE;
  7249. else
  7250. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7251. HDA_OUTPUT, 0);
  7252. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7253. HDA_AMP_MUTE, mute);
  7254. }
  7255. return change;
  7256. }
  7257. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7258. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7259. {
  7260. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7261. .name = "Master Playback Switch",
  7262. .info = snd_hda_mixer_amp_switch_info,
  7263. .get = snd_hda_mixer_amp_switch_get,
  7264. .put = alc262_sony_master_sw_put,
  7265. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7266. },
  7267. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7268. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7269. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7270. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7271. { } /* end */
  7272. };
  7273. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7274. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7275. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7276. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7277. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7278. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7279. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7280. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7281. { } /* end */
  7282. };
  7283. #define alc262_capture_mixer alc882_capture_mixer
  7284. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7285. /*
  7286. * generic initialization of ADC, input mixers and output mixers
  7287. */
  7288. static struct hda_verb alc262_init_verbs[] = {
  7289. /*
  7290. * Unmute ADC0-2 and set the default input to mic-in
  7291. */
  7292. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7293. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7294. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7295. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7296. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7297. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7298. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7299. * mixer widget
  7300. * Note: PASD motherboards uses the Line In 2 as the input for
  7301. * front panel mic (mic 2)
  7302. */
  7303. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7304. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7305. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7306. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7307. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7308. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7309. /*
  7310. * Set up output mixers (0x0c - 0x0e)
  7311. */
  7312. /* set vol=0 to output mixers */
  7313. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7314. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7315. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7316. /* set up input amps for analog loopback */
  7317. /* Amp Indices: DAC = 0, mixer = 1 */
  7318. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7319. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7320. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7321. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7323. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7324. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7325. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7326. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7327. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7328. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7330. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7331. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7332. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7333. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7334. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7335. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7336. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7337. /* FIXME: use matrix-type input source selection */
  7338. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7339. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7340. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7341. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7342. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7343. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7344. /* Input mixer2 */
  7345. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7346. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7347. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7348. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7349. /* Input mixer3 */
  7350. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7351. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7352. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7353. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7354. { }
  7355. };
  7356. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7357. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7358. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7359. {}
  7360. };
  7361. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7362. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7363. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7364. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7365. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7366. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7367. {}
  7368. };
  7369. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7370. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7371. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7372. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7373. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7375. };
  7376. /* mute/unmute internal speaker according to the hp jack and mute state */
  7377. static void alc262_hippo_automute(struct hda_codec *codec)
  7378. {
  7379. struct alc_spec *spec = codec->spec;
  7380. unsigned int mute;
  7381. unsigned int present;
  7382. /* need to execute and sync at first */
  7383. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7384. present = snd_hda_codec_read(codec, 0x15, 0,
  7385. AC_VERB_GET_PIN_SENSE, 0);
  7386. spec->jack_present = (present & 0x80000000) != 0;
  7387. if (spec->jack_present) {
  7388. /* mute internal speaker */
  7389. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7390. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7391. } else {
  7392. /* unmute internal speaker if necessary */
  7393. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7394. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7395. HDA_AMP_MUTE, mute);
  7396. }
  7397. }
  7398. /* unsolicited event for HP jack sensing */
  7399. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7400. unsigned int res)
  7401. {
  7402. if ((res >> 26) != ALC880_HP_EVENT)
  7403. return;
  7404. alc262_hippo_automute(codec);
  7405. }
  7406. static void alc262_hippo1_automute(struct hda_codec *codec)
  7407. {
  7408. unsigned int mute;
  7409. unsigned int present;
  7410. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7411. present = snd_hda_codec_read(codec, 0x1b, 0,
  7412. AC_VERB_GET_PIN_SENSE, 0);
  7413. present = (present & 0x80000000) != 0;
  7414. if (present) {
  7415. /* mute internal speaker */
  7416. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7417. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7418. } else {
  7419. /* unmute internal speaker if necessary */
  7420. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7421. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7422. HDA_AMP_MUTE, mute);
  7423. }
  7424. }
  7425. /* unsolicited event for HP jack sensing */
  7426. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7427. unsigned int res)
  7428. {
  7429. if ((res >> 26) != ALC880_HP_EVENT)
  7430. return;
  7431. alc262_hippo1_automute(codec);
  7432. }
  7433. /*
  7434. * fujitsu model
  7435. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7436. */
  7437. #define ALC_HP_EVENT 0x37
  7438. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7439. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7440. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7441. {}
  7442. };
  7443. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7444. .num_items = 3,
  7445. .items = {
  7446. { "Mic", 0x0 },
  7447. { "Int Mic", 0x1 },
  7448. { "CD", 0x4 },
  7449. },
  7450. };
  7451. static struct hda_input_mux alc262_HP_capture_source = {
  7452. .num_items = 5,
  7453. .items = {
  7454. { "Mic", 0x0 },
  7455. { "Front Mic", 0x1 },
  7456. { "Line", 0x2 },
  7457. { "CD", 0x4 },
  7458. { "AUX IN", 0x6 },
  7459. },
  7460. };
  7461. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7462. .num_items = 4,
  7463. .items = {
  7464. { "Mic", 0x0 },
  7465. { "Front Mic", 0x2 },
  7466. { "Line", 0x1 },
  7467. { "CD", 0x4 },
  7468. },
  7469. };
  7470. /* mute/unmute internal speaker according to the hp jack and mute state */
  7471. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7472. {
  7473. struct alc_spec *spec = codec->spec;
  7474. unsigned int mute;
  7475. if (force || !spec->sense_updated) {
  7476. unsigned int present;
  7477. /* need to execute and sync at first */
  7478. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7479. present = snd_hda_codec_read(codec, 0x14, 0,
  7480. AC_VERB_GET_PIN_SENSE, 0);
  7481. spec->jack_present = (present & 0x80000000) != 0;
  7482. spec->sense_updated = 1;
  7483. }
  7484. if (spec->jack_present) {
  7485. /* mute internal speaker */
  7486. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7487. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7488. } else {
  7489. /* unmute internal speaker if necessary */
  7490. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7491. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7492. HDA_AMP_MUTE, mute);
  7493. }
  7494. }
  7495. /* unsolicited event for HP jack sensing */
  7496. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7497. unsigned int res)
  7498. {
  7499. if ((res >> 26) != ALC_HP_EVENT)
  7500. return;
  7501. alc262_fujitsu_automute(codec, 1);
  7502. }
  7503. /* bind volumes of both NID 0x0c and 0x0d */
  7504. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7505. .ops = &snd_hda_bind_vol,
  7506. .values = {
  7507. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7508. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7509. 0
  7510. },
  7511. };
  7512. /* bind hp and internal speaker mute (with plug check) */
  7513. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7514. struct snd_ctl_elem_value *ucontrol)
  7515. {
  7516. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7517. long *valp = ucontrol->value.integer.value;
  7518. int change;
  7519. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7520. HDA_AMP_MUTE,
  7521. valp[0] ? 0 : HDA_AMP_MUTE);
  7522. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7523. HDA_AMP_MUTE,
  7524. valp[1] ? 0 : HDA_AMP_MUTE);
  7525. if (change)
  7526. alc262_fujitsu_automute(codec, 0);
  7527. return change;
  7528. }
  7529. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7530. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7531. {
  7532. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7533. .name = "Master Playback Switch",
  7534. .info = snd_hda_mixer_amp_switch_info,
  7535. .get = snd_hda_mixer_amp_switch_get,
  7536. .put = alc262_fujitsu_master_sw_put,
  7537. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7538. },
  7539. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7540. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7541. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7542. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7543. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7544. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7545. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7546. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7547. { } /* end */
  7548. };
  7549. /* additional init verbs for Benq laptops */
  7550. static struct hda_verb alc262_EAPD_verbs[] = {
  7551. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7552. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7553. {}
  7554. };
  7555. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7556. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7557. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7558. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7559. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7560. {}
  7561. };
  7562. /* Samsung Q1 Ultra Vista model setup */
  7563. static struct snd_kcontrol_new alc262_ultra_mixer[] = {
  7564. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7565. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7566. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7567. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7568. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7569. HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
  7570. { } /* end */
  7571. };
  7572. static struct hda_verb alc262_ultra_verbs[] = {
  7573. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7574. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7575. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7576. /* Mic is on Node 0x19 */
  7577. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7578. {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
  7579. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7580. {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
  7581. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7582. {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
  7583. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7584. {}
  7585. };
  7586. static struct hda_input_mux alc262_ultra_capture_source = {
  7587. .num_items = 1,
  7588. .items = {
  7589. { "Mic", 0x1 },
  7590. },
  7591. };
  7592. /* mute/unmute internal speaker according to the hp jack and mute state */
  7593. static void alc262_ultra_automute(struct hda_codec *codec)
  7594. {
  7595. struct alc_spec *spec = codec->spec;
  7596. unsigned int mute;
  7597. unsigned int present;
  7598. /* need to execute and sync at first */
  7599. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7600. present = snd_hda_codec_read(codec, 0x15, 0,
  7601. AC_VERB_GET_PIN_SENSE, 0);
  7602. spec->jack_present = (present & 0x80000000) != 0;
  7603. if (spec->jack_present) {
  7604. /* mute internal speaker */
  7605. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7606. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7607. } else {
  7608. /* unmute internal speaker if necessary */
  7609. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7610. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7611. HDA_AMP_MUTE, mute);
  7612. }
  7613. }
  7614. /* unsolicited event for HP jack sensing */
  7615. static void alc262_ultra_unsol_event(struct hda_codec *codec,
  7616. unsigned int res)
  7617. {
  7618. if ((res >> 26) != ALC880_HP_EVENT)
  7619. return;
  7620. alc262_ultra_automute(codec);
  7621. }
  7622. /* add playback controls from the parsed DAC table */
  7623. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7624. const struct auto_pin_cfg *cfg)
  7625. {
  7626. hda_nid_t nid;
  7627. int err;
  7628. spec->multiout.num_dacs = 1; /* only use one dac */
  7629. spec->multiout.dac_nids = spec->private_dac_nids;
  7630. spec->multiout.dac_nids[0] = 2;
  7631. nid = cfg->line_out_pins[0];
  7632. if (nid) {
  7633. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7634. "Front Playback Volume",
  7635. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7636. if (err < 0)
  7637. return err;
  7638. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7639. "Front Playback Switch",
  7640. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7641. if (err < 0)
  7642. return err;
  7643. }
  7644. nid = cfg->speaker_pins[0];
  7645. if (nid) {
  7646. if (nid == 0x16) {
  7647. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7648. "Speaker Playback Volume",
  7649. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7650. HDA_OUTPUT));
  7651. if (err < 0)
  7652. return err;
  7653. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7654. "Speaker Playback Switch",
  7655. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7656. HDA_OUTPUT));
  7657. if (err < 0)
  7658. return err;
  7659. } else {
  7660. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7661. "Speaker Playback Switch",
  7662. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7663. HDA_OUTPUT));
  7664. if (err < 0)
  7665. return err;
  7666. }
  7667. }
  7668. nid = cfg->hp_pins[0];
  7669. if (nid) {
  7670. /* spec->multiout.hp_nid = 2; */
  7671. if (nid == 0x16) {
  7672. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7673. "Headphone Playback Volume",
  7674. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7675. HDA_OUTPUT));
  7676. if (err < 0)
  7677. return err;
  7678. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7679. "Headphone Playback Switch",
  7680. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7681. HDA_OUTPUT));
  7682. if (err < 0)
  7683. return err;
  7684. } else {
  7685. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7686. "Headphone Playback Switch",
  7687. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7688. HDA_OUTPUT));
  7689. if (err < 0)
  7690. return err;
  7691. }
  7692. }
  7693. return 0;
  7694. }
  7695. /* identical with ALC880 */
  7696. #define alc262_auto_create_analog_input_ctls \
  7697. alc880_auto_create_analog_input_ctls
  7698. /*
  7699. * generic initialization of ADC, input mixers and output mixers
  7700. */
  7701. static struct hda_verb alc262_volume_init_verbs[] = {
  7702. /*
  7703. * Unmute ADC0-2 and set the default input to mic-in
  7704. */
  7705. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7706. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7707. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7708. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7709. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7710. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7711. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7712. * mixer widget
  7713. * Note: PASD motherboards uses the Line In 2 as the input for
  7714. * front panel mic (mic 2)
  7715. */
  7716. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7717. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7718. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7719. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7720. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7721. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7722. /*
  7723. * Set up output mixers (0x0c - 0x0f)
  7724. */
  7725. /* set vol=0 to output mixers */
  7726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7727. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7728. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7729. /* set up input amps for analog loopback */
  7730. /* Amp Indices: DAC = 0, mixer = 1 */
  7731. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7732. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7733. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7734. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7735. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7736. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7737. /* FIXME: use matrix-type input source selection */
  7738. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7739. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7741. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7742. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7743. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7744. /* Input mixer2 */
  7745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7748. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7749. /* Input mixer3 */
  7750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7751. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7753. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7754. { }
  7755. };
  7756. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7757. /*
  7758. * Unmute ADC0-2 and set the default input to mic-in
  7759. */
  7760. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7761. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7762. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7763. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7764. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7765. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7766. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7767. * mixer widget
  7768. * Note: PASD motherboards uses the Line In 2 as the input for
  7769. * front panel mic (mic 2)
  7770. */
  7771. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7772. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7773. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7774. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7775. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7776. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7777. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7778. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7779. /*
  7780. * Set up output mixers (0x0c - 0x0e)
  7781. */
  7782. /* set vol=0 to output mixers */
  7783. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7784. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7785. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7786. /* set up input amps for analog loopback */
  7787. /* Amp Indices: DAC = 0, mixer = 1 */
  7788. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7789. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7790. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7791. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7792. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7793. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7794. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7795. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7796. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7797. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7798. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7799. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7800. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7801. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7802. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7803. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7804. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7805. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7806. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7807. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7808. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7809. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7810. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7811. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7812. /* FIXME: use matrix-type input source selection */
  7813. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7814. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7815. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7816. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7817. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7818. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7819. /* Input mixer2 */
  7820. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7821. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7822. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7823. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7824. /* Input mixer3 */
  7825. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7826. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7827. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7828. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7829. { }
  7830. };
  7831. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7832. /*
  7833. * Unmute ADC0-2 and set the default input to mic-in
  7834. */
  7835. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7836. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7837. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7838. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7839. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7840. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7841. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7842. * mixer widget
  7843. * Note: PASD motherboards uses the Line In 2 as the input for front
  7844. * panel mic (mic 2)
  7845. */
  7846. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7847. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7848. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7849. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7850. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7852. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7853. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7854. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7855. /*
  7856. * Set up output mixers (0x0c - 0x0e)
  7857. */
  7858. /* set vol=0 to output mixers */
  7859. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7860. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7861. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7862. /* set up input amps for analog loopback */
  7863. /* Amp Indices: DAC = 0, mixer = 1 */
  7864. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7865. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7866. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7867. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7868. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7869. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7870. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7871. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7872. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7873. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7874. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7875. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7876. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7877. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7878. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7879. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7880. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7881. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7882. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7883. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7884. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7885. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7886. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7887. /* FIXME: use matrix-type input source selection */
  7888. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7889. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7890. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7891. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7892. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7893. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7894. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7895. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7897. /* Input mixer2 */
  7898. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7899. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7900. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7903. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7905. /* Input mixer3 */
  7906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7911. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7913. { }
  7914. };
  7915. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7916. #define alc262_loopbacks alc880_loopbacks
  7917. #endif
  7918. /* pcm configuration: identiacal with ALC880 */
  7919. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7920. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7921. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7922. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7923. /*
  7924. * BIOS auto configuration
  7925. */
  7926. static int alc262_parse_auto_config(struct hda_codec *codec)
  7927. {
  7928. struct alc_spec *spec = codec->spec;
  7929. int err;
  7930. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7931. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7932. alc262_ignore);
  7933. if (err < 0)
  7934. return err;
  7935. if (!spec->autocfg.line_outs)
  7936. return 0; /* can't find valid BIOS pin config */
  7937. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7938. if (err < 0)
  7939. return err;
  7940. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7941. if (err < 0)
  7942. return err;
  7943. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7944. if (spec->autocfg.dig_out_pin)
  7945. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7946. if (spec->autocfg.dig_in_pin)
  7947. spec->dig_in_nid = ALC262_DIGIN_NID;
  7948. if (spec->kctl_alloc)
  7949. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7950. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7951. spec->num_mux_defs = 1;
  7952. spec->input_mux = &spec->private_imux;
  7953. err = alc_auto_add_mic_boost(codec);
  7954. if (err < 0)
  7955. return err;
  7956. return 1;
  7957. }
  7958. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7959. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7960. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7961. /* init callback for auto-configuration model -- overriding the default init */
  7962. static void alc262_auto_init(struct hda_codec *codec)
  7963. {
  7964. alc262_auto_init_multi_out(codec);
  7965. alc262_auto_init_hp_out(codec);
  7966. alc262_auto_init_analog_input(codec);
  7967. }
  7968. /*
  7969. * configuration and preset
  7970. */
  7971. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7972. [ALC262_BASIC] = "basic",
  7973. [ALC262_HIPPO] = "hippo",
  7974. [ALC262_HIPPO_1] = "hippo_1",
  7975. [ALC262_FUJITSU] = "fujitsu",
  7976. [ALC262_HP_BPC] = "hp-bpc",
  7977. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7978. [ALC262_HP_TC_T5735] = "hp-tc-t5735",
  7979. [ALC262_BENQ_ED8] = "benq",
  7980. [ALC262_BENQ_T31] = "benq-t31",
  7981. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7982. [ALC262_ULTRA] = "ultra",
  7983. [ALC262_AUTO] = "auto",
  7984. };
  7985. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7986. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7987. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7988. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7989. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7990. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7991. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7992. SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
  7993. SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
  7994. SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
  7995. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7996. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7997. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7998. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7999. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  8000. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  8001. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  8002. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  8003. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  8004. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  8005. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  8006. SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
  8007. ALC262_HP_TC_T5735),
  8008. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  8009. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  8010. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  8011. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  8012. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  8013. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  8014. SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
  8015. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  8016. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  8017. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  8018. {}
  8019. };
  8020. static struct alc_config_preset alc262_presets[] = {
  8021. [ALC262_BASIC] = {
  8022. .mixers = { alc262_base_mixer },
  8023. .init_verbs = { alc262_init_verbs },
  8024. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8025. .dac_nids = alc262_dac_nids,
  8026. .hp_nid = 0x03,
  8027. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8028. .channel_mode = alc262_modes,
  8029. .input_mux = &alc262_capture_source,
  8030. },
  8031. [ALC262_HIPPO] = {
  8032. .mixers = { alc262_base_mixer },
  8033. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  8034. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8035. .dac_nids = alc262_dac_nids,
  8036. .hp_nid = 0x03,
  8037. .dig_out_nid = ALC262_DIGOUT_NID,
  8038. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8039. .channel_mode = alc262_modes,
  8040. .input_mux = &alc262_capture_source,
  8041. .unsol_event = alc262_hippo_unsol_event,
  8042. .init_hook = alc262_hippo_automute,
  8043. },
  8044. [ALC262_HIPPO_1] = {
  8045. .mixers = { alc262_hippo1_mixer },
  8046. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  8047. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8048. .dac_nids = alc262_dac_nids,
  8049. .hp_nid = 0x02,
  8050. .dig_out_nid = ALC262_DIGOUT_NID,
  8051. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8052. .channel_mode = alc262_modes,
  8053. .input_mux = &alc262_capture_source,
  8054. .unsol_event = alc262_hippo1_unsol_event,
  8055. .init_hook = alc262_hippo1_automute,
  8056. },
  8057. [ALC262_FUJITSU] = {
  8058. .mixers = { alc262_fujitsu_mixer },
  8059. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  8060. alc262_fujitsu_unsol_verbs },
  8061. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8062. .dac_nids = alc262_dac_nids,
  8063. .hp_nid = 0x03,
  8064. .dig_out_nid = ALC262_DIGOUT_NID,
  8065. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8066. .channel_mode = alc262_modes,
  8067. .input_mux = &alc262_fujitsu_capture_source,
  8068. .unsol_event = alc262_fujitsu_unsol_event,
  8069. },
  8070. [ALC262_HP_BPC] = {
  8071. .mixers = { alc262_HP_BPC_mixer },
  8072. .init_verbs = { alc262_HP_BPC_init_verbs },
  8073. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8074. .dac_nids = alc262_dac_nids,
  8075. .hp_nid = 0x03,
  8076. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8077. .channel_mode = alc262_modes,
  8078. .input_mux = &alc262_HP_capture_source,
  8079. },
  8080. [ALC262_HP_BPC_D7000_WF] = {
  8081. .mixers = { alc262_HP_BPC_WildWest_mixer },
  8082. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  8083. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8084. .dac_nids = alc262_dac_nids,
  8085. .hp_nid = 0x03,
  8086. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8087. .channel_mode = alc262_modes,
  8088. .input_mux = &alc262_HP_D7000_capture_source,
  8089. },
  8090. [ALC262_HP_BPC_D7000_WL] = {
  8091. .mixers = { alc262_HP_BPC_WildWest_mixer,
  8092. alc262_HP_BPC_WildWest_option_mixer },
  8093. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  8094. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8095. .dac_nids = alc262_dac_nids,
  8096. .hp_nid = 0x03,
  8097. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8098. .channel_mode = alc262_modes,
  8099. .input_mux = &alc262_HP_D7000_capture_source,
  8100. },
  8101. [ALC262_HP_TC_T5735] = {
  8102. .mixers = { alc262_hp_t5735_mixer },
  8103. .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
  8104. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8105. .dac_nids = alc262_dac_nids,
  8106. .hp_nid = 0x03,
  8107. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8108. .channel_mode = alc262_modes,
  8109. .input_mux = &alc262_capture_source,
  8110. .unsol_event = alc262_hp_t5735_unsol_event,
  8111. .init_hook = alc262_hp_t5735_init_hook,
  8112. },
  8113. [ALC262_BENQ_ED8] = {
  8114. .mixers = { alc262_base_mixer },
  8115. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  8116. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8117. .dac_nids = alc262_dac_nids,
  8118. .hp_nid = 0x03,
  8119. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8120. .channel_mode = alc262_modes,
  8121. .input_mux = &alc262_capture_source,
  8122. },
  8123. [ALC262_SONY_ASSAMD] = {
  8124. .mixers = { alc262_sony_mixer },
  8125. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  8126. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8127. .dac_nids = alc262_dac_nids,
  8128. .hp_nid = 0x02,
  8129. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8130. .channel_mode = alc262_modes,
  8131. .input_mux = &alc262_capture_source,
  8132. .unsol_event = alc262_hippo_unsol_event,
  8133. .init_hook = alc262_hippo_automute,
  8134. },
  8135. [ALC262_BENQ_T31] = {
  8136. .mixers = { alc262_benq_t31_mixer },
  8137. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  8138. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8139. .dac_nids = alc262_dac_nids,
  8140. .hp_nid = 0x03,
  8141. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8142. .channel_mode = alc262_modes,
  8143. .input_mux = &alc262_capture_source,
  8144. .unsol_event = alc262_hippo_unsol_event,
  8145. .init_hook = alc262_hippo_automute,
  8146. },
  8147. [ALC262_ULTRA] = {
  8148. .mixers = { alc262_ultra_mixer },
  8149. .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
  8150. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8151. .dac_nids = alc262_dac_nids,
  8152. .hp_nid = 0x03,
  8153. .dig_out_nid = ALC262_DIGOUT_NID,
  8154. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8155. .channel_mode = alc262_modes,
  8156. .input_mux = &alc262_ultra_capture_source,
  8157. .unsol_event = alc262_ultra_unsol_event,
  8158. .init_hook = alc262_ultra_automute,
  8159. },
  8160. };
  8161. static int patch_alc262(struct hda_codec *codec)
  8162. {
  8163. struct alc_spec *spec;
  8164. int board_config;
  8165. int err;
  8166. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8167. if (spec == NULL)
  8168. return -ENOMEM;
  8169. codec->spec = spec;
  8170. #if 0
  8171. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  8172. * under-run
  8173. */
  8174. {
  8175. int tmp;
  8176. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8177. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  8178. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8179. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  8180. }
  8181. #endif
  8182. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  8183. alc262_models,
  8184. alc262_cfg_tbl);
  8185. if (board_config < 0) {
  8186. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  8187. "trying auto-probe from BIOS...\n");
  8188. board_config = ALC262_AUTO;
  8189. }
  8190. if (board_config == ALC262_AUTO) {
  8191. /* automatic parse from the BIOS config */
  8192. err = alc262_parse_auto_config(codec);
  8193. if (err < 0) {
  8194. alc_free(codec);
  8195. return err;
  8196. } else if (!err) {
  8197. printk(KERN_INFO
  8198. "hda_codec: Cannot set up configuration "
  8199. "from BIOS. Using base mode...\n");
  8200. board_config = ALC262_BASIC;
  8201. }
  8202. }
  8203. if (board_config != ALC262_AUTO)
  8204. setup_preset(spec, &alc262_presets[board_config]);
  8205. spec->stream_name_analog = "ALC262 Analog";
  8206. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  8207. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  8208. spec->stream_name_digital = "ALC262 Digital";
  8209. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  8210. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  8211. if (!spec->adc_nids && spec->input_mux) {
  8212. /* check whether NID 0x07 is valid */
  8213. unsigned int wcap = get_wcaps(codec, 0x07);
  8214. /* get type */
  8215. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8216. if (wcap != AC_WID_AUD_IN) {
  8217. spec->adc_nids = alc262_adc_nids_alt;
  8218. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  8219. spec->mixers[spec->num_mixers] =
  8220. alc262_capture_alt_mixer;
  8221. spec->num_mixers++;
  8222. } else {
  8223. spec->adc_nids = alc262_adc_nids;
  8224. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  8225. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  8226. spec->num_mixers++;
  8227. }
  8228. }
  8229. codec->patch_ops = alc_patch_ops;
  8230. if (board_config == ALC262_AUTO)
  8231. spec->init_hook = alc262_auto_init;
  8232. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8233. if (!spec->loopback.amplist)
  8234. spec->loopback.amplist = alc262_loopbacks;
  8235. #endif
  8236. return 0;
  8237. }
  8238. /*
  8239. * ALC268 channel source setting (2 channel)
  8240. */
  8241. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  8242. #define alc268_modes alc260_modes
  8243. static hda_nid_t alc268_dac_nids[2] = {
  8244. /* front, hp */
  8245. 0x02, 0x03
  8246. };
  8247. static hda_nid_t alc268_adc_nids[2] = {
  8248. /* ADC0-1 */
  8249. 0x08, 0x07
  8250. };
  8251. static hda_nid_t alc268_adc_nids_alt[1] = {
  8252. /* ADC0 */
  8253. 0x08
  8254. };
  8255. static struct snd_kcontrol_new alc268_base_mixer[] = {
  8256. /* output mixer control */
  8257. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8258. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8259. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8260. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8261. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8262. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8263. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8264. { }
  8265. };
  8266. static struct hda_verb alc268_eapd_verbs[] = {
  8267. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8268. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8269. { }
  8270. };
  8271. /* Toshiba specific */
  8272. #define alc268_toshiba_automute alc262_hippo_automute
  8273. static struct hda_verb alc268_toshiba_verbs[] = {
  8274. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8275. { } /* end */
  8276. };
  8277. /* Acer specific */
  8278. /* bind volumes of both NID 0x02 and 0x03 */
  8279. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  8280. .ops = &snd_hda_bind_vol,
  8281. .values = {
  8282. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  8283. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  8284. 0
  8285. },
  8286. };
  8287. /* mute/unmute internal speaker according to the hp jack and mute state */
  8288. static void alc268_acer_automute(struct hda_codec *codec, int force)
  8289. {
  8290. struct alc_spec *spec = codec->spec;
  8291. unsigned int mute;
  8292. if (force || !spec->sense_updated) {
  8293. unsigned int present;
  8294. present = snd_hda_codec_read(codec, 0x14, 0,
  8295. AC_VERB_GET_PIN_SENSE, 0);
  8296. spec->jack_present = (present & 0x80000000) != 0;
  8297. spec->sense_updated = 1;
  8298. }
  8299. if (spec->jack_present)
  8300. mute = HDA_AMP_MUTE; /* mute internal speaker */
  8301. else /* unmute internal speaker if necessary */
  8302. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  8303. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  8304. HDA_AMP_MUTE, mute);
  8305. }
  8306. /* bind hp and internal speaker mute (with plug check) */
  8307. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  8308. struct snd_ctl_elem_value *ucontrol)
  8309. {
  8310. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8311. long *valp = ucontrol->value.integer.value;
  8312. int change;
  8313. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8314. HDA_AMP_MUTE,
  8315. valp[0] ? 0 : HDA_AMP_MUTE);
  8316. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8317. HDA_AMP_MUTE,
  8318. valp[1] ? 0 : HDA_AMP_MUTE);
  8319. if (change)
  8320. alc268_acer_automute(codec, 0);
  8321. return change;
  8322. }
  8323. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8324. /* output mixer control */
  8325. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8326. {
  8327. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8328. .name = "Master Playback Switch",
  8329. .info = snd_hda_mixer_amp_switch_info,
  8330. .get = snd_hda_mixer_amp_switch_get,
  8331. .put = alc268_acer_master_sw_put,
  8332. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8333. },
  8334. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8335. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8336. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8337. { }
  8338. };
  8339. static struct hda_verb alc268_acer_verbs[] = {
  8340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8342. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8343. { }
  8344. };
  8345. /* unsolicited event for HP jack sensing */
  8346. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8347. unsigned int res)
  8348. {
  8349. if ((res >> 26) != ALC880_HP_EVENT)
  8350. return;
  8351. alc268_toshiba_automute(codec);
  8352. }
  8353. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8354. unsigned int res)
  8355. {
  8356. if ((res >> 26) != ALC880_HP_EVENT)
  8357. return;
  8358. alc268_acer_automute(codec, 1);
  8359. }
  8360. static void alc268_acer_init_hook(struct hda_codec *codec)
  8361. {
  8362. alc268_acer_automute(codec, 1);
  8363. }
  8364. /*
  8365. * generic initialization of ADC, input mixers and output mixers
  8366. */
  8367. static struct hda_verb alc268_base_init_verbs[] = {
  8368. /* Unmute DAC0-1 and set vol = 0 */
  8369. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8370. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8371. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8372. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8373. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8374. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8375. /*
  8376. * Set up output mixers (0x0c - 0x0e)
  8377. */
  8378. /* set vol=0 to output mixers */
  8379. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8380. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8382. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8383. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8384. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8385. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8386. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8387. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8388. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8389. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8390. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8391. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8392. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8393. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8394. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8395. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8396. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8397. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8398. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8399. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8400. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8401. /* Unmute Selector 23h,24h and set the default input to mic-in */
  8402. {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
  8403. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8404. {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
  8405. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8406. { }
  8407. };
  8408. /*
  8409. * generic initialization of ADC, input mixers and output mixers
  8410. */
  8411. static struct hda_verb alc268_volume_init_verbs[] = {
  8412. /* set output DAC */
  8413. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8414. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8415. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8416. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8417. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8418. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8419. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8420. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8421. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8422. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8423. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8424. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8425. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8426. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8427. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8428. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8429. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8430. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8431. /* set PCBEEP vol = 0 */
  8432. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8433. { }
  8434. };
  8435. #define alc268_mux_enum_info alc_mux_enum_info
  8436. #define alc268_mux_enum_get alc_mux_enum_get
  8437. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8438. struct snd_ctl_elem_value *ucontrol)
  8439. {
  8440. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8441. struct alc_spec *spec = codec->spec;
  8442. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8443. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8444. hda_nid_t nid = capture_mixers[adc_idx];
  8445. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  8446. nid,
  8447. &spec->cur_mux[adc_idx]);
  8448. }
  8449. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8450. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8451. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8452. {
  8453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8454. /* The multiple "Capture Source" controls confuse alsamixer
  8455. * So call somewhat different..
  8456. * FIXME: the controls appear in the "playback" view!
  8457. */
  8458. /* .name = "Capture Source", */
  8459. .name = "Input Source",
  8460. .count = 1,
  8461. .info = alc268_mux_enum_info,
  8462. .get = alc268_mux_enum_get,
  8463. .put = alc268_mux_enum_put,
  8464. },
  8465. { } /* end */
  8466. };
  8467. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8468. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8469. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8470. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8471. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8472. {
  8473. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8474. /* The multiple "Capture Source" controls confuse alsamixer
  8475. * So call somewhat different..
  8476. * FIXME: the controls appear in the "playback" view!
  8477. */
  8478. /* .name = "Capture Source", */
  8479. .name = "Input Source",
  8480. .count = 2,
  8481. .info = alc268_mux_enum_info,
  8482. .get = alc268_mux_enum_get,
  8483. .put = alc268_mux_enum_put,
  8484. },
  8485. { } /* end */
  8486. };
  8487. static struct hda_input_mux alc268_capture_source = {
  8488. .num_items = 4,
  8489. .items = {
  8490. { "Mic", 0x0 },
  8491. { "Front Mic", 0x1 },
  8492. { "Line", 0x2 },
  8493. { "CD", 0x3 },
  8494. },
  8495. };
  8496. /* create input playback/capture controls for the given pin */
  8497. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8498. const char *ctlname, int idx)
  8499. {
  8500. char name[32];
  8501. int err;
  8502. sprintf(name, "%s Playback Volume", ctlname);
  8503. if (nid == 0x14) {
  8504. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8505. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8506. HDA_OUTPUT));
  8507. if (err < 0)
  8508. return err;
  8509. } else if (nid == 0x15) {
  8510. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8511. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8512. HDA_OUTPUT));
  8513. if (err < 0)
  8514. return err;
  8515. } else
  8516. return -1;
  8517. sprintf(name, "%s Playback Switch", ctlname);
  8518. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8519. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8520. if (err < 0)
  8521. return err;
  8522. return 0;
  8523. }
  8524. /* add playback controls from the parsed DAC table */
  8525. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8526. const struct auto_pin_cfg *cfg)
  8527. {
  8528. hda_nid_t nid;
  8529. int err;
  8530. spec->multiout.num_dacs = 2; /* only use one dac */
  8531. spec->multiout.dac_nids = spec->private_dac_nids;
  8532. spec->multiout.dac_nids[0] = 2;
  8533. spec->multiout.dac_nids[1] = 3;
  8534. nid = cfg->line_out_pins[0];
  8535. if (nid)
  8536. alc268_new_analog_output(spec, nid, "Front", 0);
  8537. nid = cfg->speaker_pins[0];
  8538. if (nid == 0x1d) {
  8539. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8540. "Speaker Playback Volume",
  8541. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8542. if (err < 0)
  8543. return err;
  8544. }
  8545. nid = cfg->hp_pins[0];
  8546. if (nid)
  8547. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8548. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8549. if (nid == 0x16) {
  8550. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8551. "Mono Playback Switch",
  8552. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8553. if (err < 0)
  8554. return err;
  8555. }
  8556. return 0;
  8557. }
  8558. /* create playback/capture controls for input pins */
  8559. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8560. const struct auto_pin_cfg *cfg)
  8561. {
  8562. struct hda_input_mux *imux = &spec->private_imux;
  8563. int i, idx1;
  8564. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8565. switch(cfg->input_pins[i]) {
  8566. case 0x18:
  8567. idx1 = 0; /* Mic 1 */
  8568. break;
  8569. case 0x19:
  8570. idx1 = 1; /* Mic 2 */
  8571. break;
  8572. case 0x1a:
  8573. idx1 = 2; /* Line In */
  8574. break;
  8575. case 0x1c:
  8576. idx1 = 3; /* CD */
  8577. break;
  8578. default:
  8579. continue;
  8580. }
  8581. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8582. imux->items[imux->num_items].index = idx1;
  8583. imux->num_items++;
  8584. }
  8585. return 0;
  8586. }
  8587. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8588. {
  8589. struct alc_spec *spec = codec->spec;
  8590. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8591. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8592. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8593. unsigned int dac_vol1, dac_vol2;
  8594. if (speaker_nid) {
  8595. snd_hda_codec_write(codec, speaker_nid, 0,
  8596. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8597. snd_hda_codec_write(codec, 0x0f, 0,
  8598. AC_VERB_SET_AMP_GAIN_MUTE,
  8599. AMP_IN_UNMUTE(1));
  8600. snd_hda_codec_write(codec, 0x10, 0,
  8601. AC_VERB_SET_AMP_GAIN_MUTE,
  8602. AMP_IN_UNMUTE(1));
  8603. } else {
  8604. snd_hda_codec_write(codec, 0x0f, 0,
  8605. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8606. snd_hda_codec_write(codec, 0x10, 0,
  8607. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8608. }
  8609. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8610. if (line_nid == 0x14)
  8611. dac_vol2 = AMP_OUT_ZERO;
  8612. else if (line_nid == 0x15)
  8613. dac_vol1 = AMP_OUT_ZERO;
  8614. if (hp_nid == 0x14)
  8615. dac_vol2 = AMP_OUT_ZERO;
  8616. else if (hp_nid == 0x15)
  8617. dac_vol1 = AMP_OUT_ZERO;
  8618. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8619. spec->autocfg.line_out_pins[1] != 0x16 ||
  8620. spec->autocfg.line_out_pins[2] != 0x16)
  8621. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8622. snd_hda_codec_write(codec, 0x02, 0,
  8623. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8624. snd_hda_codec_write(codec, 0x03, 0,
  8625. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8626. }
  8627. /* pcm configuration: identiacal with ALC880 */
  8628. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8629. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8630. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8631. /*
  8632. * BIOS auto configuration
  8633. */
  8634. static int alc268_parse_auto_config(struct hda_codec *codec)
  8635. {
  8636. struct alc_spec *spec = codec->spec;
  8637. int err;
  8638. static hda_nid_t alc268_ignore[] = { 0 };
  8639. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8640. alc268_ignore);
  8641. if (err < 0)
  8642. return err;
  8643. if (!spec->autocfg.line_outs)
  8644. return 0; /* can't find valid BIOS pin config */
  8645. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8646. if (err < 0)
  8647. return err;
  8648. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8649. if (err < 0)
  8650. return err;
  8651. spec->multiout.max_channels = 2;
  8652. /* digital only support output */
  8653. if (spec->autocfg.dig_out_pin)
  8654. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8655. if (spec->kctl_alloc)
  8656. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8657. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8658. spec->num_mux_defs = 1;
  8659. spec->input_mux = &spec->private_imux;
  8660. err = alc_auto_add_mic_boost(codec);
  8661. if (err < 0)
  8662. return err;
  8663. return 1;
  8664. }
  8665. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8666. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8667. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8668. /* init callback for auto-configuration model -- overriding the default init */
  8669. static void alc268_auto_init(struct hda_codec *codec)
  8670. {
  8671. alc268_auto_init_multi_out(codec);
  8672. alc268_auto_init_hp_out(codec);
  8673. alc268_auto_init_mono_speaker_out(codec);
  8674. alc268_auto_init_analog_input(codec);
  8675. }
  8676. /*
  8677. * configuration and preset
  8678. */
  8679. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8680. [ALC268_3ST] = "3stack",
  8681. [ALC268_TOSHIBA] = "toshiba",
  8682. [ALC268_ACER] = "acer",
  8683. [ALC268_AUTO] = "auto",
  8684. };
  8685. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8686. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8687. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8688. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8689. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8690. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8691. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8692. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8693. {}
  8694. };
  8695. static struct alc_config_preset alc268_presets[] = {
  8696. [ALC268_3ST] = {
  8697. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8698. .init_verbs = { alc268_base_init_verbs },
  8699. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8700. .dac_nids = alc268_dac_nids,
  8701. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8702. .adc_nids = alc268_adc_nids_alt,
  8703. .hp_nid = 0x03,
  8704. .dig_out_nid = ALC268_DIGOUT_NID,
  8705. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8706. .channel_mode = alc268_modes,
  8707. .input_mux = &alc268_capture_source,
  8708. },
  8709. [ALC268_TOSHIBA] = {
  8710. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8711. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8712. alc268_toshiba_verbs },
  8713. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8714. .dac_nids = alc268_dac_nids,
  8715. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8716. .adc_nids = alc268_adc_nids_alt,
  8717. .hp_nid = 0x03,
  8718. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8719. .channel_mode = alc268_modes,
  8720. .input_mux = &alc268_capture_source,
  8721. .unsol_event = alc268_toshiba_unsol_event,
  8722. .init_hook = alc268_toshiba_automute,
  8723. },
  8724. [ALC268_ACER] = {
  8725. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8726. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8727. alc268_acer_verbs },
  8728. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8729. .dac_nids = alc268_dac_nids,
  8730. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8731. .adc_nids = alc268_adc_nids_alt,
  8732. .hp_nid = 0x02,
  8733. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8734. .channel_mode = alc268_modes,
  8735. .input_mux = &alc268_capture_source,
  8736. .unsol_event = alc268_acer_unsol_event,
  8737. .init_hook = alc268_acer_init_hook,
  8738. },
  8739. };
  8740. static int patch_alc268(struct hda_codec *codec)
  8741. {
  8742. struct alc_spec *spec;
  8743. int board_config;
  8744. int err;
  8745. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8746. if (spec == NULL)
  8747. return -ENOMEM;
  8748. codec->spec = spec;
  8749. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8750. alc268_models,
  8751. alc268_cfg_tbl);
  8752. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8753. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8754. "trying auto-probe from BIOS...\n");
  8755. board_config = ALC268_AUTO;
  8756. }
  8757. if (board_config == ALC268_AUTO) {
  8758. /* automatic parse from the BIOS config */
  8759. err = alc268_parse_auto_config(codec);
  8760. if (err < 0) {
  8761. alc_free(codec);
  8762. return err;
  8763. } else if (!err) {
  8764. printk(KERN_INFO
  8765. "hda_codec: Cannot set up configuration "
  8766. "from BIOS. Using base mode...\n");
  8767. board_config = ALC268_3ST;
  8768. }
  8769. }
  8770. if (board_config != ALC268_AUTO)
  8771. setup_preset(spec, &alc268_presets[board_config]);
  8772. spec->stream_name_analog = "ALC268 Analog";
  8773. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8774. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8775. spec->stream_name_digital = "ALC268 Digital";
  8776. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8777. if (board_config == ALC268_AUTO) {
  8778. if (!spec->adc_nids && spec->input_mux) {
  8779. /* check whether NID 0x07 is valid */
  8780. unsigned int wcap = get_wcaps(codec, 0x07);
  8781. /* get type */
  8782. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8783. if (wcap != AC_WID_AUD_IN) {
  8784. spec->adc_nids = alc268_adc_nids_alt;
  8785. spec->num_adc_nids =
  8786. ARRAY_SIZE(alc268_adc_nids_alt);
  8787. spec->mixers[spec->num_mixers] =
  8788. alc268_capture_alt_mixer;
  8789. spec->num_mixers++;
  8790. } else {
  8791. spec->adc_nids = alc268_adc_nids;
  8792. spec->num_adc_nids =
  8793. ARRAY_SIZE(alc268_adc_nids);
  8794. spec->mixers[spec->num_mixers] =
  8795. alc268_capture_mixer;
  8796. spec->num_mixers++;
  8797. }
  8798. }
  8799. }
  8800. codec->patch_ops = alc_patch_ops;
  8801. if (board_config == ALC268_AUTO)
  8802. spec->init_hook = alc268_auto_init;
  8803. return 0;
  8804. }
  8805. /*
  8806. * ALC269 channel source setting (2 channel)
  8807. */
  8808. #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
  8809. #define alc269_dac_nids alc260_dac_nids
  8810. static hda_nid_t alc269_adc_nids[1] = {
  8811. /* ADC1 */
  8812. 0x07,
  8813. };
  8814. #define alc269_modes alc260_modes
  8815. #define alc269_capture_source alc880_lg_lw_capture_source
  8816. static struct snd_kcontrol_new alc269_base_mixer[] = {
  8817. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8818. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8819. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8820. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8823. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8824. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  8825. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  8826. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8827. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8828. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  8829. { } /* end */
  8830. };
  8831. /* capture mixer elements */
  8832. static struct snd_kcontrol_new alc269_capture_mixer[] = {
  8833. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  8834. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  8835. {
  8836. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8837. /* The multiple "Capture Source" controls confuse alsamixer
  8838. * So call somewhat different..
  8839. * FIXME: the controls appear in the "playback" view!
  8840. */
  8841. /* .name = "Capture Source", */
  8842. .name = "Input Source",
  8843. .count = 1,
  8844. .info = alc_mux_enum_info,
  8845. .get = alc_mux_enum_get,
  8846. .put = alc_mux_enum_put,
  8847. },
  8848. { } /* end */
  8849. };
  8850. /*
  8851. * generic initialization of ADC, input mixers and output mixers
  8852. */
  8853. static struct hda_verb alc269_init_verbs[] = {
  8854. /*
  8855. * Unmute ADC0 and set the default input to mic-in
  8856. */
  8857. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8858. /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
  8859. * analog-loopback mixer widget
  8860. * Note: PASD motherboards uses the Line In 2 as the input for
  8861. * front panel mic (mic 2)
  8862. */
  8863. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8864. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8865. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8866. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8867. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8868. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8869. /*
  8870. * Set up output mixers (0x0c - 0x0e)
  8871. */
  8872. /* set vol=0 to output mixers */
  8873. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8874. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8875. /* set up input amps for analog loopback */
  8876. /* Amp Indices: DAC = 0, mixer = 1 */
  8877. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8878. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8879. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8880. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8881. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8882. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8883. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8884. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8885. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8886. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8887. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8888. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8889. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8891. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8892. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8893. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8894. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8895. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8896. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8897. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8898. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  8899. /* FIXME: use matrix-type input source selection */
  8900. /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
  8901. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8902. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8903. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8904. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8905. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8906. /* set EAPD */
  8907. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8908. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8909. { }
  8910. };
  8911. /* add playback controls from the parsed DAC table */
  8912. static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
  8913. const struct auto_pin_cfg *cfg)
  8914. {
  8915. hda_nid_t nid;
  8916. int err;
  8917. spec->multiout.num_dacs = 1; /* only use one dac */
  8918. spec->multiout.dac_nids = spec->private_dac_nids;
  8919. spec->multiout.dac_nids[0] = 2;
  8920. nid = cfg->line_out_pins[0];
  8921. if (nid) {
  8922. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8923. "Front Playback Volume",
  8924. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
  8925. if (err < 0)
  8926. return err;
  8927. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8928. "Front Playback Switch",
  8929. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8930. if (err < 0)
  8931. return err;
  8932. }
  8933. nid = cfg->speaker_pins[0];
  8934. if (nid) {
  8935. if (!cfg->line_out_pins[0]) {
  8936. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8937. "Speaker Playback Volume",
  8938. HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
  8939. HDA_OUTPUT));
  8940. if (err < 0)
  8941. return err;
  8942. }
  8943. if (nid == 0x16) {
  8944. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8945. "Speaker Playback Switch",
  8946. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8947. HDA_OUTPUT));
  8948. if (err < 0)
  8949. return err;
  8950. } else {
  8951. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8952. "Speaker Playback Switch",
  8953. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8954. HDA_OUTPUT));
  8955. if (err < 0)
  8956. return err;
  8957. }
  8958. }
  8959. nid = cfg->hp_pins[0];
  8960. if (nid) {
  8961. /* spec->multiout.hp_nid = 2; */
  8962. if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
  8963. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8964. "Headphone Playback Volume",
  8965. HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
  8966. HDA_OUTPUT));
  8967. if (err < 0)
  8968. return err;
  8969. }
  8970. if (nid == 0x16) {
  8971. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8972. "Headphone Playback Switch",
  8973. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8974. HDA_OUTPUT));
  8975. if (err < 0)
  8976. return err;
  8977. } else {
  8978. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8979. "Headphone Playback Switch",
  8980. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8981. HDA_OUTPUT));
  8982. if (err < 0)
  8983. return err;
  8984. }
  8985. }
  8986. return 0;
  8987. }
  8988. #define alc269_auto_create_analog_input_ctls \
  8989. alc880_auto_create_analog_input_ctls
  8990. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8991. #define alc269_loopbacks alc880_loopbacks
  8992. #endif
  8993. /* pcm configuration: identiacal with ALC880 */
  8994. #define alc269_pcm_analog_playback alc880_pcm_analog_playback
  8995. #define alc269_pcm_analog_capture alc880_pcm_analog_capture
  8996. #define alc269_pcm_digital_playback alc880_pcm_digital_playback
  8997. #define alc269_pcm_digital_capture alc880_pcm_digital_capture
  8998. /*
  8999. * BIOS auto configuration
  9000. */
  9001. static int alc269_parse_auto_config(struct hda_codec *codec)
  9002. {
  9003. struct alc_spec *spec = codec->spec;
  9004. int err;
  9005. static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
  9006. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9007. alc269_ignore);
  9008. if (err < 0)
  9009. return err;
  9010. err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9011. if (err < 0)
  9012. return err;
  9013. err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9014. if (err < 0)
  9015. return err;
  9016. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9017. if (spec->autocfg.dig_out_pin)
  9018. spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
  9019. if (spec->kctl_alloc)
  9020. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9021. spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
  9022. spec->num_mux_defs = 1;
  9023. spec->input_mux = &spec->private_imux;
  9024. err = alc_auto_add_mic_boost(codec);
  9025. if (err < 0)
  9026. return err;
  9027. return 1;
  9028. }
  9029. #define alc269_auto_init_multi_out alc882_auto_init_multi_out
  9030. #define alc269_auto_init_hp_out alc882_auto_init_hp_out
  9031. #define alc269_auto_init_analog_input alc882_auto_init_analog_input
  9032. /* init callback for auto-configuration model -- overriding the default init */
  9033. static void alc269_auto_init(struct hda_codec *codec)
  9034. {
  9035. alc269_auto_init_multi_out(codec);
  9036. alc269_auto_init_hp_out(codec);
  9037. alc269_auto_init_analog_input(codec);
  9038. }
  9039. /*
  9040. * configuration and preset
  9041. */
  9042. static const char *alc269_models[ALC269_MODEL_LAST] = {
  9043. [ALC269_BASIC] = "basic",
  9044. };
  9045. static struct snd_pci_quirk alc269_cfg_tbl[] = {
  9046. {}
  9047. };
  9048. static struct alc_config_preset alc269_presets[] = {
  9049. [ALC269_BASIC] = {
  9050. .mixers = { alc269_base_mixer },
  9051. .init_verbs = { alc269_init_verbs },
  9052. .num_dacs = ARRAY_SIZE(alc269_dac_nids),
  9053. .dac_nids = alc269_dac_nids,
  9054. .hp_nid = 0x03,
  9055. .num_channel_mode = ARRAY_SIZE(alc269_modes),
  9056. .channel_mode = alc269_modes,
  9057. .input_mux = &alc269_capture_source,
  9058. },
  9059. };
  9060. static int patch_alc269(struct hda_codec *codec)
  9061. {
  9062. struct alc_spec *spec;
  9063. int board_config;
  9064. int err;
  9065. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9066. if (spec == NULL)
  9067. return -ENOMEM;
  9068. codec->spec = spec;
  9069. board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
  9070. alc269_models,
  9071. alc269_cfg_tbl);
  9072. if (board_config < 0) {
  9073. printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
  9074. "trying auto-probe from BIOS...\n");
  9075. board_config = ALC269_AUTO;
  9076. }
  9077. if (board_config == ALC269_AUTO) {
  9078. /* automatic parse from the BIOS config */
  9079. err = alc269_parse_auto_config(codec);
  9080. if (err < 0) {
  9081. alc_free(codec);
  9082. return err;
  9083. } else if (!err) {
  9084. printk(KERN_INFO
  9085. "hda_codec: Cannot set up configuration "
  9086. "from BIOS. Using base mode...\n");
  9087. board_config = ALC269_BASIC;
  9088. }
  9089. }
  9090. if (board_config != ALC269_AUTO)
  9091. setup_preset(spec, &alc269_presets[board_config]);
  9092. spec->stream_name_analog = "ALC269 Analog";
  9093. spec->stream_analog_playback = &alc269_pcm_analog_playback;
  9094. spec->stream_analog_capture = &alc269_pcm_analog_capture;
  9095. spec->stream_name_digital = "ALC269 Digital";
  9096. spec->stream_digital_playback = &alc269_pcm_digital_playback;
  9097. spec->stream_digital_capture = &alc269_pcm_digital_capture;
  9098. spec->adc_nids = alc269_adc_nids;
  9099. spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
  9100. spec->mixers[spec->num_mixers] = alc269_capture_mixer;
  9101. spec->num_mixers++;
  9102. codec->patch_ops = alc_patch_ops;
  9103. if (board_config == ALC269_AUTO)
  9104. spec->init_hook = alc269_auto_init;
  9105. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9106. if (!spec->loopback.amplist)
  9107. spec->loopback.amplist = alc269_loopbacks;
  9108. #endif
  9109. return 0;
  9110. }
  9111. /*
  9112. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  9113. */
  9114. /*
  9115. * set the path ways for 2 channel output
  9116. * need to set the codec line out and mic 1 pin widgets to inputs
  9117. */
  9118. static struct hda_verb alc861_threestack_ch2_init[] = {
  9119. /* set pin widget 1Ah (line in) for input */
  9120. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9121. /* set pin widget 18h (mic1/2) for input, for mic also enable
  9122. * the vref
  9123. */
  9124. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9125. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  9126. #if 0
  9127. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9128. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  9129. #endif
  9130. { } /* end */
  9131. };
  9132. /*
  9133. * 6ch mode
  9134. * need to set the codec line out and mic 1 pin widgets to outputs
  9135. */
  9136. static struct hda_verb alc861_threestack_ch6_init[] = {
  9137. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  9138. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9139. /* set pin widget 18h (mic1) for output (CLFE)*/
  9140. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9141. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9142. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9143. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  9144. #if 0
  9145. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9146. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  9147. #endif
  9148. { } /* end */
  9149. };
  9150. static struct hda_channel_mode alc861_threestack_modes[2] = {
  9151. { 2, alc861_threestack_ch2_init },
  9152. { 6, alc861_threestack_ch6_init },
  9153. };
  9154. /* Set mic1 as input and unmute the mixer */
  9155. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  9156. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9157. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9158. { } /* end */
  9159. };
  9160. /* Set mic1 as output and mute mixer */
  9161. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  9162. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9163. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9164. { } /* end */
  9165. };
  9166. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  9167. { 2, alc861_uniwill_m31_ch2_init },
  9168. { 4, alc861_uniwill_m31_ch4_init },
  9169. };
  9170. /* Set mic1 and line-in as input and unmute the mixer */
  9171. static struct hda_verb alc861_asus_ch2_init[] = {
  9172. /* set pin widget 1Ah (line in) for input */
  9173. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9174. /* set pin widget 18h (mic1/2) for input, for mic also enable
  9175. * the vref
  9176. */
  9177. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9178. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  9179. #if 0
  9180. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9181. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  9182. #endif
  9183. { } /* end */
  9184. };
  9185. /* Set mic1 nad line-in as output and mute mixer */
  9186. static struct hda_verb alc861_asus_ch6_init[] = {
  9187. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  9188. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9189. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  9190. /* set pin widget 18h (mic1) for output (CLFE)*/
  9191. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9192. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  9193. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9194. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9195. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  9196. #if 0
  9197. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9198. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  9199. #endif
  9200. { } /* end */
  9201. };
  9202. static struct hda_channel_mode alc861_asus_modes[2] = {
  9203. { 2, alc861_asus_ch2_init },
  9204. { 6, alc861_asus_ch6_init },
  9205. };
  9206. /* patch-ALC861 */
  9207. static struct snd_kcontrol_new alc861_base_mixer[] = {
  9208. /* output mixer control */
  9209. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9210. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9211. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9212. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9213. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  9214. /*Input mixer control */
  9215. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9216. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9217. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9218. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9219. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9220. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9221. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9222. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9223. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9224. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9225. /* Capture mixer control */
  9226. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9227. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9228. {
  9229. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9230. .name = "Capture Source",
  9231. .count = 1,
  9232. .info = alc_mux_enum_info,
  9233. .get = alc_mux_enum_get,
  9234. .put = alc_mux_enum_put,
  9235. },
  9236. { } /* end */
  9237. };
  9238. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  9239. /* output mixer control */
  9240. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9241. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9242. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9243. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9244. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  9245. /* Input mixer control */
  9246. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9247. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9248. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9249. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9250. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9251. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9252. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9253. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9254. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9255. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9256. /* Capture mixer control */
  9257. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9258. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9259. {
  9260. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9261. .name = "Capture Source",
  9262. .count = 1,
  9263. .info = alc_mux_enum_info,
  9264. .get = alc_mux_enum_get,
  9265. .put = alc_mux_enum_put,
  9266. },
  9267. {
  9268. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9269. .name = "Channel Mode",
  9270. .info = alc_ch_mode_info,
  9271. .get = alc_ch_mode_get,
  9272. .put = alc_ch_mode_put,
  9273. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  9274. },
  9275. { } /* end */
  9276. };
  9277. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  9278. /* output mixer control */
  9279. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9281. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9282. /*Capture mixer control */
  9283. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9284. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9285. {
  9286. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9287. .name = "Capture Source",
  9288. .count = 1,
  9289. .info = alc_mux_enum_info,
  9290. .get = alc_mux_enum_get,
  9291. .put = alc_mux_enum_put,
  9292. },
  9293. { } /* end */
  9294. };
  9295. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  9296. /* output mixer control */
  9297. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9298. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9299. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9300. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9301. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  9302. /* Input mixer control */
  9303. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9304. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9305. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9306. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9307. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9308. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9309. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9310. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9311. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9312. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9313. /* Capture mixer control */
  9314. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9315. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9316. {
  9317. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9318. .name = "Capture Source",
  9319. .count = 1,
  9320. .info = alc_mux_enum_info,
  9321. .get = alc_mux_enum_get,
  9322. .put = alc_mux_enum_put,
  9323. },
  9324. {
  9325. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9326. .name = "Channel Mode",
  9327. .info = alc_ch_mode_info,
  9328. .get = alc_ch_mode_get,
  9329. .put = alc_ch_mode_put,
  9330. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9331. },
  9332. { } /* end */
  9333. };
  9334. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  9335. /* output mixer control */
  9336. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9337. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9338. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9339. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9340. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  9341. /* Input mixer control */
  9342. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9343. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  9344. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9345. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9346. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9347. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9348. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9349. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9350. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9351. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  9352. /* Capture mixer control */
  9353. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9354. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9355. {
  9356. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9357. .name = "Capture Source",
  9358. .count = 1,
  9359. .info = alc_mux_enum_info,
  9360. .get = alc_mux_enum_get,
  9361. .put = alc_mux_enum_put,
  9362. },
  9363. {
  9364. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9365. .name = "Channel Mode",
  9366. .info = alc_ch_mode_info,
  9367. .get = alc_ch_mode_get,
  9368. .put = alc_ch_mode_put,
  9369. .private_value = ARRAY_SIZE(alc861_asus_modes),
  9370. },
  9371. { }
  9372. };
  9373. /* additional mixer */
  9374. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  9375. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9376. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9377. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  9378. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  9379. { }
  9380. };
  9381. /*
  9382. * generic initialization of ADC, input mixers and output mixers
  9383. */
  9384. static struct hda_verb alc861_base_init_verbs[] = {
  9385. /*
  9386. * Unmute ADC0 and set the default input to mic-in
  9387. */
  9388. /* port-A for surround (rear panel) */
  9389. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9390. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9391. /* port-B for mic-in (rear panel) with vref */
  9392. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9393. /* port-C for line-in (rear panel) */
  9394. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9395. /* port-D for Front */
  9396. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9397. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9398. /* port-E for HP out (front panel) */
  9399. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  9400. /* route front PCM to HP */
  9401. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9402. /* port-F for mic-in (front panel) with vref */
  9403. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9404. /* port-G for CLFE (rear panel) */
  9405. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9406. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9407. /* port-H for side (rear panel) */
  9408. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9409. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9410. /* CD-in */
  9411. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9412. /* route front mic to ADC1*/
  9413. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9414. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9415. /* Unmute DAC0~3 & spdif out*/
  9416. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9417. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9418. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9419. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9420. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9421. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9422. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9423. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9424. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9425. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9426. /* Unmute Stereo Mixer 15 */
  9427. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9428. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9429. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9430. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9431. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9432. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9433. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9434. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9435. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9436. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9437. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9438. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9439. /* hp used DAC 3 (Front) */
  9440. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9441. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9442. { }
  9443. };
  9444. static struct hda_verb alc861_threestack_init_verbs[] = {
  9445. /*
  9446. * Unmute ADC0 and set the default input to mic-in
  9447. */
  9448. /* port-A for surround (rear panel) */
  9449. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9450. /* port-B for mic-in (rear panel) with vref */
  9451. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9452. /* port-C for line-in (rear panel) */
  9453. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9454. /* port-D for Front */
  9455. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9456. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9457. /* port-E for HP out (front panel) */
  9458. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  9459. /* route front PCM to HP */
  9460. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9461. /* port-F for mic-in (front panel) with vref */
  9462. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9463. /* port-G for CLFE (rear panel) */
  9464. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9465. /* port-H for side (rear panel) */
  9466. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9467. /* CD-in */
  9468. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9469. /* route front mic to ADC1*/
  9470. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9471. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9472. /* Unmute DAC0~3 & spdif out*/
  9473. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9474. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9475. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9476. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9478. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9479. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9480. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9481. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9482. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9483. /* Unmute Stereo Mixer 15 */
  9484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9486. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9487. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9488. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9489. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9490. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9491. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9492. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9493. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9494. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9495. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9496. /* hp used DAC 3 (Front) */
  9497. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9498. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9499. { }
  9500. };
  9501. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  9502. /*
  9503. * Unmute ADC0 and set the default input to mic-in
  9504. */
  9505. /* port-A for surround (rear panel) */
  9506. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9507. /* port-B for mic-in (rear panel) with vref */
  9508. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9509. /* port-C for line-in (rear panel) */
  9510. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9511. /* port-D for Front */
  9512. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9513. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9514. /* port-E for HP out (front panel) */
  9515. /* this has to be set to VREF80 */
  9516. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9517. /* route front PCM to HP */
  9518. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9519. /* port-F for mic-in (front panel) with vref */
  9520. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9521. /* port-G for CLFE (rear panel) */
  9522. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9523. /* port-H for side (rear panel) */
  9524. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9525. /* CD-in */
  9526. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9527. /* route front mic to ADC1*/
  9528. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9529. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9530. /* Unmute DAC0~3 & spdif out*/
  9531. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9532. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9533. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9534. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9536. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9537. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9538. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9539. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9540. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9541. /* Unmute Stereo Mixer 15 */
  9542. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9543. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9544. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9545. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9546. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9547. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9548. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9549. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9550. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9551. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9552. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9553. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9554. /* hp used DAC 3 (Front) */
  9555. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9556. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9557. { }
  9558. };
  9559. static struct hda_verb alc861_asus_init_verbs[] = {
  9560. /*
  9561. * Unmute ADC0 and set the default input to mic-in
  9562. */
  9563. /* port-A for surround (rear panel)
  9564. * according to codec#0 this is the HP jack
  9565. */
  9566. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  9567. /* route front PCM to HP */
  9568. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9569. /* port-B for mic-in (rear panel) with vref */
  9570. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9571. /* port-C for line-in (rear panel) */
  9572. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9573. /* port-D for Front */
  9574. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9575. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9576. /* port-E for HP out (front panel) */
  9577. /* this has to be set to VREF80 */
  9578. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9579. /* route front PCM to HP */
  9580. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9581. /* port-F for mic-in (front panel) with vref */
  9582. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9583. /* port-G for CLFE (rear panel) */
  9584. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9585. /* port-H for side (rear panel) */
  9586. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9587. /* CD-in */
  9588. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9589. /* route front mic to ADC1*/
  9590. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9591. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9592. /* Unmute DAC0~3 & spdif out*/
  9593. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9594. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9595. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9596. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9597. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9598. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9599. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9600. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9601. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9602. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9603. /* Unmute Stereo Mixer 15 */
  9604. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9605. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9606. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9607. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9608. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9609. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9610. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9611. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9612. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9613. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9614. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9615. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9616. /* hp used DAC 3 (Front) */
  9617. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9618. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9619. { }
  9620. };
  9621. /* additional init verbs for ASUS laptops */
  9622. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9623. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9624. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9625. { }
  9626. };
  9627. /*
  9628. * generic initialization of ADC, input mixers and output mixers
  9629. */
  9630. static struct hda_verb alc861_auto_init_verbs[] = {
  9631. /*
  9632. * Unmute ADC0 and set the default input to mic-in
  9633. */
  9634. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9636. /* Unmute DAC0~3 & spdif out*/
  9637. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9638. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9639. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9640. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9641. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9642. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9643. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9644. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9645. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9646. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9647. /* Unmute Stereo Mixer 15 */
  9648. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9649. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9650. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9651. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9652. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9653. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9654. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9655. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9656. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9657. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9658. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9659. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9660. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9661. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9662. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9663. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9664. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9665. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9666. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9667. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9668. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9669. { }
  9670. };
  9671. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9672. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9673. { }
  9674. };
  9675. /* toggle speaker-output according to the hp-jack state */
  9676. static void alc861_toshiba_automute(struct hda_codec *codec)
  9677. {
  9678. unsigned int present;
  9679. present = snd_hda_codec_read(codec, 0x0f, 0,
  9680. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9681. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9682. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9683. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9684. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9685. }
  9686. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9687. unsigned int res)
  9688. {
  9689. if ((res >> 26) == ALC880_HP_EVENT)
  9690. alc861_toshiba_automute(codec);
  9691. }
  9692. /* pcm configuration: identiacal with ALC880 */
  9693. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9694. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9695. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9696. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9697. #define ALC861_DIGOUT_NID 0x07
  9698. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9699. { 8, NULL }
  9700. };
  9701. static hda_nid_t alc861_dac_nids[4] = {
  9702. /* front, surround, clfe, side */
  9703. 0x03, 0x06, 0x05, 0x04
  9704. };
  9705. static hda_nid_t alc660_dac_nids[3] = {
  9706. /* front, clfe, surround */
  9707. 0x03, 0x05, 0x06
  9708. };
  9709. static hda_nid_t alc861_adc_nids[1] = {
  9710. /* ADC0-2 */
  9711. 0x08,
  9712. };
  9713. static struct hda_input_mux alc861_capture_source = {
  9714. .num_items = 5,
  9715. .items = {
  9716. { "Mic", 0x0 },
  9717. { "Front Mic", 0x3 },
  9718. { "Line", 0x1 },
  9719. { "CD", 0x4 },
  9720. { "Mixer", 0x5 },
  9721. },
  9722. };
  9723. /* fill in the dac_nids table from the parsed pin configuration */
  9724. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9725. const struct auto_pin_cfg *cfg)
  9726. {
  9727. int i;
  9728. hda_nid_t nid;
  9729. spec->multiout.dac_nids = spec->private_dac_nids;
  9730. for (i = 0; i < cfg->line_outs; i++) {
  9731. nid = cfg->line_out_pins[i];
  9732. if (nid) {
  9733. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9734. continue;
  9735. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9736. }
  9737. }
  9738. spec->multiout.num_dacs = cfg->line_outs;
  9739. return 0;
  9740. }
  9741. /* add playback controls from the parsed DAC table */
  9742. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9743. const struct auto_pin_cfg *cfg)
  9744. {
  9745. char name[32];
  9746. static const char *chname[4] = {
  9747. "Front", "Surround", NULL /*CLFE*/, "Side"
  9748. };
  9749. hda_nid_t nid;
  9750. int i, idx, err;
  9751. for (i = 0; i < cfg->line_outs; i++) {
  9752. nid = spec->multiout.dac_nids[i];
  9753. if (!nid)
  9754. continue;
  9755. if (nid == 0x05) {
  9756. /* Center/LFE */
  9757. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9758. "Center Playback Switch",
  9759. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9760. HDA_OUTPUT));
  9761. if (err < 0)
  9762. return err;
  9763. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9764. "LFE Playback Switch",
  9765. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9766. HDA_OUTPUT));
  9767. if (err < 0)
  9768. return err;
  9769. } else {
  9770. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9771. idx++)
  9772. if (nid == alc861_dac_nids[idx])
  9773. break;
  9774. sprintf(name, "%s Playback Switch", chname[idx]);
  9775. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9776. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9777. HDA_OUTPUT));
  9778. if (err < 0)
  9779. return err;
  9780. }
  9781. }
  9782. return 0;
  9783. }
  9784. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9785. {
  9786. int err;
  9787. hda_nid_t nid;
  9788. if (!pin)
  9789. return 0;
  9790. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9791. nid = 0x03;
  9792. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9793. "Headphone Playback Switch",
  9794. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9795. if (err < 0)
  9796. return err;
  9797. spec->multiout.hp_nid = nid;
  9798. }
  9799. return 0;
  9800. }
  9801. /* create playback/capture controls for input pins */
  9802. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9803. const struct auto_pin_cfg *cfg)
  9804. {
  9805. struct hda_input_mux *imux = &spec->private_imux;
  9806. int i, err, idx, idx1;
  9807. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9808. switch (cfg->input_pins[i]) {
  9809. case 0x0c:
  9810. idx1 = 1;
  9811. idx = 2; /* Line In */
  9812. break;
  9813. case 0x0f:
  9814. idx1 = 2;
  9815. idx = 2; /* Line In */
  9816. break;
  9817. case 0x0d:
  9818. idx1 = 0;
  9819. idx = 1; /* Mic In */
  9820. break;
  9821. case 0x10:
  9822. idx1 = 3;
  9823. idx = 1; /* Mic In */
  9824. break;
  9825. case 0x11:
  9826. idx1 = 4;
  9827. idx = 0; /* CD */
  9828. break;
  9829. default:
  9830. continue;
  9831. }
  9832. err = new_analog_input(spec, cfg->input_pins[i],
  9833. auto_pin_cfg_labels[i], idx, 0x15);
  9834. if (err < 0)
  9835. return err;
  9836. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9837. imux->items[imux->num_items].index = idx1;
  9838. imux->num_items++;
  9839. }
  9840. return 0;
  9841. }
  9842. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9843. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9844. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9845. {
  9846. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9847. /* The multiple "Capture Source" controls confuse alsamixer
  9848. * So call somewhat different..
  9849. *FIXME: the controls appear in the "playback" view!
  9850. */
  9851. /* .name = "Capture Source", */
  9852. .name = "Input Source",
  9853. .count = 1,
  9854. .info = alc_mux_enum_info,
  9855. .get = alc_mux_enum_get,
  9856. .put = alc_mux_enum_put,
  9857. },
  9858. { } /* end */
  9859. };
  9860. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9861. hda_nid_t nid,
  9862. int pin_type, int dac_idx)
  9863. {
  9864. /* set as output */
  9865. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9866. pin_type);
  9867. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9868. AMP_OUT_UNMUTE);
  9869. }
  9870. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9871. {
  9872. struct alc_spec *spec = codec->spec;
  9873. int i;
  9874. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9875. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9876. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9877. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9878. if (nid)
  9879. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9880. spec->multiout.dac_nids[i]);
  9881. }
  9882. }
  9883. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9884. {
  9885. struct alc_spec *spec = codec->spec;
  9886. hda_nid_t pin;
  9887. pin = spec->autocfg.hp_pins[0];
  9888. if (pin) /* connect to front */
  9889. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9890. spec->multiout.dac_nids[0]);
  9891. }
  9892. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9893. {
  9894. struct alc_spec *spec = codec->spec;
  9895. int i;
  9896. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9897. hda_nid_t nid = spec->autocfg.input_pins[i];
  9898. if (nid >= 0x0c && nid <= 0x11) {
  9899. snd_hda_codec_write(codec, nid, 0,
  9900. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9901. i <= AUTO_PIN_FRONT_MIC ?
  9902. PIN_VREF80 : PIN_IN);
  9903. }
  9904. }
  9905. }
  9906. /* parse the BIOS configuration and set up the alc_spec */
  9907. /* return 1 if successful, 0 if the proper config is not found,
  9908. * or a negative error code
  9909. */
  9910. static int alc861_parse_auto_config(struct hda_codec *codec)
  9911. {
  9912. struct alc_spec *spec = codec->spec;
  9913. int err;
  9914. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9915. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9916. alc861_ignore);
  9917. if (err < 0)
  9918. return err;
  9919. if (!spec->autocfg.line_outs)
  9920. return 0; /* can't find valid BIOS pin config */
  9921. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9922. if (err < 0)
  9923. return err;
  9924. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9925. if (err < 0)
  9926. return err;
  9927. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9928. if (err < 0)
  9929. return err;
  9930. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9931. if (err < 0)
  9932. return err;
  9933. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9934. if (spec->autocfg.dig_out_pin)
  9935. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9936. if (spec->kctl_alloc)
  9937. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9938. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9939. spec->num_mux_defs = 1;
  9940. spec->input_mux = &spec->private_imux;
  9941. spec->adc_nids = alc861_adc_nids;
  9942. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9943. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9944. spec->num_mixers++;
  9945. return 1;
  9946. }
  9947. /* additional initialization for auto-configuration model */
  9948. static void alc861_auto_init(struct hda_codec *codec)
  9949. {
  9950. alc861_auto_init_multi_out(codec);
  9951. alc861_auto_init_hp_out(codec);
  9952. alc861_auto_init_analog_input(codec);
  9953. }
  9954. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9955. static struct hda_amp_list alc861_loopbacks[] = {
  9956. { 0x15, HDA_INPUT, 0 },
  9957. { 0x15, HDA_INPUT, 1 },
  9958. { 0x15, HDA_INPUT, 2 },
  9959. { 0x15, HDA_INPUT, 3 },
  9960. { } /* end */
  9961. };
  9962. #endif
  9963. /*
  9964. * configuration and preset
  9965. */
  9966. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9967. [ALC861_3ST] = "3stack",
  9968. [ALC660_3ST] = "3stack-660",
  9969. [ALC861_3ST_DIG] = "3stack-dig",
  9970. [ALC861_6ST_DIG] = "6stack-dig",
  9971. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9972. [ALC861_TOSHIBA] = "toshiba",
  9973. [ALC861_ASUS] = "asus",
  9974. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9975. [ALC861_AUTO] = "auto",
  9976. };
  9977. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9978. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9979. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9980. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9981. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9982. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9983. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9984. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9985. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9986. * Any other models that need this preset?
  9987. */
  9988. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9989. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9990. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9991. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9992. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9993. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9994. /* FIXME: the below seems conflict */
  9995. /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
  9996. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9997. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9998. {}
  9999. };
  10000. static struct alc_config_preset alc861_presets[] = {
  10001. [ALC861_3ST] = {
  10002. .mixers = { alc861_3ST_mixer },
  10003. .init_verbs = { alc861_threestack_init_verbs },
  10004. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10005. .dac_nids = alc861_dac_nids,
  10006. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  10007. .channel_mode = alc861_threestack_modes,
  10008. .need_dac_fix = 1,
  10009. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10010. .adc_nids = alc861_adc_nids,
  10011. .input_mux = &alc861_capture_source,
  10012. },
  10013. [ALC861_3ST_DIG] = {
  10014. .mixers = { alc861_base_mixer },
  10015. .init_verbs = { alc861_threestack_init_verbs },
  10016. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10017. .dac_nids = alc861_dac_nids,
  10018. .dig_out_nid = ALC861_DIGOUT_NID,
  10019. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  10020. .channel_mode = alc861_threestack_modes,
  10021. .need_dac_fix = 1,
  10022. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10023. .adc_nids = alc861_adc_nids,
  10024. .input_mux = &alc861_capture_source,
  10025. },
  10026. [ALC861_6ST_DIG] = {
  10027. .mixers = { alc861_base_mixer },
  10028. .init_verbs = { alc861_base_init_verbs },
  10029. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10030. .dac_nids = alc861_dac_nids,
  10031. .dig_out_nid = ALC861_DIGOUT_NID,
  10032. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  10033. .channel_mode = alc861_8ch_modes,
  10034. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10035. .adc_nids = alc861_adc_nids,
  10036. .input_mux = &alc861_capture_source,
  10037. },
  10038. [ALC660_3ST] = {
  10039. .mixers = { alc861_3ST_mixer },
  10040. .init_verbs = { alc861_threestack_init_verbs },
  10041. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  10042. .dac_nids = alc660_dac_nids,
  10043. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  10044. .channel_mode = alc861_threestack_modes,
  10045. .need_dac_fix = 1,
  10046. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10047. .adc_nids = alc861_adc_nids,
  10048. .input_mux = &alc861_capture_source,
  10049. },
  10050. [ALC861_UNIWILL_M31] = {
  10051. .mixers = { alc861_uniwill_m31_mixer },
  10052. .init_verbs = { alc861_uniwill_m31_init_verbs },
  10053. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10054. .dac_nids = alc861_dac_nids,
  10055. .dig_out_nid = ALC861_DIGOUT_NID,
  10056. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  10057. .channel_mode = alc861_uniwill_m31_modes,
  10058. .need_dac_fix = 1,
  10059. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10060. .adc_nids = alc861_adc_nids,
  10061. .input_mux = &alc861_capture_source,
  10062. },
  10063. [ALC861_TOSHIBA] = {
  10064. .mixers = { alc861_toshiba_mixer },
  10065. .init_verbs = { alc861_base_init_verbs,
  10066. alc861_toshiba_init_verbs },
  10067. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10068. .dac_nids = alc861_dac_nids,
  10069. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  10070. .channel_mode = alc883_3ST_2ch_modes,
  10071. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10072. .adc_nids = alc861_adc_nids,
  10073. .input_mux = &alc861_capture_source,
  10074. .unsol_event = alc861_toshiba_unsol_event,
  10075. .init_hook = alc861_toshiba_automute,
  10076. },
  10077. [ALC861_ASUS] = {
  10078. .mixers = { alc861_asus_mixer },
  10079. .init_verbs = { alc861_asus_init_verbs },
  10080. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10081. .dac_nids = alc861_dac_nids,
  10082. .dig_out_nid = ALC861_DIGOUT_NID,
  10083. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  10084. .channel_mode = alc861_asus_modes,
  10085. .need_dac_fix = 1,
  10086. .hp_nid = 0x06,
  10087. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10088. .adc_nids = alc861_adc_nids,
  10089. .input_mux = &alc861_capture_source,
  10090. },
  10091. [ALC861_ASUS_LAPTOP] = {
  10092. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  10093. .init_verbs = { alc861_asus_init_verbs,
  10094. alc861_asus_laptop_init_verbs },
  10095. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  10096. .dac_nids = alc861_dac_nids,
  10097. .dig_out_nid = ALC861_DIGOUT_NID,
  10098. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  10099. .channel_mode = alc883_3ST_2ch_modes,
  10100. .need_dac_fix = 1,
  10101. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  10102. .adc_nids = alc861_adc_nids,
  10103. .input_mux = &alc861_capture_source,
  10104. },
  10105. };
  10106. static int patch_alc861(struct hda_codec *codec)
  10107. {
  10108. struct alc_spec *spec;
  10109. int board_config;
  10110. int err;
  10111. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10112. if (spec == NULL)
  10113. return -ENOMEM;
  10114. codec->spec = spec;
  10115. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  10116. alc861_models,
  10117. alc861_cfg_tbl);
  10118. if (board_config < 0) {
  10119. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  10120. "trying auto-probe from BIOS...\n");
  10121. board_config = ALC861_AUTO;
  10122. }
  10123. if (board_config == ALC861_AUTO) {
  10124. /* automatic parse from the BIOS config */
  10125. err = alc861_parse_auto_config(codec);
  10126. if (err < 0) {
  10127. alc_free(codec);
  10128. return err;
  10129. } else if (!err) {
  10130. printk(KERN_INFO
  10131. "hda_codec: Cannot set up configuration "
  10132. "from BIOS. Using base mode...\n");
  10133. board_config = ALC861_3ST_DIG;
  10134. }
  10135. }
  10136. if (board_config != ALC861_AUTO)
  10137. setup_preset(spec, &alc861_presets[board_config]);
  10138. spec->stream_name_analog = "ALC861 Analog";
  10139. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  10140. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  10141. spec->stream_name_digital = "ALC861 Digital";
  10142. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  10143. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  10144. codec->patch_ops = alc_patch_ops;
  10145. if (board_config == ALC861_AUTO)
  10146. spec->init_hook = alc861_auto_init;
  10147. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10148. if (!spec->loopback.amplist)
  10149. spec->loopback.amplist = alc861_loopbacks;
  10150. #endif
  10151. return 0;
  10152. }
  10153. /*
  10154. * ALC861-VD support
  10155. *
  10156. * Based on ALC882
  10157. *
  10158. * In addition, an independent DAC
  10159. */
  10160. #define ALC861VD_DIGOUT_NID 0x06
  10161. static hda_nid_t alc861vd_dac_nids[4] = {
  10162. /* front, surr, clfe, side surr */
  10163. 0x02, 0x03, 0x04, 0x05
  10164. };
  10165. /* dac_nids for ALC660vd are in a different order - according to
  10166. * Realtek's driver.
  10167. * This should probably tesult in a different mixer for 6stack models
  10168. * of ALC660vd codecs, but for now there is only 3stack mixer
  10169. * - and it is the same as in 861vd.
  10170. * adc_nids in ALC660vd are (is) the same as in 861vd
  10171. */
  10172. static hda_nid_t alc660vd_dac_nids[3] = {
  10173. /* front, rear, clfe, rear_surr */
  10174. 0x02, 0x04, 0x03
  10175. };
  10176. static hda_nid_t alc861vd_adc_nids[1] = {
  10177. /* ADC0 */
  10178. 0x09,
  10179. };
  10180. /* input MUX */
  10181. /* FIXME: should be a matrix-type input source selection */
  10182. static struct hda_input_mux alc861vd_capture_source = {
  10183. .num_items = 4,
  10184. .items = {
  10185. { "Mic", 0x0 },
  10186. { "Front Mic", 0x1 },
  10187. { "Line", 0x2 },
  10188. { "CD", 0x4 },
  10189. },
  10190. };
  10191. static struct hda_input_mux alc861vd_dallas_capture_source = {
  10192. .num_items = 3,
  10193. .items = {
  10194. { "Front Mic", 0x0 },
  10195. { "ATAPI Mic", 0x1 },
  10196. { "Line In", 0x5 },
  10197. },
  10198. };
  10199. static struct hda_input_mux alc861vd_hp_capture_source = {
  10200. .num_items = 2,
  10201. .items = {
  10202. { "Front Mic", 0x0 },
  10203. { "ATAPI Mic", 0x1 },
  10204. },
  10205. };
  10206. #define alc861vd_mux_enum_info alc_mux_enum_info
  10207. #define alc861vd_mux_enum_get alc_mux_enum_get
  10208. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  10209. struct snd_ctl_elem_value *ucontrol)
  10210. {
  10211. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10212. struct alc_spec *spec = codec->spec;
  10213. const struct hda_input_mux *imux = spec->input_mux;
  10214. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10215. static hda_nid_t capture_mixers[1] = { 0x22 };
  10216. hda_nid_t nid = capture_mixers[adc_idx];
  10217. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10218. unsigned int i, idx;
  10219. idx = ucontrol->value.enumerated.item[0];
  10220. if (idx >= imux->num_items)
  10221. idx = imux->num_items - 1;
  10222. if (*cur_val == idx)
  10223. return 0;
  10224. for (i = 0; i < imux->num_items; i++) {
  10225. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10226. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10227. imux->items[i].index,
  10228. HDA_AMP_MUTE, v);
  10229. }
  10230. *cur_val = idx;
  10231. return 1;
  10232. }
  10233. /*
  10234. * 2ch mode
  10235. */
  10236. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  10237. { 2, NULL }
  10238. };
  10239. /*
  10240. * 6ch mode
  10241. */
  10242. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  10243. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10244. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10245. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10246. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10247. { } /* end */
  10248. };
  10249. /*
  10250. * 8ch mode
  10251. */
  10252. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  10253. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10254. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10255. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10256. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10257. { } /* end */
  10258. };
  10259. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  10260. { 6, alc861vd_6stack_ch6_init },
  10261. { 8, alc861vd_6stack_ch8_init },
  10262. };
  10263. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  10264. {
  10265. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10266. .name = "Channel Mode",
  10267. .info = alc_ch_mode_info,
  10268. .get = alc_ch_mode_get,
  10269. .put = alc_ch_mode_put,
  10270. },
  10271. { } /* end */
  10272. };
  10273. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  10274. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10275. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10276. {
  10277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10278. /* The multiple "Capture Source" controls confuse alsamixer
  10279. * So call somewhat different..
  10280. *FIXME: the controls appear in the "playback" view!
  10281. */
  10282. /* .name = "Capture Source", */
  10283. .name = "Input Source",
  10284. .count = 1,
  10285. .info = alc861vd_mux_enum_info,
  10286. .get = alc861vd_mux_enum_get,
  10287. .put = alc861vd_mux_enum_put,
  10288. },
  10289. { } /* end */
  10290. };
  10291. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10292. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10293. */
  10294. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  10295. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10296. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10297. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10298. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  10299. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  10300. HDA_OUTPUT),
  10301. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  10302. HDA_OUTPUT),
  10303. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  10304. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  10305. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  10306. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  10307. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10308. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10309. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10310. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10311. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10312. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10313. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10314. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10315. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10316. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10317. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10318. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10319. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10320. { } /* end */
  10321. };
  10322. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  10323. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10324. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10325. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10326. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10327. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10328. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10329. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10330. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10331. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10332. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10333. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10334. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10335. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10336. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10337. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10338. { } /* end */
  10339. };
  10340. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  10341. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10342. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  10343. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10344. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10345. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10346. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10347. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10348. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10349. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10350. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10351. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10352. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10353. { } /* end */
  10354. };
  10355. /* Pin assignment: Front=0x14, HP = 0x15,
  10356. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  10357. */
  10358. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  10359. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10360. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10361. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10362. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  10363. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10364. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10365. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10366. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10367. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10368. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10369. { } /* end */
  10370. };
  10371. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  10372. * Front Mic=0x18, ATAPI Mic = 0x19,
  10373. */
  10374. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  10375. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10376. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10377. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10378. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  10379. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10380. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10381. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10382. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10383. { } /* end */
  10384. };
  10385. /*
  10386. * generic initialization of ADC, input mixers and output mixers
  10387. */
  10388. static struct hda_verb alc861vd_volume_init_verbs[] = {
  10389. /*
  10390. * Unmute ADC0 and set the default input to mic-in
  10391. */
  10392. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10393. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10394. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  10395. * the analog-loopback mixer widget
  10396. */
  10397. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10398. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10399. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10400. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10401. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10402. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10403. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  10404. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10405. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10406. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10407. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10408. /*
  10409. * Set up output mixers (0x02 - 0x05)
  10410. */
  10411. /* set vol=0 to output mixers */
  10412. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10413. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10414. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10415. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10416. /* set up input amps for analog loopback */
  10417. /* Amp Indices: DAC = 0, mixer = 1 */
  10418. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10419. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10420. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10421. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10422. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10423. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10424. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10425. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10426. { }
  10427. };
  10428. /*
  10429. * 3-stack pin configuration:
  10430. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  10431. */
  10432. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  10433. /*
  10434. * Set pin mode and muting
  10435. */
  10436. /* set front pin widgets 0x14 for output */
  10437. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10438. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10439. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10440. /* Mic (rear) pin: input vref at 80% */
  10441. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10442. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10443. /* Front Mic pin: input vref at 80% */
  10444. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10445. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10446. /* Line In pin: input */
  10447. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10448. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10449. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10450. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10451. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10452. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10453. /* CD pin widget for input */
  10454. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10455. { }
  10456. };
  10457. /*
  10458. * 6-stack pin configuration:
  10459. */
  10460. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  10461. /*
  10462. * Set pin mode and muting
  10463. */
  10464. /* set front pin widgets 0x14 for output */
  10465. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10466. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10467. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10468. /* Rear Pin: output 1 (0x0d) */
  10469. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10470. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10471. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  10472. /* CLFE Pin: output 2 (0x0e) */
  10473. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10474. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10475. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  10476. /* Side Pin: output 3 (0x0f) */
  10477. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10478. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10479. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  10480. /* Mic (rear) pin: input vref at 80% */
  10481. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10482. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10483. /* Front Mic pin: input vref at 80% */
  10484. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10485. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10486. /* Line In pin: input */
  10487. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10488. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10489. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10490. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10491. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10492. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10493. /* CD pin widget for input */
  10494. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10495. { }
  10496. };
  10497. static struct hda_verb alc861vd_eapd_verbs[] = {
  10498. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  10499. { }
  10500. };
  10501. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  10502. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10503. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10504. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  10505. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10506. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10507. {}
  10508. };
  10509. /* toggle speaker-output according to the hp-jack state */
  10510. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  10511. {
  10512. unsigned int present;
  10513. unsigned char bits;
  10514. present = snd_hda_codec_read(codec, 0x1b, 0,
  10515. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10516. bits = present ? HDA_AMP_MUTE : 0;
  10517. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10518. HDA_AMP_MUTE, bits);
  10519. }
  10520. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  10521. {
  10522. unsigned int present;
  10523. unsigned char bits;
  10524. present = snd_hda_codec_read(codec, 0x18, 0,
  10525. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10526. bits = present ? HDA_AMP_MUTE : 0;
  10527. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  10528. HDA_AMP_MUTE, bits);
  10529. }
  10530. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  10531. {
  10532. alc861vd_lenovo_hp_automute(codec);
  10533. alc861vd_lenovo_mic_automute(codec);
  10534. }
  10535. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  10536. unsigned int res)
  10537. {
  10538. switch (res >> 26) {
  10539. case ALC880_HP_EVENT:
  10540. alc861vd_lenovo_hp_automute(codec);
  10541. break;
  10542. case ALC880_MIC_EVENT:
  10543. alc861vd_lenovo_mic_automute(codec);
  10544. break;
  10545. }
  10546. }
  10547. static struct hda_verb alc861vd_dallas_verbs[] = {
  10548. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10549. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10550. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10551. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10554. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10555. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10556. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10557. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10558. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10559. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10560. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10561. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10562. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10563. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10564. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10565. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10566. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10567. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10568. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10569. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10570. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10571. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10572. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10573. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10574. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10575. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10576. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10577. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10578. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10579. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10580. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10581. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10582. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10583. { } /* end */
  10584. };
  10585. /* toggle speaker-output according to the hp-jack state */
  10586. static void alc861vd_dallas_automute(struct hda_codec *codec)
  10587. {
  10588. unsigned int present;
  10589. present = snd_hda_codec_read(codec, 0x15, 0,
  10590. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10591. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10592. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  10593. }
  10594. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  10595. {
  10596. if ((res >> 26) == ALC880_HP_EVENT)
  10597. alc861vd_dallas_automute(codec);
  10598. }
  10599. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10600. #define alc861vd_loopbacks alc880_loopbacks
  10601. #endif
  10602. /* pcm configuration: identiacal with ALC880 */
  10603. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10604. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10605. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10606. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10607. /*
  10608. * configuration and preset
  10609. */
  10610. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10611. [ALC660VD_3ST] = "3stack-660",
  10612. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10613. [ALC861VD_3ST] = "3stack",
  10614. [ALC861VD_3ST_DIG] = "3stack-digout",
  10615. [ALC861VD_6ST_DIG] = "6stack-digout",
  10616. [ALC861VD_LENOVO] = "lenovo",
  10617. [ALC861VD_DALLAS] = "dallas",
  10618. [ALC861VD_HP] = "hp",
  10619. [ALC861VD_AUTO] = "auto",
  10620. };
  10621. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10622. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10623. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10624. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10625. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10626. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10627. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10628. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10629. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10630. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10631. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10632. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10633. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10634. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10635. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10636. {}
  10637. };
  10638. static struct alc_config_preset alc861vd_presets[] = {
  10639. [ALC660VD_3ST] = {
  10640. .mixers = { alc861vd_3st_mixer },
  10641. .init_verbs = { alc861vd_volume_init_verbs,
  10642. alc861vd_3stack_init_verbs },
  10643. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10644. .dac_nids = alc660vd_dac_nids,
  10645. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10646. .adc_nids = alc861vd_adc_nids,
  10647. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10648. .channel_mode = alc861vd_3stack_2ch_modes,
  10649. .input_mux = &alc861vd_capture_source,
  10650. },
  10651. [ALC660VD_3ST_DIG] = {
  10652. .mixers = { alc861vd_3st_mixer },
  10653. .init_verbs = { alc861vd_volume_init_verbs,
  10654. alc861vd_3stack_init_verbs },
  10655. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10656. .dac_nids = alc660vd_dac_nids,
  10657. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10658. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10659. .adc_nids = alc861vd_adc_nids,
  10660. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10661. .channel_mode = alc861vd_3stack_2ch_modes,
  10662. .input_mux = &alc861vd_capture_source,
  10663. },
  10664. [ALC861VD_3ST] = {
  10665. .mixers = { alc861vd_3st_mixer },
  10666. .init_verbs = { alc861vd_volume_init_verbs,
  10667. alc861vd_3stack_init_verbs },
  10668. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10669. .dac_nids = alc861vd_dac_nids,
  10670. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10671. .channel_mode = alc861vd_3stack_2ch_modes,
  10672. .input_mux = &alc861vd_capture_source,
  10673. },
  10674. [ALC861VD_3ST_DIG] = {
  10675. .mixers = { alc861vd_3st_mixer },
  10676. .init_verbs = { alc861vd_volume_init_verbs,
  10677. alc861vd_3stack_init_verbs },
  10678. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10679. .dac_nids = alc861vd_dac_nids,
  10680. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10681. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10682. .channel_mode = alc861vd_3stack_2ch_modes,
  10683. .input_mux = &alc861vd_capture_source,
  10684. },
  10685. [ALC861VD_6ST_DIG] = {
  10686. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10687. .init_verbs = { alc861vd_volume_init_verbs,
  10688. alc861vd_6stack_init_verbs },
  10689. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10690. .dac_nids = alc861vd_dac_nids,
  10691. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10692. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10693. .channel_mode = alc861vd_6stack_modes,
  10694. .input_mux = &alc861vd_capture_source,
  10695. },
  10696. [ALC861VD_LENOVO] = {
  10697. .mixers = { alc861vd_lenovo_mixer },
  10698. .init_verbs = { alc861vd_volume_init_verbs,
  10699. alc861vd_3stack_init_verbs,
  10700. alc861vd_eapd_verbs,
  10701. alc861vd_lenovo_unsol_verbs },
  10702. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10703. .dac_nids = alc660vd_dac_nids,
  10704. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10705. .adc_nids = alc861vd_adc_nids,
  10706. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10707. .channel_mode = alc861vd_3stack_2ch_modes,
  10708. .input_mux = &alc861vd_capture_source,
  10709. .unsol_event = alc861vd_lenovo_unsol_event,
  10710. .init_hook = alc861vd_lenovo_automute,
  10711. },
  10712. [ALC861VD_DALLAS] = {
  10713. .mixers = { alc861vd_dallas_mixer },
  10714. .init_verbs = { alc861vd_dallas_verbs },
  10715. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10716. .dac_nids = alc861vd_dac_nids,
  10717. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10718. .adc_nids = alc861vd_adc_nids,
  10719. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10720. .channel_mode = alc861vd_3stack_2ch_modes,
  10721. .input_mux = &alc861vd_dallas_capture_source,
  10722. .unsol_event = alc861vd_dallas_unsol_event,
  10723. .init_hook = alc861vd_dallas_automute,
  10724. },
  10725. [ALC861VD_HP] = {
  10726. .mixers = { alc861vd_hp_mixer },
  10727. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10728. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10729. .dac_nids = alc861vd_dac_nids,
  10730. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10731. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10732. .adc_nids = alc861vd_adc_nids,
  10733. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10734. .channel_mode = alc861vd_3stack_2ch_modes,
  10735. .input_mux = &alc861vd_hp_capture_source,
  10736. .unsol_event = alc861vd_dallas_unsol_event,
  10737. .init_hook = alc861vd_dallas_automute,
  10738. },
  10739. };
  10740. /*
  10741. * BIOS auto configuration
  10742. */
  10743. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10744. hda_nid_t nid, int pin_type, int dac_idx)
  10745. {
  10746. /* set as output */
  10747. snd_hda_codec_write(codec, nid, 0,
  10748. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10749. snd_hda_codec_write(codec, nid, 0,
  10750. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10751. }
  10752. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10753. {
  10754. struct alc_spec *spec = codec->spec;
  10755. int i;
  10756. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10757. for (i = 0; i <= HDA_SIDE; i++) {
  10758. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10759. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10760. if (nid)
  10761. alc861vd_auto_set_output_and_unmute(codec, nid,
  10762. pin_type, i);
  10763. }
  10764. }
  10765. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10766. {
  10767. struct alc_spec *spec = codec->spec;
  10768. hda_nid_t pin;
  10769. pin = spec->autocfg.hp_pins[0];
  10770. if (pin) /* connect to front and use dac 0 */
  10771. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10772. }
  10773. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10774. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10775. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10776. {
  10777. struct alc_spec *spec = codec->spec;
  10778. int i;
  10779. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10780. hda_nid_t nid = spec->autocfg.input_pins[i];
  10781. if (alc861vd_is_input_pin(nid)) {
  10782. snd_hda_codec_write(codec, nid, 0,
  10783. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10784. i <= AUTO_PIN_FRONT_MIC ?
  10785. PIN_VREF80 : PIN_IN);
  10786. if (nid != ALC861VD_PIN_CD_NID)
  10787. snd_hda_codec_write(codec, nid, 0,
  10788. AC_VERB_SET_AMP_GAIN_MUTE,
  10789. AMP_OUT_MUTE);
  10790. }
  10791. }
  10792. }
  10793. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10794. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10795. /* add playback controls from the parsed DAC table */
  10796. /* Based on ALC880 version. But ALC861VD has separate,
  10797. * different NIDs for mute/unmute switch and volume control */
  10798. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10799. const struct auto_pin_cfg *cfg)
  10800. {
  10801. char name[32];
  10802. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10803. hda_nid_t nid_v, nid_s;
  10804. int i, err;
  10805. for (i = 0; i < cfg->line_outs; i++) {
  10806. if (!spec->multiout.dac_nids[i])
  10807. continue;
  10808. nid_v = alc861vd_idx_to_mixer_vol(
  10809. alc880_dac_to_idx(
  10810. spec->multiout.dac_nids[i]));
  10811. nid_s = alc861vd_idx_to_mixer_switch(
  10812. alc880_dac_to_idx(
  10813. spec->multiout.dac_nids[i]));
  10814. if (i == 2) {
  10815. /* Center/LFE */
  10816. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10817. "Center Playback Volume",
  10818. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10819. HDA_OUTPUT));
  10820. if (err < 0)
  10821. return err;
  10822. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10823. "LFE Playback Volume",
  10824. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10825. HDA_OUTPUT));
  10826. if (err < 0)
  10827. return err;
  10828. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10829. "Center Playback Switch",
  10830. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10831. HDA_INPUT));
  10832. if (err < 0)
  10833. return err;
  10834. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10835. "LFE Playback Switch",
  10836. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10837. HDA_INPUT));
  10838. if (err < 0)
  10839. return err;
  10840. } else {
  10841. sprintf(name, "%s Playback Volume", chname[i]);
  10842. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10843. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10844. HDA_OUTPUT));
  10845. if (err < 0)
  10846. return err;
  10847. sprintf(name, "%s Playback Switch", chname[i]);
  10848. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10849. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10850. HDA_INPUT));
  10851. if (err < 0)
  10852. return err;
  10853. }
  10854. }
  10855. return 0;
  10856. }
  10857. /* add playback controls for speaker and HP outputs */
  10858. /* Based on ALC880 version. But ALC861VD has separate,
  10859. * different NIDs for mute/unmute switch and volume control */
  10860. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10861. hda_nid_t pin, const char *pfx)
  10862. {
  10863. hda_nid_t nid_v, nid_s;
  10864. int err;
  10865. char name[32];
  10866. if (!pin)
  10867. return 0;
  10868. if (alc880_is_fixed_pin(pin)) {
  10869. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10870. /* specify the DAC as the extra output */
  10871. if (!spec->multiout.hp_nid)
  10872. spec->multiout.hp_nid = nid_v;
  10873. else
  10874. spec->multiout.extra_out_nid[0] = nid_v;
  10875. /* control HP volume/switch on the output mixer amp */
  10876. nid_v = alc861vd_idx_to_mixer_vol(
  10877. alc880_fixed_pin_idx(pin));
  10878. nid_s = alc861vd_idx_to_mixer_switch(
  10879. alc880_fixed_pin_idx(pin));
  10880. sprintf(name, "%s Playback Volume", pfx);
  10881. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10882. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10883. if (err < 0)
  10884. return err;
  10885. sprintf(name, "%s Playback Switch", pfx);
  10886. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10887. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10888. if (err < 0)
  10889. return err;
  10890. } else if (alc880_is_multi_pin(pin)) {
  10891. /* set manual connection */
  10892. /* we have only a switch on HP-out PIN */
  10893. sprintf(name, "%s Playback Switch", pfx);
  10894. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10895. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10896. if (err < 0)
  10897. return err;
  10898. }
  10899. return 0;
  10900. }
  10901. /* parse the BIOS configuration and set up the alc_spec
  10902. * return 1 if successful, 0 if the proper config is not found,
  10903. * or a negative error code
  10904. * Based on ALC880 version - had to change it to override
  10905. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10906. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10907. {
  10908. struct alc_spec *spec = codec->spec;
  10909. int err;
  10910. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10911. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10912. alc861vd_ignore);
  10913. if (err < 0)
  10914. return err;
  10915. if (!spec->autocfg.line_outs)
  10916. return 0; /* can't find valid BIOS pin config */
  10917. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10918. if (err < 0)
  10919. return err;
  10920. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10921. if (err < 0)
  10922. return err;
  10923. err = alc861vd_auto_create_extra_out(spec,
  10924. spec->autocfg.speaker_pins[0],
  10925. "Speaker");
  10926. if (err < 0)
  10927. return err;
  10928. err = alc861vd_auto_create_extra_out(spec,
  10929. spec->autocfg.hp_pins[0],
  10930. "Headphone");
  10931. if (err < 0)
  10932. return err;
  10933. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10934. if (err < 0)
  10935. return err;
  10936. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10937. if (spec->autocfg.dig_out_pin)
  10938. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10939. if (spec->kctl_alloc)
  10940. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10941. spec->init_verbs[spec->num_init_verbs++]
  10942. = alc861vd_volume_init_verbs;
  10943. spec->num_mux_defs = 1;
  10944. spec->input_mux = &spec->private_imux;
  10945. err = alc_auto_add_mic_boost(codec);
  10946. if (err < 0)
  10947. return err;
  10948. return 1;
  10949. }
  10950. /* additional initialization for auto-configuration model */
  10951. static void alc861vd_auto_init(struct hda_codec *codec)
  10952. {
  10953. alc861vd_auto_init_multi_out(codec);
  10954. alc861vd_auto_init_hp_out(codec);
  10955. alc861vd_auto_init_analog_input(codec);
  10956. }
  10957. static int patch_alc861vd(struct hda_codec *codec)
  10958. {
  10959. struct alc_spec *spec;
  10960. int err, board_config;
  10961. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10962. if (spec == NULL)
  10963. return -ENOMEM;
  10964. codec->spec = spec;
  10965. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10966. alc861vd_models,
  10967. alc861vd_cfg_tbl);
  10968. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10969. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10970. "ALC861VD, trying auto-probe from BIOS...\n");
  10971. board_config = ALC861VD_AUTO;
  10972. }
  10973. if (board_config == ALC861VD_AUTO) {
  10974. /* automatic parse from the BIOS config */
  10975. err = alc861vd_parse_auto_config(codec);
  10976. if (err < 0) {
  10977. alc_free(codec);
  10978. return err;
  10979. } else if (!err) {
  10980. printk(KERN_INFO
  10981. "hda_codec: Cannot set up configuration "
  10982. "from BIOS. Using base mode...\n");
  10983. board_config = ALC861VD_3ST;
  10984. }
  10985. }
  10986. if (board_config != ALC861VD_AUTO)
  10987. setup_preset(spec, &alc861vd_presets[board_config]);
  10988. spec->stream_name_analog = "ALC861VD Analog";
  10989. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10990. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10991. spec->stream_name_digital = "ALC861VD Digital";
  10992. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10993. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10994. spec->adc_nids = alc861vd_adc_nids;
  10995. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10996. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10997. spec->num_mixers++;
  10998. codec->patch_ops = alc_patch_ops;
  10999. if (board_config == ALC861VD_AUTO)
  11000. spec->init_hook = alc861vd_auto_init;
  11001. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11002. if (!spec->loopback.amplist)
  11003. spec->loopback.amplist = alc861vd_loopbacks;
  11004. #endif
  11005. return 0;
  11006. }
  11007. /*
  11008. * ALC662 support
  11009. *
  11010. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  11011. * configuration. Each pin widget can choose any input DACs and a mixer.
  11012. * Each ADC is connected from a mixer of all inputs. This makes possible
  11013. * 6-channel independent captures.
  11014. *
  11015. * In addition, an independent DAC for the multi-playback (not used in this
  11016. * driver yet).
  11017. */
  11018. #define ALC662_DIGOUT_NID 0x06
  11019. #define ALC662_DIGIN_NID 0x0a
  11020. static hda_nid_t alc662_dac_nids[4] = {
  11021. /* front, rear, clfe, rear_surr */
  11022. 0x02, 0x03, 0x04
  11023. };
  11024. static hda_nid_t alc662_adc_nids[1] = {
  11025. /* ADC1-2 */
  11026. 0x09,
  11027. };
  11028. /* input MUX */
  11029. /* FIXME: should be a matrix-type input source selection */
  11030. static struct hda_input_mux alc662_capture_source = {
  11031. .num_items = 4,
  11032. .items = {
  11033. { "Mic", 0x0 },
  11034. { "Front Mic", 0x1 },
  11035. { "Line", 0x2 },
  11036. { "CD", 0x4 },
  11037. },
  11038. };
  11039. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  11040. .num_items = 2,
  11041. .items = {
  11042. { "Mic", 0x1 },
  11043. { "Line", 0x2 },
  11044. },
  11045. };
  11046. static struct hda_input_mux alc662_eeepc_capture_source = {
  11047. .num_items = 2,
  11048. .items = {
  11049. { "i-Mic", 0x1 },
  11050. { "e-Mic", 0x0 },
  11051. },
  11052. };
  11053. #define alc662_mux_enum_info alc_mux_enum_info
  11054. #define alc662_mux_enum_get alc_mux_enum_get
  11055. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  11056. struct snd_ctl_elem_value *ucontrol)
  11057. {
  11058. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  11059. struct alc_spec *spec = codec->spec;
  11060. const struct hda_input_mux *imux = spec->input_mux;
  11061. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  11062. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  11063. hda_nid_t nid = capture_mixers[adc_idx];
  11064. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  11065. unsigned int i, idx;
  11066. idx = ucontrol->value.enumerated.item[0];
  11067. if (idx >= imux->num_items)
  11068. idx = imux->num_items - 1;
  11069. if (*cur_val == idx)
  11070. return 0;
  11071. for (i = 0; i < imux->num_items; i++) {
  11072. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  11073. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  11074. imux->items[i].index,
  11075. HDA_AMP_MUTE, v);
  11076. }
  11077. *cur_val = idx;
  11078. return 1;
  11079. }
  11080. /*
  11081. * 2ch mode
  11082. */
  11083. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  11084. { 2, NULL }
  11085. };
  11086. /*
  11087. * 2ch mode
  11088. */
  11089. static struct hda_verb alc662_3ST_ch2_init[] = {
  11090. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  11091. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  11092. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  11093. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  11094. { } /* end */
  11095. };
  11096. /*
  11097. * 6ch mode
  11098. */
  11099. static struct hda_verb alc662_3ST_ch6_init[] = {
  11100. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11101. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  11102. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  11103. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11104. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  11105. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  11106. { } /* end */
  11107. };
  11108. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  11109. { 2, alc662_3ST_ch2_init },
  11110. { 6, alc662_3ST_ch6_init },
  11111. };
  11112. /*
  11113. * 2ch mode
  11114. */
  11115. static struct hda_verb alc662_sixstack_ch6_init[] = {
  11116. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  11117. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  11118. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11119. { } /* end */
  11120. };
  11121. /*
  11122. * 6ch mode
  11123. */
  11124. static struct hda_verb alc662_sixstack_ch8_init[] = {
  11125. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11126. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11127. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11128. { } /* end */
  11129. };
  11130. static struct hda_channel_mode alc662_5stack_modes[2] = {
  11131. { 2, alc662_sixstack_ch6_init },
  11132. { 6, alc662_sixstack_ch8_init },
  11133. };
  11134. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  11135. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  11136. */
  11137. static struct snd_kcontrol_new alc662_base_mixer[] = {
  11138. /* output mixer control */
  11139. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  11140. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  11141. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  11142. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  11143. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  11144. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  11145. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  11146. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  11147. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11148. /*Input mixer control */
  11149. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  11150. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  11151. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  11152. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  11153. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  11154. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  11155. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  11156. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  11157. { } /* end */
  11158. };
  11159. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  11160. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11161. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11162. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11163. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  11164. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  11165. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11166. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11167. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11168. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11169. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11170. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11171. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  11172. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  11173. { } /* end */
  11174. };
  11175. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  11176. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11177. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11178. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  11179. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  11180. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  11181. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  11182. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  11183. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  11184. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11185. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  11186. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  11187. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11188. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11189. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11190. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11191. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11192. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11193. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  11194. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  11195. { } /* end */
  11196. };
  11197. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  11198. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11199. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11200. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  11201. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  11202. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11203. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11204. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11205. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11206. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11207. { } /* end */
  11208. };
  11209. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  11210. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  11211. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11212. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11213. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  11214. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11215. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11216. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  11217. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11218. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11219. { } /* end */
  11220. };
  11221. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  11222. {
  11223. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11224. .name = "Channel Mode",
  11225. .info = alc_ch_mode_info,
  11226. .get = alc_ch_mode_get,
  11227. .put = alc_ch_mode_put,
  11228. },
  11229. { } /* end */
  11230. };
  11231. static struct hda_verb alc662_init_verbs[] = {
  11232. /* ADC: mute amp left and right */
  11233. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11234. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  11235. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  11236. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11237. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  11238. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  11239. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  11240. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  11241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11247. /* Front Pin: output 0 (0x0c) */
  11248. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11249. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11250. /* Rear Pin: output 1 (0x0d) */
  11251. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11252. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11253. /* CLFE Pin: output 2 (0x0e) */
  11254. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11256. /* Mic (rear) pin: input vref at 80% */
  11257. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  11258. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11259. /* Front Mic pin: input vref at 80% */
  11260. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  11261. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11262. /* Line In pin: input */
  11263. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  11264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11265. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  11266. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  11267. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11268. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  11269. /* CD pin widget for input */
  11270. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  11271. /* FIXME: use matrix-type input source selection */
  11272. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  11273. /* Input mixer */
  11274. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11275. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11276. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  11277. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  11278. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11279. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11280. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  11281. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  11282. { }
  11283. };
  11284. static struct hda_verb alc662_sue_init_verbs[] = {
  11285. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  11286. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  11287. {}
  11288. };
  11289. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  11290. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  11291. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  11292. {}
  11293. };
  11294. /*
  11295. * generic initialization of ADC, input mixers and output mixers
  11296. */
  11297. static struct hda_verb alc662_auto_init_verbs[] = {
  11298. /*
  11299. * Unmute ADC and set the default input to mic-in
  11300. */
  11301. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  11302. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11303. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  11304. * mixer widget
  11305. * Note: PASD motherboards uses the Line In 2 as the input for front
  11306. * panel mic (mic 2)
  11307. */
  11308. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  11309. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11310. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  11311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  11312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  11313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  11314. /*
  11315. * Set up output mixers (0x0c - 0x0f)
  11316. */
  11317. /* set vol=0 to output mixers */
  11318. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11319. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11320. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11321. /* set up input amps for analog loopback */
  11322. /* Amp Indices: DAC = 0, mixer = 1 */
  11323. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11324. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11325. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11326. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11327. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11328. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11329. /* FIXME: use matrix-type input source selection */
  11330. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  11331. /* Input mixer */
  11332. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11333. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11334. { }
  11335. };
  11336. /* capture mixer elements */
  11337. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  11338. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11339. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11340. {
  11341. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11342. /* The multiple "Capture Source" controls confuse alsamixer
  11343. * So call somewhat different..
  11344. * FIXME: the controls appear in the "playback" view!
  11345. */
  11346. /* .name = "Capture Source", */
  11347. .name = "Input Source",
  11348. .count = 1,
  11349. .info = alc662_mux_enum_info,
  11350. .get = alc662_mux_enum_get,
  11351. .put = alc662_mux_enum_put,
  11352. },
  11353. { } /* end */
  11354. };
  11355. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  11356. {
  11357. unsigned int present;
  11358. unsigned char bits;
  11359. present = snd_hda_codec_read(codec, 0x14, 0,
  11360. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11361. bits = present ? HDA_AMP_MUTE : 0;
  11362. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  11363. HDA_AMP_MUTE, bits);
  11364. }
  11365. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  11366. {
  11367. unsigned int present;
  11368. unsigned char bits;
  11369. present = snd_hda_codec_read(codec, 0x1b, 0,
  11370. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11371. bits = present ? HDA_AMP_MUTE : 0;
  11372. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  11373. HDA_AMP_MUTE, bits);
  11374. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  11375. HDA_AMP_MUTE, bits);
  11376. }
  11377. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  11378. unsigned int res)
  11379. {
  11380. if ((res >> 26) == ALC880_HP_EVENT)
  11381. alc662_lenovo_101e_all_automute(codec);
  11382. if ((res >> 26) == ALC880_FRONT_EVENT)
  11383. alc662_lenovo_101e_ispeaker_automute(codec);
  11384. }
  11385. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  11386. {
  11387. unsigned int present;
  11388. present = snd_hda_codec_read(codec, 0x18, 0,
  11389. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11390. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11391. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  11392. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11393. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  11394. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11395. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11396. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11397. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11398. }
  11399. /* unsolicited event for HP jack sensing */
  11400. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  11401. unsigned int res)
  11402. {
  11403. if ((res >> 26) == ALC880_HP_EVENT)
  11404. alc262_hippo1_automute( codec );
  11405. if ((res >> 26) == ALC880_MIC_EVENT)
  11406. alc662_eeepc_mic_automute(codec);
  11407. }
  11408. static void alc662_eeepc_inithook(struct hda_codec *codec)
  11409. {
  11410. alc262_hippo1_automute( codec );
  11411. alc662_eeepc_mic_automute(codec);
  11412. }
  11413. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11414. #define alc662_loopbacks alc880_loopbacks
  11415. #endif
  11416. /* pcm configuration: identiacal with ALC880 */
  11417. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  11418. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  11419. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  11420. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  11421. /*
  11422. * configuration and preset
  11423. */
  11424. static const char *alc662_models[ALC662_MODEL_LAST] = {
  11425. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  11426. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  11427. [ALC662_3ST_6ch] = "3stack-6ch",
  11428. [ALC662_5ST_DIG] = "6stack-dig",
  11429. [ALC662_LENOVO_101E] = "lenovo-101e",
  11430. [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
  11431. [ALC662_AUTO] = "auto",
  11432. };
  11433. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  11434. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  11435. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  11436. {}
  11437. };
  11438. static struct alc_config_preset alc662_presets[] = {
  11439. [ALC662_3ST_2ch_DIG] = {
  11440. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  11441. .init_verbs = { alc662_init_verbs },
  11442. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11443. .dac_nids = alc662_dac_nids,
  11444. .dig_out_nid = ALC662_DIGOUT_NID,
  11445. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11446. .adc_nids = alc662_adc_nids,
  11447. .dig_in_nid = ALC662_DIGIN_NID,
  11448. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11449. .channel_mode = alc662_3ST_2ch_modes,
  11450. .input_mux = &alc662_capture_source,
  11451. },
  11452. [ALC662_3ST_6ch_DIG] = {
  11453. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11454. alc662_capture_mixer },
  11455. .init_verbs = { alc662_init_verbs },
  11456. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11457. .dac_nids = alc662_dac_nids,
  11458. .dig_out_nid = ALC662_DIGOUT_NID,
  11459. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11460. .adc_nids = alc662_adc_nids,
  11461. .dig_in_nid = ALC662_DIGIN_NID,
  11462. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11463. .channel_mode = alc662_3ST_6ch_modes,
  11464. .need_dac_fix = 1,
  11465. .input_mux = &alc662_capture_source,
  11466. },
  11467. [ALC662_3ST_6ch] = {
  11468. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11469. alc662_capture_mixer },
  11470. .init_verbs = { alc662_init_verbs },
  11471. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11472. .dac_nids = alc662_dac_nids,
  11473. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11474. .adc_nids = alc662_adc_nids,
  11475. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11476. .channel_mode = alc662_3ST_6ch_modes,
  11477. .need_dac_fix = 1,
  11478. .input_mux = &alc662_capture_source,
  11479. },
  11480. [ALC662_5ST_DIG] = {
  11481. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  11482. alc662_capture_mixer },
  11483. .init_verbs = { alc662_init_verbs },
  11484. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11485. .dac_nids = alc662_dac_nids,
  11486. .dig_out_nid = ALC662_DIGOUT_NID,
  11487. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11488. .adc_nids = alc662_adc_nids,
  11489. .dig_in_nid = ALC662_DIGIN_NID,
  11490. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  11491. .channel_mode = alc662_5stack_modes,
  11492. .input_mux = &alc662_capture_source,
  11493. },
  11494. [ALC662_LENOVO_101E] = {
  11495. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  11496. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  11497. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11498. .dac_nids = alc662_dac_nids,
  11499. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11500. .adc_nids = alc662_adc_nids,
  11501. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11502. .channel_mode = alc662_3ST_2ch_modes,
  11503. .input_mux = &alc662_lenovo_101e_capture_source,
  11504. .unsol_event = alc662_lenovo_101e_unsol_event,
  11505. .init_hook = alc662_lenovo_101e_all_automute,
  11506. },
  11507. [ALC662_ASUS_EEEPC_P701] = {
  11508. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  11509. .init_verbs = { alc662_init_verbs,
  11510. alc662_eeepc_sue_init_verbs },
  11511. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11512. .dac_nids = alc662_dac_nids,
  11513. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  11514. .adc_nids = alc662_adc_nids,
  11515. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11516. .channel_mode = alc662_3ST_2ch_modes,
  11517. .input_mux = &alc662_eeepc_capture_source,
  11518. .unsol_event = alc662_eeepc_unsol_event,
  11519. .init_hook = alc662_eeepc_inithook,
  11520. },
  11521. };
  11522. /*
  11523. * BIOS auto configuration
  11524. */
  11525. /* add playback controls from the parsed DAC table */
  11526. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  11527. const struct auto_pin_cfg *cfg)
  11528. {
  11529. char name[32];
  11530. static const char *chname[4] = {
  11531. "Front", "Surround", NULL /*CLFE*/, "Side"
  11532. };
  11533. hda_nid_t nid;
  11534. int i, err;
  11535. for (i = 0; i < cfg->line_outs; i++) {
  11536. if (!spec->multiout.dac_nids[i])
  11537. continue;
  11538. nid = alc880_idx_to_dac(i);
  11539. if (i == 2) {
  11540. /* Center/LFE */
  11541. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11542. "Center Playback Volume",
  11543. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  11544. HDA_OUTPUT));
  11545. if (err < 0)
  11546. return err;
  11547. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11548. "LFE Playback Volume",
  11549. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  11550. HDA_OUTPUT));
  11551. if (err < 0)
  11552. return err;
  11553. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11554. "Center Playback Switch",
  11555. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11556. HDA_INPUT));
  11557. if (err < 0)
  11558. return err;
  11559. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11560. "LFE Playback Switch",
  11561. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11562. HDA_INPUT));
  11563. if (err < 0)
  11564. return err;
  11565. } else {
  11566. sprintf(name, "%s Playback Volume", chname[i]);
  11567. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11568. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11569. HDA_OUTPUT));
  11570. if (err < 0)
  11571. return err;
  11572. sprintf(name, "%s Playback Switch", chname[i]);
  11573. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11574. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11575. HDA_INPUT));
  11576. if (err < 0)
  11577. return err;
  11578. }
  11579. }
  11580. return 0;
  11581. }
  11582. /* add playback controls for speaker and HP outputs */
  11583. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11584. const char *pfx)
  11585. {
  11586. hda_nid_t nid;
  11587. int err;
  11588. char name[32];
  11589. if (!pin)
  11590. return 0;
  11591. if (alc880_is_fixed_pin(pin)) {
  11592. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11593. /* printk("DAC nid=%x\n",nid); */
  11594. /* specify the DAC as the extra output */
  11595. if (!spec->multiout.hp_nid)
  11596. spec->multiout.hp_nid = nid;
  11597. else
  11598. spec->multiout.extra_out_nid[0] = nid;
  11599. /* control HP volume/switch on the output mixer amp */
  11600. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11601. sprintf(name, "%s Playback Volume", pfx);
  11602. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11603. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11604. if (err < 0)
  11605. return err;
  11606. sprintf(name, "%s Playback Switch", pfx);
  11607. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11608. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11609. if (err < 0)
  11610. return err;
  11611. } else if (alc880_is_multi_pin(pin)) {
  11612. /* set manual connection */
  11613. /* we have only a switch on HP-out PIN */
  11614. sprintf(name, "%s Playback Switch", pfx);
  11615. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11616. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11617. if (err < 0)
  11618. return err;
  11619. }
  11620. return 0;
  11621. }
  11622. /* create playback/capture controls for input pins */
  11623. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11624. const struct auto_pin_cfg *cfg)
  11625. {
  11626. struct hda_input_mux *imux = &spec->private_imux;
  11627. int i, err, idx;
  11628. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11629. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11630. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11631. err = new_analog_input(spec, cfg->input_pins[i],
  11632. auto_pin_cfg_labels[i],
  11633. idx, 0x0b);
  11634. if (err < 0)
  11635. return err;
  11636. imux->items[imux->num_items].label =
  11637. auto_pin_cfg_labels[i];
  11638. imux->items[imux->num_items].index =
  11639. alc880_input_pin_idx(cfg->input_pins[i]);
  11640. imux->num_items++;
  11641. }
  11642. }
  11643. return 0;
  11644. }
  11645. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11646. hda_nid_t nid, int pin_type,
  11647. int dac_idx)
  11648. {
  11649. /* set as output */
  11650. snd_hda_codec_write(codec, nid, 0,
  11651. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11652. snd_hda_codec_write(codec, nid, 0,
  11653. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11654. /* need the manual connection? */
  11655. if (alc880_is_multi_pin(nid)) {
  11656. struct alc_spec *spec = codec->spec;
  11657. int idx = alc880_multi_pin_idx(nid);
  11658. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11659. AC_VERB_SET_CONNECT_SEL,
  11660. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11661. }
  11662. }
  11663. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11664. {
  11665. struct alc_spec *spec = codec->spec;
  11666. int i;
  11667. for (i = 0; i <= HDA_SIDE; i++) {
  11668. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11669. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11670. if (nid)
  11671. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11672. i);
  11673. }
  11674. }
  11675. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11676. {
  11677. struct alc_spec *spec = codec->spec;
  11678. hda_nid_t pin;
  11679. pin = spec->autocfg.hp_pins[0];
  11680. if (pin) /* connect to front */
  11681. /* use dac 0 */
  11682. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11683. }
  11684. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11685. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11686. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11687. {
  11688. struct alc_spec *spec = codec->spec;
  11689. int i;
  11690. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11691. hda_nid_t nid = spec->autocfg.input_pins[i];
  11692. if (alc662_is_input_pin(nid)) {
  11693. snd_hda_codec_write(codec, nid, 0,
  11694. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11695. (i <= AUTO_PIN_FRONT_MIC ?
  11696. PIN_VREF80 : PIN_IN));
  11697. if (nid != ALC662_PIN_CD_NID)
  11698. snd_hda_codec_write(codec, nid, 0,
  11699. AC_VERB_SET_AMP_GAIN_MUTE,
  11700. AMP_OUT_MUTE);
  11701. }
  11702. }
  11703. }
  11704. static int alc662_parse_auto_config(struct hda_codec *codec)
  11705. {
  11706. struct alc_spec *spec = codec->spec;
  11707. int err;
  11708. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11709. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11710. alc662_ignore);
  11711. if (err < 0)
  11712. return err;
  11713. if (!spec->autocfg.line_outs)
  11714. return 0; /* can't find valid BIOS pin config */
  11715. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11716. if (err < 0)
  11717. return err;
  11718. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11719. if (err < 0)
  11720. return err;
  11721. err = alc662_auto_create_extra_out(spec,
  11722. spec->autocfg.speaker_pins[0],
  11723. "Speaker");
  11724. if (err < 0)
  11725. return err;
  11726. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11727. "Headphone");
  11728. if (err < 0)
  11729. return err;
  11730. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11731. if (err < 0)
  11732. return err;
  11733. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11734. if (spec->autocfg.dig_out_pin)
  11735. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11736. if (spec->kctl_alloc)
  11737. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11738. spec->num_mux_defs = 1;
  11739. spec->input_mux = &spec->private_imux;
  11740. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11741. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11742. spec->num_mixers++;
  11743. return 1;
  11744. }
  11745. /* additional initialization for auto-configuration model */
  11746. static void alc662_auto_init(struct hda_codec *codec)
  11747. {
  11748. alc662_auto_init_multi_out(codec);
  11749. alc662_auto_init_hp_out(codec);
  11750. alc662_auto_init_analog_input(codec);
  11751. }
  11752. static int patch_alc662(struct hda_codec *codec)
  11753. {
  11754. struct alc_spec *spec;
  11755. int err, board_config;
  11756. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11757. if (!spec)
  11758. return -ENOMEM;
  11759. codec->spec = spec;
  11760. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11761. alc662_models,
  11762. alc662_cfg_tbl);
  11763. if (board_config < 0) {
  11764. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11765. "trying auto-probe from BIOS...\n");
  11766. board_config = ALC662_AUTO;
  11767. }
  11768. if (board_config == ALC662_AUTO) {
  11769. /* automatic parse from the BIOS config */
  11770. err = alc662_parse_auto_config(codec);
  11771. if (err < 0) {
  11772. alc_free(codec);
  11773. return err;
  11774. } else if (!err) {
  11775. printk(KERN_INFO
  11776. "hda_codec: Cannot set up configuration "
  11777. "from BIOS. Using base mode...\n");
  11778. board_config = ALC662_3ST_2ch_DIG;
  11779. }
  11780. }
  11781. if (board_config != ALC662_AUTO)
  11782. setup_preset(spec, &alc662_presets[board_config]);
  11783. spec->stream_name_analog = "ALC662 Analog";
  11784. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11785. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11786. spec->stream_name_digital = "ALC662 Digital";
  11787. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11788. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11789. if (!spec->adc_nids && spec->input_mux) {
  11790. spec->adc_nids = alc662_adc_nids;
  11791. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11792. }
  11793. codec->patch_ops = alc_patch_ops;
  11794. if (board_config == ALC662_AUTO)
  11795. spec->init_hook = alc662_auto_init;
  11796. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11797. if (!spec->loopback.amplist)
  11798. spec->loopback.amplist = alc662_loopbacks;
  11799. #endif
  11800. return 0;
  11801. }
  11802. /*
  11803. * patch entries
  11804. */
  11805. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11806. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11807. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11808. { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
  11809. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11810. { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
  11811. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11812. .patch = patch_alc861 },
  11813. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11814. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11815. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11816. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11817. .patch = patch_alc883 },
  11818. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11819. .patch = patch_alc662 },
  11820. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11821. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11822. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11823. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11824. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11825. { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
  11826. {} /* terminator */
  11827. };