patch_realtek.c 356 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_AUTO,
  93. ALC262_MODEL_LAST /* last tag */
  94. };
  95. /* ALC861 models */
  96. enum {
  97. ALC861_3ST,
  98. ALC660_3ST,
  99. ALC861_3ST_DIG,
  100. ALC861_6ST_DIG,
  101. ALC861_UNIWILL_M31,
  102. ALC861_TOSHIBA,
  103. ALC861_ASUS,
  104. ALC861_ASUS_LAPTOP,
  105. ALC861_AUTO,
  106. ALC861_MODEL_LAST,
  107. };
  108. /* ALC861-VD models */
  109. enum {
  110. ALC660VD_3ST,
  111. ALC861VD_3ST,
  112. ALC861VD_3ST_DIG,
  113. ALC861VD_6ST_DIG,
  114. ALC861VD_LENOVO,
  115. ALC861VD_DALLAS,
  116. ALC861VD_AUTO,
  117. ALC861VD_MODEL_LAST,
  118. };
  119. /* ALC662 models */
  120. enum {
  121. ALC662_3ST_2ch_DIG,
  122. ALC662_3ST_6ch_DIG,
  123. ALC662_3ST_6ch,
  124. ALC662_5ST_DIG,
  125. ALC662_LENOVO_101E,
  126. ALC662_AUTO,
  127. ALC662_MODEL_LAST,
  128. };
  129. /* ALC882 models */
  130. enum {
  131. ALC882_3ST_DIG,
  132. ALC882_6ST_DIG,
  133. ALC882_ARIMA,
  134. ALC882_W2JC,
  135. ALC882_TARGA,
  136. ALC882_ASUS_A7J,
  137. ALC885_MACPRO,
  138. ALC882_AUTO,
  139. ALC882_MODEL_LAST,
  140. };
  141. /* ALC883 models */
  142. enum {
  143. ALC883_3ST_2ch_DIG,
  144. ALC883_3ST_6ch_DIG,
  145. ALC883_3ST_6ch,
  146. ALC883_6ST_DIG,
  147. ALC883_TARGA_DIG,
  148. ALC883_TARGA_2ch_DIG,
  149. ALC883_ACER,
  150. ALC883_MEDION,
  151. ALC883_MEDION_MD2,
  152. ALC883_LAPTOP_EAPD,
  153. ALC883_LENOVO_101E_2ch,
  154. ALC883_LENOVO_NB0763,
  155. ALC888_LENOVO_MS7195_DIG,
  156. ALC883_AUTO,
  157. ALC883_MODEL_LAST,
  158. };
  159. /* for GPIO Poll */
  160. #define GPIO_MASK 0x03
  161. struct alc_spec {
  162. /* codec parameterization */
  163. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  164. unsigned int num_mixers;
  165. const struct hda_verb *init_verbs[5]; /* initialization verbs
  166. * don't forget NULL
  167. * termination!
  168. */
  169. unsigned int num_init_verbs;
  170. char *stream_name_analog; /* analog PCM stream */
  171. struct hda_pcm_stream *stream_analog_playback;
  172. struct hda_pcm_stream *stream_analog_capture;
  173. char *stream_name_digital; /* digital PCM stream */
  174. struct hda_pcm_stream *stream_digital_playback;
  175. struct hda_pcm_stream *stream_digital_capture;
  176. /* playback */
  177. struct hda_multi_out multiout; /* playback set-up
  178. * max_channels, dacs must be set
  179. * dig_out_nid and hp_nid are optional
  180. */
  181. /* capture */
  182. unsigned int num_adc_nids;
  183. hda_nid_t *adc_nids;
  184. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  185. /* capture source */
  186. unsigned int num_mux_defs;
  187. const struct hda_input_mux *input_mux;
  188. unsigned int cur_mux[3];
  189. /* channel model */
  190. const struct hda_channel_mode *channel_mode;
  191. int num_channel_mode;
  192. int need_dac_fix;
  193. /* PCM information */
  194. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  195. /* dynamic controls, init_verbs and input_mux */
  196. struct auto_pin_cfg autocfg;
  197. unsigned int num_kctl_alloc, num_kctl_used;
  198. struct snd_kcontrol_new *kctl_alloc;
  199. struct hda_input_mux private_imux;
  200. hda_nid_t private_dac_nids[5];
  201. /* hooks */
  202. void (*init_hook)(struct hda_codec *codec);
  203. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  204. /* for pin sensing */
  205. unsigned int sense_updated: 1;
  206. unsigned int jack_present: 1;
  207. };
  208. /*
  209. * configuration template - to be copied to the spec instance
  210. */
  211. struct alc_config_preset {
  212. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  213. * with spec
  214. */
  215. const struct hda_verb *init_verbs[5];
  216. unsigned int num_dacs;
  217. hda_nid_t *dac_nids;
  218. hda_nid_t dig_out_nid; /* optional */
  219. hda_nid_t hp_nid; /* optional */
  220. unsigned int num_adc_nids;
  221. hda_nid_t *adc_nids;
  222. hda_nid_t dig_in_nid;
  223. unsigned int num_channel_mode;
  224. const struct hda_channel_mode *channel_mode;
  225. int need_dac_fix;
  226. unsigned int num_mux_defs;
  227. const struct hda_input_mux *input_mux;
  228. void (*unsol_event)(struct hda_codec *, unsigned int);
  229. void (*init_hook)(struct hda_codec *);
  230. };
  231. /*
  232. * input MUX handling
  233. */
  234. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  235. struct snd_ctl_elem_info *uinfo)
  236. {
  237. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  238. struct alc_spec *spec = codec->spec;
  239. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  240. if (mux_idx >= spec->num_mux_defs)
  241. mux_idx = 0;
  242. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  243. }
  244. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  245. struct snd_ctl_elem_value *ucontrol)
  246. {
  247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  248. struct alc_spec *spec = codec->spec;
  249. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  250. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  251. return 0;
  252. }
  253. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  254. struct snd_ctl_elem_value *ucontrol)
  255. {
  256. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  257. struct alc_spec *spec = codec->spec;
  258. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  259. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  260. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  261. spec->adc_nids[adc_idx],
  262. &spec->cur_mux[adc_idx]);
  263. }
  264. /*
  265. * channel mode setting
  266. */
  267. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_info *uinfo)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  273. spec->num_channel_mode);
  274. }
  275. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  276. struct snd_ctl_elem_value *ucontrol)
  277. {
  278. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  279. struct alc_spec *spec = codec->spec;
  280. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  281. spec->num_channel_mode,
  282. spec->multiout.max_channels);
  283. }
  284. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  285. struct snd_ctl_elem_value *ucontrol)
  286. {
  287. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  288. struct alc_spec *spec = codec->spec;
  289. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  290. spec->num_channel_mode,
  291. &spec->multiout.max_channels);
  292. if (err >= 0 && spec->need_dac_fix)
  293. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  294. return err;
  295. }
  296. /*
  297. * Control the mode of pin widget settings via the mixer. "pc" is used
  298. * instead of "%" to avoid consequences of accidently treating the % as
  299. * being part of a format specifier. Maximum allowed length of a value is
  300. * 63 characters plus NULL terminator.
  301. *
  302. * Note: some retasking pin complexes seem to ignore requests for input
  303. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  304. * are requested. Therefore order this list so that this behaviour will not
  305. * cause problems when mixer clients move through the enum sequentially.
  306. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  307. * March 2006.
  308. */
  309. static char *alc_pin_mode_names[] = {
  310. "Mic 50pc bias", "Mic 80pc bias",
  311. "Line in", "Line out", "Headphone out",
  312. };
  313. static unsigned char alc_pin_mode_values[] = {
  314. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  315. };
  316. /* The control can present all 5 options, or it can limit the options based
  317. * in the pin being assumed to be exclusively an input or an output pin. In
  318. * addition, "input" pins may or may not process the mic bias option
  319. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  320. * accept requests for bias as of chip versions up to March 2006) and/or
  321. * wiring in the computer.
  322. */
  323. #define ALC_PIN_DIR_IN 0x00
  324. #define ALC_PIN_DIR_OUT 0x01
  325. #define ALC_PIN_DIR_INOUT 0x02
  326. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  327. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  328. /* Info about the pin modes supported by the different pin direction modes.
  329. * For each direction the minimum and maximum values are given.
  330. */
  331. static signed char alc_pin_mode_dir_info[5][2] = {
  332. { 0, 2 }, /* ALC_PIN_DIR_IN */
  333. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  334. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  335. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  336. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  337. };
  338. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  339. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  340. #define alc_pin_mode_n_items(_dir) \
  341. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  342. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  343. struct snd_ctl_elem_info *uinfo)
  344. {
  345. unsigned int item_num = uinfo->value.enumerated.item;
  346. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  347. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  348. uinfo->count = 1;
  349. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  350. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  351. item_num = alc_pin_mode_min(dir);
  352. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  353. return 0;
  354. }
  355. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  356. struct snd_ctl_elem_value *ucontrol)
  357. {
  358. unsigned int i;
  359. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  360. hda_nid_t nid = kcontrol->private_value & 0xffff;
  361. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  362. long *valp = ucontrol->value.integer.value;
  363. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  364. AC_VERB_GET_PIN_WIDGET_CONTROL,
  365. 0x00);
  366. /* Find enumerated value for current pinctl setting */
  367. i = alc_pin_mode_min(dir);
  368. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  369. i++;
  370. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  371. return 0;
  372. }
  373. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  374. struct snd_ctl_elem_value *ucontrol)
  375. {
  376. signed int change;
  377. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  378. hda_nid_t nid = kcontrol->private_value & 0xffff;
  379. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  380. long val = *ucontrol->value.integer.value;
  381. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  382. AC_VERB_GET_PIN_WIDGET_CONTROL,
  383. 0x00);
  384. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  385. val = alc_pin_mode_min(dir);
  386. change = pinctl != alc_pin_mode_values[val];
  387. if (change) {
  388. /* Set pin mode to that requested */
  389. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  390. alc_pin_mode_values[val]);
  391. /* Also enable the retasking pin's input/output as required
  392. * for the requested pin mode. Enum values of 2 or less are
  393. * input modes.
  394. *
  395. * Dynamically switching the input/output buffers probably
  396. * reduces noise slightly (particularly on input) so we'll
  397. * do it. However, having both input and output buffers
  398. * enabled simultaneously doesn't seem to be problematic if
  399. * this turns out to be necessary in the future.
  400. */
  401. if (val <= 2) {
  402. snd_hda_codec_write(codec, nid, 0,
  403. AC_VERB_SET_AMP_GAIN_MUTE,
  404. AMP_OUT_MUTE);
  405. snd_hda_codec_write(codec, nid, 0,
  406. AC_VERB_SET_AMP_GAIN_MUTE,
  407. AMP_IN_UNMUTE(0));
  408. } else {
  409. snd_hda_codec_write(codec, nid, 0,
  410. AC_VERB_SET_AMP_GAIN_MUTE,
  411. AMP_IN_MUTE(0));
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_OUT_UNMUTE);
  415. }
  416. }
  417. return change;
  418. }
  419. #define ALC_PIN_MODE(xname, nid, dir) \
  420. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  421. .info = alc_pin_mode_info, \
  422. .get = alc_pin_mode_get, \
  423. .put = alc_pin_mode_put, \
  424. .private_value = nid | (dir<<16) }
  425. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  426. * together using a mask with more than one bit set. This control is
  427. * currently used only by the ALC260 test model. At this stage they are not
  428. * needed for any "production" models.
  429. */
  430. #ifdef CONFIG_SND_DEBUG
  431. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_info *uinfo)
  433. {
  434. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  435. uinfo->count = 1;
  436. uinfo->value.integer.min = 0;
  437. uinfo->value.integer.max = 1;
  438. return 0;
  439. }
  440. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  441. struct snd_ctl_elem_value *ucontrol)
  442. {
  443. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  444. hda_nid_t nid = kcontrol->private_value & 0xffff;
  445. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  446. long *valp = ucontrol->value.integer.value;
  447. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  448. AC_VERB_GET_GPIO_DATA, 0x00);
  449. *valp = (val & mask) != 0;
  450. return 0;
  451. }
  452. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  453. struct snd_ctl_elem_value *ucontrol)
  454. {
  455. signed int change;
  456. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  457. hda_nid_t nid = kcontrol->private_value & 0xffff;
  458. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  459. long val = *ucontrol->value.integer.value;
  460. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  461. AC_VERB_GET_GPIO_DATA,
  462. 0x00);
  463. /* Set/unset the masked GPIO bit(s) as needed */
  464. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  465. if (val == 0)
  466. gpio_data &= ~mask;
  467. else
  468. gpio_data |= mask;
  469. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  470. return change;
  471. }
  472. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  473. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  474. .info = alc_gpio_data_info, \
  475. .get = alc_gpio_data_get, \
  476. .put = alc_gpio_data_put, \
  477. .private_value = nid | (mask<<16) }
  478. #endif /* CONFIG_SND_DEBUG */
  479. /* A switch control to allow the enabling of the digital IO pins on the
  480. * ALC260. This is incredibly simplistic; the intention of this control is
  481. * to provide something in the test model allowing digital outputs to be
  482. * identified if present. If models are found which can utilise these
  483. * outputs a more complete mixer control can be devised for those models if
  484. * necessary.
  485. */
  486. #ifdef CONFIG_SND_DEBUG
  487. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  488. struct snd_ctl_elem_info *uinfo)
  489. {
  490. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  491. uinfo->count = 1;
  492. uinfo->value.integer.min = 0;
  493. uinfo->value.integer.max = 1;
  494. return 0;
  495. }
  496. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  497. struct snd_ctl_elem_value *ucontrol)
  498. {
  499. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  500. hda_nid_t nid = kcontrol->private_value & 0xffff;
  501. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  502. long *valp = ucontrol->value.integer.value;
  503. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  504. AC_VERB_GET_DIGI_CONVERT, 0x00);
  505. *valp = (val & mask) != 0;
  506. return 0;
  507. }
  508. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  509. struct snd_ctl_elem_value *ucontrol)
  510. {
  511. signed int change;
  512. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  513. hda_nid_t nid = kcontrol->private_value & 0xffff;
  514. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  515. long val = *ucontrol->value.integer.value;
  516. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  517. AC_VERB_GET_DIGI_CONVERT,
  518. 0x00);
  519. /* Set/unset the masked control bit(s) as needed */
  520. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  521. if (val==0)
  522. ctrl_data &= ~mask;
  523. else
  524. ctrl_data |= mask;
  525. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  526. ctrl_data);
  527. return change;
  528. }
  529. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  530. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  531. .info = alc_spdif_ctrl_info, \
  532. .get = alc_spdif_ctrl_get, \
  533. .put = alc_spdif_ctrl_put, \
  534. .private_value = nid | (mask<<16) }
  535. #endif /* CONFIG_SND_DEBUG */
  536. /*
  537. * set up from the preset table
  538. */
  539. static void setup_preset(struct alc_spec *spec,
  540. const struct alc_config_preset *preset)
  541. {
  542. int i;
  543. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  544. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  545. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  546. i++)
  547. spec->init_verbs[spec->num_init_verbs++] =
  548. preset->init_verbs[i];
  549. spec->channel_mode = preset->channel_mode;
  550. spec->num_channel_mode = preset->num_channel_mode;
  551. spec->need_dac_fix = preset->need_dac_fix;
  552. spec->multiout.max_channels = spec->channel_mode[0].channels;
  553. spec->multiout.num_dacs = preset->num_dacs;
  554. spec->multiout.dac_nids = preset->dac_nids;
  555. spec->multiout.dig_out_nid = preset->dig_out_nid;
  556. spec->multiout.hp_nid = preset->hp_nid;
  557. spec->num_mux_defs = preset->num_mux_defs;
  558. if (!spec->num_mux_defs)
  559. spec->num_mux_defs = 1;
  560. spec->input_mux = preset->input_mux;
  561. spec->num_adc_nids = preset->num_adc_nids;
  562. spec->adc_nids = preset->adc_nids;
  563. spec->dig_in_nid = preset->dig_in_nid;
  564. spec->unsol_event = preset->unsol_event;
  565. spec->init_hook = preset->init_hook;
  566. }
  567. /* Enable GPIO mask and set output */
  568. static struct hda_verb alc_gpio1_init_verbs[] = {
  569. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  570. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  571. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  572. { }
  573. };
  574. static struct hda_verb alc_gpio2_init_verbs[] = {
  575. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  576. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  577. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  578. { }
  579. };
  580. static struct hda_verb alc_gpio3_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  584. { }
  585. };
  586. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  587. * 31 ~ 16 : Manufacture ID
  588. * 15 ~ 8 : SKU ID
  589. * 7 ~ 0 : Assembly ID
  590. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  591. */
  592. static void alc_subsystem_id(struct hda_codec *codec,
  593. unsigned int porta, unsigned int porte,
  594. unsigned int portd)
  595. {
  596. unsigned int ass, tmp;
  597. ass = codec->subsystem_id;
  598. if (!(ass & 1))
  599. return;
  600. /* Override */
  601. tmp = (ass & 0x38) >> 3; /* external Amp control */
  602. switch (tmp) {
  603. case 1:
  604. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  605. break;
  606. case 3:
  607. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  608. break;
  609. case 7:
  610. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  611. break;
  612. case 5:
  613. switch (codec->vendor_id) {
  614. case 0x10ec0862:
  615. case 0x10ec0660:
  616. case 0x10ec0662:
  617. case 0x10ec0267:
  618. case 0x10ec0268:
  619. snd_hda_codec_write(codec, 0x14, 0,
  620. AC_VERB_SET_EAPD_BTLENABLE, 2);
  621. snd_hda_codec_write(codec, 0x15, 0,
  622. AC_VERB_SET_EAPD_BTLENABLE, 2);
  623. return;
  624. }
  625. case 6:
  626. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  627. hda_nid_t port = 0;
  628. tmp = (ass & 0x1800) >> 11;
  629. switch (tmp) {
  630. case 0: port = porta; break;
  631. case 1: port = porte; break;
  632. case 2: port = portd; break;
  633. }
  634. if (port)
  635. snd_hda_codec_write(codec, port, 0,
  636. AC_VERB_SET_EAPD_BTLENABLE,
  637. 2);
  638. }
  639. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  640. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  641. (tmp == 5 ? 0x3040 : 0x3050));
  642. break;
  643. }
  644. }
  645. /*
  646. * ALC880 3-stack model
  647. *
  648. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  649. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  650. * F-Mic = 0x1b, HP = 0x19
  651. */
  652. static hda_nid_t alc880_dac_nids[4] = {
  653. /* front, rear, clfe, rear_surr */
  654. 0x02, 0x05, 0x04, 0x03
  655. };
  656. static hda_nid_t alc880_adc_nids[3] = {
  657. /* ADC0-2 */
  658. 0x07, 0x08, 0x09,
  659. };
  660. /* The datasheet says the node 0x07 is connected from inputs,
  661. * but it shows zero connection in the real implementation on some devices.
  662. * Note: this is a 915GAV bug, fixed on 915GLV
  663. */
  664. static hda_nid_t alc880_adc_nids_alt[2] = {
  665. /* ADC1-2 */
  666. 0x08, 0x09,
  667. };
  668. #define ALC880_DIGOUT_NID 0x06
  669. #define ALC880_DIGIN_NID 0x0a
  670. static struct hda_input_mux alc880_capture_source = {
  671. .num_items = 4,
  672. .items = {
  673. { "Mic", 0x0 },
  674. { "Front Mic", 0x3 },
  675. { "Line", 0x2 },
  676. { "CD", 0x4 },
  677. },
  678. };
  679. /* channel source setting (2/6 channel selection for 3-stack) */
  680. /* 2ch mode */
  681. static struct hda_verb alc880_threestack_ch2_init[] = {
  682. /* set line-in to input, mute it */
  683. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  684. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  685. /* set mic-in to input vref 80%, mute it */
  686. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  687. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  688. { } /* end */
  689. };
  690. /* 6ch mode */
  691. static struct hda_verb alc880_threestack_ch6_init[] = {
  692. /* set line-in to output, unmute it */
  693. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  694. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  695. /* set mic-in to output, unmute it */
  696. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  697. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  698. { } /* end */
  699. };
  700. static struct hda_channel_mode alc880_threestack_modes[2] = {
  701. { 2, alc880_threestack_ch2_init },
  702. { 6, alc880_threestack_ch6_init },
  703. };
  704. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  705. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  706. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  707. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  708. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  709. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  710. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  711. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  712. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  713. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  714. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  715. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  716. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  717. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  718. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  719. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  720. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  721. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  722. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  723. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  724. {
  725. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  726. .name = "Channel Mode",
  727. .info = alc_ch_mode_info,
  728. .get = alc_ch_mode_get,
  729. .put = alc_ch_mode_put,
  730. },
  731. { } /* end */
  732. };
  733. /* capture mixer elements */
  734. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  735. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  736. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  737. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  738. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  739. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  740. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  741. {
  742. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  743. /* The multiple "Capture Source" controls confuse alsamixer
  744. * So call somewhat different..
  745. * FIXME: the controls appear in the "playback" view!
  746. */
  747. /* .name = "Capture Source", */
  748. .name = "Input Source",
  749. .count = 3,
  750. .info = alc_mux_enum_info,
  751. .get = alc_mux_enum_get,
  752. .put = alc_mux_enum_put,
  753. },
  754. { } /* end */
  755. };
  756. /* capture mixer elements (in case NID 0x07 not available) */
  757. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  758. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  759. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  760. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  761. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  762. {
  763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  764. /* The multiple "Capture Source" controls confuse alsamixer
  765. * So call somewhat different..
  766. * FIXME: the controls appear in the "playback" view!
  767. */
  768. /* .name = "Capture Source", */
  769. .name = "Input Source",
  770. .count = 2,
  771. .info = alc_mux_enum_info,
  772. .get = alc_mux_enum_get,
  773. .put = alc_mux_enum_put,
  774. },
  775. { } /* end */
  776. };
  777. /*
  778. * ALC880 5-stack model
  779. *
  780. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  781. * Side = 0x02 (0xd)
  782. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  783. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  784. */
  785. /* additional mixers to alc880_three_stack_mixer */
  786. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  787. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  788. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  789. { } /* end */
  790. };
  791. /* channel source setting (6/8 channel selection for 5-stack) */
  792. /* 6ch mode */
  793. static struct hda_verb alc880_fivestack_ch6_init[] = {
  794. /* set line-in to input, mute it */
  795. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  796. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  797. { } /* end */
  798. };
  799. /* 8ch mode */
  800. static struct hda_verb alc880_fivestack_ch8_init[] = {
  801. /* set line-in to output, unmute it */
  802. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  803. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  804. { } /* end */
  805. };
  806. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  807. { 6, alc880_fivestack_ch6_init },
  808. { 8, alc880_fivestack_ch8_init },
  809. };
  810. /*
  811. * ALC880 6-stack model
  812. *
  813. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  814. * Side = 0x05 (0x0f)
  815. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  816. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  817. */
  818. static hda_nid_t alc880_6st_dac_nids[4] = {
  819. /* front, rear, clfe, rear_surr */
  820. 0x02, 0x03, 0x04, 0x05
  821. };
  822. static struct hda_input_mux alc880_6stack_capture_source = {
  823. .num_items = 4,
  824. .items = {
  825. { "Mic", 0x0 },
  826. { "Front Mic", 0x1 },
  827. { "Line", 0x2 },
  828. { "CD", 0x4 },
  829. },
  830. };
  831. /* fixed 8-channels */
  832. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  833. { 8, NULL },
  834. };
  835. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  836. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  837. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  838. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  839. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  840. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  841. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  842. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  843. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  844. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  845. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  846. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  847. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  848. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  849. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  850. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  851. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  852. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  853. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  854. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  855. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  856. {
  857. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  858. .name = "Channel Mode",
  859. .info = alc_ch_mode_info,
  860. .get = alc_ch_mode_get,
  861. .put = alc_ch_mode_put,
  862. },
  863. { } /* end */
  864. };
  865. /*
  866. * ALC880 W810 model
  867. *
  868. * W810 has rear IO for:
  869. * Front (DAC 02)
  870. * Surround (DAC 03)
  871. * Center/LFE (DAC 04)
  872. * Digital out (06)
  873. *
  874. * The system also has a pair of internal speakers, and a headphone jack.
  875. * These are both connected to Line2 on the codec, hence to DAC 02.
  876. *
  877. * There is a variable resistor to control the speaker or headphone
  878. * volume. This is a hardware-only device without a software API.
  879. *
  880. * Plugging headphones in will disable the internal speakers. This is
  881. * implemented in hardware, not via the driver using jack sense. In
  882. * a similar fashion, plugging into the rear socket marked "front" will
  883. * disable both the speakers and headphones.
  884. *
  885. * For input, there's a microphone jack, and an "audio in" jack.
  886. * These may not do anything useful with this driver yet, because I
  887. * haven't setup any initialization verbs for these yet...
  888. */
  889. static hda_nid_t alc880_w810_dac_nids[3] = {
  890. /* front, rear/surround, clfe */
  891. 0x02, 0x03, 0x04
  892. };
  893. /* fixed 6 channels */
  894. static struct hda_channel_mode alc880_w810_modes[1] = {
  895. { 6, NULL }
  896. };
  897. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  898. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  899. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  900. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  901. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  902. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  903. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  904. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  905. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  906. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  907. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  908. { } /* end */
  909. };
  910. /*
  911. * Z710V model
  912. *
  913. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  914. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  915. * Line = 0x1a
  916. */
  917. static hda_nid_t alc880_z71v_dac_nids[1] = {
  918. 0x02
  919. };
  920. #define ALC880_Z71V_HP_DAC 0x03
  921. /* fixed 2 channels */
  922. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  923. { 2, NULL }
  924. };
  925. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  926. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  927. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  928. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  929. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  930. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  931. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  932. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  933. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  934. { } /* end */
  935. };
  936. /* FIXME! */
  937. /*
  938. * ALC880 F1734 model
  939. *
  940. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  941. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  942. */
  943. static hda_nid_t alc880_f1734_dac_nids[1] = {
  944. 0x03
  945. };
  946. #define ALC880_F1734_HP_DAC 0x02
  947. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  948. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  949. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  950. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  951. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  952. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  953. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  954. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  955. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  956. { } /* end */
  957. };
  958. /* FIXME! */
  959. /*
  960. * ALC880 ASUS model
  961. *
  962. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  963. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  964. * Mic = 0x18, Line = 0x1a
  965. */
  966. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  967. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  968. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  969. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  970. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  971. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  972. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  973. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  974. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  975. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  976. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  977. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  978. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  979. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  980. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  981. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  982. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  983. {
  984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  985. .name = "Channel Mode",
  986. .info = alc_ch_mode_info,
  987. .get = alc_ch_mode_get,
  988. .put = alc_ch_mode_put,
  989. },
  990. { } /* end */
  991. };
  992. /* FIXME! */
  993. /*
  994. * ALC880 ASUS W1V model
  995. *
  996. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  997. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  998. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  999. */
  1000. /* additional mixers to alc880_asus_mixer */
  1001. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1002. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1003. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1004. { } /* end */
  1005. };
  1006. /* additional mixers to alc880_asus_mixer */
  1007. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1008. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1009. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1010. { } /* end */
  1011. };
  1012. /* TCL S700 */
  1013. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1014. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1015. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1016. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1017. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1018. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1020. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1021. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1022. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1023. {
  1024. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1025. /* The multiple "Capture Source" controls confuse alsamixer
  1026. * So call somewhat different..
  1027. * FIXME: the controls appear in the "playback" view!
  1028. */
  1029. /* .name = "Capture Source", */
  1030. .name = "Input Source",
  1031. .count = 1,
  1032. .info = alc_mux_enum_info,
  1033. .get = alc_mux_enum_get,
  1034. .put = alc_mux_enum_put,
  1035. },
  1036. { } /* end */
  1037. };
  1038. /* Uniwill */
  1039. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1040. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1041. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1042. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1043. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1044. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1045. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1046. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1047. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1048. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1049. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1050. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1051. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1052. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1053. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1057. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1058. {
  1059. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1060. .name = "Channel Mode",
  1061. .info = alc_ch_mode_info,
  1062. .get = alc_ch_mode_get,
  1063. .put = alc_ch_mode_put,
  1064. },
  1065. { } /* end */
  1066. };
  1067. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1068. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1069. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1070. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1071. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1072. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1073. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1074. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1075. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1077. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1078. { } /* end */
  1079. };
  1080. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1081. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1082. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1084. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1087. { } /* end */
  1088. };
  1089. /*
  1090. * build control elements
  1091. */
  1092. static int alc_build_controls(struct hda_codec *codec)
  1093. {
  1094. struct alc_spec *spec = codec->spec;
  1095. int err;
  1096. int i;
  1097. for (i = 0; i < spec->num_mixers; i++) {
  1098. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1099. if (err < 0)
  1100. return err;
  1101. }
  1102. if (spec->multiout.dig_out_nid) {
  1103. err = snd_hda_create_spdif_out_ctls(codec,
  1104. spec->multiout.dig_out_nid);
  1105. if (err < 0)
  1106. return err;
  1107. }
  1108. if (spec->dig_in_nid) {
  1109. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1110. if (err < 0)
  1111. return err;
  1112. }
  1113. return 0;
  1114. }
  1115. /*
  1116. * initialize the codec volumes, etc
  1117. */
  1118. /*
  1119. * generic initialization of ADC, input mixers and output mixers
  1120. */
  1121. static struct hda_verb alc880_volume_init_verbs[] = {
  1122. /*
  1123. * Unmute ADC0-2 and set the default input to mic-in
  1124. */
  1125. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1126. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1127. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1128. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1129. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1130. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1131. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1132. * mixer widget
  1133. * Note: PASD motherboards uses the Line In 2 as the input for front
  1134. * panel mic (mic 2)
  1135. */
  1136. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1137. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1138. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1139. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1140. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1141. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1142. /*
  1143. * Set up output mixers (0x0c - 0x0f)
  1144. */
  1145. /* set vol=0 to output mixers */
  1146. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1147. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1148. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1149. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1150. /* set up input amps for analog loopback */
  1151. /* Amp Indices: DAC = 0, mixer = 1 */
  1152. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1153. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1154. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1155. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1156. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1157. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1158. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1159. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1160. { }
  1161. };
  1162. /*
  1163. * 3-stack pin configuration:
  1164. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1165. */
  1166. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1167. /*
  1168. * preset connection lists of input pins
  1169. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1170. */
  1171. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1172. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1173. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1174. /*
  1175. * Set pin mode and muting
  1176. */
  1177. /* set front pin widgets 0x14 for output */
  1178. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1179. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1180. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1181. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1182. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1183. /* Mic2 (as headphone out) for HP output */
  1184. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1185. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. /* Line In pin widget for input */
  1187. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1188. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1190. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1191. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1192. /* CD pin widget for input */
  1193. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. { }
  1195. };
  1196. /*
  1197. * 5-stack pin configuration:
  1198. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1199. * line-in/side = 0x1a, f-mic = 0x1b
  1200. */
  1201. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1202. /*
  1203. * preset connection lists of input pins
  1204. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1205. */
  1206. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1207. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1208. /*
  1209. * Set pin mode and muting
  1210. */
  1211. /* set pin widgets 0x14-0x17 for output */
  1212. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1213. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1214. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1215. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. /* unmute pins for output (no gain on this amp) */
  1217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1219. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1220. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1221. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1222. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1223. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1224. /* Mic2 (as headphone out) for HP output */
  1225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1226. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. /* Line In pin widget for input */
  1228. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1229. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1231. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1232. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1233. /* CD pin widget for input */
  1234. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1235. { }
  1236. };
  1237. /*
  1238. * W810 pin configuration:
  1239. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1240. */
  1241. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1242. /* hphone/speaker input selector: front DAC */
  1243. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1244. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1245. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1246. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1247. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1248. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1249. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1250. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1251. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1252. { }
  1253. };
  1254. /*
  1255. * Z71V pin configuration:
  1256. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1257. */
  1258. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1259. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1261. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1262. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1263. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1264. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1265. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1266. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. { }
  1268. };
  1269. /*
  1270. * 6-stack pin configuration:
  1271. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1272. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1273. */
  1274. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1275. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1276. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1277. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1278. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1279. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1280. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1281. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1282. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1285. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1286. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1287. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1288. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1289. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1290. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1291. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1292. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1293. { }
  1294. };
  1295. /*
  1296. * Uniwill pin configuration:
  1297. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1298. * line = 0x1a
  1299. */
  1300. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1301. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1302. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1303. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1304. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1306. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1307. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1308. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1309. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1311. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1312. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1313. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1314. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1315. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1316. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1317. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1318. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1320. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1321. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1323. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1324. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1325. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1326. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1327. { }
  1328. };
  1329. /*
  1330. * Uniwill P53
  1331. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1332. */
  1333. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1334. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1335. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1336. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1337. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1338. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1339. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1342. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1343. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1344. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1345. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1346. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1347. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1348. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1349. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1350. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1351. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1352. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1353. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1354. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1355. { }
  1356. };
  1357. static struct hda_verb alc880_beep_init_verbs[] = {
  1358. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1359. { }
  1360. };
  1361. /* toggle speaker-output according to the hp-jack state */
  1362. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1363. {
  1364. unsigned int present;
  1365. unsigned char bits;
  1366. present = snd_hda_codec_read(codec, 0x14, 0,
  1367. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1368. bits = present ? 0x80 : 0;
  1369. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1370. 0x80, bits);
  1371. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1372. 0x80, bits);
  1373. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1374. 0x80, bits);
  1375. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1376. 0x80, bits);
  1377. }
  1378. /* auto-toggle front mic */
  1379. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1380. {
  1381. unsigned int present;
  1382. unsigned char bits;
  1383. present = snd_hda_codec_read(codec, 0x18, 0,
  1384. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1385. bits = present ? 0x80 : 0;
  1386. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1387. 0x80, bits);
  1388. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1389. 0x80, bits);
  1390. }
  1391. static void alc880_uniwill_automute(struct hda_codec *codec)
  1392. {
  1393. alc880_uniwill_hp_automute(codec);
  1394. alc880_uniwill_mic_automute(codec);
  1395. }
  1396. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1397. unsigned int res)
  1398. {
  1399. /* Looks like the unsol event is incompatible with the standard
  1400. * definition. 4bit tag is placed at 28 bit!
  1401. */
  1402. switch (res >> 28) {
  1403. case ALC880_HP_EVENT:
  1404. alc880_uniwill_hp_automute(codec);
  1405. break;
  1406. case ALC880_MIC_EVENT:
  1407. alc880_uniwill_mic_automute(codec);
  1408. break;
  1409. }
  1410. }
  1411. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1412. {
  1413. unsigned int present;
  1414. unsigned char bits;
  1415. present = snd_hda_codec_read(codec, 0x14, 0,
  1416. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1417. bits = present ? 0x80 : 0;
  1418. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1419. 0x80, bits);
  1420. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1421. 0x80, bits);
  1422. }
  1423. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1424. {
  1425. unsigned int present;
  1426. present = snd_hda_codec_read(codec, 0x21, 0,
  1427. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1428. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1429. 0x7f, present);
  1430. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1431. 0x7f, present);
  1432. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1433. 0x7f, present);
  1434. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1435. 0x7f, present);
  1436. }
  1437. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1438. unsigned int res)
  1439. {
  1440. /* Looks like the unsol event is incompatible with the standard
  1441. * definition. 4bit tag is placed at 28 bit!
  1442. */
  1443. if ((res >> 28) == ALC880_HP_EVENT)
  1444. alc880_uniwill_p53_hp_automute(codec);
  1445. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1446. alc880_uniwill_p53_dcvol_automute(codec);
  1447. }
  1448. /* FIXME! */
  1449. /*
  1450. * F1734 pin configuration:
  1451. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1452. */
  1453. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1454. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1455. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1456. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1457. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1458. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1459. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1460. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1461. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1462. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1463. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1464. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1465. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1466. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1467. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1468. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1469. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1470. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1471. { }
  1472. };
  1473. /* FIXME! */
  1474. /*
  1475. * ASUS pin configuration:
  1476. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1477. */
  1478. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1479. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1480. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1482. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1486. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1487. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1488. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1489. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1492. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1493. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1495. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1497. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1499. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1500. { }
  1501. };
  1502. /* Enable GPIO mask and set output */
  1503. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1504. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1505. /* Clevo m520g init */
  1506. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1507. /* headphone output */
  1508. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1509. /* line-out */
  1510. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. /* Line-in */
  1513. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1514. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. /* CD */
  1516. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1517. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1518. /* Mic1 (rear panel) */
  1519. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1520. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. /* Mic2 (front panel) */
  1522. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1523. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. /* headphone */
  1525. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1526. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1527. /* change to EAPD mode */
  1528. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1529. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1530. { }
  1531. };
  1532. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1533. /* change to EAPD mode */
  1534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1536. /* Headphone output */
  1537. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1538. /* Front output*/
  1539. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1540. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1541. /* Line In pin widget for input */
  1542. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1543. /* CD pin widget for input */
  1544. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1545. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1546. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1547. /* change to EAPD mode */
  1548. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1549. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1550. { }
  1551. };
  1552. /*
  1553. * LG m1 express dual
  1554. *
  1555. * Pin assignment:
  1556. * Rear Line-In/Out (blue): 0x14
  1557. * Build-in Mic-In: 0x15
  1558. * Speaker-out: 0x17
  1559. * HP-Out (green): 0x1b
  1560. * Mic-In/Out (red): 0x19
  1561. * SPDIF-Out: 0x1e
  1562. */
  1563. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1564. static hda_nid_t alc880_lg_dac_nids[3] = {
  1565. 0x05, 0x02, 0x03
  1566. };
  1567. /* seems analog CD is not working */
  1568. static struct hda_input_mux alc880_lg_capture_source = {
  1569. .num_items = 3,
  1570. .items = {
  1571. { "Mic", 0x1 },
  1572. { "Line", 0x5 },
  1573. { "Internal Mic", 0x6 },
  1574. },
  1575. };
  1576. /* 2,4,6 channel modes */
  1577. static struct hda_verb alc880_lg_ch2_init[] = {
  1578. /* set line-in and mic-in to input */
  1579. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1580. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1581. { }
  1582. };
  1583. static struct hda_verb alc880_lg_ch4_init[] = {
  1584. /* set line-in to out and mic-in to input */
  1585. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1586. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1587. { }
  1588. };
  1589. static struct hda_verb alc880_lg_ch6_init[] = {
  1590. /* set line-in and mic-in to output */
  1591. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1592. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1593. { }
  1594. };
  1595. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1596. { 2, alc880_lg_ch2_init },
  1597. { 4, alc880_lg_ch4_init },
  1598. { 6, alc880_lg_ch6_init },
  1599. };
  1600. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1601. /* FIXME: it's not really "master" but front channels */
  1602. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1603. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1604. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1605. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1606. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1607. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1608. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1609. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1610. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1611. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1612. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1613. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1614. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1615. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1616. {
  1617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1618. .name = "Channel Mode",
  1619. .info = alc_ch_mode_info,
  1620. .get = alc_ch_mode_get,
  1621. .put = alc_ch_mode_put,
  1622. },
  1623. { } /* end */
  1624. };
  1625. static struct hda_verb alc880_lg_init_verbs[] = {
  1626. /* set capture source to mic-in */
  1627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1628. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1629. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1630. /* mute all amp mixer inputs */
  1631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1634. /* line-in to input */
  1635. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1636. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1637. /* built-in mic */
  1638. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1639. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1640. /* speaker-out */
  1641. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1642. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1643. /* mic-in to input */
  1644. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1645. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1646. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* HP-out */
  1648. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1649. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1650. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1651. /* jack sense */
  1652. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1653. { }
  1654. };
  1655. /* toggle speaker-output according to the hp-jack state */
  1656. static void alc880_lg_automute(struct hda_codec *codec)
  1657. {
  1658. unsigned int present;
  1659. unsigned char bits;
  1660. present = snd_hda_codec_read(codec, 0x1b, 0,
  1661. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1662. bits = present ? 0x80 : 0;
  1663. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1664. 0x80, bits);
  1665. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1666. 0x80, bits);
  1667. }
  1668. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1669. {
  1670. /* Looks like the unsol event is incompatible with the standard
  1671. * definition. 4bit tag is placed at 28 bit!
  1672. */
  1673. if ((res >> 28) == 0x01)
  1674. alc880_lg_automute(codec);
  1675. }
  1676. /*
  1677. * LG LW20
  1678. *
  1679. * Pin assignment:
  1680. * Speaker-out: 0x14
  1681. * Mic-In: 0x18
  1682. * Built-in Mic-In: 0x19 (?)
  1683. * HP-Out: 0x1b
  1684. * SPDIF-Out: 0x1e
  1685. */
  1686. /* seems analog CD is not working */
  1687. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1688. .num_items = 2,
  1689. .items = {
  1690. { "Mic", 0x0 },
  1691. { "Internal Mic", 0x1 },
  1692. },
  1693. };
  1694. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1695. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1696. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1697. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1698. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1699. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1700. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1701. { } /* end */
  1702. };
  1703. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1704. /* set capture source to mic-in */
  1705. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1706. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1707. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1709. /* speaker-out */
  1710. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1711. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1712. /* HP-out */
  1713. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1714. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1715. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1716. /* mic-in to input */
  1717. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1718. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1719. /* built-in mic */
  1720. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1721. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1722. /* jack sense */
  1723. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1724. { }
  1725. };
  1726. /* toggle speaker-output according to the hp-jack state */
  1727. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1728. {
  1729. unsigned int present;
  1730. unsigned char bits;
  1731. present = snd_hda_codec_read(codec, 0x1b, 0,
  1732. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1733. bits = present ? 0x80 : 0;
  1734. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1735. 0x80, bits);
  1736. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1737. 0x80, bits);
  1738. }
  1739. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1740. {
  1741. /* Looks like the unsol event is incompatible with the standard
  1742. * definition. 4bit tag is placed at 28 bit!
  1743. */
  1744. if ((res >> 28) == 0x01)
  1745. alc880_lg_lw_automute(codec);
  1746. }
  1747. /*
  1748. * Common callbacks
  1749. */
  1750. static int alc_init(struct hda_codec *codec)
  1751. {
  1752. struct alc_spec *spec = codec->spec;
  1753. unsigned int i;
  1754. for (i = 0; i < spec->num_init_verbs; i++)
  1755. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1756. if (spec->init_hook)
  1757. spec->init_hook(codec);
  1758. return 0;
  1759. }
  1760. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1761. {
  1762. struct alc_spec *spec = codec->spec;
  1763. if (spec->unsol_event)
  1764. spec->unsol_event(codec, res);
  1765. }
  1766. #ifdef CONFIG_PM
  1767. /*
  1768. * resume
  1769. */
  1770. static int alc_resume(struct hda_codec *codec)
  1771. {
  1772. struct alc_spec *spec = codec->spec;
  1773. int i;
  1774. alc_init(codec);
  1775. for (i = 0; i < spec->num_mixers; i++)
  1776. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1777. if (spec->multiout.dig_out_nid)
  1778. snd_hda_resume_spdif_out(codec);
  1779. if (spec->dig_in_nid)
  1780. snd_hda_resume_spdif_in(codec);
  1781. return 0;
  1782. }
  1783. #endif
  1784. /*
  1785. * Analog playback callbacks
  1786. */
  1787. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1788. struct hda_codec *codec,
  1789. struct snd_pcm_substream *substream)
  1790. {
  1791. struct alc_spec *spec = codec->spec;
  1792. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1793. }
  1794. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1795. struct hda_codec *codec,
  1796. unsigned int stream_tag,
  1797. unsigned int format,
  1798. struct snd_pcm_substream *substream)
  1799. {
  1800. struct alc_spec *spec = codec->spec;
  1801. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1802. stream_tag, format, substream);
  1803. }
  1804. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1805. struct hda_codec *codec,
  1806. struct snd_pcm_substream *substream)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1810. }
  1811. /*
  1812. * Digital out
  1813. */
  1814. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1815. struct hda_codec *codec,
  1816. struct snd_pcm_substream *substream)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1820. }
  1821. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1822. struct hda_codec *codec,
  1823. unsigned int stream_tag,
  1824. unsigned int format,
  1825. struct snd_pcm_substream *substream)
  1826. {
  1827. struct alc_spec *spec = codec->spec;
  1828. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1829. stream_tag, format, substream);
  1830. }
  1831. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1832. struct hda_codec *codec,
  1833. struct snd_pcm_substream *substream)
  1834. {
  1835. struct alc_spec *spec = codec->spec;
  1836. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1837. }
  1838. /*
  1839. * Analog capture
  1840. */
  1841. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1842. struct hda_codec *codec,
  1843. unsigned int stream_tag,
  1844. unsigned int format,
  1845. struct snd_pcm_substream *substream)
  1846. {
  1847. struct alc_spec *spec = codec->spec;
  1848. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1849. stream_tag, 0, format);
  1850. return 0;
  1851. }
  1852. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1853. struct hda_codec *codec,
  1854. struct snd_pcm_substream *substream)
  1855. {
  1856. struct alc_spec *spec = codec->spec;
  1857. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1858. 0, 0, 0);
  1859. return 0;
  1860. }
  1861. /*
  1862. */
  1863. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1864. .substreams = 1,
  1865. .channels_min = 2,
  1866. .channels_max = 8,
  1867. /* NID is set in alc_build_pcms */
  1868. .ops = {
  1869. .open = alc880_playback_pcm_open,
  1870. .prepare = alc880_playback_pcm_prepare,
  1871. .cleanup = alc880_playback_pcm_cleanup
  1872. },
  1873. };
  1874. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1875. .substreams = 2,
  1876. .channels_min = 2,
  1877. .channels_max = 2,
  1878. /* NID is set in alc_build_pcms */
  1879. .ops = {
  1880. .prepare = alc880_capture_pcm_prepare,
  1881. .cleanup = alc880_capture_pcm_cleanup
  1882. },
  1883. };
  1884. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1885. .substreams = 1,
  1886. .channels_min = 2,
  1887. .channels_max = 2,
  1888. /* NID is set in alc_build_pcms */
  1889. .ops = {
  1890. .open = alc880_dig_playback_pcm_open,
  1891. .close = alc880_dig_playback_pcm_close,
  1892. .prepare = alc880_dig_playback_pcm_prepare
  1893. },
  1894. };
  1895. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1896. .substreams = 1,
  1897. .channels_min = 2,
  1898. .channels_max = 2,
  1899. /* NID is set in alc_build_pcms */
  1900. };
  1901. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1902. static struct hda_pcm_stream alc_pcm_null_playback = {
  1903. .substreams = 0,
  1904. .channels_min = 0,
  1905. .channels_max = 0,
  1906. };
  1907. static int alc_build_pcms(struct hda_codec *codec)
  1908. {
  1909. struct alc_spec *spec = codec->spec;
  1910. struct hda_pcm *info = spec->pcm_rec;
  1911. int i;
  1912. codec->num_pcms = 1;
  1913. codec->pcm_info = info;
  1914. info->name = spec->stream_name_analog;
  1915. if (spec->stream_analog_playback) {
  1916. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1917. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1918. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1919. }
  1920. if (spec->stream_analog_capture) {
  1921. snd_assert(spec->adc_nids, return -EINVAL);
  1922. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1923. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1924. }
  1925. if (spec->channel_mode) {
  1926. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1927. for (i = 0; i < spec->num_channel_mode; i++) {
  1928. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1929. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1930. }
  1931. }
  1932. }
  1933. /* SPDIF for stream index #1 */
  1934. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1935. codec->num_pcms = 2;
  1936. info = spec->pcm_rec + 1;
  1937. info->name = spec->stream_name_digital;
  1938. if (spec->multiout.dig_out_nid &&
  1939. spec->stream_digital_playback) {
  1940. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1941. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1942. }
  1943. if (spec->dig_in_nid &&
  1944. spec->stream_digital_capture) {
  1945. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1946. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1947. }
  1948. }
  1949. /* If the use of more than one ADC is requested for the current
  1950. * model, configure a second analog capture-only PCM.
  1951. */
  1952. /* Additional Analaog capture for index #2 */
  1953. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1954. spec->adc_nids) {
  1955. codec->num_pcms = 3;
  1956. info = spec->pcm_rec + 2;
  1957. info->name = spec->stream_name_analog;
  1958. /* No playback stream for second PCM */
  1959. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1960. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1961. if (spec->stream_analog_capture) {
  1962. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1963. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1964. }
  1965. }
  1966. return 0;
  1967. }
  1968. static void alc_free(struct hda_codec *codec)
  1969. {
  1970. struct alc_spec *spec = codec->spec;
  1971. unsigned int i;
  1972. if (!spec)
  1973. return;
  1974. if (spec->kctl_alloc) {
  1975. for (i = 0; i < spec->num_kctl_used; i++)
  1976. kfree(spec->kctl_alloc[i].name);
  1977. kfree(spec->kctl_alloc);
  1978. }
  1979. kfree(spec);
  1980. }
  1981. /*
  1982. */
  1983. static struct hda_codec_ops alc_patch_ops = {
  1984. .build_controls = alc_build_controls,
  1985. .build_pcms = alc_build_pcms,
  1986. .init = alc_init,
  1987. .free = alc_free,
  1988. .unsol_event = alc_unsol_event,
  1989. #ifdef CONFIG_PM
  1990. .resume = alc_resume,
  1991. #endif
  1992. };
  1993. /*
  1994. * Test configuration for debugging
  1995. *
  1996. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1997. * enum controls.
  1998. */
  1999. #ifdef CONFIG_SND_DEBUG
  2000. static hda_nid_t alc880_test_dac_nids[4] = {
  2001. 0x02, 0x03, 0x04, 0x05
  2002. };
  2003. static struct hda_input_mux alc880_test_capture_source = {
  2004. .num_items = 7,
  2005. .items = {
  2006. { "In-1", 0x0 },
  2007. { "In-2", 0x1 },
  2008. { "In-3", 0x2 },
  2009. { "In-4", 0x3 },
  2010. { "CD", 0x4 },
  2011. { "Front", 0x5 },
  2012. { "Surround", 0x6 },
  2013. },
  2014. };
  2015. static struct hda_channel_mode alc880_test_modes[4] = {
  2016. { 2, NULL },
  2017. { 4, NULL },
  2018. { 6, NULL },
  2019. { 8, NULL },
  2020. };
  2021. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2022. struct snd_ctl_elem_info *uinfo)
  2023. {
  2024. static char *texts[] = {
  2025. "N/A", "Line Out", "HP Out",
  2026. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2027. };
  2028. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2029. uinfo->count = 1;
  2030. uinfo->value.enumerated.items = 8;
  2031. if (uinfo->value.enumerated.item >= 8)
  2032. uinfo->value.enumerated.item = 7;
  2033. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2034. return 0;
  2035. }
  2036. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2037. struct snd_ctl_elem_value *ucontrol)
  2038. {
  2039. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2040. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2041. unsigned int pin_ctl, item = 0;
  2042. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2043. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2044. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2045. if (pin_ctl & AC_PINCTL_HP_EN)
  2046. item = 2;
  2047. else
  2048. item = 1;
  2049. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2050. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2051. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2052. case AC_PINCTL_VREF_50: item = 4; break;
  2053. case AC_PINCTL_VREF_GRD: item = 5; break;
  2054. case AC_PINCTL_VREF_80: item = 6; break;
  2055. case AC_PINCTL_VREF_100: item = 7; break;
  2056. }
  2057. }
  2058. ucontrol->value.enumerated.item[0] = item;
  2059. return 0;
  2060. }
  2061. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2062. struct snd_ctl_elem_value *ucontrol)
  2063. {
  2064. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2065. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2066. static unsigned int ctls[] = {
  2067. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2068. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2069. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2070. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2071. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2072. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2073. };
  2074. unsigned int old_ctl, new_ctl;
  2075. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2076. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2077. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2078. if (old_ctl != new_ctl) {
  2079. snd_hda_codec_write(codec, nid, 0,
  2080. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2081. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2082. (ucontrol->value.enumerated.item[0] >= 3 ?
  2083. 0xb080 : 0xb000));
  2084. return 1;
  2085. }
  2086. return 0;
  2087. }
  2088. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2089. struct snd_ctl_elem_info *uinfo)
  2090. {
  2091. static char *texts[] = {
  2092. "Front", "Surround", "CLFE", "Side"
  2093. };
  2094. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2095. uinfo->count = 1;
  2096. uinfo->value.enumerated.items = 4;
  2097. if (uinfo->value.enumerated.item >= 4)
  2098. uinfo->value.enumerated.item = 3;
  2099. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2100. return 0;
  2101. }
  2102. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2103. struct snd_ctl_elem_value *ucontrol)
  2104. {
  2105. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2106. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2107. unsigned int sel;
  2108. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2109. ucontrol->value.enumerated.item[0] = sel & 3;
  2110. return 0;
  2111. }
  2112. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2113. struct snd_ctl_elem_value *ucontrol)
  2114. {
  2115. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2116. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2117. unsigned int sel;
  2118. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2119. if (ucontrol->value.enumerated.item[0] != sel) {
  2120. sel = ucontrol->value.enumerated.item[0] & 3;
  2121. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2122. return 1;
  2123. }
  2124. return 0;
  2125. }
  2126. #define PIN_CTL_TEST(xname,nid) { \
  2127. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2128. .name = xname, \
  2129. .info = alc_test_pin_ctl_info, \
  2130. .get = alc_test_pin_ctl_get, \
  2131. .put = alc_test_pin_ctl_put, \
  2132. .private_value = nid \
  2133. }
  2134. #define PIN_SRC_TEST(xname,nid) { \
  2135. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2136. .name = xname, \
  2137. .info = alc_test_pin_src_info, \
  2138. .get = alc_test_pin_src_get, \
  2139. .put = alc_test_pin_src_put, \
  2140. .private_value = nid \
  2141. }
  2142. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2143. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2144. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2145. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2146. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2147. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2148. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2149. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2150. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2151. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2152. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2153. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2154. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2155. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2156. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2157. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2158. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2159. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2160. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2161. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2162. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2163. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2164. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2165. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2166. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2167. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2168. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2169. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2170. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2171. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2172. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2173. {
  2174. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2175. .name = "Channel Mode",
  2176. .info = alc_ch_mode_info,
  2177. .get = alc_ch_mode_get,
  2178. .put = alc_ch_mode_put,
  2179. },
  2180. { } /* end */
  2181. };
  2182. static struct hda_verb alc880_test_init_verbs[] = {
  2183. /* Unmute inputs of 0x0c - 0x0f */
  2184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2189. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2190. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2191. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2192. /* Vol output for 0x0c-0x0f */
  2193. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2197. /* Set output pins 0x14-0x17 */
  2198. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2199. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2200. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2201. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2202. /* Unmute output pins 0x14-0x17 */
  2203. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2204. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2205. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2206. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2207. /* Set input pins 0x18-0x1c */
  2208. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2209. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2210. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2211. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2212. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2213. /* Mute input pins 0x18-0x1b */
  2214. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2215. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2216. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2217. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2218. /* ADC set up */
  2219. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2220. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2221. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2222. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2223. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2224. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2225. /* Analog input/passthru */
  2226. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2227. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2230. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2231. { }
  2232. };
  2233. #endif
  2234. /*
  2235. */
  2236. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2237. [ALC880_3ST] = "3stack",
  2238. [ALC880_TCL_S700] = "tcl",
  2239. [ALC880_3ST_DIG] = "3stack-digout",
  2240. [ALC880_CLEVO] = "clevo",
  2241. [ALC880_5ST] = "5stack",
  2242. [ALC880_5ST_DIG] = "5stack-digout",
  2243. [ALC880_W810] = "w810",
  2244. [ALC880_Z71V] = "z71v",
  2245. [ALC880_6ST] = "6stack",
  2246. [ALC880_6ST_DIG] = "6stack-digout",
  2247. [ALC880_ASUS] = "asus",
  2248. [ALC880_ASUS_W1V] = "asus-w1v",
  2249. [ALC880_ASUS_DIG] = "asus-dig",
  2250. [ALC880_ASUS_DIG2] = "asus-dig2",
  2251. [ALC880_UNIWILL_DIG] = "uniwill",
  2252. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2253. [ALC880_FUJITSU] = "fujitsu",
  2254. [ALC880_F1734] = "F1734",
  2255. [ALC880_LG] = "lg",
  2256. [ALC880_LG_LW] = "lg-lw",
  2257. #ifdef CONFIG_SND_DEBUG
  2258. [ALC880_TEST] = "test",
  2259. #endif
  2260. [ALC880_AUTO] = "auto",
  2261. };
  2262. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2263. /* Broken BIOS configuration */
  2264. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2265. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2266. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2267. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2268. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2269. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2270. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2271. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2273. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2274. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2275. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2276. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2277. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2278. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2279. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2280. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2281. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2282. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2283. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2284. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2285. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2288. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2290. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2291. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2292. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2293. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2294. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2295. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2296. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2297. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2298. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2299. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2300. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2301. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2302. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2303. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2304. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2305. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2306. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2307. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2308. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2309. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2310. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2311. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2312. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2313. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2314. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2315. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2316. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2317. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2318. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2319. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2320. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2321. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2322. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2323. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2324. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2325. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2326. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2327. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2328. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2329. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2333. {}
  2334. };
  2335. /*
  2336. * ALC880 codec presets
  2337. */
  2338. static struct alc_config_preset alc880_presets[] = {
  2339. [ALC880_3ST] = {
  2340. .mixers = { alc880_three_stack_mixer },
  2341. .init_verbs = { alc880_volume_init_verbs,
  2342. alc880_pin_3stack_init_verbs },
  2343. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2344. .dac_nids = alc880_dac_nids,
  2345. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2346. .channel_mode = alc880_threestack_modes,
  2347. .need_dac_fix = 1,
  2348. .input_mux = &alc880_capture_source,
  2349. },
  2350. [ALC880_3ST_DIG] = {
  2351. .mixers = { alc880_three_stack_mixer },
  2352. .init_verbs = { alc880_volume_init_verbs,
  2353. alc880_pin_3stack_init_verbs },
  2354. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2355. .dac_nids = alc880_dac_nids,
  2356. .dig_out_nid = ALC880_DIGOUT_NID,
  2357. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2358. .channel_mode = alc880_threestack_modes,
  2359. .need_dac_fix = 1,
  2360. .input_mux = &alc880_capture_source,
  2361. },
  2362. [ALC880_TCL_S700] = {
  2363. .mixers = { alc880_tcl_s700_mixer },
  2364. .init_verbs = { alc880_volume_init_verbs,
  2365. alc880_pin_tcl_S700_init_verbs,
  2366. alc880_gpio2_init_verbs },
  2367. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2368. .dac_nids = alc880_dac_nids,
  2369. .hp_nid = 0x03,
  2370. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2371. .channel_mode = alc880_2_jack_modes,
  2372. .input_mux = &alc880_capture_source,
  2373. },
  2374. [ALC880_5ST] = {
  2375. .mixers = { alc880_three_stack_mixer,
  2376. alc880_five_stack_mixer},
  2377. .init_verbs = { alc880_volume_init_verbs,
  2378. alc880_pin_5stack_init_verbs },
  2379. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2380. .dac_nids = alc880_dac_nids,
  2381. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2382. .channel_mode = alc880_fivestack_modes,
  2383. .input_mux = &alc880_capture_source,
  2384. },
  2385. [ALC880_5ST_DIG] = {
  2386. .mixers = { alc880_three_stack_mixer,
  2387. alc880_five_stack_mixer },
  2388. .init_verbs = { alc880_volume_init_verbs,
  2389. alc880_pin_5stack_init_verbs },
  2390. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2391. .dac_nids = alc880_dac_nids,
  2392. .dig_out_nid = ALC880_DIGOUT_NID,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2394. .channel_mode = alc880_fivestack_modes,
  2395. .input_mux = &alc880_capture_source,
  2396. },
  2397. [ALC880_6ST] = {
  2398. .mixers = { alc880_six_stack_mixer },
  2399. .init_verbs = { alc880_volume_init_verbs,
  2400. alc880_pin_6stack_init_verbs },
  2401. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2402. .dac_nids = alc880_6st_dac_nids,
  2403. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2404. .channel_mode = alc880_sixstack_modes,
  2405. .input_mux = &alc880_6stack_capture_source,
  2406. },
  2407. [ALC880_6ST_DIG] = {
  2408. .mixers = { alc880_six_stack_mixer },
  2409. .init_verbs = { alc880_volume_init_verbs,
  2410. alc880_pin_6stack_init_verbs },
  2411. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2412. .dac_nids = alc880_6st_dac_nids,
  2413. .dig_out_nid = ALC880_DIGOUT_NID,
  2414. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2415. .channel_mode = alc880_sixstack_modes,
  2416. .input_mux = &alc880_6stack_capture_source,
  2417. },
  2418. [ALC880_W810] = {
  2419. .mixers = { alc880_w810_base_mixer },
  2420. .init_verbs = { alc880_volume_init_verbs,
  2421. alc880_pin_w810_init_verbs,
  2422. alc880_gpio2_init_verbs },
  2423. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2424. .dac_nids = alc880_w810_dac_nids,
  2425. .dig_out_nid = ALC880_DIGOUT_NID,
  2426. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2427. .channel_mode = alc880_w810_modes,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_Z71V] = {
  2431. .mixers = { alc880_z71v_mixer },
  2432. .init_verbs = { alc880_volume_init_verbs,
  2433. alc880_pin_z71v_init_verbs },
  2434. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2435. .dac_nids = alc880_z71v_dac_nids,
  2436. .dig_out_nid = ALC880_DIGOUT_NID,
  2437. .hp_nid = 0x03,
  2438. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2439. .channel_mode = alc880_2_jack_modes,
  2440. .input_mux = &alc880_capture_source,
  2441. },
  2442. [ALC880_F1734] = {
  2443. .mixers = { alc880_f1734_mixer },
  2444. .init_verbs = { alc880_volume_init_verbs,
  2445. alc880_pin_f1734_init_verbs },
  2446. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2447. .dac_nids = alc880_f1734_dac_nids,
  2448. .hp_nid = 0x02,
  2449. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2450. .channel_mode = alc880_2_jack_modes,
  2451. .input_mux = &alc880_capture_source,
  2452. },
  2453. [ALC880_ASUS] = {
  2454. .mixers = { alc880_asus_mixer },
  2455. .init_verbs = { alc880_volume_init_verbs,
  2456. alc880_pin_asus_init_verbs,
  2457. alc880_gpio1_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2459. .dac_nids = alc880_asus_dac_nids,
  2460. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2461. .channel_mode = alc880_asus_modes,
  2462. .need_dac_fix = 1,
  2463. .input_mux = &alc880_capture_source,
  2464. },
  2465. [ALC880_ASUS_DIG] = {
  2466. .mixers = { alc880_asus_mixer },
  2467. .init_verbs = { alc880_volume_init_verbs,
  2468. alc880_pin_asus_init_verbs,
  2469. alc880_gpio1_init_verbs },
  2470. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2471. .dac_nids = alc880_asus_dac_nids,
  2472. .dig_out_nid = ALC880_DIGOUT_NID,
  2473. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2474. .channel_mode = alc880_asus_modes,
  2475. .need_dac_fix = 1,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_ASUS_DIG2] = {
  2479. .mixers = { alc880_asus_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_asus_init_verbs,
  2482. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2483. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2484. .dac_nids = alc880_asus_dac_nids,
  2485. .dig_out_nid = ALC880_DIGOUT_NID,
  2486. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2487. .channel_mode = alc880_asus_modes,
  2488. .need_dac_fix = 1,
  2489. .input_mux = &alc880_capture_source,
  2490. },
  2491. [ALC880_ASUS_W1V] = {
  2492. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2493. .init_verbs = { alc880_volume_init_verbs,
  2494. alc880_pin_asus_init_verbs,
  2495. alc880_gpio1_init_verbs },
  2496. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2497. .dac_nids = alc880_asus_dac_nids,
  2498. .dig_out_nid = ALC880_DIGOUT_NID,
  2499. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2500. .channel_mode = alc880_asus_modes,
  2501. .need_dac_fix = 1,
  2502. .input_mux = &alc880_capture_source,
  2503. },
  2504. [ALC880_UNIWILL_DIG] = {
  2505. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2506. .init_verbs = { alc880_volume_init_verbs,
  2507. alc880_pin_asus_init_verbs },
  2508. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2509. .dac_nids = alc880_asus_dac_nids,
  2510. .dig_out_nid = ALC880_DIGOUT_NID,
  2511. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2512. .channel_mode = alc880_asus_modes,
  2513. .need_dac_fix = 1,
  2514. .input_mux = &alc880_capture_source,
  2515. },
  2516. [ALC880_UNIWILL] = {
  2517. .mixers = { alc880_uniwill_mixer },
  2518. .init_verbs = { alc880_volume_init_verbs,
  2519. alc880_uniwill_init_verbs },
  2520. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2521. .dac_nids = alc880_asus_dac_nids,
  2522. .dig_out_nid = ALC880_DIGOUT_NID,
  2523. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2524. .channel_mode = alc880_threestack_modes,
  2525. .need_dac_fix = 1,
  2526. .input_mux = &alc880_capture_source,
  2527. .unsol_event = alc880_uniwill_unsol_event,
  2528. .init_hook = alc880_uniwill_automute,
  2529. },
  2530. [ALC880_UNIWILL_P53] = {
  2531. .mixers = { alc880_uniwill_p53_mixer },
  2532. .init_verbs = { alc880_volume_init_verbs,
  2533. alc880_uniwill_p53_init_verbs },
  2534. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2535. .dac_nids = alc880_asus_dac_nids,
  2536. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2537. .channel_mode = alc880_threestack_modes,
  2538. .input_mux = &alc880_capture_source,
  2539. .unsol_event = alc880_uniwill_p53_unsol_event,
  2540. .init_hook = alc880_uniwill_p53_hp_automute,
  2541. },
  2542. [ALC880_FUJITSU] = {
  2543. .mixers = { alc880_fujitsu_mixer,
  2544. alc880_pcbeep_mixer, },
  2545. .init_verbs = { alc880_volume_init_verbs,
  2546. alc880_uniwill_p53_init_verbs,
  2547. alc880_beep_init_verbs },
  2548. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2549. .dac_nids = alc880_dac_nids,
  2550. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2551. .channel_mode = alc880_2_jack_modes,
  2552. .input_mux = &alc880_capture_source,
  2553. .unsol_event = alc880_uniwill_p53_unsol_event,
  2554. .init_hook = alc880_uniwill_p53_hp_automute,
  2555. },
  2556. [ALC880_CLEVO] = {
  2557. .mixers = { alc880_three_stack_mixer },
  2558. .init_verbs = { alc880_volume_init_verbs,
  2559. alc880_pin_clevo_init_verbs },
  2560. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2561. .dac_nids = alc880_dac_nids,
  2562. .hp_nid = 0x03,
  2563. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2564. .channel_mode = alc880_threestack_modes,
  2565. .need_dac_fix = 1,
  2566. .input_mux = &alc880_capture_source,
  2567. },
  2568. [ALC880_LG] = {
  2569. .mixers = { alc880_lg_mixer },
  2570. .init_verbs = { alc880_volume_init_verbs,
  2571. alc880_lg_init_verbs },
  2572. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2573. .dac_nids = alc880_lg_dac_nids,
  2574. .dig_out_nid = ALC880_DIGOUT_NID,
  2575. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2576. .channel_mode = alc880_lg_ch_modes,
  2577. .need_dac_fix = 1,
  2578. .input_mux = &alc880_lg_capture_source,
  2579. .unsol_event = alc880_lg_unsol_event,
  2580. .init_hook = alc880_lg_automute,
  2581. },
  2582. [ALC880_LG_LW] = {
  2583. .mixers = { alc880_lg_lw_mixer },
  2584. .init_verbs = { alc880_volume_init_verbs,
  2585. alc880_lg_lw_init_verbs },
  2586. .num_dacs = 1,
  2587. .dac_nids = alc880_dac_nids,
  2588. .dig_out_nid = ALC880_DIGOUT_NID,
  2589. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2590. .channel_mode = alc880_2_jack_modes,
  2591. .input_mux = &alc880_lg_lw_capture_source,
  2592. .unsol_event = alc880_lg_lw_unsol_event,
  2593. .init_hook = alc880_lg_lw_automute,
  2594. },
  2595. #ifdef CONFIG_SND_DEBUG
  2596. [ALC880_TEST] = {
  2597. .mixers = { alc880_test_mixer },
  2598. .init_verbs = { alc880_test_init_verbs },
  2599. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2600. .dac_nids = alc880_test_dac_nids,
  2601. .dig_out_nid = ALC880_DIGOUT_NID,
  2602. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2603. .channel_mode = alc880_test_modes,
  2604. .input_mux = &alc880_test_capture_source,
  2605. },
  2606. #endif
  2607. };
  2608. /*
  2609. * Automatic parse of I/O pins from the BIOS configuration
  2610. */
  2611. #define NUM_CONTROL_ALLOC 32
  2612. #define NUM_VERB_ALLOC 32
  2613. enum {
  2614. ALC_CTL_WIDGET_VOL,
  2615. ALC_CTL_WIDGET_MUTE,
  2616. ALC_CTL_BIND_MUTE,
  2617. };
  2618. static struct snd_kcontrol_new alc880_control_templates[] = {
  2619. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2620. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2621. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2622. };
  2623. /* add dynamic controls */
  2624. static int add_control(struct alc_spec *spec, int type, const char *name,
  2625. unsigned long val)
  2626. {
  2627. struct snd_kcontrol_new *knew;
  2628. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2629. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2630. /* array + terminator */
  2631. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2632. if (!knew)
  2633. return -ENOMEM;
  2634. if (spec->kctl_alloc) {
  2635. memcpy(knew, spec->kctl_alloc,
  2636. sizeof(*knew) * spec->num_kctl_alloc);
  2637. kfree(spec->kctl_alloc);
  2638. }
  2639. spec->kctl_alloc = knew;
  2640. spec->num_kctl_alloc = num;
  2641. }
  2642. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2643. *knew = alc880_control_templates[type];
  2644. knew->name = kstrdup(name, GFP_KERNEL);
  2645. if (!knew->name)
  2646. return -ENOMEM;
  2647. knew->private_value = val;
  2648. spec->num_kctl_used++;
  2649. return 0;
  2650. }
  2651. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2652. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2653. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2654. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2655. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2656. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2657. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2658. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2659. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2660. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2661. #define ALC880_PIN_CD_NID 0x1c
  2662. /* fill in the dac_nids table from the parsed pin configuration */
  2663. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2664. const struct auto_pin_cfg *cfg)
  2665. {
  2666. hda_nid_t nid;
  2667. int assigned[4];
  2668. int i, j;
  2669. memset(assigned, 0, sizeof(assigned));
  2670. spec->multiout.dac_nids = spec->private_dac_nids;
  2671. /* check the pins hardwired to audio widget */
  2672. for (i = 0; i < cfg->line_outs; i++) {
  2673. nid = cfg->line_out_pins[i];
  2674. if (alc880_is_fixed_pin(nid)) {
  2675. int idx = alc880_fixed_pin_idx(nid);
  2676. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2677. assigned[idx] = 1;
  2678. }
  2679. }
  2680. /* left pins can be connect to any audio widget */
  2681. for (i = 0; i < cfg->line_outs; i++) {
  2682. nid = cfg->line_out_pins[i];
  2683. if (alc880_is_fixed_pin(nid))
  2684. continue;
  2685. /* search for an empty channel */
  2686. for (j = 0; j < cfg->line_outs; j++) {
  2687. if (!assigned[j]) {
  2688. spec->multiout.dac_nids[i] =
  2689. alc880_idx_to_dac(j);
  2690. assigned[j] = 1;
  2691. break;
  2692. }
  2693. }
  2694. }
  2695. spec->multiout.num_dacs = cfg->line_outs;
  2696. return 0;
  2697. }
  2698. /* add playback controls from the parsed DAC table */
  2699. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2700. const struct auto_pin_cfg *cfg)
  2701. {
  2702. char name[32];
  2703. static const char *chname[4] = {
  2704. "Front", "Surround", NULL /*CLFE*/, "Side"
  2705. };
  2706. hda_nid_t nid;
  2707. int i, err;
  2708. for (i = 0; i < cfg->line_outs; i++) {
  2709. if (!spec->multiout.dac_nids[i])
  2710. continue;
  2711. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2712. if (i == 2) {
  2713. /* Center/LFE */
  2714. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2715. "Center Playback Volume",
  2716. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2717. HDA_OUTPUT));
  2718. if (err < 0)
  2719. return err;
  2720. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2721. "LFE Playback Volume",
  2722. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2723. HDA_OUTPUT));
  2724. if (err < 0)
  2725. return err;
  2726. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2727. "Center Playback Switch",
  2728. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2729. HDA_INPUT));
  2730. if (err < 0)
  2731. return err;
  2732. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2733. "LFE Playback Switch",
  2734. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2735. HDA_INPUT));
  2736. if (err < 0)
  2737. return err;
  2738. } else {
  2739. sprintf(name, "%s Playback Volume", chname[i]);
  2740. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2741. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2742. HDA_OUTPUT));
  2743. if (err < 0)
  2744. return err;
  2745. sprintf(name, "%s Playback Switch", chname[i]);
  2746. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2747. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2748. HDA_INPUT));
  2749. if (err < 0)
  2750. return err;
  2751. }
  2752. }
  2753. return 0;
  2754. }
  2755. /* add playback controls for speaker and HP outputs */
  2756. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2757. const char *pfx)
  2758. {
  2759. hda_nid_t nid;
  2760. int err;
  2761. char name[32];
  2762. if (!pin)
  2763. return 0;
  2764. if (alc880_is_fixed_pin(pin)) {
  2765. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2766. /* specify the DAC as the extra output */
  2767. if (!spec->multiout.hp_nid)
  2768. spec->multiout.hp_nid = nid;
  2769. else
  2770. spec->multiout.extra_out_nid[0] = nid;
  2771. /* control HP volume/switch on the output mixer amp */
  2772. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2773. sprintf(name, "%s Playback Volume", pfx);
  2774. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2775. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2776. if (err < 0)
  2777. return err;
  2778. sprintf(name, "%s Playback Switch", pfx);
  2779. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2780. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2781. if (err < 0)
  2782. return err;
  2783. } else if (alc880_is_multi_pin(pin)) {
  2784. /* set manual connection */
  2785. /* we have only a switch on HP-out PIN */
  2786. sprintf(name, "%s Playback Switch", pfx);
  2787. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2788. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2789. if (err < 0)
  2790. return err;
  2791. }
  2792. return 0;
  2793. }
  2794. /* create input playback/capture controls for the given pin */
  2795. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2796. const char *ctlname,
  2797. int idx, hda_nid_t mix_nid)
  2798. {
  2799. char name[32];
  2800. int err;
  2801. sprintf(name, "%s Playback Volume", ctlname);
  2802. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2803. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2804. if (err < 0)
  2805. return err;
  2806. sprintf(name, "%s Playback Switch", ctlname);
  2807. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2808. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2809. if (err < 0)
  2810. return err;
  2811. return 0;
  2812. }
  2813. /* create playback/capture controls for input pins */
  2814. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2815. const struct auto_pin_cfg *cfg)
  2816. {
  2817. struct hda_input_mux *imux = &spec->private_imux;
  2818. int i, err, idx;
  2819. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2820. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2821. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2822. err = new_analog_input(spec, cfg->input_pins[i],
  2823. auto_pin_cfg_labels[i],
  2824. idx, 0x0b);
  2825. if (err < 0)
  2826. return err;
  2827. imux->items[imux->num_items].label =
  2828. auto_pin_cfg_labels[i];
  2829. imux->items[imux->num_items].index =
  2830. alc880_input_pin_idx(cfg->input_pins[i]);
  2831. imux->num_items++;
  2832. }
  2833. }
  2834. return 0;
  2835. }
  2836. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2837. hda_nid_t nid, int pin_type,
  2838. int dac_idx)
  2839. {
  2840. /* set as output */
  2841. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2842. pin_type);
  2843. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2844. AMP_OUT_UNMUTE);
  2845. /* need the manual connection? */
  2846. if (alc880_is_multi_pin(nid)) {
  2847. struct alc_spec *spec = codec->spec;
  2848. int idx = alc880_multi_pin_idx(nid);
  2849. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2850. AC_VERB_SET_CONNECT_SEL,
  2851. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2852. }
  2853. }
  2854. static int get_pin_type(int line_out_type)
  2855. {
  2856. if (line_out_type == AUTO_PIN_HP_OUT)
  2857. return PIN_HP;
  2858. else
  2859. return PIN_OUT;
  2860. }
  2861. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2862. {
  2863. struct alc_spec *spec = codec->spec;
  2864. int i;
  2865. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2866. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2867. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2868. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2869. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2870. }
  2871. }
  2872. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2873. {
  2874. struct alc_spec *spec = codec->spec;
  2875. hda_nid_t pin;
  2876. pin = spec->autocfg.speaker_pins[0];
  2877. if (pin) /* connect to front */
  2878. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2879. pin = spec->autocfg.hp_pins[0];
  2880. if (pin) /* connect to front */
  2881. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2882. }
  2883. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2884. {
  2885. struct alc_spec *spec = codec->spec;
  2886. int i;
  2887. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2888. hda_nid_t nid = spec->autocfg.input_pins[i];
  2889. if (alc880_is_input_pin(nid)) {
  2890. snd_hda_codec_write(codec, nid, 0,
  2891. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2892. i <= AUTO_PIN_FRONT_MIC ?
  2893. PIN_VREF80 : PIN_IN);
  2894. if (nid != ALC880_PIN_CD_NID)
  2895. snd_hda_codec_write(codec, nid, 0,
  2896. AC_VERB_SET_AMP_GAIN_MUTE,
  2897. AMP_OUT_MUTE);
  2898. }
  2899. }
  2900. }
  2901. /* parse the BIOS configuration and set up the alc_spec */
  2902. /* return 1 if successful, 0 if the proper config is not found,
  2903. * or a negative error code
  2904. */
  2905. static int alc880_parse_auto_config(struct hda_codec *codec)
  2906. {
  2907. struct alc_spec *spec = codec->spec;
  2908. int err;
  2909. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2910. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2911. alc880_ignore);
  2912. if (err < 0)
  2913. return err;
  2914. if (!spec->autocfg.line_outs)
  2915. return 0; /* can't find valid BIOS pin config */
  2916. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2917. if (err < 0)
  2918. return err;
  2919. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2920. if (err < 0)
  2921. return err;
  2922. err = alc880_auto_create_extra_out(spec,
  2923. spec->autocfg.speaker_pins[0],
  2924. "Speaker");
  2925. if (err < 0)
  2926. return err;
  2927. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2928. "Headphone");
  2929. if (err < 0)
  2930. return err;
  2931. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2932. if (err < 0)
  2933. return err;
  2934. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2935. if (spec->autocfg.dig_out_pin)
  2936. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2937. if (spec->autocfg.dig_in_pin)
  2938. spec->dig_in_nid = ALC880_DIGIN_NID;
  2939. if (spec->kctl_alloc)
  2940. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2941. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2942. spec->num_mux_defs = 1;
  2943. spec->input_mux = &spec->private_imux;
  2944. return 1;
  2945. }
  2946. /* additional initialization for auto-configuration model */
  2947. static void alc880_auto_init(struct hda_codec *codec)
  2948. {
  2949. alc880_auto_init_multi_out(codec);
  2950. alc880_auto_init_extra_out(codec);
  2951. alc880_auto_init_analog_input(codec);
  2952. }
  2953. /*
  2954. * OK, here we have finally the patch for ALC880
  2955. */
  2956. static int patch_alc880(struct hda_codec *codec)
  2957. {
  2958. struct alc_spec *spec;
  2959. int board_config;
  2960. int err;
  2961. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2962. if (spec == NULL)
  2963. return -ENOMEM;
  2964. codec->spec = spec;
  2965. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2966. alc880_models,
  2967. alc880_cfg_tbl);
  2968. if (board_config < 0) {
  2969. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2970. "trying auto-probe from BIOS...\n");
  2971. board_config = ALC880_AUTO;
  2972. }
  2973. if (board_config == ALC880_AUTO) {
  2974. /* automatic parse from the BIOS config */
  2975. err = alc880_parse_auto_config(codec);
  2976. if (err < 0) {
  2977. alc_free(codec);
  2978. return err;
  2979. } else if (!err) {
  2980. printk(KERN_INFO
  2981. "hda_codec: Cannot set up configuration "
  2982. "from BIOS. Using 3-stack mode...\n");
  2983. board_config = ALC880_3ST;
  2984. }
  2985. }
  2986. if (board_config != ALC880_AUTO)
  2987. setup_preset(spec, &alc880_presets[board_config]);
  2988. spec->stream_name_analog = "ALC880 Analog";
  2989. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2990. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2991. spec->stream_name_digital = "ALC880 Digital";
  2992. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2993. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2994. if (!spec->adc_nids && spec->input_mux) {
  2995. /* check whether NID 0x07 is valid */
  2996. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2997. /* get type */
  2998. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  2999. if (wcap != AC_WID_AUD_IN) {
  3000. spec->adc_nids = alc880_adc_nids_alt;
  3001. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3002. spec->mixers[spec->num_mixers] =
  3003. alc880_capture_alt_mixer;
  3004. spec->num_mixers++;
  3005. } else {
  3006. spec->adc_nids = alc880_adc_nids;
  3007. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3008. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3009. spec->num_mixers++;
  3010. }
  3011. }
  3012. codec->patch_ops = alc_patch_ops;
  3013. if (board_config == ALC880_AUTO)
  3014. spec->init_hook = alc880_auto_init;
  3015. return 0;
  3016. }
  3017. /*
  3018. * ALC260 support
  3019. */
  3020. static hda_nid_t alc260_dac_nids[1] = {
  3021. /* front */
  3022. 0x02,
  3023. };
  3024. static hda_nid_t alc260_adc_nids[1] = {
  3025. /* ADC0 */
  3026. 0x04,
  3027. };
  3028. static hda_nid_t alc260_adc_nids_alt[1] = {
  3029. /* ADC1 */
  3030. 0x05,
  3031. };
  3032. static hda_nid_t alc260_hp_adc_nids[2] = {
  3033. /* ADC1, 0 */
  3034. 0x05, 0x04
  3035. };
  3036. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3037. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3038. */
  3039. static hda_nid_t alc260_dual_adc_nids[2] = {
  3040. /* ADC0, ADC1 */
  3041. 0x04, 0x05
  3042. };
  3043. #define ALC260_DIGOUT_NID 0x03
  3044. #define ALC260_DIGIN_NID 0x06
  3045. static struct hda_input_mux alc260_capture_source = {
  3046. .num_items = 4,
  3047. .items = {
  3048. { "Mic", 0x0 },
  3049. { "Front Mic", 0x1 },
  3050. { "Line", 0x2 },
  3051. { "CD", 0x4 },
  3052. },
  3053. };
  3054. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3055. * headphone jack and the internal CD lines since these are the only pins at
  3056. * which audio can appear. For flexibility, also allow the option of
  3057. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3058. * connection to the mixer output).
  3059. */
  3060. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3061. {
  3062. .num_items = 3,
  3063. .items = {
  3064. { "Mic/Line", 0x0 },
  3065. { "CD", 0x4 },
  3066. { "Headphone", 0x2 },
  3067. },
  3068. },
  3069. {
  3070. .num_items = 4,
  3071. .items = {
  3072. { "Mic/Line", 0x0 },
  3073. { "CD", 0x4 },
  3074. { "Headphone", 0x2 },
  3075. { "Mixer", 0x5 },
  3076. },
  3077. },
  3078. };
  3079. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3080. * the Fujitsu S702x, but jacks are marked differently.
  3081. */
  3082. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3083. {
  3084. .num_items = 4,
  3085. .items = {
  3086. { "Mic", 0x0 },
  3087. { "Line", 0x2 },
  3088. { "CD", 0x4 },
  3089. { "Headphone", 0x5 },
  3090. },
  3091. },
  3092. {
  3093. .num_items = 5,
  3094. .items = {
  3095. { "Mic", 0x0 },
  3096. { "Line", 0x2 },
  3097. { "CD", 0x4 },
  3098. { "Headphone", 0x6 },
  3099. { "Mixer", 0x5 },
  3100. },
  3101. },
  3102. };
  3103. /*
  3104. * This is just place-holder, so there's something for alc_build_pcms to look
  3105. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3106. * element which allows changing the channel mode, so the verb list is
  3107. * never used.
  3108. */
  3109. static struct hda_channel_mode alc260_modes[1] = {
  3110. { 2, NULL },
  3111. };
  3112. /* Mixer combinations
  3113. *
  3114. * basic: base_output + input + pc_beep + capture
  3115. * HP: base_output + input + capture_alt
  3116. * HP_3013: hp_3013 + input + capture
  3117. * fujitsu: fujitsu + capture
  3118. * acer: acer + capture
  3119. */
  3120. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3121. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3122. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3123. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3124. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3125. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3126. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3127. { } /* end */
  3128. };
  3129. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3130. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3131. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3132. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3133. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3134. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3135. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3136. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3137. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3138. { } /* end */
  3139. };
  3140. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3141. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3142. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3143. { } /* end */
  3144. };
  3145. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3146. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3147. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3148. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3149. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3150. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3151. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3152. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3153. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3154. { } /* end */
  3155. };
  3156. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3157. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3158. */
  3159. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3160. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3161. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3162. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3163. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3164. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3165. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3166. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3167. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3168. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3169. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3170. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3171. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3172. { } /* end */
  3173. };
  3174. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3175. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3176. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3177. * datasheet doesn't mention this restriction. At this stage it's not clear
  3178. * whether this behaviour is intentional or is a hardware bug in chip
  3179. * revisions available in early 2006. Therefore for now allow the
  3180. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3181. * that the lack of mic bias for this NID is intentional we could change the
  3182. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3183. *
  3184. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3185. * don't appear to make the mic bias available from the "line" jack, even
  3186. * though the NID used for this jack (0x14) can supply it. The theory is
  3187. * that perhaps Acer have included blocking capacitors between the ALC260
  3188. * and the output jack. If this turns out to be the case for all such
  3189. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3190. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3191. *
  3192. * The C20x Tablet series have a mono internal speaker which is controlled
  3193. * via the chip's Mono sum widget and pin complex, so include the necessary
  3194. * controls for such models. On models without a "mono speaker" the control
  3195. * won't do anything.
  3196. */
  3197. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3198. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3199. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3200. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3201. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3202. HDA_OUTPUT),
  3203. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3204. HDA_INPUT),
  3205. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3206. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3207. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3208. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3209. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3210. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3211. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3212. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3213. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3214. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3215. { } /* end */
  3216. };
  3217. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3218. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3219. */
  3220. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3221. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3222. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3224. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3225. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3226. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3227. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3228. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3229. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3230. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3231. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3232. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3233. { } /* end */
  3234. };
  3235. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3236. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3237. */
  3238. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3239. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3240. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3241. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3242. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3243. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3244. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3245. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3246. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3247. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3248. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3249. { } /* end */
  3250. };
  3251. /* capture mixer elements */
  3252. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3253. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3254. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3255. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3256. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3257. {
  3258. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3259. /* The multiple "Capture Source" controls confuse alsamixer
  3260. * So call somewhat different..
  3261. * FIXME: the controls appear in the "playback" view!
  3262. */
  3263. /* .name = "Capture Source", */
  3264. .name = "Input Source",
  3265. .count = 2,
  3266. .info = alc_mux_enum_info,
  3267. .get = alc_mux_enum_get,
  3268. .put = alc_mux_enum_put,
  3269. },
  3270. { } /* end */
  3271. };
  3272. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3273. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3274. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3275. {
  3276. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3277. /* The multiple "Capture Source" controls confuse alsamixer
  3278. * So call somewhat different..
  3279. * FIXME: the controls appear in the "playback" view!
  3280. */
  3281. /* .name = "Capture Source", */
  3282. .name = "Input Source",
  3283. .count = 1,
  3284. .info = alc_mux_enum_info,
  3285. .get = alc_mux_enum_get,
  3286. .put = alc_mux_enum_put,
  3287. },
  3288. { } /* end */
  3289. };
  3290. /*
  3291. * initialization verbs
  3292. */
  3293. static struct hda_verb alc260_init_verbs[] = {
  3294. /* Line In pin widget for input */
  3295. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3296. /* CD pin widget for input */
  3297. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3298. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3299. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3300. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3301. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3302. /* LINE-2 is used for line-out in rear */
  3303. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3304. /* select line-out */
  3305. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3306. /* LINE-OUT pin */
  3307. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3308. /* enable HP */
  3309. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3310. /* enable Mono */
  3311. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3312. /* mute capture amp left and right */
  3313. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3314. /* set connection select to line in (default select for this ADC) */
  3315. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3316. /* mute capture amp left and right */
  3317. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3318. /* set connection select to line in (default select for this ADC) */
  3319. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3320. /* set vol=0 Line-Out mixer amp left and right */
  3321. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3322. /* unmute pin widget amp left and right (no gain on this amp) */
  3323. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3324. /* set vol=0 HP mixer amp left and right */
  3325. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3326. /* unmute pin widget amp left and right (no gain on this amp) */
  3327. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3328. /* set vol=0 Mono mixer amp left and right */
  3329. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3330. /* unmute pin widget amp left and right (no gain on this amp) */
  3331. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3332. /* unmute LINE-2 out pin */
  3333. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3334. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3335. * Line In 2 = 0x03
  3336. */
  3337. /* mute CD */
  3338. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3339. /* mute Line In */
  3340. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3341. /* mute Mic */
  3342. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3343. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3344. /* mute Front out path */
  3345. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3347. /* mute Headphone out path */
  3348. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3349. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3350. /* mute Mono out path */
  3351. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3352. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3353. { }
  3354. };
  3355. #if 0 /* should be identical with alc260_init_verbs? */
  3356. static struct hda_verb alc260_hp_init_verbs[] = {
  3357. /* Headphone and output */
  3358. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3359. /* mono output */
  3360. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3361. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3362. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3363. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3364. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3365. /* Line In pin widget for input */
  3366. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3367. /* Line-2 pin widget for output */
  3368. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3369. /* CD pin widget for input */
  3370. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3371. /* unmute amp left and right */
  3372. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3373. /* set connection select to line in (default select for this ADC) */
  3374. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3375. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3376. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3377. /* mute pin widget amp left and right (no gain on this amp) */
  3378. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3379. /* unmute HP mixer amp left and right (volume = 0) */
  3380. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3381. /* mute pin widget amp left and right (no gain on this amp) */
  3382. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3383. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3384. * Line In 2 = 0x03
  3385. */
  3386. /* unmute CD */
  3387. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3388. /* unmute Line In */
  3389. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3390. /* unmute Mic */
  3391. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3392. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3393. /* Unmute Front out path */
  3394. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3395. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3396. /* Unmute Headphone out path */
  3397. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3398. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3399. /* Unmute Mono out path */
  3400. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3401. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3402. { }
  3403. };
  3404. #endif
  3405. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3406. /* Line out and output */
  3407. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3408. /* mono output */
  3409. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3410. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3411. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3412. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3413. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3414. /* Line In pin widget for input */
  3415. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3416. /* Headphone pin widget for output */
  3417. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3418. /* CD pin widget for input */
  3419. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3420. /* unmute amp left and right */
  3421. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3422. /* set connection select to line in (default select for this ADC) */
  3423. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3424. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3425. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3426. /* mute pin widget amp left and right (no gain on this amp) */
  3427. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3428. /* unmute HP mixer amp left and right (volume = 0) */
  3429. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3430. /* mute pin widget amp left and right (no gain on this amp) */
  3431. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3432. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3433. * Line In 2 = 0x03
  3434. */
  3435. /* unmute CD */
  3436. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3437. /* unmute Line In */
  3438. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3439. /* unmute Mic */
  3440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3441. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3442. /* Unmute Front out path */
  3443. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3444. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3445. /* Unmute Headphone out path */
  3446. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3447. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3448. /* Unmute Mono out path */
  3449. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3450. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3451. { }
  3452. };
  3453. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3454. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3455. * audio = 0x16, internal speaker = 0x10.
  3456. */
  3457. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3458. /* Disable all GPIOs */
  3459. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3460. /* Internal speaker is connected to headphone pin */
  3461. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3462. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3463. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3464. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3465. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3466. /* Ensure all other unused pins are disabled and muted. */
  3467. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3468. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3469. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3470. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3471. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3472. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3474. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. /* Disable digital (SPDIF) pins */
  3476. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3477. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3478. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3479. * when acting as an output.
  3480. */
  3481. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3482. /* Start with output sum widgets muted and their output gains at min */
  3483. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3484. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3487. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3488. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3489. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3493. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3494. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3495. * If the pin mode is changed by the user the pin mode control will
  3496. * take care of enabling the pin's input/output buffers as needed.
  3497. * Therefore there's no need to enable the input buffer at this
  3498. * stage.
  3499. */
  3500. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3501. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3502. * mixer ctrl)
  3503. */
  3504. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3505. /* Mute capture amp left and right */
  3506. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3507. /* Set ADC connection select to match default mixer setting - line
  3508. * in (on mic1 pin)
  3509. */
  3510. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3511. /* Do the same for the second ADC: mute capture input amp and
  3512. * set ADC connection to line in (on mic1 pin)
  3513. */
  3514. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3516. /* Mute all inputs to mixer widget (even unconnected ones) */
  3517. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3518. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3519. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3520. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3521. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3522. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3525. { }
  3526. };
  3527. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3528. * similar laptops (adapted from Fujitsu init verbs).
  3529. */
  3530. static struct hda_verb alc260_acer_init_verbs[] = {
  3531. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3532. * the headphone jack. Turn this on and rely on the standard mute
  3533. * methods whenever the user wants to turn these outputs off.
  3534. */
  3535. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3536. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3537. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3538. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3539. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3540. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3541. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3542. /* Line In jack is connected to Line1 pin */
  3543. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3544. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3545. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3546. /* Ensure all other unused pins are disabled and muted. */
  3547. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3548. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3549. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3550. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3551. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3552. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3553. /* Disable digital (SPDIF) pins */
  3554. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3555. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3556. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3557. * bus when acting as outputs.
  3558. */
  3559. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3560. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3561. /* Start with output sum widgets muted and their output gains at min */
  3562. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3564. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3565. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3566. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3567. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3568. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3569. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3570. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3571. /* Unmute Line-out pin widget amp left and right
  3572. * (no equiv mixer ctrl)
  3573. */
  3574. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3575. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3576. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3577. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3578. * inputs. If the pin mode is changed by the user the pin mode control
  3579. * will take care of enabling the pin's input/output buffers as needed.
  3580. * Therefore there's no need to enable the input buffer at this
  3581. * stage.
  3582. */
  3583. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3584. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3585. /* Mute capture amp left and right */
  3586. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3587. /* Set ADC connection select to match default mixer setting - mic
  3588. * (on mic1 pin)
  3589. */
  3590. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3591. /* Do similar with the second ADC: mute capture input amp and
  3592. * set ADC connection to mic to match ALSA's default state.
  3593. */
  3594. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3595. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3596. /* Mute all inputs to mixer widget (even unconnected ones) */
  3597. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3598. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3599. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3600. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3601. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3602. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3603. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3605. { }
  3606. };
  3607. static struct hda_verb alc260_will_verbs[] = {
  3608. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3609. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3610. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3611. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3612. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3613. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3614. {}
  3615. };
  3616. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3617. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3618. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3619. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3620. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3621. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3622. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3623. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3624. {}
  3625. };
  3626. /* toggle speaker-output according to the hp-jack state */
  3627. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3628. {
  3629. unsigned int present;
  3630. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3631. present = snd_hda_codec_read(codec, 0x0f, 0,
  3632. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3633. if (present) {
  3634. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3635. snd_hda_codec_write(codec, 0x0f, 0,
  3636. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3637. } else {
  3638. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3639. snd_hda_codec_write(codec, 0x0f, 0,
  3640. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3641. }
  3642. }
  3643. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3644. unsigned int res)
  3645. {
  3646. if ((res >> 26) == ALC880_HP_EVENT)
  3647. alc260_replacer_672v_automute(codec);
  3648. }
  3649. /* Test configuration for debugging, modelled after the ALC880 test
  3650. * configuration.
  3651. */
  3652. #ifdef CONFIG_SND_DEBUG
  3653. static hda_nid_t alc260_test_dac_nids[1] = {
  3654. 0x02,
  3655. };
  3656. static hda_nid_t alc260_test_adc_nids[2] = {
  3657. 0x04, 0x05,
  3658. };
  3659. /* For testing the ALC260, each input MUX needs its own definition since
  3660. * the signal assignments are different. This assumes that the first ADC
  3661. * is NID 0x04.
  3662. */
  3663. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3664. {
  3665. .num_items = 7,
  3666. .items = {
  3667. { "MIC1 pin", 0x0 },
  3668. { "MIC2 pin", 0x1 },
  3669. { "LINE1 pin", 0x2 },
  3670. { "LINE2 pin", 0x3 },
  3671. { "CD pin", 0x4 },
  3672. { "LINE-OUT pin", 0x5 },
  3673. { "HP-OUT pin", 0x6 },
  3674. },
  3675. },
  3676. {
  3677. .num_items = 8,
  3678. .items = {
  3679. { "MIC1 pin", 0x0 },
  3680. { "MIC2 pin", 0x1 },
  3681. { "LINE1 pin", 0x2 },
  3682. { "LINE2 pin", 0x3 },
  3683. { "CD pin", 0x4 },
  3684. { "Mixer", 0x5 },
  3685. { "LINE-OUT pin", 0x6 },
  3686. { "HP-OUT pin", 0x7 },
  3687. },
  3688. },
  3689. };
  3690. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3691. /* Output driver widgets */
  3692. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3693. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3694. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3695. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3696. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3697. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3698. /* Modes for retasking pin widgets
  3699. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3700. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3701. * mention this restriction. At this stage it's not clear whether
  3702. * this behaviour is intentional or is a hardware bug in chip
  3703. * revisions available at least up until early 2006. Therefore for
  3704. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3705. * choices, but if it turns out that the lack of mic bias for these
  3706. * NIDs is intentional we could change their modes from
  3707. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3708. */
  3709. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3710. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3711. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3712. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3713. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3714. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3715. /* Loopback mixer controls */
  3716. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3717. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3718. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3719. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3720. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3721. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3722. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3723. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3724. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3725. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3726. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3727. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3728. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3729. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3730. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3731. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3732. /* Controls for GPIO pins, assuming they are configured as outputs */
  3733. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3734. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3735. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3736. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3737. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3738. * is ambigious as to which NID is which; testing on laptops which
  3739. * make this output available should provide clarification.
  3740. */
  3741. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3742. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3743. { } /* end */
  3744. };
  3745. static struct hda_verb alc260_test_init_verbs[] = {
  3746. /* Enable all GPIOs as outputs with an initial value of 0 */
  3747. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3748. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3749. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3750. /* Enable retasking pins as output, initially without power amp */
  3751. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3752. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3753. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3754. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3755. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3756. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3757. /* Disable digital (SPDIF) pins initially, but users can enable
  3758. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3759. * payload also sets the generation to 0, output to be in "consumer"
  3760. * PCM format, copyright asserted, no pre-emphasis and no validity
  3761. * control.
  3762. */
  3763. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3764. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3765. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3766. * OUT1 sum bus when acting as an output.
  3767. */
  3768. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3769. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3770. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3771. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3772. /* Start with output sum widgets muted and their output gains at min */
  3773. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3774. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3775. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3776. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3777. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3778. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3779. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3781. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3782. /* Unmute retasking pin widget output buffers since the default
  3783. * state appears to be output. As the pin mode is changed by the
  3784. * user the pin mode control will take care of enabling the pin's
  3785. * input/output buffers as needed.
  3786. */
  3787. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3788. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3789. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3790. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3791. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3792. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3793. /* Also unmute the mono-out pin widget */
  3794. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. /* Mute capture amp left and right */
  3796. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3797. /* Set ADC connection select to match default mixer setting (mic1
  3798. * pin)
  3799. */
  3800. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3801. /* Do the same for the second ADC: mute capture input amp and
  3802. * set ADC connection to mic1 pin
  3803. */
  3804. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3805. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3806. /* Mute all inputs to mixer widget (even unconnected ones) */
  3807. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3808. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3809. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3810. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3811. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3812. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3813. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3815. { }
  3816. };
  3817. #endif
  3818. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3819. .substreams = 1,
  3820. .channels_min = 2,
  3821. .channels_max = 2,
  3822. };
  3823. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3824. .substreams = 1,
  3825. .channels_min = 2,
  3826. .channels_max = 2,
  3827. };
  3828. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3829. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3830. /*
  3831. * for BIOS auto-configuration
  3832. */
  3833. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3834. const char *pfx)
  3835. {
  3836. hda_nid_t nid_vol;
  3837. unsigned long vol_val, sw_val;
  3838. char name[32];
  3839. int err;
  3840. if (nid >= 0x0f && nid < 0x11) {
  3841. nid_vol = nid - 0x7;
  3842. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3843. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3844. } else if (nid == 0x11) {
  3845. nid_vol = nid - 0x7;
  3846. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3847. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3848. } else if (nid >= 0x12 && nid <= 0x15) {
  3849. nid_vol = 0x08;
  3850. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3851. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3852. } else
  3853. return 0; /* N/A */
  3854. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3855. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3856. if (err < 0)
  3857. return err;
  3858. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3859. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3860. if (err < 0)
  3861. return err;
  3862. return 1;
  3863. }
  3864. /* add playback controls from the parsed DAC table */
  3865. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3866. const struct auto_pin_cfg *cfg)
  3867. {
  3868. hda_nid_t nid;
  3869. int err;
  3870. spec->multiout.num_dacs = 1;
  3871. spec->multiout.dac_nids = spec->private_dac_nids;
  3872. spec->multiout.dac_nids[0] = 0x02;
  3873. nid = cfg->line_out_pins[0];
  3874. if (nid) {
  3875. err = alc260_add_playback_controls(spec, nid, "Front");
  3876. if (err < 0)
  3877. return err;
  3878. }
  3879. nid = cfg->speaker_pins[0];
  3880. if (nid) {
  3881. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3882. if (err < 0)
  3883. return err;
  3884. }
  3885. nid = cfg->hp_pins[0];
  3886. if (nid) {
  3887. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3888. if (err < 0)
  3889. return err;
  3890. }
  3891. return 0;
  3892. }
  3893. /* create playback/capture controls for input pins */
  3894. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3895. const struct auto_pin_cfg *cfg)
  3896. {
  3897. struct hda_input_mux *imux = &spec->private_imux;
  3898. int i, err, idx;
  3899. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3900. if (cfg->input_pins[i] >= 0x12) {
  3901. idx = cfg->input_pins[i] - 0x12;
  3902. err = new_analog_input(spec, cfg->input_pins[i],
  3903. auto_pin_cfg_labels[i], idx,
  3904. 0x07);
  3905. if (err < 0)
  3906. return err;
  3907. imux->items[imux->num_items].label =
  3908. auto_pin_cfg_labels[i];
  3909. imux->items[imux->num_items].index = idx;
  3910. imux->num_items++;
  3911. }
  3912. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3913. idx = cfg->input_pins[i] - 0x09;
  3914. err = new_analog_input(spec, cfg->input_pins[i],
  3915. auto_pin_cfg_labels[i], idx,
  3916. 0x07);
  3917. if (err < 0)
  3918. return err;
  3919. imux->items[imux->num_items].label =
  3920. auto_pin_cfg_labels[i];
  3921. imux->items[imux->num_items].index = idx;
  3922. imux->num_items++;
  3923. }
  3924. }
  3925. return 0;
  3926. }
  3927. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3928. hda_nid_t nid, int pin_type,
  3929. int sel_idx)
  3930. {
  3931. /* set as output */
  3932. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3933. pin_type);
  3934. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3935. AMP_OUT_UNMUTE);
  3936. /* need the manual connection? */
  3937. if (nid >= 0x12) {
  3938. int idx = nid - 0x12;
  3939. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3940. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3941. }
  3942. }
  3943. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3944. {
  3945. struct alc_spec *spec = codec->spec;
  3946. hda_nid_t nid;
  3947. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3948. nid = spec->autocfg.line_out_pins[0];
  3949. if (nid) {
  3950. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3951. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3952. }
  3953. nid = spec->autocfg.speaker_pins[0];
  3954. if (nid)
  3955. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3956. nid = spec->autocfg.hp_pins[0];
  3957. if (nid)
  3958. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3959. }
  3960. #define ALC260_PIN_CD_NID 0x16
  3961. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3962. {
  3963. struct alc_spec *spec = codec->spec;
  3964. int i;
  3965. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3966. hda_nid_t nid = spec->autocfg.input_pins[i];
  3967. if (nid >= 0x12) {
  3968. snd_hda_codec_write(codec, nid, 0,
  3969. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3970. i <= AUTO_PIN_FRONT_MIC ?
  3971. PIN_VREF80 : PIN_IN);
  3972. if (nid != ALC260_PIN_CD_NID)
  3973. snd_hda_codec_write(codec, nid, 0,
  3974. AC_VERB_SET_AMP_GAIN_MUTE,
  3975. AMP_OUT_MUTE);
  3976. }
  3977. }
  3978. }
  3979. /*
  3980. * generic initialization of ADC, input mixers and output mixers
  3981. */
  3982. static struct hda_verb alc260_volume_init_verbs[] = {
  3983. /*
  3984. * Unmute ADC0-1 and set the default input to mic-in
  3985. */
  3986. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3987. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3988. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3989. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3990. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3991. * mixer widget
  3992. * Note: PASD motherboards uses the Line In 2 as the input for
  3993. * front panel mic (mic 2)
  3994. */
  3995. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3996. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3997. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3998. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3999. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4000. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4001. /*
  4002. * Set up output mixers (0x08 - 0x0a)
  4003. */
  4004. /* set vol=0 to output mixers */
  4005. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4006. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4007. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4008. /* set up input amps for analog loopback */
  4009. /* Amp Indices: DAC = 0, mixer = 1 */
  4010. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4011. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4012. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4013. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4014. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4015. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4016. { }
  4017. };
  4018. static int alc260_parse_auto_config(struct hda_codec *codec)
  4019. {
  4020. struct alc_spec *spec = codec->spec;
  4021. unsigned int wcap;
  4022. int err;
  4023. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4024. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4025. alc260_ignore);
  4026. if (err < 0)
  4027. return err;
  4028. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4029. if (err < 0)
  4030. return err;
  4031. if (!spec->kctl_alloc)
  4032. return 0; /* can't find valid BIOS pin config */
  4033. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4034. if (err < 0)
  4035. return err;
  4036. spec->multiout.max_channels = 2;
  4037. if (spec->autocfg.dig_out_pin)
  4038. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4039. if (spec->kctl_alloc)
  4040. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4041. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4042. spec->num_mux_defs = 1;
  4043. spec->input_mux = &spec->private_imux;
  4044. /* check whether NID 0x04 is valid */
  4045. wcap = get_wcaps(codec, 0x04);
  4046. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4047. if (wcap != AC_WID_AUD_IN) {
  4048. spec->adc_nids = alc260_adc_nids_alt;
  4049. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4050. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4051. } else {
  4052. spec->adc_nids = alc260_adc_nids;
  4053. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4054. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4055. }
  4056. spec->num_mixers++;
  4057. return 1;
  4058. }
  4059. /* additional initialization for auto-configuration model */
  4060. static void alc260_auto_init(struct hda_codec *codec)
  4061. {
  4062. alc260_auto_init_multi_out(codec);
  4063. alc260_auto_init_analog_input(codec);
  4064. }
  4065. /*
  4066. * ALC260 configurations
  4067. */
  4068. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4069. [ALC260_BASIC] = "basic",
  4070. [ALC260_HP] = "hp",
  4071. [ALC260_HP_3013] = "hp-3013",
  4072. [ALC260_FUJITSU_S702X] = "fujitsu",
  4073. [ALC260_ACER] = "acer",
  4074. [ALC260_WILL] = "will",
  4075. [ALC260_REPLACER_672V] = "replacer",
  4076. #ifdef CONFIG_SND_DEBUG
  4077. [ALC260_TEST] = "test",
  4078. #endif
  4079. [ALC260_AUTO] = "auto",
  4080. };
  4081. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4082. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4083. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4084. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4085. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4086. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4087. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4088. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4089. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4090. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4091. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4092. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4093. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4094. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4095. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4096. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4097. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4098. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4099. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4100. {}
  4101. };
  4102. static struct alc_config_preset alc260_presets[] = {
  4103. [ALC260_BASIC] = {
  4104. .mixers = { alc260_base_output_mixer,
  4105. alc260_input_mixer,
  4106. alc260_pc_beep_mixer,
  4107. alc260_capture_mixer },
  4108. .init_verbs = { alc260_init_verbs },
  4109. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4110. .dac_nids = alc260_dac_nids,
  4111. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4112. .adc_nids = alc260_adc_nids,
  4113. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4114. .channel_mode = alc260_modes,
  4115. .input_mux = &alc260_capture_source,
  4116. },
  4117. [ALC260_HP] = {
  4118. .mixers = { alc260_base_output_mixer,
  4119. alc260_input_mixer,
  4120. alc260_capture_alt_mixer },
  4121. .init_verbs = { alc260_init_verbs },
  4122. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4123. .dac_nids = alc260_dac_nids,
  4124. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4125. .adc_nids = alc260_hp_adc_nids,
  4126. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4127. .channel_mode = alc260_modes,
  4128. .input_mux = &alc260_capture_source,
  4129. },
  4130. [ALC260_HP_3013] = {
  4131. .mixers = { alc260_hp_3013_mixer,
  4132. alc260_input_mixer,
  4133. alc260_capture_alt_mixer },
  4134. .init_verbs = { alc260_hp_3013_init_verbs },
  4135. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4136. .dac_nids = alc260_dac_nids,
  4137. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4138. .adc_nids = alc260_hp_adc_nids,
  4139. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4140. .channel_mode = alc260_modes,
  4141. .input_mux = &alc260_capture_source,
  4142. },
  4143. [ALC260_FUJITSU_S702X] = {
  4144. .mixers = { alc260_fujitsu_mixer,
  4145. alc260_capture_mixer },
  4146. .init_verbs = { alc260_fujitsu_init_verbs },
  4147. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4148. .dac_nids = alc260_dac_nids,
  4149. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4150. .adc_nids = alc260_dual_adc_nids,
  4151. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4152. .channel_mode = alc260_modes,
  4153. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4154. .input_mux = alc260_fujitsu_capture_sources,
  4155. },
  4156. [ALC260_ACER] = {
  4157. .mixers = { alc260_acer_mixer,
  4158. alc260_capture_mixer },
  4159. .init_verbs = { alc260_acer_init_verbs },
  4160. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4161. .dac_nids = alc260_dac_nids,
  4162. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4163. .adc_nids = alc260_dual_adc_nids,
  4164. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4165. .channel_mode = alc260_modes,
  4166. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4167. .input_mux = alc260_acer_capture_sources,
  4168. },
  4169. [ALC260_WILL] = {
  4170. .mixers = { alc260_will_mixer,
  4171. alc260_capture_mixer },
  4172. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4173. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4174. .dac_nids = alc260_dac_nids,
  4175. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4176. .adc_nids = alc260_adc_nids,
  4177. .dig_out_nid = ALC260_DIGOUT_NID,
  4178. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4179. .channel_mode = alc260_modes,
  4180. .input_mux = &alc260_capture_source,
  4181. },
  4182. [ALC260_REPLACER_672V] = {
  4183. .mixers = { alc260_replacer_672v_mixer,
  4184. alc260_capture_mixer },
  4185. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4186. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4187. .dac_nids = alc260_dac_nids,
  4188. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4189. .adc_nids = alc260_adc_nids,
  4190. .dig_out_nid = ALC260_DIGOUT_NID,
  4191. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4192. .channel_mode = alc260_modes,
  4193. .input_mux = &alc260_capture_source,
  4194. .unsol_event = alc260_replacer_672v_unsol_event,
  4195. .init_hook = alc260_replacer_672v_automute,
  4196. },
  4197. #ifdef CONFIG_SND_DEBUG
  4198. [ALC260_TEST] = {
  4199. .mixers = { alc260_test_mixer,
  4200. alc260_capture_mixer },
  4201. .init_verbs = { alc260_test_init_verbs },
  4202. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4203. .dac_nids = alc260_test_dac_nids,
  4204. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4205. .adc_nids = alc260_test_adc_nids,
  4206. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4207. .channel_mode = alc260_modes,
  4208. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4209. .input_mux = alc260_test_capture_sources,
  4210. },
  4211. #endif
  4212. };
  4213. static int patch_alc260(struct hda_codec *codec)
  4214. {
  4215. struct alc_spec *spec;
  4216. int err, board_config;
  4217. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4218. if (spec == NULL)
  4219. return -ENOMEM;
  4220. codec->spec = spec;
  4221. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4222. alc260_models,
  4223. alc260_cfg_tbl);
  4224. if (board_config < 0) {
  4225. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4226. "trying auto-probe from BIOS...\n");
  4227. board_config = ALC260_AUTO;
  4228. }
  4229. if (board_config == ALC260_AUTO) {
  4230. /* automatic parse from the BIOS config */
  4231. err = alc260_parse_auto_config(codec);
  4232. if (err < 0) {
  4233. alc_free(codec);
  4234. return err;
  4235. } else if (!err) {
  4236. printk(KERN_INFO
  4237. "hda_codec: Cannot set up configuration "
  4238. "from BIOS. Using base mode...\n");
  4239. board_config = ALC260_BASIC;
  4240. }
  4241. }
  4242. if (board_config != ALC260_AUTO)
  4243. setup_preset(spec, &alc260_presets[board_config]);
  4244. spec->stream_name_analog = "ALC260 Analog";
  4245. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4246. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4247. spec->stream_name_digital = "ALC260 Digital";
  4248. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4249. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4250. codec->patch_ops = alc_patch_ops;
  4251. if (board_config == ALC260_AUTO)
  4252. spec->init_hook = alc260_auto_init;
  4253. return 0;
  4254. }
  4255. /*
  4256. * ALC882 support
  4257. *
  4258. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4259. * configuration. Each pin widget can choose any input DACs and a mixer.
  4260. * Each ADC is connected from a mixer of all inputs. This makes possible
  4261. * 6-channel independent captures.
  4262. *
  4263. * In addition, an independent DAC for the multi-playback (not used in this
  4264. * driver yet).
  4265. */
  4266. #define ALC882_DIGOUT_NID 0x06
  4267. #define ALC882_DIGIN_NID 0x0a
  4268. static struct hda_channel_mode alc882_ch_modes[1] = {
  4269. { 8, NULL }
  4270. };
  4271. static hda_nid_t alc882_dac_nids[4] = {
  4272. /* front, rear, clfe, rear_surr */
  4273. 0x02, 0x03, 0x04, 0x05
  4274. };
  4275. /* identical with ALC880 */
  4276. #define alc882_adc_nids alc880_adc_nids
  4277. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4278. /* input MUX */
  4279. /* FIXME: should be a matrix-type input source selection */
  4280. static struct hda_input_mux alc882_capture_source = {
  4281. .num_items = 4,
  4282. .items = {
  4283. { "Mic", 0x0 },
  4284. { "Front Mic", 0x1 },
  4285. { "Line", 0x2 },
  4286. { "CD", 0x4 },
  4287. },
  4288. };
  4289. #define alc882_mux_enum_info alc_mux_enum_info
  4290. #define alc882_mux_enum_get alc_mux_enum_get
  4291. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4292. struct snd_ctl_elem_value *ucontrol)
  4293. {
  4294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4295. struct alc_spec *spec = codec->spec;
  4296. const struct hda_input_mux *imux = spec->input_mux;
  4297. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4298. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4299. hda_nid_t nid = capture_mixers[adc_idx];
  4300. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4301. unsigned int i, idx;
  4302. idx = ucontrol->value.enumerated.item[0];
  4303. if (idx >= imux->num_items)
  4304. idx = imux->num_items - 1;
  4305. if (*cur_val == idx && !codec->in_resume)
  4306. return 0;
  4307. for (i = 0; i < imux->num_items; i++) {
  4308. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4309. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4310. v | (imux->items[i].index << 8));
  4311. }
  4312. *cur_val = idx;
  4313. return 1;
  4314. }
  4315. /*
  4316. * 2ch mode
  4317. */
  4318. static struct hda_verb alc882_3ST_ch2_init[] = {
  4319. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4320. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4321. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4322. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4323. { } /* end */
  4324. };
  4325. /*
  4326. * 6ch mode
  4327. */
  4328. static struct hda_verb alc882_3ST_ch6_init[] = {
  4329. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4330. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4331. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4332. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4333. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4334. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4335. { } /* end */
  4336. };
  4337. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4338. { 2, alc882_3ST_ch2_init },
  4339. { 6, alc882_3ST_ch6_init },
  4340. };
  4341. /*
  4342. * 6ch mode
  4343. */
  4344. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4345. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4346. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4347. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4348. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4349. { } /* end */
  4350. };
  4351. /*
  4352. * 8ch mode
  4353. */
  4354. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4355. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4356. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4357. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4358. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4359. { } /* end */
  4360. };
  4361. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4362. { 6, alc882_sixstack_ch6_init },
  4363. { 8, alc882_sixstack_ch8_init },
  4364. };
  4365. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4366. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4367. */
  4368. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4369. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4370. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4371. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4372. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4373. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4374. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4375. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4376. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4378. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4379. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4380. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4381. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4382. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4383. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4385. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4386. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4387. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4391. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4392. { } /* end */
  4393. };
  4394. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4395. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4396. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4397. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4398. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4399. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4400. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4401. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4402. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4403. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4404. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4405. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4406. { } /* end */
  4407. };
  4408. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4409. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4410. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4411. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4412. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4413. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4414. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4415. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4416. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4417. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4418. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4419. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4420. { } /* end */
  4421. };
  4422. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4423. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4424. */
  4425. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4427. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4428. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4429. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4430. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4431. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4432. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4433. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4434. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4435. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4436. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4437. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4438. { } /* end */
  4439. };
  4440. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4441. {
  4442. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4443. .name = "Channel Mode",
  4444. .info = alc_ch_mode_info,
  4445. .get = alc_ch_mode_get,
  4446. .put = alc_ch_mode_put,
  4447. },
  4448. { } /* end */
  4449. };
  4450. static struct hda_verb alc882_init_verbs[] = {
  4451. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4452. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4453. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4454. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4455. /* Rear mixer */
  4456. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4457. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4458. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4459. /* CLFE mixer */
  4460. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4461. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4462. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4463. /* Side mixer */
  4464. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4465. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4466. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4467. /* Front Pin: output 0 (0x0c) */
  4468. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4469. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4470. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4471. /* Rear Pin: output 1 (0x0d) */
  4472. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4473. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4474. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4475. /* CLFE Pin: output 2 (0x0e) */
  4476. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4477. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4478. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4479. /* Side Pin: output 3 (0x0f) */
  4480. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4481. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4482. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4483. /* Mic (rear) pin: input vref at 80% */
  4484. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4485. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4486. /* Front Mic pin: input vref at 80% */
  4487. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4488. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4489. /* Line In pin: input */
  4490. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4492. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4493. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4494. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4495. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4496. /* CD pin widget for input */
  4497. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4498. /* FIXME: use matrix-type input source selection */
  4499. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4500. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4501. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4502. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4503. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4504. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4505. /* Input mixer2 */
  4506. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4507. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4508. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4509. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4510. /* Input mixer3 */
  4511. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4512. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4513. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4514. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4515. /* ADC1: mute amp left and right */
  4516. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4517. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4518. /* ADC2: mute amp left and right */
  4519. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4520. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4521. /* ADC3: mute amp left and right */
  4522. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4523. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4524. { }
  4525. };
  4526. static struct hda_verb alc882_eapd_verbs[] = {
  4527. /* change to EAPD mode */
  4528. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4529. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4530. { }
  4531. };
  4532. /* Mac Pro test */
  4533. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4534. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4535. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4536. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4537. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4538. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4539. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4540. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4541. { } /* end */
  4542. };
  4543. static struct hda_verb alc882_macpro_init_verbs[] = {
  4544. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4545. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4546. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4547. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4548. /* Front Pin: output 0 (0x0c) */
  4549. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4550. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4551. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4552. /* Front Mic pin: input vref at 80% */
  4553. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4554. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4555. /* Speaker: output */
  4556. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4557. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4558. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4559. /* Headphone output (output 0 - 0x0c) */
  4560. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4561. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4562. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4563. /* FIXME: use matrix-type input source selection */
  4564. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4565. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4566. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4567. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4568. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4569. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4570. /* Input mixer2 */
  4571. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4572. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4573. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4574. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4575. /* Input mixer3 */
  4576. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4577. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4578. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4579. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4580. /* ADC1: mute amp left and right */
  4581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4582. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4583. /* ADC2: mute amp left and right */
  4584. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4585. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4586. /* ADC3: mute amp left and right */
  4587. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4589. { }
  4590. };
  4591. static struct hda_verb alc882_targa_verbs[] = {
  4592. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4593. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4594. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4595. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4596. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4597. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4598. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4599. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4600. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4601. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4602. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4603. { } /* end */
  4604. };
  4605. /* toggle speaker-output according to the hp-jack state */
  4606. static void alc882_targa_automute(struct hda_codec *codec)
  4607. {
  4608. unsigned int present;
  4609. present = snd_hda_codec_read(codec, 0x14, 0,
  4610. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4611. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4612. 0x80, present ? 0x80 : 0);
  4613. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4614. 0x80, present ? 0x80 : 0);
  4615. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4616. }
  4617. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4618. {
  4619. /* Looks like the unsol event is incompatible with the standard
  4620. * definition. 4bit tag is placed at 26 bit!
  4621. */
  4622. if (((res >> 26) == ALC880_HP_EVENT)) {
  4623. alc882_targa_automute(codec);
  4624. }
  4625. }
  4626. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4627. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4629. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4630. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4631. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4632. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4633. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4634. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4635. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4636. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4637. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4638. { } /* end */
  4639. };
  4640. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4641. {
  4642. unsigned int gpiostate, gpiomask, gpiodir;
  4643. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4644. AC_VERB_GET_GPIO_DATA, 0);
  4645. if (!muted)
  4646. gpiostate |= (1 << pin);
  4647. else
  4648. gpiostate &= ~(1 << pin);
  4649. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4650. AC_VERB_GET_GPIO_MASK, 0);
  4651. gpiomask |= (1 << pin);
  4652. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4653. AC_VERB_GET_GPIO_DIRECTION, 0);
  4654. gpiodir |= (1 << pin);
  4655. snd_hda_codec_write(codec, codec->afg, 0,
  4656. AC_VERB_SET_GPIO_MASK, gpiomask);
  4657. snd_hda_codec_write(codec, codec->afg, 0,
  4658. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4659. msleep(1);
  4660. snd_hda_codec_write(codec, codec->afg, 0,
  4661. AC_VERB_SET_GPIO_DATA, gpiostate);
  4662. }
  4663. /*
  4664. * generic initialization of ADC, input mixers and output mixers
  4665. */
  4666. static struct hda_verb alc882_auto_init_verbs[] = {
  4667. /*
  4668. * Unmute ADC0-2 and set the default input to mic-in
  4669. */
  4670. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4671. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4672. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4673. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4674. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4675. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4676. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4677. * mixer widget
  4678. * Note: PASD motherboards uses the Line In 2 as the input for
  4679. * front panel mic (mic 2)
  4680. */
  4681. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4686. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4687. /*
  4688. * Set up output mixers (0x0c - 0x0f)
  4689. */
  4690. /* set vol=0 to output mixers */
  4691. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4692. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4693. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4694. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4695. /* set up input amps for analog loopback */
  4696. /* Amp Indices: DAC = 0, mixer = 1 */
  4697. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4700. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4701. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4703. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4704. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4705. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4706. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4707. /* FIXME: use matrix-type input source selection */
  4708. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4709. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4710. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4711. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4712. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4713. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4714. /* Input mixer2 */
  4715. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4716. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4717. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4718. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4719. /* Input mixer3 */
  4720. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4721. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4722. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4723. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4724. { }
  4725. };
  4726. /* capture mixer elements */
  4727. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4728. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4729. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4730. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4731. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4732. {
  4733. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4734. /* The multiple "Capture Source" controls confuse alsamixer
  4735. * So call somewhat different..
  4736. * FIXME: the controls appear in the "playback" view!
  4737. */
  4738. /* .name = "Capture Source", */
  4739. .name = "Input Source",
  4740. .count = 2,
  4741. .info = alc882_mux_enum_info,
  4742. .get = alc882_mux_enum_get,
  4743. .put = alc882_mux_enum_put,
  4744. },
  4745. { } /* end */
  4746. };
  4747. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4748. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4749. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4750. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4751. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4752. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4753. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4754. {
  4755. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4756. /* The multiple "Capture Source" controls confuse alsamixer
  4757. * So call somewhat different..
  4758. * FIXME: the controls appear in the "playback" view!
  4759. */
  4760. /* .name = "Capture Source", */
  4761. .name = "Input Source",
  4762. .count = 3,
  4763. .info = alc882_mux_enum_info,
  4764. .get = alc882_mux_enum_get,
  4765. .put = alc882_mux_enum_put,
  4766. },
  4767. { } /* end */
  4768. };
  4769. /* pcm configuration: identiacal with ALC880 */
  4770. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4771. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4772. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4773. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4774. /*
  4775. * configuration and preset
  4776. */
  4777. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4778. [ALC882_3ST_DIG] = "3stack-dig",
  4779. [ALC882_6ST_DIG] = "6stack-dig",
  4780. [ALC882_ARIMA] = "arima",
  4781. [ALC882_W2JC] = "w2jc",
  4782. [ALC885_MACPRO] = "macpro",
  4783. [ALC882_AUTO] = "auto",
  4784. };
  4785. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4786. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4787. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4788. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4789. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4790. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4791. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4792. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4793. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4794. {}
  4795. };
  4796. static struct alc_config_preset alc882_presets[] = {
  4797. [ALC882_3ST_DIG] = {
  4798. .mixers = { alc882_base_mixer },
  4799. .init_verbs = { alc882_init_verbs },
  4800. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4801. .dac_nids = alc882_dac_nids,
  4802. .dig_out_nid = ALC882_DIGOUT_NID,
  4803. .dig_in_nid = ALC882_DIGIN_NID,
  4804. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4805. .channel_mode = alc882_ch_modes,
  4806. .need_dac_fix = 1,
  4807. .input_mux = &alc882_capture_source,
  4808. },
  4809. [ALC882_6ST_DIG] = {
  4810. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4811. .init_verbs = { alc882_init_verbs },
  4812. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4813. .dac_nids = alc882_dac_nids,
  4814. .dig_out_nid = ALC882_DIGOUT_NID,
  4815. .dig_in_nid = ALC882_DIGIN_NID,
  4816. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4817. .channel_mode = alc882_sixstack_modes,
  4818. .input_mux = &alc882_capture_source,
  4819. },
  4820. [ALC882_ARIMA] = {
  4821. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4822. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4823. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4824. .dac_nids = alc882_dac_nids,
  4825. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4826. .channel_mode = alc882_sixstack_modes,
  4827. .input_mux = &alc882_capture_source,
  4828. },
  4829. [ALC882_W2JC] = {
  4830. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4831. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4832. alc880_gpio1_init_verbs },
  4833. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4834. .dac_nids = alc882_dac_nids,
  4835. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4836. .channel_mode = alc880_threestack_modes,
  4837. .need_dac_fix = 1,
  4838. .input_mux = &alc882_capture_source,
  4839. .dig_out_nid = ALC882_DIGOUT_NID,
  4840. },
  4841. [ALC885_MACPRO] = {
  4842. .mixers = { alc882_macpro_mixer },
  4843. .init_verbs = { alc882_macpro_init_verbs },
  4844. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4845. .dac_nids = alc882_dac_nids,
  4846. .dig_out_nid = ALC882_DIGOUT_NID,
  4847. .dig_in_nid = ALC882_DIGIN_NID,
  4848. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4849. .channel_mode = alc882_ch_modes,
  4850. .input_mux = &alc882_capture_source,
  4851. },
  4852. [ALC882_TARGA] = {
  4853. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4854. alc882_capture_mixer },
  4855. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4856. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4857. .dac_nids = alc882_dac_nids,
  4858. .dig_out_nid = ALC882_DIGOUT_NID,
  4859. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4860. .adc_nids = alc882_adc_nids,
  4861. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4862. .channel_mode = alc882_3ST_6ch_modes,
  4863. .need_dac_fix = 1,
  4864. .input_mux = &alc882_capture_source,
  4865. .unsol_event = alc882_targa_unsol_event,
  4866. .init_hook = alc882_targa_automute,
  4867. },
  4868. [ALC882_ASUS_A7J] = {
  4869. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4870. alc882_capture_mixer },
  4871. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4872. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4873. .dac_nids = alc882_dac_nids,
  4874. .dig_out_nid = ALC882_DIGOUT_NID,
  4875. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4876. .adc_nids = alc882_adc_nids,
  4877. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4878. .channel_mode = alc882_3ST_6ch_modes,
  4879. .need_dac_fix = 1,
  4880. .input_mux = &alc882_capture_source,
  4881. },
  4882. };
  4883. /*
  4884. * BIOS auto configuration
  4885. */
  4886. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4887. hda_nid_t nid, int pin_type,
  4888. int dac_idx)
  4889. {
  4890. /* set as output */
  4891. struct alc_spec *spec = codec->spec;
  4892. int idx;
  4893. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4894. idx = 4;
  4895. else
  4896. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4897. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4898. pin_type);
  4899. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4900. AMP_OUT_UNMUTE);
  4901. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4902. }
  4903. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4904. {
  4905. struct alc_spec *spec = codec->spec;
  4906. int i;
  4907. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4908. for (i = 0; i <= HDA_SIDE; i++) {
  4909. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4910. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4911. if (nid)
  4912. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4913. i);
  4914. }
  4915. }
  4916. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4917. {
  4918. struct alc_spec *spec = codec->spec;
  4919. hda_nid_t pin;
  4920. pin = spec->autocfg.hp_pins[0];
  4921. if (pin) /* connect to front */
  4922. /* use dac 0 */
  4923. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4924. }
  4925. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4926. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4927. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4928. {
  4929. struct alc_spec *spec = codec->spec;
  4930. int i;
  4931. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4932. hda_nid_t nid = spec->autocfg.input_pins[i];
  4933. if (alc882_is_input_pin(nid)) {
  4934. snd_hda_codec_write(codec, nid, 0,
  4935. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4936. i <= AUTO_PIN_FRONT_MIC ?
  4937. PIN_VREF80 : PIN_IN);
  4938. if (nid != ALC882_PIN_CD_NID)
  4939. snd_hda_codec_write(codec, nid, 0,
  4940. AC_VERB_SET_AMP_GAIN_MUTE,
  4941. AMP_OUT_MUTE);
  4942. }
  4943. }
  4944. }
  4945. /* almost identical with ALC880 parser... */
  4946. static int alc882_parse_auto_config(struct hda_codec *codec)
  4947. {
  4948. struct alc_spec *spec = codec->spec;
  4949. int err = alc880_parse_auto_config(codec);
  4950. if (err < 0)
  4951. return err;
  4952. else if (err > 0)
  4953. /* hack - override the init verbs */
  4954. spec->init_verbs[0] = alc882_auto_init_verbs;
  4955. return err;
  4956. }
  4957. /* additional initialization for auto-configuration model */
  4958. static void alc882_auto_init(struct hda_codec *codec)
  4959. {
  4960. alc882_auto_init_multi_out(codec);
  4961. alc882_auto_init_hp_out(codec);
  4962. alc882_auto_init_analog_input(codec);
  4963. }
  4964. static int patch_alc882(struct hda_codec *codec)
  4965. {
  4966. struct alc_spec *spec;
  4967. int err, board_config;
  4968. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4969. if (spec == NULL)
  4970. return -ENOMEM;
  4971. codec->spec = spec;
  4972. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4973. alc882_models,
  4974. alc882_cfg_tbl);
  4975. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4976. /* Pick up systems that don't supply PCI SSID */
  4977. switch (codec->subsystem_id) {
  4978. case 0x106b0c00: /* Mac Pro */
  4979. board_config = ALC885_MACPRO;
  4980. break;
  4981. default:
  4982. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4983. "trying auto-probe from BIOS...\n");
  4984. board_config = ALC882_AUTO;
  4985. }
  4986. }
  4987. if (board_config == ALC882_AUTO) {
  4988. /* automatic parse from the BIOS config */
  4989. err = alc882_parse_auto_config(codec);
  4990. if (err < 0) {
  4991. alc_free(codec);
  4992. return err;
  4993. } else if (!err) {
  4994. printk(KERN_INFO
  4995. "hda_codec: Cannot set up configuration "
  4996. "from BIOS. Using base mode...\n");
  4997. board_config = ALC882_3ST_DIG;
  4998. }
  4999. }
  5000. if (board_config != ALC882_AUTO)
  5001. setup_preset(spec, &alc882_presets[board_config]);
  5002. if (board_config == ALC885_MACPRO) {
  5003. alc882_gpio_mute(codec, 0, 0);
  5004. alc882_gpio_mute(codec, 1, 0);
  5005. }
  5006. spec->stream_name_analog = "ALC882 Analog";
  5007. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5008. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5009. spec->stream_name_digital = "ALC882 Digital";
  5010. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5011. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5012. if (!spec->adc_nids && spec->input_mux) {
  5013. /* check whether NID 0x07 is valid */
  5014. unsigned int wcap = get_wcaps(codec, 0x07);
  5015. /* get type */
  5016. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5017. if (wcap != AC_WID_AUD_IN) {
  5018. spec->adc_nids = alc882_adc_nids_alt;
  5019. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5020. spec->mixers[spec->num_mixers] =
  5021. alc882_capture_alt_mixer;
  5022. spec->num_mixers++;
  5023. } else {
  5024. spec->adc_nids = alc882_adc_nids;
  5025. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5026. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5027. spec->num_mixers++;
  5028. }
  5029. }
  5030. codec->patch_ops = alc_patch_ops;
  5031. if (board_config == ALC882_AUTO)
  5032. spec->init_hook = alc882_auto_init;
  5033. return 0;
  5034. }
  5035. /*
  5036. * ALC883 support
  5037. *
  5038. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5039. * configuration. Each pin widget can choose any input DACs and a mixer.
  5040. * Each ADC is connected from a mixer of all inputs. This makes possible
  5041. * 6-channel independent captures.
  5042. *
  5043. * In addition, an independent DAC for the multi-playback (not used in this
  5044. * driver yet).
  5045. */
  5046. #define ALC883_DIGOUT_NID 0x06
  5047. #define ALC883_DIGIN_NID 0x0a
  5048. static hda_nid_t alc883_dac_nids[4] = {
  5049. /* front, rear, clfe, rear_surr */
  5050. 0x02, 0x04, 0x03, 0x05
  5051. };
  5052. static hda_nid_t alc883_adc_nids[2] = {
  5053. /* ADC1-2 */
  5054. 0x08, 0x09,
  5055. };
  5056. /* input MUX */
  5057. /* FIXME: should be a matrix-type input source selection */
  5058. static struct hda_input_mux alc883_capture_source = {
  5059. .num_items = 4,
  5060. .items = {
  5061. { "Mic", 0x0 },
  5062. { "Front Mic", 0x1 },
  5063. { "Line", 0x2 },
  5064. { "CD", 0x4 },
  5065. },
  5066. };
  5067. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5068. .num_items = 2,
  5069. .items = {
  5070. { "Mic", 0x1 },
  5071. { "Line", 0x2 },
  5072. },
  5073. };
  5074. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5075. .num_items = 4,
  5076. .items = {
  5077. { "Mic", 0x0 },
  5078. { "iMic", 0x1 },
  5079. { "Line", 0x2 },
  5080. { "CD", 0x4 },
  5081. },
  5082. };
  5083. #define alc883_mux_enum_info alc_mux_enum_info
  5084. #define alc883_mux_enum_get alc_mux_enum_get
  5085. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5086. struct snd_ctl_elem_value *ucontrol)
  5087. {
  5088. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5089. struct alc_spec *spec = codec->spec;
  5090. const struct hda_input_mux *imux = spec->input_mux;
  5091. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5092. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5093. hda_nid_t nid = capture_mixers[adc_idx];
  5094. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5095. unsigned int i, idx;
  5096. idx = ucontrol->value.enumerated.item[0];
  5097. if (idx >= imux->num_items)
  5098. idx = imux->num_items - 1;
  5099. if (*cur_val == idx && !codec->in_resume)
  5100. return 0;
  5101. for (i = 0; i < imux->num_items; i++) {
  5102. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5103. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5104. v | (imux->items[i].index << 8));
  5105. }
  5106. *cur_val = idx;
  5107. return 1;
  5108. }
  5109. /*
  5110. * 2ch mode
  5111. */
  5112. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5113. { 2, NULL }
  5114. };
  5115. /*
  5116. * 2ch mode
  5117. */
  5118. static struct hda_verb alc883_3ST_ch2_init[] = {
  5119. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5120. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5121. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5122. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5123. { } /* end */
  5124. };
  5125. /*
  5126. * 6ch mode
  5127. */
  5128. static struct hda_verb alc883_3ST_ch6_init[] = {
  5129. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5130. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5131. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5132. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5133. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5134. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5135. { } /* end */
  5136. };
  5137. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5138. { 2, alc883_3ST_ch2_init },
  5139. { 6, alc883_3ST_ch6_init },
  5140. };
  5141. /*
  5142. * 6ch mode
  5143. */
  5144. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5145. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5146. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5147. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5148. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5149. { } /* end */
  5150. };
  5151. /*
  5152. * 8ch mode
  5153. */
  5154. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5155. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5156. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5157. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5158. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5159. { } /* end */
  5160. };
  5161. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5162. { 6, alc883_sixstack_ch6_init },
  5163. { 8, alc883_sixstack_ch8_init },
  5164. };
  5165. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5166. /* eanable EAPD on medion laptop */
  5167. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5168. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5169. { }
  5170. };
  5171. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5172. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5173. */
  5174. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5175. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5176. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5177. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5178. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5179. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5180. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5181. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5182. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5183. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5184. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5185. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5186. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5187. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5188. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5189. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5191. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5192. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5193. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5194. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5195. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5196. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5197. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5198. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5199. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5200. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5201. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5202. {
  5203. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5204. /* .name = "Capture Source", */
  5205. .name = "Input Source",
  5206. .count = 2,
  5207. .info = alc883_mux_enum_info,
  5208. .get = alc883_mux_enum_get,
  5209. .put = alc883_mux_enum_put,
  5210. },
  5211. { } /* end */
  5212. };
  5213. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5214. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5215. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5216. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5217. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5218. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5219. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5220. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5221. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5222. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5224. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5225. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5226. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5227. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5228. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5229. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5230. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5231. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5232. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5233. {
  5234. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5235. /* .name = "Capture Source", */
  5236. .name = "Input Source",
  5237. .count = 2,
  5238. .info = alc883_mux_enum_info,
  5239. .get = alc883_mux_enum_get,
  5240. .put = alc883_mux_enum_put,
  5241. },
  5242. { } /* end */
  5243. };
  5244. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5245. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5246. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5247. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5248. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5249. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5250. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5251. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5252. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5253. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5254. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5255. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5256. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5257. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5258. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5259. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5260. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5261. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5262. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5263. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5265. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5267. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5268. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5269. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5270. {
  5271. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5272. /* .name = "Capture Source", */
  5273. .name = "Input Source",
  5274. .count = 2,
  5275. .info = alc883_mux_enum_info,
  5276. .get = alc883_mux_enum_get,
  5277. .put = alc883_mux_enum_put,
  5278. },
  5279. { } /* end */
  5280. };
  5281. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5282. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5283. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5284. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5285. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5286. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5287. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5288. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5289. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5292. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5293. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5294. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5296. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5297. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5298. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5299. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5300. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5302. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5304. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5305. {
  5306. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5307. /* .name = "Capture Source", */
  5308. .name = "Input Source",
  5309. .count = 1,
  5310. .info = alc883_mux_enum_info,
  5311. .get = alc883_mux_enum_get,
  5312. .put = alc883_mux_enum_put,
  5313. },
  5314. { } /* end */
  5315. };
  5316. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5317. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5318. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5319. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5320. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5321. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5322. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5323. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5324. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5325. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5326. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5327. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5328. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5330. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5331. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5332. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5333. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5334. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5335. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5336. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5337. {
  5338. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5339. /* .name = "Capture Source", */
  5340. .name = "Input Source",
  5341. .count = 2,
  5342. .info = alc883_mux_enum_info,
  5343. .get = alc883_mux_enum_get,
  5344. .put = alc883_mux_enum_put,
  5345. },
  5346. { } /* end */
  5347. };
  5348. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5349. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5350. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5351. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5352. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5353. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5355. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5356. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5357. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5358. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5359. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5360. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5361. {
  5362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5363. /* .name = "Capture Source", */
  5364. .name = "Input Source",
  5365. .count = 2,
  5366. .info = alc883_mux_enum_info,
  5367. .get = alc883_mux_enum_get,
  5368. .put = alc883_mux_enum_put,
  5369. },
  5370. { } /* end */
  5371. };
  5372. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5374. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5376. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5377. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5378. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5380. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5382. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5383. {
  5384. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5385. /* .name = "Capture Source", */
  5386. .name = "Input Source",
  5387. .count = 1,
  5388. .info = alc883_mux_enum_info,
  5389. .get = alc883_mux_enum_get,
  5390. .put = alc883_mux_enum_put,
  5391. },
  5392. { } /* end */
  5393. };
  5394. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5395. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5396. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5397. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5398. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5399. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5400. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5401. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5402. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5403. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5406. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5407. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5408. {
  5409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5410. /* .name = "Capture Source", */
  5411. .name = "Input Source",
  5412. .count = 2,
  5413. .info = alc883_mux_enum_info,
  5414. .get = alc883_mux_enum_get,
  5415. .put = alc883_mux_enum_put,
  5416. },
  5417. { } /* end */
  5418. };
  5419. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5420. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5421. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5422. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5423. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5424. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5425. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5426. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5428. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5430. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5433. {
  5434. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5435. /* .name = "Capture Source", */
  5436. .name = "Input Source",
  5437. .count = 2,
  5438. .info = alc883_mux_enum_info,
  5439. .get = alc883_mux_enum_get,
  5440. .put = alc883_mux_enum_put,
  5441. },
  5442. { } /* end */
  5443. };
  5444. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5445. {
  5446. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5447. .name = "Channel Mode",
  5448. .info = alc_ch_mode_info,
  5449. .get = alc_ch_mode_get,
  5450. .put = alc_ch_mode_put,
  5451. },
  5452. { } /* end */
  5453. };
  5454. static struct hda_verb alc883_init_verbs[] = {
  5455. /* ADC1: mute amp left and right */
  5456. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5457. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5458. /* ADC2: mute amp left and right */
  5459. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5460. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5461. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5462. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5463. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5464. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5465. /* Rear mixer */
  5466. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5467. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5468. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5469. /* CLFE mixer */
  5470. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5471. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5472. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5473. /* Side mixer */
  5474. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5475. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5476. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5477. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5478. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5479. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5480. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5481. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5482. /* Front Pin: output 0 (0x0c) */
  5483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5485. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5486. /* Rear Pin: output 1 (0x0d) */
  5487. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5488. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5489. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5490. /* CLFE Pin: output 2 (0x0e) */
  5491. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5492. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5493. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5494. /* Side Pin: output 3 (0x0f) */
  5495. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5496. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5497. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5498. /* Mic (rear) pin: input vref at 80% */
  5499. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5500. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5501. /* Front Mic pin: input vref at 80% */
  5502. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5503. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5504. /* Line In pin: input */
  5505. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5506. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5507. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5508. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5509. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5510. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5511. /* CD pin widget for input */
  5512. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5513. /* FIXME: use matrix-type input source selection */
  5514. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5515. /* Input mixer2 */
  5516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5517. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5518. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5519. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5520. /* Input mixer3 */
  5521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5522. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5523. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5524. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5525. { }
  5526. };
  5527. static struct hda_verb alc883_tagra_verbs[] = {
  5528. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5529. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5530. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5531. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5532. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5533. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5534. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5535. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5536. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5537. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5538. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5539. { } /* end */
  5540. };
  5541. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5542. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5543. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5544. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5545. { } /* end */
  5546. };
  5547. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5548. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5549. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5550. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5551. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5552. { } /* end */
  5553. };
  5554. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5555. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5556. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5557. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5558. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5559. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5560. { } /* end */
  5561. };
  5562. /* toggle front-jack and RCA according to the hp-jack state */
  5563. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5564. {
  5565. unsigned int present;
  5566. present = snd_hda_codec_read(codec, 0x1b, 0,
  5567. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5568. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5569. 0x80, present ? 0x80 : 0);
  5570. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5571. 0x80, present ? 0x80 : 0);
  5572. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5573. 0x80, present ? 0x80 : 0);
  5574. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5575. 0x80, present ? 0x80 : 0);
  5576. }
  5577. /* toggle RCA according to the front-jack state */
  5578. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5579. {
  5580. unsigned int present;
  5581. present = snd_hda_codec_read(codec, 0x14, 0,
  5582. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5583. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5584. 0x80, present ? 0x80 : 0);
  5585. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5586. 0x80, present ? 0x80 : 0);
  5587. }
  5588. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5589. unsigned int res)
  5590. {
  5591. if ((res >> 26) == ALC880_HP_EVENT)
  5592. alc888_lenovo_ms7195_front_automute(codec);
  5593. if ((res >> 26) == ALC880_FRONT_EVENT)
  5594. alc888_lenovo_ms7195_rca_automute(codec);
  5595. }
  5596. static struct hda_verb alc883_medion_md2_verbs[] = {
  5597. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5598. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5600. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5601. { } /* end */
  5602. };
  5603. /* toggle speaker-output according to the hp-jack state */
  5604. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5605. {
  5606. unsigned int present;
  5607. present = snd_hda_codec_read(codec, 0x14, 0,
  5608. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5609. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5610. 0x80, present ? 0x80 : 0);
  5611. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5612. 0x80, present ? 0x80 : 0);
  5613. }
  5614. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5615. unsigned int res)
  5616. {
  5617. if ((res >> 26) == ALC880_HP_EVENT)
  5618. alc883_medion_md2_automute(codec);
  5619. }
  5620. /* toggle speaker-output according to the hp-jack state */
  5621. static void alc883_tagra_automute(struct hda_codec *codec)
  5622. {
  5623. unsigned int present;
  5624. unsigned char bits;
  5625. present = snd_hda_codec_read(codec, 0x14, 0,
  5626. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5627. bits = present ? 0x80 : 0;
  5628. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5629. 0x80, bits);
  5630. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5631. 0x80, bits);
  5632. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5633. present ? 1 : 3);
  5634. }
  5635. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5636. {
  5637. if ((res >> 26) == ALC880_HP_EVENT)
  5638. alc883_tagra_automute(codec);
  5639. }
  5640. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5641. {
  5642. unsigned int present;
  5643. unsigned char bits;
  5644. present = snd_hda_codec_read(codec, 0x14, 0,
  5645. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5646. bits = present ? 0x80 : 0;
  5647. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5648. 0x80, bits);
  5649. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5650. 0x80, bits);
  5651. }
  5652. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5653. {
  5654. unsigned int present;
  5655. unsigned char bits;
  5656. present = snd_hda_codec_read(codec, 0x1b, 0,
  5657. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5658. bits = present ? 0x80 : 0;
  5659. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5660. 0x80, bits);
  5661. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5662. 0x80, bits);
  5663. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5664. 0x80, bits);
  5665. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5666. 0x80, bits);
  5667. }
  5668. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5669. unsigned int res)
  5670. {
  5671. if ((res >> 26) == ALC880_HP_EVENT)
  5672. alc883_lenovo_101e_all_automute(codec);
  5673. if ((res >> 26) == ALC880_FRONT_EVENT)
  5674. alc883_lenovo_101e_ispeaker_automute(codec);
  5675. }
  5676. /*
  5677. * generic initialization of ADC, input mixers and output mixers
  5678. */
  5679. static struct hda_verb alc883_auto_init_verbs[] = {
  5680. /*
  5681. * Unmute ADC0-2 and set the default input to mic-in
  5682. */
  5683. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5684. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5685. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5686. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5687. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5688. * mixer widget
  5689. * Note: PASD motherboards uses the Line In 2 as the input for
  5690. * front panel mic (mic 2)
  5691. */
  5692. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5698. /*
  5699. * Set up output mixers (0x0c - 0x0f)
  5700. */
  5701. /* set vol=0 to output mixers */
  5702. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5703. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5704. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5705. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5706. /* set up input amps for analog loopback */
  5707. /* Amp Indices: DAC = 0, mixer = 1 */
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5710. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5711. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5712. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5713. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5714. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5715. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5716. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5717. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5718. /* FIXME: use matrix-type input source selection */
  5719. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5720. /* Input mixer1 */
  5721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5724. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5726. /* Input mixer2 */
  5727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5730. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5732. { }
  5733. };
  5734. /* capture mixer elements */
  5735. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5736. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5737. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5738. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5739. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5740. {
  5741. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5742. /* The multiple "Capture Source" controls confuse alsamixer
  5743. * So call somewhat different..
  5744. * FIXME: the controls appear in the "playback" view!
  5745. */
  5746. /* .name = "Capture Source", */
  5747. .name = "Input Source",
  5748. .count = 2,
  5749. .info = alc882_mux_enum_info,
  5750. .get = alc882_mux_enum_get,
  5751. .put = alc882_mux_enum_put,
  5752. },
  5753. { } /* end */
  5754. };
  5755. /* pcm configuration: identiacal with ALC880 */
  5756. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5757. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5758. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5759. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5760. /*
  5761. * configuration and preset
  5762. */
  5763. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5764. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5765. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5766. [ALC883_3ST_6ch] = "3stack-6ch",
  5767. [ALC883_6ST_DIG] = "6stack-dig",
  5768. [ALC883_TARGA_DIG] = "targa-dig",
  5769. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5770. [ALC883_ACER] = "acer",
  5771. [ALC883_MEDION] = "medion",
  5772. [ALC883_MEDION_MD2] = "medion-md2",
  5773. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5774. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5775. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5776. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5777. [ALC883_AUTO] = "auto",
  5778. };
  5779. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5780. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5781. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5782. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5783. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5784. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5785. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5786. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5787. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5788. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5789. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5790. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5791. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5792. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5799. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5800. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5801. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5802. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5803. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5804. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5805. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5806. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5807. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5808. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5809. {}
  5810. };
  5811. static struct alc_config_preset alc883_presets[] = {
  5812. [ALC883_3ST_2ch_DIG] = {
  5813. .mixers = { alc883_3ST_2ch_mixer },
  5814. .init_verbs = { alc883_init_verbs },
  5815. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5816. .dac_nids = alc883_dac_nids,
  5817. .dig_out_nid = ALC883_DIGOUT_NID,
  5818. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5819. .adc_nids = alc883_adc_nids,
  5820. .dig_in_nid = ALC883_DIGIN_NID,
  5821. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5822. .channel_mode = alc883_3ST_2ch_modes,
  5823. .input_mux = &alc883_capture_source,
  5824. },
  5825. [ALC883_3ST_6ch_DIG] = {
  5826. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5827. .init_verbs = { alc883_init_verbs },
  5828. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5829. .dac_nids = alc883_dac_nids,
  5830. .dig_out_nid = ALC883_DIGOUT_NID,
  5831. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5832. .adc_nids = alc883_adc_nids,
  5833. .dig_in_nid = ALC883_DIGIN_NID,
  5834. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5835. .channel_mode = alc883_3ST_6ch_modes,
  5836. .need_dac_fix = 1,
  5837. .input_mux = &alc883_capture_source,
  5838. },
  5839. [ALC883_3ST_6ch] = {
  5840. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5841. .init_verbs = { alc883_init_verbs },
  5842. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5843. .dac_nids = alc883_dac_nids,
  5844. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5845. .adc_nids = alc883_adc_nids,
  5846. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5847. .channel_mode = alc883_3ST_6ch_modes,
  5848. .need_dac_fix = 1,
  5849. .input_mux = &alc883_capture_source,
  5850. },
  5851. [ALC883_6ST_DIG] = {
  5852. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5853. .init_verbs = { alc883_init_verbs },
  5854. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5855. .dac_nids = alc883_dac_nids,
  5856. .dig_out_nid = ALC883_DIGOUT_NID,
  5857. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5858. .adc_nids = alc883_adc_nids,
  5859. .dig_in_nid = ALC883_DIGIN_NID,
  5860. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5861. .channel_mode = alc883_sixstack_modes,
  5862. .input_mux = &alc883_capture_source,
  5863. },
  5864. [ALC883_TARGA_DIG] = {
  5865. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5866. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5867. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5868. .dac_nids = alc883_dac_nids,
  5869. .dig_out_nid = ALC883_DIGOUT_NID,
  5870. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5871. .adc_nids = alc883_adc_nids,
  5872. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5873. .channel_mode = alc883_3ST_6ch_modes,
  5874. .need_dac_fix = 1,
  5875. .input_mux = &alc883_capture_source,
  5876. .unsol_event = alc883_tagra_unsol_event,
  5877. .init_hook = alc883_tagra_automute,
  5878. },
  5879. [ALC883_TARGA_2ch_DIG] = {
  5880. .mixers = { alc883_tagra_2ch_mixer},
  5881. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5882. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5883. .dac_nids = alc883_dac_nids,
  5884. .dig_out_nid = ALC883_DIGOUT_NID,
  5885. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5886. .adc_nids = alc883_adc_nids,
  5887. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5888. .channel_mode = alc883_3ST_2ch_modes,
  5889. .input_mux = &alc883_capture_source,
  5890. .unsol_event = alc883_tagra_unsol_event,
  5891. .init_hook = alc883_tagra_automute,
  5892. },
  5893. [ALC883_ACER] = {
  5894. .mixers = { alc883_base_mixer,
  5895. alc883_chmode_mixer },
  5896. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5897. * and the headphone jack. Turn this on and rely on the
  5898. * standard mute methods whenever the user wants to turn
  5899. * these outputs off.
  5900. */
  5901. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5902. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5903. .dac_nids = alc883_dac_nids,
  5904. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5905. .adc_nids = alc883_adc_nids,
  5906. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5907. .channel_mode = alc883_3ST_2ch_modes,
  5908. .input_mux = &alc883_capture_source,
  5909. },
  5910. [ALC883_MEDION] = {
  5911. .mixers = { alc883_fivestack_mixer,
  5912. alc883_chmode_mixer },
  5913. .init_verbs = { alc883_init_verbs,
  5914. alc883_medion_eapd_verbs },
  5915. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5916. .dac_nids = alc883_dac_nids,
  5917. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5918. .adc_nids = alc883_adc_nids,
  5919. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5920. .channel_mode = alc883_sixstack_modes,
  5921. .input_mux = &alc883_capture_source,
  5922. },
  5923. [ALC883_MEDION_MD2] = {
  5924. .mixers = { alc883_medion_md2_mixer},
  5925. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5926. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5927. .dac_nids = alc883_dac_nids,
  5928. .dig_out_nid = ALC883_DIGOUT_NID,
  5929. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5930. .adc_nids = alc883_adc_nids,
  5931. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5932. .channel_mode = alc883_3ST_2ch_modes,
  5933. .input_mux = &alc883_capture_source,
  5934. .unsol_event = alc883_medion_md2_unsol_event,
  5935. .init_hook = alc883_medion_md2_automute,
  5936. },
  5937. [ALC883_LAPTOP_EAPD] = {
  5938. .mixers = { alc883_base_mixer,
  5939. alc883_chmode_mixer },
  5940. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5941. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5942. .dac_nids = alc883_dac_nids,
  5943. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5944. .adc_nids = alc883_adc_nids,
  5945. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5946. .channel_mode = alc883_3ST_2ch_modes,
  5947. .input_mux = &alc883_capture_source,
  5948. },
  5949. [ALC883_LENOVO_101E_2ch] = {
  5950. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5951. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5952. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5953. .dac_nids = alc883_dac_nids,
  5954. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5955. .adc_nids = alc883_adc_nids,
  5956. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5957. .channel_mode = alc883_3ST_2ch_modes,
  5958. .input_mux = &alc883_lenovo_101e_capture_source,
  5959. .unsol_event = alc883_lenovo_101e_unsol_event,
  5960. .init_hook = alc883_lenovo_101e_all_automute,
  5961. },
  5962. [ALC883_LENOVO_NB0763] = {
  5963. .mixers = { alc883_lenovo_nb0763_mixer },
  5964. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5965. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5966. .dac_nids = alc883_dac_nids,
  5967. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5968. .adc_nids = alc883_adc_nids,
  5969. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5970. .channel_mode = alc883_3ST_2ch_modes,
  5971. .need_dac_fix = 1,
  5972. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5973. .unsol_event = alc883_medion_md2_unsol_event,
  5974. .init_hook = alc883_medion_md2_automute,
  5975. },
  5976. [ALC888_LENOVO_MS7195_DIG] = {
  5977. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5978. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5979. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5980. .dac_nids = alc883_dac_nids,
  5981. .dig_out_nid = ALC883_DIGOUT_NID,
  5982. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5983. .adc_nids = alc883_adc_nids,
  5984. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5985. .channel_mode = alc883_3ST_6ch_modes,
  5986. .need_dac_fix = 1,
  5987. .input_mux = &alc883_capture_source,
  5988. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5989. .init_hook = alc888_lenovo_ms7195_front_automute,
  5990. },
  5991. };
  5992. /*
  5993. * BIOS auto configuration
  5994. */
  5995. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5996. hda_nid_t nid, int pin_type,
  5997. int dac_idx)
  5998. {
  5999. /* set as output */
  6000. struct alc_spec *spec = codec->spec;
  6001. int idx;
  6002. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6003. idx = 4;
  6004. else
  6005. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6006. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6007. pin_type);
  6008. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6009. AMP_OUT_UNMUTE);
  6010. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6011. }
  6012. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6013. {
  6014. struct alc_spec *spec = codec->spec;
  6015. int i;
  6016. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6017. for (i = 0; i <= HDA_SIDE; i++) {
  6018. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6019. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6020. if (nid)
  6021. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6022. i);
  6023. }
  6024. }
  6025. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6026. {
  6027. struct alc_spec *spec = codec->spec;
  6028. hda_nid_t pin;
  6029. pin = spec->autocfg.hp_pins[0];
  6030. if (pin) /* connect to front */
  6031. /* use dac 0 */
  6032. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6033. }
  6034. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6035. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6036. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6037. {
  6038. struct alc_spec *spec = codec->spec;
  6039. int i;
  6040. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6041. hda_nid_t nid = spec->autocfg.input_pins[i];
  6042. if (alc883_is_input_pin(nid)) {
  6043. snd_hda_codec_write(codec, nid, 0,
  6044. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6045. (i <= AUTO_PIN_FRONT_MIC ?
  6046. PIN_VREF80 : PIN_IN));
  6047. if (nid != ALC883_PIN_CD_NID)
  6048. snd_hda_codec_write(codec, nid, 0,
  6049. AC_VERB_SET_AMP_GAIN_MUTE,
  6050. AMP_OUT_MUTE);
  6051. }
  6052. }
  6053. }
  6054. /* almost identical with ALC880 parser... */
  6055. static int alc883_parse_auto_config(struct hda_codec *codec)
  6056. {
  6057. struct alc_spec *spec = codec->spec;
  6058. int err = alc880_parse_auto_config(codec);
  6059. if (err < 0)
  6060. return err;
  6061. else if (err > 0)
  6062. /* hack - override the init verbs */
  6063. spec->init_verbs[0] = alc883_auto_init_verbs;
  6064. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6065. spec->num_mixers++;
  6066. return err;
  6067. }
  6068. /* additional initialization for auto-configuration model */
  6069. static void alc883_auto_init(struct hda_codec *codec)
  6070. {
  6071. alc883_auto_init_multi_out(codec);
  6072. alc883_auto_init_hp_out(codec);
  6073. alc883_auto_init_analog_input(codec);
  6074. }
  6075. static int patch_alc883(struct hda_codec *codec)
  6076. {
  6077. struct alc_spec *spec;
  6078. int err, board_config;
  6079. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6080. if (spec == NULL)
  6081. return -ENOMEM;
  6082. codec->spec = spec;
  6083. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6084. alc883_models,
  6085. alc883_cfg_tbl);
  6086. if (board_config < 0) {
  6087. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6088. "trying auto-probe from BIOS...\n");
  6089. board_config = ALC883_AUTO;
  6090. }
  6091. if (board_config == ALC883_AUTO) {
  6092. /* automatic parse from the BIOS config */
  6093. err = alc883_parse_auto_config(codec);
  6094. if (err < 0) {
  6095. alc_free(codec);
  6096. return err;
  6097. } else if (!err) {
  6098. printk(KERN_INFO
  6099. "hda_codec: Cannot set up configuration "
  6100. "from BIOS. Using base mode...\n");
  6101. board_config = ALC883_3ST_2ch_DIG;
  6102. }
  6103. }
  6104. if (board_config != ALC883_AUTO)
  6105. setup_preset(spec, &alc883_presets[board_config]);
  6106. spec->stream_name_analog = "ALC883 Analog";
  6107. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6108. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6109. spec->stream_name_digital = "ALC883 Digital";
  6110. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6111. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6112. if (!spec->adc_nids && spec->input_mux) {
  6113. spec->adc_nids = alc883_adc_nids;
  6114. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6115. }
  6116. codec->patch_ops = alc_patch_ops;
  6117. if (board_config == ALC883_AUTO)
  6118. spec->init_hook = alc883_auto_init;
  6119. return 0;
  6120. }
  6121. /*
  6122. * ALC262 support
  6123. */
  6124. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6125. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6126. #define alc262_dac_nids alc260_dac_nids
  6127. #define alc262_adc_nids alc882_adc_nids
  6128. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6129. #define alc262_modes alc260_modes
  6130. #define alc262_capture_source alc882_capture_source
  6131. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6132. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6133. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6134. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6135. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6136. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6137. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6138. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6139. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6140. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6141. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6142. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6143. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6144. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6145. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6146. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6147. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6148. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6149. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6150. { } /* end */
  6151. };
  6152. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6153. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6154. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6155. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6156. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6157. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6158. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6159. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6160. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6161. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6162. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6163. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6164. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6165. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6166. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6167. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6168. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6169. { } /* end */
  6170. };
  6171. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6172. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6173. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6174. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6175. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6176. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6177. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6178. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6179. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6180. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6181. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6182. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6183. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6184. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6185. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6186. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6187. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6188. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6190. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6191. { } /* end */
  6192. };
  6193. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6194. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6195. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6196. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6197. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6198. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6199. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6200. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6201. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6202. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6203. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6204. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6205. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6206. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6207. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6208. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6209. { } /* end */
  6210. };
  6211. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6212. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6213. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6214. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6215. { } /* end */
  6216. };
  6217. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6218. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6219. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6220. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6221. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6222. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6223. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6224. { } /* end */
  6225. };
  6226. #define alc262_capture_mixer alc882_capture_mixer
  6227. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6228. /*
  6229. * generic initialization of ADC, input mixers and output mixers
  6230. */
  6231. static struct hda_verb alc262_init_verbs[] = {
  6232. /*
  6233. * Unmute ADC0-2 and set the default input to mic-in
  6234. */
  6235. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6236. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6237. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6238. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6239. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6240. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6241. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6242. * mixer widget
  6243. * Note: PASD motherboards uses the Line In 2 as the input for
  6244. * front panel mic (mic 2)
  6245. */
  6246. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6247. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6248. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6249. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6250. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6251. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6252. /*
  6253. * Set up output mixers (0x0c - 0x0e)
  6254. */
  6255. /* set vol=0 to output mixers */
  6256. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6257. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6258. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6259. /* set up input amps for analog loopback */
  6260. /* Amp Indices: DAC = 0, mixer = 1 */
  6261. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6262. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6263. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6264. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6265. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6266. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6267. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6268. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6269. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6270. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6271. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6273. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6274. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6275. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6276. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6277. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6278. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6279. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6280. /* FIXME: use matrix-type input source selection */
  6281. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6282. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6283. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6284. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6285. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6286. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6287. /* Input mixer2 */
  6288. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6289. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6290. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6291. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6292. /* Input mixer3 */
  6293. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6294. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6295. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6296. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6297. { }
  6298. };
  6299. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6300. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6301. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6302. {}
  6303. };
  6304. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6305. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6306. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6307. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6308. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6309. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6310. {}
  6311. };
  6312. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6314. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6315. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6316. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6317. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6318. };
  6319. /* mute/unmute internal speaker according to the hp jack and mute state */
  6320. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6321. {
  6322. struct alc_spec *spec = codec->spec;
  6323. unsigned int mute;
  6324. if (force || !spec->sense_updated) {
  6325. unsigned int present;
  6326. /* need to execute and sync at first */
  6327. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6328. present = snd_hda_codec_read(codec, 0x15, 0,
  6329. AC_VERB_GET_PIN_SENSE, 0);
  6330. spec->jack_present = (present & 0x80000000) != 0;
  6331. spec->sense_updated = 1;
  6332. }
  6333. if (spec->jack_present) {
  6334. /* mute internal speaker */
  6335. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6336. 0x80, 0x80);
  6337. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6338. 0x80, 0x80);
  6339. } else {
  6340. /* unmute internal speaker if necessary */
  6341. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6342. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6343. 0x80, mute & 0x80);
  6344. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6345. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6346. 0x80, mute & 0x80);
  6347. }
  6348. }
  6349. /* unsolicited event for HP jack sensing */
  6350. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6351. unsigned int res)
  6352. {
  6353. if ((res >> 26) != ALC880_HP_EVENT)
  6354. return;
  6355. alc262_hippo_automute(codec, 1);
  6356. }
  6357. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6358. {
  6359. struct alc_spec *spec = codec->spec;
  6360. unsigned int mute;
  6361. if (force || !spec->sense_updated) {
  6362. unsigned int present;
  6363. /* need to execute and sync at first */
  6364. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6365. present = snd_hda_codec_read(codec, 0x1b, 0,
  6366. AC_VERB_GET_PIN_SENSE, 0);
  6367. spec->jack_present = (present & 0x80000000) != 0;
  6368. spec->sense_updated = 1;
  6369. }
  6370. if (spec->jack_present) {
  6371. /* mute internal speaker */
  6372. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6373. 0x80, 0x80);
  6374. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6375. 0x80, 0x80);
  6376. } else {
  6377. /* unmute internal speaker if necessary */
  6378. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6379. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6380. 0x80, mute & 0x80);
  6381. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6382. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6383. 0x80, mute & 0x80);
  6384. }
  6385. }
  6386. /* unsolicited event for HP jack sensing */
  6387. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6388. unsigned int res)
  6389. {
  6390. if ((res >> 26) != ALC880_HP_EVENT)
  6391. return;
  6392. alc262_hippo1_automute(codec, 1);
  6393. }
  6394. /*
  6395. * fujitsu model
  6396. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6397. */
  6398. #define ALC_HP_EVENT 0x37
  6399. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6400. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6401. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6402. {}
  6403. };
  6404. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6405. .num_items = 2,
  6406. .items = {
  6407. { "Mic", 0x0 },
  6408. { "CD", 0x4 },
  6409. },
  6410. };
  6411. static struct hda_input_mux alc262_HP_capture_source = {
  6412. .num_items = 5,
  6413. .items = {
  6414. { "Mic", 0x0 },
  6415. { "Front Mic", 0x3 },
  6416. { "Line", 0x2 },
  6417. { "CD", 0x4 },
  6418. { "AUX IN", 0x6 },
  6419. },
  6420. };
  6421. /* mute/unmute internal speaker according to the hp jack and mute state */
  6422. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6423. {
  6424. struct alc_spec *spec = codec->spec;
  6425. unsigned int mute;
  6426. if (force || !spec->sense_updated) {
  6427. unsigned int present;
  6428. /* need to execute and sync at first */
  6429. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6430. present = snd_hda_codec_read(codec, 0x14, 0,
  6431. AC_VERB_GET_PIN_SENSE, 0);
  6432. spec->jack_present = (present & 0x80000000) != 0;
  6433. spec->sense_updated = 1;
  6434. }
  6435. if (spec->jack_present) {
  6436. /* mute internal speaker */
  6437. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6438. 0x80, 0x80);
  6439. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6440. 0x80, 0x80);
  6441. } else {
  6442. /* unmute internal speaker if necessary */
  6443. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6444. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6445. 0x80, mute & 0x80);
  6446. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6447. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6448. 0x80, mute & 0x80);
  6449. }
  6450. }
  6451. /* unsolicited event for HP jack sensing */
  6452. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6453. unsigned int res)
  6454. {
  6455. if ((res >> 26) != ALC_HP_EVENT)
  6456. return;
  6457. alc262_fujitsu_automute(codec, 1);
  6458. }
  6459. /* bind volumes of both NID 0x0c and 0x0d */
  6460. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6461. struct snd_ctl_elem_value *ucontrol)
  6462. {
  6463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6464. long *valp = ucontrol->value.integer.value;
  6465. int change;
  6466. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6467. 0x7f, valp[0] & 0x7f);
  6468. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6469. 0x7f, valp[1] & 0x7f);
  6470. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6471. 0x7f, valp[0] & 0x7f);
  6472. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6473. 0x7f, valp[1] & 0x7f);
  6474. return change;
  6475. }
  6476. /* bind hp and internal speaker mute (with plug check) */
  6477. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6478. struct snd_ctl_elem_value *ucontrol)
  6479. {
  6480. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6481. long *valp = ucontrol->value.integer.value;
  6482. int change;
  6483. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6484. 0x80, valp[0] ? 0 : 0x80);
  6485. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6486. 0x80, valp[1] ? 0 : 0x80);
  6487. if (change || codec->in_resume)
  6488. alc262_fujitsu_automute(codec, codec->in_resume);
  6489. return change;
  6490. }
  6491. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6492. {
  6493. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6494. .name = "Master Playback Volume",
  6495. .info = snd_hda_mixer_amp_volume_info,
  6496. .get = snd_hda_mixer_amp_volume_get,
  6497. .put = alc262_fujitsu_master_vol_put,
  6498. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6499. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6500. },
  6501. {
  6502. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6503. .name = "Master Playback Switch",
  6504. .info = snd_hda_mixer_amp_switch_info,
  6505. .get = snd_hda_mixer_amp_switch_get,
  6506. .put = alc262_fujitsu_master_sw_put,
  6507. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6508. },
  6509. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6510. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6511. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6512. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6513. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6514. { } /* end */
  6515. };
  6516. /* additional init verbs for Benq laptops */
  6517. static struct hda_verb alc262_EAPD_verbs[] = {
  6518. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6519. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6520. {}
  6521. };
  6522. /* add playback controls from the parsed DAC table */
  6523. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6524. const struct auto_pin_cfg *cfg)
  6525. {
  6526. hda_nid_t nid;
  6527. int err;
  6528. spec->multiout.num_dacs = 1; /* only use one dac */
  6529. spec->multiout.dac_nids = spec->private_dac_nids;
  6530. spec->multiout.dac_nids[0] = 2;
  6531. nid = cfg->line_out_pins[0];
  6532. if (nid) {
  6533. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6534. "Front Playback Volume",
  6535. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6536. if (err < 0)
  6537. return err;
  6538. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6539. "Front Playback Switch",
  6540. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6541. if (err < 0)
  6542. return err;
  6543. }
  6544. nid = cfg->speaker_pins[0];
  6545. if (nid) {
  6546. if (nid == 0x16) {
  6547. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6548. "Speaker Playback Volume",
  6549. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6550. HDA_OUTPUT));
  6551. if (err < 0)
  6552. return err;
  6553. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6554. "Speaker Playback Switch",
  6555. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6556. HDA_OUTPUT));
  6557. if (err < 0)
  6558. return err;
  6559. } else {
  6560. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6561. "Speaker Playback Switch",
  6562. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6563. HDA_OUTPUT));
  6564. if (err < 0)
  6565. return err;
  6566. }
  6567. }
  6568. nid = cfg->hp_pins[0];
  6569. if (nid) {
  6570. /* spec->multiout.hp_nid = 2; */
  6571. if (nid == 0x16) {
  6572. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6573. "Headphone Playback Volume",
  6574. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6575. HDA_OUTPUT));
  6576. if (err < 0)
  6577. return err;
  6578. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6579. "Headphone Playback Switch",
  6580. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6581. HDA_OUTPUT));
  6582. if (err < 0)
  6583. return err;
  6584. } else {
  6585. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6586. "Headphone Playback Switch",
  6587. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6588. HDA_OUTPUT));
  6589. if (err < 0)
  6590. return err;
  6591. }
  6592. }
  6593. return 0;
  6594. }
  6595. /* identical with ALC880 */
  6596. #define alc262_auto_create_analog_input_ctls \
  6597. alc880_auto_create_analog_input_ctls
  6598. /*
  6599. * generic initialization of ADC, input mixers and output mixers
  6600. */
  6601. static struct hda_verb alc262_volume_init_verbs[] = {
  6602. /*
  6603. * Unmute ADC0-2 and set the default input to mic-in
  6604. */
  6605. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6607. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6608. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6609. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6610. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6611. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6612. * mixer widget
  6613. * Note: PASD motherboards uses the Line In 2 as the input for
  6614. * front panel mic (mic 2)
  6615. */
  6616. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6617. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6618. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6619. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6620. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6621. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6622. /*
  6623. * Set up output mixers (0x0c - 0x0f)
  6624. */
  6625. /* set vol=0 to output mixers */
  6626. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6627. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6628. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6629. /* set up input amps for analog loopback */
  6630. /* Amp Indices: DAC = 0, mixer = 1 */
  6631. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6632. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6633. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6634. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6635. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6636. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6637. /* FIXME: use matrix-type input source selection */
  6638. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6639. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6640. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6641. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6642. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6643. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6644. /* Input mixer2 */
  6645. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6646. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6647. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6648. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6649. /* Input mixer3 */
  6650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6651. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6652. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6653. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6654. { }
  6655. };
  6656. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6657. /*
  6658. * Unmute ADC0-2 and set the default input to mic-in
  6659. */
  6660. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6661. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6662. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6663. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6664. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6665. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6666. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6667. * mixer widget
  6668. * Note: PASD motherboards uses the Line In 2 as the input for
  6669. * front panel mic (mic 2)
  6670. */
  6671. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6672. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6673. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6674. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6675. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6676. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6677. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6678. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6679. /*
  6680. * Set up output mixers (0x0c - 0x0e)
  6681. */
  6682. /* set vol=0 to output mixers */
  6683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6684. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6685. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6686. /* set up input amps for analog loopback */
  6687. /* Amp Indices: DAC = 0, mixer = 1 */
  6688. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6689. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6690. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6691. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6693. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6694. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6695. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6696. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6697. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6698. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6699. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6700. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6701. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6702. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6703. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6704. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6705. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6706. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6707. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6708. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6709. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6710. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6711. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6712. /* FIXME: use matrix-type input source selection */
  6713. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6714. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6715. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6716. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6718. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6719. /* Input mixer2 */
  6720. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6724. /* Input mixer3 */
  6725. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6726. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6729. { }
  6730. };
  6731. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6732. /*
  6733. * Unmute ADC0-2 and set the default input to mic-in
  6734. */
  6735. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6736. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6737. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6738. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6739. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6740. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6741. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6742. * mixer widget
  6743. * Note: PASD motherboards uses the Line In 2 as the input for front
  6744. * panel mic (mic 2)
  6745. */
  6746. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6747. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6748. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6749. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6752. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6753. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6754. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6755. /*
  6756. * Set up output mixers (0x0c - 0x0e)
  6757. */
  6758. /* set vol=0 to output mixers */
  6759. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6760. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6761. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6762. /* set up input amps for analog loopback */
  6763. /* Amp Indices: DAC = 0, mixer = 1 */
  6764. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6765. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6766. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6767. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6768. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6769. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6770. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6771. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6772. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6773. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6774. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6775. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6776. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6777. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6778. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6779. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6780. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6781. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6782. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6783. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6784. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6785. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6786. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6787. /* FIXME: use matrix-type input source selection */
  6788. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6789. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6790. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6791. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6792. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6793. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6794. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6795. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6796. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6797. /* Input mixer2 */
  6798. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6799. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6800. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6801. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6802. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6803. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6804. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6805. /* Input mixer3 */
  6806. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6807. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6808. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6809. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6810. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6811. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6813. { }
  6814. };
  6815. /* pcm configuration: identiacal with ALC880 */
  6816. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6817. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6818. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6819. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6820. /*
  6821. * BIOS auto configuration
  6822. */
  6823. static int alc262_parse_auto_config(struct hda_codec *codec)
  6824. {
  6825. struct alc_spec *spec = codec->spec;
  6826. int err;
  6827. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6828. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6829. alc262_ignore);
  6830. if (err < 0)
  6831. return err;
  6832. if (!spec->autocfg.line_outs)
  6833. return 0; /* can't find valid BIOS pin config */
  6834. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6835. if (err < 0)
  6836. return err;
  6837. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6838. if (err < 0)
  6839. return err;
  6840. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6841. if (spec->autocfg.dig_out_pin)
  6842. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6843. if (spec->autocfg.dig_in_pin)
  6844. spec->dig_in_nid = ALC262_DIGIN_NID;
  6845. if (spec->kctl_alloc)
  6846. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6847. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6848. spec->num_mux_defs = 1;
  6849. spec->input_mux = &spec->private_imux;
  6850. return 1;
  6851. }
  6852. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6853. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6854. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6855. /* init callback for auto-configuration model -- overriding the default init */
  6856. static void alc262_auto_init(struct hda_codec *codec)
  6857. {
  6858. alc262_auto_init_multi_out(codec);
  6859. alc262_auto_init_hp_out(codec);
  6860. alc262_auto_init_analog_input(codec);
  6861. }
  6862. /*
  6863. * configuration and preset
  6864. */
  6865. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6866. [ALC262_BASIC] = "basic",
  6867. [ALC262_HIPPO] = "hippo",
  6868. [ALC262_HIPPO_1] = "hippo_1",
  6869. [ALC262_FUJITSU] = "fujitsu",
  6870. [ALC262_HP_BPC] = "hp-bpc",
  6871. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6872. [ALC262_BENQ_ED8] = "benq",
  6873. [ALC262_BENQ_ED8] = "sony-assamd",
  6874. [ALC262_AUTO] = "auto",
  6875. };
  6876. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6877. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6878. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6879. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6880. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6881. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6882. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6883. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6884. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6885. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6886. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6887. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6888. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6889. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6890. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6891. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6892. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6893. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6894. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6895. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6896. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6897. {}
  6898. };
  6899. static struct alc_config_preset alc262_presets[] = {
  6900. [ALC262_BASIC] = {
  6901. .mixers = { alc262_base_mixer },
  6902. .init_verbs = { alc262_init_verbs },
  6903. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6904. .dac_nids = alc262_dac_nids,
  6905. .hp_nid = 0x03,
  6906. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6907. .channel_mode = alc262_modes,
  6908. .input_mux = &alc262_capture_source,
  6909. },
  6910. [ALC262_HIPPO] = {
  6911. .mixers = { alc262_base_mixer },
  6912. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6913. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6914. .dac_nids = alc262_dac_nids,
  6915. .hp_nid = 0x03,
  6916. .dig_out_nid = ALC262_DIGOUT_NID,
  6917. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6918. .channel_mode = alc262_modes,
  6919. .input_mux = &alc262_capture_source,
  6920. .unsol_event = alc262_hippo_unsol_event,
  6921. },
  6922. [ALC262_HIPPO_1] = {
  6923. .mixers = { alc262_hippo1_mixer },
  6924. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6925. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6926. .dac_nids = alc262_dac_nids,
  6927. .hp_nid = 0x02,
  6928. .dig_out_nid = ALC262_DIGOUT_NID,
  6929. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6930. .channel_mode = alc262_modes,
  6931. .input_mux = &alc262_capture_source,
  6932. .unsol_event = alc262_hippo1_unsol_event,
  6933. },
  6934. [ALC262_FUJITSU] = {
  6935. .mixers = { alc262_fujitsu_mixer },
  6936. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6937. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6938. .dac_nids = alc262_dac_nids,
  6939. .hp_nid = 0x03,
  6940. .dig_out_nid = ALC262_DIGOUT_NID,
  6941. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6942. .channel_mode = alc262_modes,
  6943. .input_mux = &alc262_fujitsu_capture_source,
  6944. .unsol_event = alc262_fujitsu_unsol_event,
  6945. },
  6946. [ALC262_HP_BPC] = {
  6947. .mixers = { alc262_HP_BPC_mixer },
  6948. .init_verbs = { alc262_HP_BPC_init_verbs },
  6949. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6950. .dac_nids = alc262_dac_nids,
  6951. .hp_nid = 0x03,
  6952. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6953. .channel_mode = alc262_modes,
  6954. .input_mux = &alc262_HP_capture_source,
  6955. },
  6956. [ALC262_HP_BPC_D7000_WF] = {
  6957. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6958. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6959. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6960. .dac_nids = alc262_dac_nids,
  6961. .hp_nid = 0x03,
  6962. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6963. .channel_mode = alc262_modes,
  6964. .input_mux = &alc262_HP_capture_source,
  6965. },
  6966. [ALC262_HP_BPC_D7000_WL] = {
  6967. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6968. alc262_HP_BPC_WildWest_option_mixer },
  6969. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6970. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6971. .dac_nids = alc262_dac_nids,
  6972. .hp_nid = 0x03,
  6973. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6974. .channel_mode = alc262_modes,
  6975. .input_mux = &alc262_HP_capture_source,
  6976. },
  6977. [ALC262_BENQ_ED8] = {
  6978. .mixers = { alc262_base_mixer },
  6979. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6980. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6981. .dac_nids = alc262_dac_nids,
  6982. .hp_nid = 0x03,
  6983. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6984. .channel_mode = alc262_modes,
  6985. .input_mux = &alc262_capture_source,
  6986. },
  6987. [ALC262_SONY_ASSAMD] = {
  6988. .mixers = { alc262_sony_mixer },
  6989. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  6990. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6991. .dac_nids = alc262_dac_nids,
  6992. .hp_nid = 0x02,
  6993. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6994. .channel_mode = alc262_modes,
  6995. .input_mux = &alc262_capture_source,
  6996. .unsol_event = alc262_hippo_unsol_event,
  6997. },
  6998. };
  6999. static int patch_alc262(struct hda_codec *codec)
  7000. {
  7001. struct alc_spec *spec;
  7002. int board_config;
  7003. int err;
  7004. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7005. if (spec == NULL)
  7006. return -ENOMEM;
  7007. codec->spec = spec;
  7008. #if 0
  7009. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7010. * under-run
  7011. */
  7012. {
  7013. int tmp;
  7014. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7015. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7016. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7017. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7018. }
  7019. #endif
  7020. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7021. alc262_models,
  7022. alc262_cfg_tbl);
  7023. if (board_config < 0) {
  7024. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7025. "trying auto-probe from BIOS...\n");
  7026. board_config = ALC262_AUTO;
  7027. }
  7028. if (board_config == ALC262_AUTO) {
  7029. /* automatic parse from the BIOS config */
  7030. err = alc262_parse_auto_config(codec);
  7031. if (err < 0) {
  7032. alc_free(codec);
  7033. return err;
  7034. } else if (!err) {
  7035. printk(KERN_INFO
  7036. "hda_codec: Cannot set up configuration "
  7037. "from BIOS. Using base mode...\n");
  7038. board_config = ALC262_BASIC;
  7039. }
  7040. }
  7041. if (board_config != ALC262_AUTO)
  7042. setup_preset(spec, &alc262_presets[board_config]);
  7043. spec->stream_name_analog = "ALC262 Analog";
  7044. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7045. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7046. spec->stream_name_digital = "ALC262 Digital";
  7047. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7048. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7049. if (!spec->adc_nids && spec->input_mux) {
  7050. /* check whether NID 0x07 is valid */
  7051. unsigned int wcap = get_wcaps(codec, 0x07);
  7052. /* get type */
  7053. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7054. if (wcap != AC_WID_AUD_IN) {
  7055. spec->adc_nids = alc262_adc_nids_alt;
  7056. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7057. spec->mixers[spec->num_mixers] =
  7058. alc262_capture_alt_mixer;
  7059. spec->num_mixers++;
  7060. } else {
  7061. spec->adc_nids = alc262_adc_nids;
  7062. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7063. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7064. spec->num_mixers++;
  7065. }
  7066. }
  7067. codec->patch_ops = alc_patch_ops;
  7068. if (board_config == ALC262_AUTO)
  7069. spec->init_hook = alc262_auto_init;
  7070. return 0;
  7071. }
  7072. /*
  7073. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7074. */
  7075. /*
  7076. * set the path ways for 2 channel output
  7077. * need to set the codec line out and mic 1 pin widgets to inputs
  7078. */
  7079. static struct hda_verb alc861_threestack_ch2_init[] = {
  7080. /* set pin widget 1Ah (line in) for input */
  7081. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7082. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7083. * the vref
  7084. */
  7085. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7086. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7087. #if 0
  7088. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7089. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7090. #endif
  7091. { } /* end */
  7092. };
  7093. /*
  7094. * 6ch mode
  7095. * need to set the codec line out and mic 1 pin widgets to outputs
  7096. */
  7097. static struct hda_verb alc861_threestack_ch6_init[] = {
  7098. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7099. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7100. /* set pin widget 18h (mic1) for output (CLFE)*/
  7101. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7102. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7103. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7104. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7105. #if 0
  7106. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7107. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7108. #endif
  7109. { } /* end */
  7110. };
  7111. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7112. { 2, alc861_threestack_ch2_init },
  7113. { 6, alc861_threestack_ch6_init },
  7114. };
  7115. /* Set mic1 as input and unmute the mixer */
  7116. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7117. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7118. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7119. { } /* end */
  7120. };
  7121. /* Set mic1 as output and mute mixer */
  7122. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7123. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7124. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7125. { } /* end */
  7126. };
  7127. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7128. { 2, alc861_uniwill_m31_ch2_init },
  7129. { 4, alc861_uniwill_m31_ch4_init },
  7130. };
  7131. /* Set mic1 and line-in as input and unmute the mixer */
  7132. static struct hda_verb alc861_asus_ch2_init[] = {
  7133. /* set pin widget 1Ah (line in) for input */
  7134. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7135. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7136. * the vref
  7137. */
  7138. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7139. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7140. #if 0
  7141. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7142. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7143. #endif
  7144. { } /* end */
  7145. };
  7146. /* Set mic1 nad line-in as output and mute mixer */
  7147. static struct hda_verb alc861_asus_ch6_init[] = {
  7148. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7149. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7150. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7151. /* set pin widget 18h (mic1) for output (CLFE)*/
  7152. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7153. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7154. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7155. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7156. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7157. #if 0
  7158. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7159. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7160. #endif
  7161. { } /* end */
  7162. };
  7163. static struct hda_channel_mode alc861_asus_modes[2] = {
  7164. { 2, alc861_asus_ch2_init },
  7165. { 6, alc861_asus_ch6_init },
  7166. };
  7167. /* patch-ALC861 */
  7168. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7169. /* output mixer control */
  7170. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7171. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7172. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7173. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7174. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7175. /*Input mixer control */
  7176. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7177. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7178. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7179. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7180. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7181. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7182. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7183. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7184. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7185. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7186. /* Capture mixer control */
  7187. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7188. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7189. {
  7190. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7191. .name = "Capture Source",
  7192. .count = 1,
  7193. .info = alc_mux_enum_info,
  7194. .get = alc_mux_enum_get,
  7195. .put = alc_mux_enum_put,
  7196. },
  7197. { } /* end */
  7198. };
  7199. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7200. /* output mixer control */
  7201. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7202. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7203. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7204. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7205. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7206. /* Input mixer control */
  7207. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7208. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7209. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7210. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7211. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7212. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7213. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7214. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7215. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7216. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7217. /* Capture mixer control */
  7218. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7219. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7220. {
  7221. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7222. .name = "Capture Source",
  7223. .count = 1,
  7224. .info = alc_mux_enum_info,
  7225. .get = alc_mux_enum_get,
  7226. .put = alc_mux_enum_put,
  7227. },
  7228. {
  7229. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7230. .name = "Channel Mode",
  7231. .info = alc_ch_mode_info,
  7232. .get = alc_ch_mode_get,
  7233. .put = alc_ch_mode_put,
  7234. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7235. },
  7236. { } /* end */
  7237. };
  7238. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7239. /* output mixer control */
  7240. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7241. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7242. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7243. /*Capture mixer control */
  7244. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7245. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7246. {
  7247. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7248. .name = "Capture Source",
  7249. .count = 1,
  7250. .info = alc_mux_enum_info,
  7251. .get = alc_mux_enum_get,
  7252. .put = alc_mux_enum_put,
  7253. },
  7254. { } /* end */
  7255. };
  7256. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7257. /* output mixer control */
  7258. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7259. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7260. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7261. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7262. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7263. /* Input mixer control */
  7264. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7265. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7266. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7267. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7268. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7269. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7270. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7271. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7272. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7273. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7274. /* Capture mixer control */
  7275. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7276. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7277. {
  7278. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7279. .name = "Capture Source",
  7280. .count = 1,
  7281. .info = alc_mux_enum_info,
  7282. .get = alc_mux_enum_get,
  7283. .put = alc_mux_enum_put,
  7284. },
  7285. {
  7286. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7287. .name = "Channel Mode",
  7288. .info = alc_ch_mode_info,
  7289. .get = alc_ch_mode_get,
  7290. .put = alc_ch_mode_put,
  7291. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7292. },
  7293. { } /* end */
  7294. };
  7295. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7296. /* output mixer control */
  7297. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7298. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7299. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7300. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7301. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7302. /* Input mixer control */
  7303. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7304. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7305. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7306. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7307. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7308. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7309. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7310. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7311. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7312. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7313. /* Capture mixer control */
  7314. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7315. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7316. {
  7317. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7318. .name = "Capture Source",
  7319. .count = 1,
  7320. .info = alc_mux_enum_info,
  7321. .get = alc_mux_enum_get,
  7322. .put = alc_mux_enum_put,
  7323. },
  7324. {
  7325. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7326. .name = "Channel Mode",
  7327. .info = alc_ch_mode_info,
  7328. .get = alc_ch_mode_get,
  7329. .put = alc_ch_mode_put,
  7330. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7331. },
  7332. { }
  7333. };
  7334. /* additional mixer */
  7335. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7336. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7337. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7338. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7339. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7340. { }
  7341. };
  7342. /*
  7343. * generic initialization of ADC, input mixers and output mixers
  7344. */
  7345. static struct hda_verb alc861_base_init_verbs[] = {
  7346. /*
  7347. * Unmute ADC0 and set the default input to mic-in
  7348. */
  7349. /* port-A for surround (rear panel) */
  7350. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7351. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7352. /* port-B for mic-in (rear panel) with vref */
  7353. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7354. /* port-C for line-in (rear panel) */
  7355. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7356. /* port-D for Front */
  7357. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7358. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7359. /* port-E for HP out (front panel) */
  7360. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7361. /* route front PCM to HP */
  7362. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7363. /* port-F for mic-in (front panel) with vref */
  7364. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7365. /* port-G for CLFE (rear panel) */
  7366. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7367. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7368. /* port-H for side (rear panel) */
  7369. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7370. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7371. /* CD-in */
  7372. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7373. /* route front mic to ADC1*/
  7374. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7375. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7376. /* Unmute DAC0~3 & spdif out*/
  7377. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7378. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7379. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7380. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7381. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7382. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7383. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7384. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7385. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7386. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7387. /* Unmute Stereo Mixer 15 */
  7388. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7391. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7392. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7393. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7394. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7395. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7396. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7397. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7398. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7399. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7400. /* hp used DAC 3 (Front) */
  7401. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7402. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7403. { }
  7404. };
  7405. static struct hda_verb alc861_threestack_init_verbs[] = {
  7406. /*
  7407. * Unmute ADC0 and set the default input to mic-in
  7408. */
  7409. /* port-A for surround (rear panel) */
  7410. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7411. /* port-B for mic-in (rear panel) with vref */
  7412. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7413. /* port-C for line-in (rear panel) */
  7414. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7415. /* port-D for Front */
  7416. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7417. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7418. /* port-E for HP out (front panel) */
  7419. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7420. /* route front PCM to HP */
  7421. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7422. /* port-F for mic-in (front panel) with vref */
  7423. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7424. /* port-G for CLFE (rear panel) */
  7425. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7426. /* port-H for side (rear panel) */
  7427. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7428. /* CD-in */
  7429. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7430. /* route front mic to ADC1*/
  7431. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7433. /* Unmute DAC0~3 & spdif out*/
  7434. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7435. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7436. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7437. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7438. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7439. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7440. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7441. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7442. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7443. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7444. /* Unmute Stereo Mixer 15 */
  7445. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7446. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7447. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7448. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7449. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7450. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7451. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7452. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7453. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7454. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7455. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7456. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7457. /* hp used DAC 3 (Front) */
  7458. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7459. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7460. { }
  7461. };
  7462. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7463. /*
  7464. * Unmute ADC0 and set the default input to mic-in
  7465. */
  7466. /* port-A for surround (rear panel) */
  7467. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7468. /* port-B for mic-in (rear panel) with vref */
  7469. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7470. /* port-C for line-in (rear panel) */
  7471. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7472. /* port-D for Front */
  7473. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7474. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7475. /* port-E for HP out (front panel) */
  7476. /* this has to be set to VREF80 */
  7477. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7478. /* route front PCM to HP */
  7479. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7480. /* port-F for mic-in (front panel) with vref */
  7481. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7482. /* port-G for CLFE (rear panel) */
  7483. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7484. /* port-H for side (rear panel) */
  7485. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7486. /* CD-in */
  7487. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7488. /* route front mic to ADC1*/
  7489. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7491. /* Unmute DAC0~3 & spdif out*/
  7492. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7493. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7494. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7495. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7497. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7498. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7499. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7500. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7501. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7502. /* Unmute Stereo Mixer 15 */
  7503. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7504. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7506. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7507. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7508. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7509. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7510. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7511. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7512. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7513. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7514. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7515. /* hp used DAC 3 (Front) */
  7516. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7517. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7518. { }
  7519. };
  7520. static struct hda_verb alc861_asus_init_verbs[] = {
  7521. /*
  7522. * Unmute ADC0 and set the default input to mic-in
  7523. */
  7524. /* port-A for surround (rear panel)
  7525. * according to codec#0 this is the HP jack
  7526. */
  7527. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7528. /* route front PCM to HP */
  7529. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7530. /* port-B for mic-in (rear panel) with vref */
  7531. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7532. /* port-C for line-in (rear panel) */
  7533. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7534. /* port-D for Front */
  7535. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7536. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7537. /* port-E for HP out (front panel) */
  7538. /* this has to be set to VREF80 */
  7539. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7540. /* route front PCM to HP */
  7541. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7542. /* port-F for mic-in (front panel) with vref */
  7543. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7544. /* port-G for CLFE (rear panel) */
  7545. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7546. /* port-H for side (rear panel) */
  7547. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7548. /* CD-in */
  7549. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7550. /* route front mic to ADC1*/
  7551. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7552. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7553. /* Unmute DAC0~3 & spdif out*/
  7554. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7555. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7556. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7557. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7558. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7559. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7560. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7561. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7562. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7563. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7564. /* Unmute Stereo Mixer 15 */
  7565. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7566. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7567. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7568. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7569. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7570. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7571. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7572. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7573. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7574. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7575. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7576. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7577. /* hp used DAC 3 (Front) */
  7578. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7579. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7580. { }
  7581. };
  7582. /* additional init verbs for ASUS laptops */
  7583. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  7584. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  7585. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  7586. { }
  7587. };
  7588. /*
  7589. * generic initialization of ADC, input mixers and output mixers
  7590. */
  7591. static struct hda_verb alc861_auto_init_verbs[] = {
  7592. /*
  7593. * Unmute ADC0 and set the default input to mic-in
  7594. */
  7595. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  7596. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7597. /* Unmute DAC0~3 & spdif out*/
  7598. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7599. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7600. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7601. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7602. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7603. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7604. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7605. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7606. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7607. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7608. /* Unmute Stereo Mixer 15 */
  7609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7610. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7611. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7612. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  7613. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7614. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7615. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7616. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7617. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7618. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7619. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7620. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7621. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7622. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7623. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7624. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7625. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7626. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7627. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7628. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7629. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  7630. { }
  7631. };
  7632. static struct hda_verb alc861_toshiba_init_verbs[] = {
  7633. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7634. { }
  7635. };
  7636. /* toggle speaker-output according to the hp-jack state */
  7637. static void alc861_toshiba_automute(struct hda_codec *codec)
  7638. {
  7639. unsigned int present;
  7640. present = snd_hda_codec_read(codec, 0x0f, 0,
  7641. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  7642. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  7643. 0x80, present ? 0x80 : 0);
  7644. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  7645. 0x80, present ? 0x80 : 0);
  7646. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  7647. 0x80, present ? 0 : 0x80);
  7648. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  7649. 0x80, present ? 0 : 0x80);
  7650. }
  7651. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  7652. unsigned int res)
  7653. {
  7654. if ((res >> 26) == ALC880_HP_EVENT)
  7655. alc861_toshiba_automute(codec);
  7656. }
  7657. /* pcm configuration: identiacal with ALC880 */
  7658. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  7659. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  7660. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  7661. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  7662. #define ALC861_DIGOUT_NID 0x07
  7663. static struct hda_channel_mode alc861_8ch_modes[1] = {
  7664. { 8, NULL }
  7665. };
  7666. static hda_nid_t alc861_dac_nids[4] = {
  7667. /* front, surround, clfe, side */
  7668. 0x03, 0x06, 0x05, 0x04
  7669. };
  7670. static hda_nid_t alc660_dac_nids[3] = {
  7671. /* front, clfe, surround */
  7672. 0x03, 0x05, 0x06
  7673. };
  7674. static hda_nid_t alc861_adc_nids[1] = {
  7675. /* ADC0-2 */
  7676. 0x08,
  7677. };
  7678. static struct hda_input_mux alc861_capture_source = {
  7679. .num_items = 5,
  7680. .items = {
  7681. { "Mic", 0x0 },
  7682. { "Front Mic", 0x3 },
  7683. { "Line", 0x1 },
  7684. { "CD", 0x4 },
  7685. { "Mixer", 0x5 },
  7686. },
  7687. };
  7688. /* fill in the dac_nids table from the parsed pin configuration */
  7689. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  7690. const struct auto_pin_cfg *cfg)
  7691. {
  7692. int i;
  7693. hda_nid_t nid;
  7694. spec->multiout.dac_nids = spec->private_dac_nids;
  7695. for (i = 0; i < cfg->line_outs; i++) {
  7696. nid = cfg->line_out_pins[i];
  7697. if (nid) {
  7698. if (i >= ARRAY_SIZE(alc861_dac_nids))
  7699. continue;
  7700. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  7701. }
  7702. }
  7703. spec->multiout.num_dacs = cfg->line_outs;
  7704. return 0;
  7705. }
  7706. /* add playback controls from the parsed DAC table */
  7707. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  7708. const struct auto_pin_cfg *cfg)
  7709. {
  7710. char name[32];
  7711. static const char *chname[4] = {
  7712. "Front", "Surround", NULL /*CLFE*/, "Side"
  7713. };
  7714. hda_nid_t nid;
  7715. int i, idx, err;
  7716. for (i = 0; i < cfg->line_outs; i++) {
  7717. nid = spec->multiout.dac_nids[i];
  7718. if (!nid)
  7719. continue;
  7720. if (nid == 0x05) {
  7721. /* Center/LFE */
  7722. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7723. "Center Playback Switch",
  7724. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  7725. HDA_OUTPUT));
  7726. if (err < 0)
  7727. return err;
  7728. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7729. "LFE Playback Switch",
  7730. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7731. HDA_OUTPUT));
  7732. if (err < 0)
  7733. return err;
  7734. } else {
  7735. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  7736. idx++)
  7737. if (nid == alc861_dac_nids[idx])
  7738. break;
  7739. sprintf(name, "%s Playback Switch", chname[idx]);
  7740. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7741. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7742. HDA_OUTPUT));
  7743. if (err < 0)
  7744. return err;
  7745. }
  7746. }
  7747. return 0;
  7748. }
  7749. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  7750. {
  7751. int err;
  7752. hda_nid_t nid;
  7753. if (!pin)
  7754. return 0;
  7755. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  7756. nid = 0x03;
  7757. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7758. "Headphone Playback Switch",
  7759. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7760. if (err < 0)
  7761. return err;
  7762. spec->multiout.hp_nid = nid;
  7763. }
  7764. return 0;
  7765. }
  7766. /* create playback/capture controls for input pins */
  7767. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  7768. const struct auto_pin_cfg *cfg)
  7769. {
  7770. struct hda_input_mux *imux = &spec->private_imux;
  7771. int i, err, idx, idx1;
  7772. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7773. switch (cfg->input_pins[i]) {
  7774. case 0x0c:
  7775. idx1 = 1;
  7776. idx = 2; /* Line In */
  7777. break;
  7778. case 0x0f:
  7779. idx1 = 2;
  7780. idx = 2; /* Line In */
  7781. break;
  7782. case 0x0d:
  7783. idx1 = 0;
  7784. idx = 1; /* Mic In */
  7785. break;
  7786. case 0x10:
  7787. idx1 = 3;
  7788. idx = 1; /* Mic In */
  7789. break;
  7790. case 0x11:
  7791. idx1 = 4;
  7792. idx = 0; /* CD */
  7793. break;
  7794. default:
  7795. continue;
  7796. }
  7797. err = new_analog_input(spec, cfg->input_pins[i],
  7798. auto_pin_cfg_labels[i], idx, 0x15);
  7799. if (err < 0)
  7800. return err;
  7801. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7802. imux->items[imux->num_items].index = idx1;
  7803. imux->num_items++;
  7804. }
  7805. return 0;
  7806. }
  7807. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  7808. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7809. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7810. {
  7811. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7812. /* The multiple "Capture Source" controls confuse alsamixer
  7813. * So call somewhat different..
  7814. *FIXME: the controls appear in the "playback" view!
  7815. */
  7816. /* .name = "Capture Source", */
  7817. .name = "Input Source",
  7818. .count = 1,
  7819. .info = alc_mux_enum_info,
  7820. .get = alc_mux_enum_get,
  7821. .put = alc_mux_enum_put,
  7822. },
  7823. { } /* end */
  7824. };
  7825. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  7826. hda_nid_t nid,
  7827. int pin_type, int dac_idx)
  7828. {
  7829. /* set as output */
  7830. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  7831. pin_type);
  7832. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7833. AMP_OUT_UNMUTE);
  7834. }
  7835. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  7836. {
  7837. struct alc_spec *spec = codec->spec;
  7838. int i;
  7839. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  7840. for (i = 0; i < spec->autocfg.line_outs; i++) {
  7841. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7842. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  7843. if (nid)
  7844. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  7845. spec->multiout.dac_nids[i]);
  7846. }
  7847. }
  7848. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  7849. {
  7850. struct alc_spec *spec = codec->spec;
  7851. hda_nid_t pin;
  7852. pin = spec->autocfg.hp_pins[0];
  7853. if (pin) /* connect to front */
  7854. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  7855. spec->multiout.dac_nids[0]);
  7856. }
  7857. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  7858. {
  7859. struct alc_spec *spec = codec->spec;
  7860. int i;
  7861. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7862. hda_nid_t nid = spec->autocfg.input_pins[i];
  7863. if (nid >= 0x0c && nid <= 0x11) {
  7864. snd_hda_codec_write(codec, nid, 0,
  7865. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7866. i <= AUTO_PIN_FRONT_MIC ?
  7867. PIN_VREF80 : PIN_IN);
  7868. }
  7869. }
  7870. }
  7871. /* parse the BIOS configuration and set up the alc_spec */
  7872. /* return 1 if successful, 0 if the proper config is not found,
  7873. * or a negative error code
  7874. */
  7875. static int alc861_parse_auto_config(struct hda_codec *codec)
  7876. {
  7877. struct alc_spec *spec = codec->spec;
  7878. int err;
  7879. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  7880. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7881. alc861_ignore);
  7882. if (err < 0)
  7883. return err;
  7884. if (!spec->autocfg.line_outs)
  7885. return 0; /* can't find valid BIOS pin config */
  7886. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  7887. if (err < 0)
  7888. return err;
  7889. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7890. if (err < 0)
  7891. return err;
  7892. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  7893. if (err < 0)
  7894. return err;
  7895. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7896. if (err < 0)
  7897. return err;
  7898. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7899. if (spec->autocfg.dig_out_pin)
  7900. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7901. if (spec->kctl_alloc)
  7902. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7903. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7904. spec->num_mux_defs = 1;
  7905. spec->input_mux = &spec->private_imux;
  7906. spec->adc_nids = alc861_adc_nids;
  7907. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7908. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7909. spec->num_mixers++;
  7910. return 1;
  7911. }
  7912. /* additional initialization for auto-configuration model */
  7913. static void alc861_auto_init(struct hda_codec *codec)
  7914. {
  7915. alc861_auto_init_multi_out(codec);
  7916. alc861_auto_init_hp_out(codec);
  7917. alc861_auto_init_analog_input(codec);
  7918. }
  7919. /*
  7920. * configuration and preset
  7921. */
  7922. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7923. [ALC861_3ST] = "3stack",
  7924. [ALC660_3ST] = "3stack-660",
  7925. [ALC861_3ST_DIG] = "3stack-dig",
  7926. [ALC861_6ST_DIG] = "6stack-dig",
  7927. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7928. [ALC861_TOSHIBA] = "toshiba",
  7929. [ALC861_ASUS] = "asus",
  7930. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7931. [ALC861_AUTO] = "auto",
  7932. };
  7933. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7934. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7935. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7936. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7937. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  7938. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7939. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7940. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7941. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7942. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7943. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  7944. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7945. {}
  7946. };
  7947. static struct alc_config_preset alc861_presets[] = {
  7948. [ALC861_3ST] = {
  7949. .mixers = { alc861_3ST_mixer },
  7950. .init_verbs = { alc861_threestack_init_verbs },
  7951. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7952. .dac_nids = alc861_dac_nids,
  7953. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7954. .channel_mode = alc861_threestack_modes,
  7955. .need_dac_fix = 1,
  7956. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7957. .adc_nids = alc861_adc_nids,
  7958. .input_mux = &alc861_capture_source,
  7959. },
  7960. [ALC861_3ST_DIG] = {
  7961. .mixers = { alc861_base_mixer },
  7962. .init_verbs = { alc861_threestack_init_verbs },
  7963. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7964. .dac_nids = alc861_dac_nids,
  7965. .dig_out_nid = ALC861_DIGOUT_NID,
  7966. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7967. .channel_mode = alc861_threestack_modes,
  7968. .need_dac_fix = 1,
  7969. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7970. .adc_nids = alc861_adc_nids,
  7971. .input_mux = &alc861_capture_source,
  7972. },
  7973. [ALC861_6ST_DIG] = {
  7974. .mixers = { alc861_base_mixer },
  7975. .init_verbs = { alc861_base_init_verbs },
  7976. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7977. .dac_nids = alc861_dac_nids,
  7978. .dig_out_nid = ALC861_DIGOUT_NID,
  7979. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7980. .channel_mode = alc861_8ch_modes,
  7981. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7982. .adc_nids = alc861_adc_nids,
  7983. .input_mux = &alc861_capture_source,
  7984. },
  7985. [ALC660_3ST] = {
  7986. .mixers = { alc861_3ST_mixer },
  7987. .init_verbs = { alc861_threestack_init_verbs },
  7988. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7989. .dac_nids = alc660_dac_nids,
  7990. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7991. .channel_mode = alc861_threestack_modes,
  7992. .need_dac_fix = 1,
  7993. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7994. .adc_nids = alc861_adc_nids,
  7995. .input_mux = &alc861_capture_source,
  7996. },
  7997. [ALC861_UNIWILL_M31] = {
  7998. .mixers = { alc861_uniwill_m31_mixer },
  7999. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8000. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8001. .dac_nids = alc861_dac_nids,
  8002. .dig_out_nid = ALC861_DIGOUT_NID,
  8003. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8004. .channel_mode = alc861_uniwill_m31_modes,
  8005. .need_dac_fix = 1,
  8006. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8007. .adc_nids = alc861_adc_nids,
  8008. .input_mux = &alc861_capture_source,
  8009. },
  8010. [ALC861_TOSHIBA] = {
  8011. .mixers = { alc861_toshiba_mixer },
  8012. .init_verbs = { alc861_base_init_verbs,
  8013. alc861_toshiba_init_verbs },
  8014. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8015. .dac_nids = alc861_dac_nids,
  8016. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8017. .channel_mode = alc883_3ST_2ch_modes,
  8018. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8019. .adc_nids = alc861_adc_nids,
  8020. .input_mux = &alc861_capture_source,
  8021. .unsol_event = alc861_toshiba_unsol_event,
  8022. .init_hook = alc861_toshiba_automute,
  8023. },
  8024. [ALC861_ASUS] = {
  8025. .mixers = { alc861_asus_mixer },
  8026. .init_verbs = { alc861_asus_init_verbs },
  8027. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8028. .dac_nids = alc861_dac_nids,
  8029. .dig_out_nid = ALC861_DIGOUT_NID,
  8030. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8031. .channel_mode = alc861_asus_modes,
  8032. .need_dac_fix = 1,
  8033. .hp_nid = 0x06,
  8034. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8035. .adc_nids = alc861_adc_nids,
  8036. .input_mux = &alc861_capture_source,
  8037. },
  8038. [ALC861_ASUS_LAPTOP] = {
  8039. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8040. .init_verbs = { alc861_asus_init_verbs,
  8041. alc861_asus_laptop_init_verbs },
  8042. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8043. .dac_nids = alc861_dac_nids,
  8044. .dig_out_nid = ALC861_DIGOUT_NID,
  8045. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8046. .channel_mode = alc883_3ST_2ch_modes,
  8047. .need_dac_fix = 1,
  8048. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8049. .adc_nids = alc861_adc_nids,
  8050. .input_mux = &alc861_capture_source,
  8051. },
  8052. };
  8053. static int patch_alc861(struct hda_codec *codec)
  8054. {
  8055. struct alc_spec *spec;
  8056. int board_config;
  8057. int err;
  8058. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8059. if (spec == NULL)
  8060. return -ENOMEM;
  8061. codec->spec = spec;
  8062. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8063. alc861_models,
  8064. alc861_cfg_tbl);
  8065. if (board_config < 0) {
  8066. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8067. "trying auto-probe from BIOS...\n");
  8068. board_config = ALC861_AUTO;
  8069. }
  8070. if (board_config == ALC861_AUTO) {
  8071. /* automatic parse from the BIOS config */
  8072. err = alc861_parse_auto_config(codec);
  8073. if (err < 0) {
  8074. alc_free(codec);
  8075. return err;
  8076. } else if (!err) {
  8077. printk(KERN_INFO
  8078. "hda_codec: Cannot set up configuration "
  8079. "from BIOS. Using base mode...\n");
  8080. board_config = ALC861_3ST_DIG;
  8081. }
  8082. }
  8083. if (board_config != ALC861_AUTO)
  8084. setup_preset(spec, &alc861_presets[board_config]);
  8085. spec->stream_name_analog = "ALC861 Analog";
  8086. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8087. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8088. spec->stream_name_digital = "ALC861 Digital";
  8089. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8090. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8091. codec->patch_ops = alc_patch_ops;
  8092. if (board_config == ALC861_AUTO)
  8093. spec->init_hook = alc861_auto_init;
  8094. return 0;
  8095. }
  8096. /*
  8097. * ALC861-VD support
  8098. *
  8099. * Based on ALC882
  8100. *
  8101. * In addition, an independent DAC
  8102. */
  8103. #define ALC861VD_DIGOUT_NID 0x06
  8104. static hda_nid_t alc861vd_dac_nids[4] = {
  8105. /* front, surr, clfe, side surr */
  8106. 0x02, 0x03, 0x04, 0x05
  8107. };
  8108. /* dac_nids for ALC660vd are in a different order - according to
  8109. * Realtek's driver.
  8110. * This should probably tesult in a different mixer for 6stack models
  8111. * of ALC660vd codecs, but for now there is only 3stack mixer
  8112. * - and it is the same as in 861vd.
  8113. * adc_nids in ALC660vd are (is) the same as in 861vd
  8114. */
  8115. static hda_nid_t alc660vd_dac_nids[3] = {
  8116. /* front, rear, clfe, rear_surr */
  8117. 0x02, 0x04, 0x03
  8118. };
  8119. static hda_nid_t alc861vd_adc_nids[1] = {
  8120. /* ADC0 */
  8121. 0x09,
  8122. };
  8123. /* input MUX */
  8124. /* FIXME: should be a matrix-type input source selection */
  8125. static struct hda_input_mux alc861vd_capture_source = {
  8126. .num_items = 4,
  8127. .items = {
  8128. { "Mic", 0x0 },
  8129. { "Front Mic", 0x1 },
  8130. { "Line", 0x2 },
  8131. { "CD", 0x4 },
  8132. },
  8133. };
  8134. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8135. .num_items = 3,
  8136. .items = {
  8137. { "Front Mic", 0x0 },
  8138. { "ATAPI Mic", 0x1 },
  8139. { "Line In", 0x5 },
  8140. },
  8141. };
  8142. #define alc861vd_mux_enum_info alc_mux_enum_info
  8143. #define alc861vd_mux_enum_get alc_mux_enum_get
  8144. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8145. struct snd_ctl_elem_value *ucontrol)
  8146. {
  8147. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8148. struct alc_spec *spec = codec->spec;
  8149. const struct hda_input_mux *imux = spec->input_mux;
  8150. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8151. static hda_nid_t capture_mixers[1] = { 0x22 };
  8152. hda_nid_t nid = capture_mixers[adc_idx];
  8153. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8154. unsigned int i, idx;
  8155. idx = ucontrol->value.enumerated.item[0];
  8156. if (idx >= imux->num_items)
  8157. idx = imux->num_items - 1;
  8158. if (*cur_val == idx && !codec->in_resume)
  8159. return 0;
  8160. for (i = 0; i < imux->num_items; i++) {
  8161. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8162. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8163. v | (imux->items[i].index << 8));
  8164. }
  8165. *cur_val = idx;
  8166. return 1;
  8167. }
  8168. /*
  8169. * 2ch mode
  8170. */
  8171. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8172. { 2, NULL }
  8173. };
  8174. /*
  8175. * 6ch mode
  8176. */
  8177. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8178. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8179. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8180. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8181. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8182. { } /* end */
  8183. };
  8184. /*
  8185. * 8ch mode
  8186. */
  8187. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8188. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8189. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8190. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8191. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8192. { } /* end */
  8193. };
  8194. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8195. { 6, alc861vd_6stack_ch6_init },
  8196. { 8, alc861vd_6stack_ch8_init },
  8197. };
  8198. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8199. {
  8200. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8201. .name = "Channel Mode",
  8202. .info = alc_ch_mode_info,
  8203. .get = alc_ch_mode_get,
  8204. .put = alc_ch_mode_put,
  8205. },
  8206. { } /* end */
  8207. };
  8208. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8209. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8210. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8211. {
  8212. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8213. /* The multiple "Capture Source" controls confuse alsamixer
  8214. * So call somewhat different..
  8215. *FIXME: the controls appear in the "playback" view!
  8216. */
  8217. /* .name = "Capture Source", */
  8218. .name = "Input Source",
  8219. .count = 1,
  8220. .info = alc861vd_mux_enum_info,
  8221. .get = alc861vd_mux_enum_get,
  8222. .put = alc861vd_mux_enum_put,
  8223. },
  8224. { } /* end */
  8225. };
  8226. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8227. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8228. */
  8229. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8230. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8231. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8232. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8233. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8234. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8235. HDA_OUTPUT),
  8236. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8237. HDA_OUTPUT),
  8238. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8239. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8240. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8241. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8242. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8243. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8244. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8245. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8246. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8247. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8248. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8249. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8250. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8251. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8252. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8253. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8254. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8255. { } /* end */
  8256. };
  8257. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8258. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8259. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8260. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8261. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8262. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8263. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8264. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8265. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8266. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8267. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8268. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8269. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8270. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8271. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8272. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8273. { } /* end */
  8274. };
  8275. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8276. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8277. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8278. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8279. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8280. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8281. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8282. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8283. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8284. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8285. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8286. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8287. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8288. { } /* end */
  8289. };
  8290. /* Pin assignment: Front=0x14, HP = 0x15,
  8291. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8292. */
  8293. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8294. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8295. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8296. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8297. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8298. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8299. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8301. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8302. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8303. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8304. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8305. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8306. {
  8307. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8308. /* .name = "Capture Source", */
  8309. .name = "Input Source",
  8310. .count = 1,
  8311. .info = alc882_mux_enum_info,
  8312. .get = alc882_mux_enum_get,
  8313. .put = alc882_mux_enum_put,
  8314. },
  8315. { } /* end */
  8316. };
  8317. /*
  8318. * generic initialization of ADC, input mixers and output mixers
  8319. */
  8320. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8321. /*
  8322. * Unmute ADC0 and set the default input to mic-in
  8323. */
  8324. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8325. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8326. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8327. * the analog-loopback mixer widget
  8328. */
  8329. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8330. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8331. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8332. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8333. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8334. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8335. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8336. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8337. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8338. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8339. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8340. /*
  8341. * Set up output mixers (0x02 - 0x05)
  8342. */
  8343. /* set vol=0 to output mixers */
  8344. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8345. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8346. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8347. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8348. /* set up input amps for analog loopback */
  8349. /* Amp Indices: DAC = 0, mixer = 1 */
  8350. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8351. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8352. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8353. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8354. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8355. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8356. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8357. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8358. { }
  8359. };
  8360. /*
  8361. * 3-stack pin configuration:
  8362. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8363. */
  8364. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8365. /*
  8366. * Set pin mode and muting
  8367. */
  8368. /* set front pin widgets 0x14 for output */
  8369. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8370. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8371. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8372. /* Mic (rear) pin: input vref at 80% */
  8373. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8374. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8375. /* Front Mic pin: input vref at 80% */
  8376. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8377. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8378. /* Line In pin: input */
  8379. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8380. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8381. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8382. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8383. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8384. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8385. /* CD pin widget for input */
  8386. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8387. { }
  8388. };
  8389. /*
  8390. * 6-stack pin configuration:
  8391. */
  8392. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8393. /*
  8394. * Set pin mode and muting
  8395. */
  8396. /* set front pin widgets 0x14 for output */
  8397. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8398. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8399. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8400. /* Rear Pin: output 1 (0x0d) */
  8401. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8402. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8403. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8404. /* CLFE Pin: output 2 (0x0e) */
  8405. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8406. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8407. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8408. /* Side Pin: output 3 (0x0f) */
  8409. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8410. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8411. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8412. /* Mic (rear) pin: input vref at 80% */
  8413. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8414. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8415. /* Front Mic pin: input vref at 80% */
  8416. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8417. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8418. /* Line In pin: input */
  8419. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8420. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8421. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8422. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8423. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8424. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8425. /* CD pin widget for input */
  8426. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8427. { }
  8428. };
  8429. static struct hda_verb alc861vd_eapd_verbs[] = {
  8430. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8431. { }
  8432. };
  8433. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8434. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8435. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8436. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8437. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8438. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8439. {}
  8440. };
  8441. /* toggle speaker-output according to the hp-jack state */
  8442. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8443. {
  8444. unsigned int present;
  8445. unsigned char bits;
  8446. present = snd_hda_codec_read(codec, 0x1b, 0,
  8447. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8448. bits = present ? 0x80 : 0;
  8449. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8450. 0x80, bits);
  8451. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8452. 0x80, bits);
  8453. }
  8454. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8455. {
  8456. unsigned int present;
  8457. unsigned char bits;
  8458. present = snd_hda_codec_read(codec, 0x18, 0,
  8459. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8460. bits = present ? 0x80 : 0;
  8461. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8462. 0x80, bits);
  8463. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8464. 0x80, bits);
  8465. }
  8466. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8467. {
  8468. alc861vd_lenovo_hp_automute(codec);
  8469. alc861vd_lenovo_mic_automute(codec);
  8470. }
  8471. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8472. unsigned int res)
  8473. {
  8474. switch (res >> 26) {
  8475. case ALC880_HP_EVENT:
  8476. alc861vd_lenovo_hp_automute(codec);
  8477. break;
  8478. case ALC880_MIC_EVENT:
  8479. alc861vd_lenovo_mic_automute(codec);
  8480. break;
  8481. }
  8482. }
  8483. static struct hda_verb alc861vd_dallas_verbs[] = {
  8484. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8485. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8486. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8487. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8488. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8489. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8490. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8491. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8492. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8493. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8494. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8495. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8496. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8500. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8501. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8502. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8503. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8504. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8505. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8506. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8507. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8508. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8509. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8510. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8511. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8512. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8513. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8514. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8515. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8516. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8517. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8518. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8519. { } /* end */
  8520. };
  8521. /* toggle speaker-output according to the hp-jack state */
  8522. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8523. {
  8524. unsigned int present;
  8525. present = snd_hda_codec_read(codec, 0x15, 0,
  8526. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8527. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8528. 0x80, present ? 0x80 : 0);
  8529. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8530. 0x80, present ? 0x80 : 0);
  8531. }
  8532. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8533. {
  8534. if ((res >> 26) == ALC880_HP_EVENT)
  8535. alc861vd_dallas_automute(codec);
  8536. }
  8537. /* pcm configuration: identiacal with ALC880 */
  8538. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  8539. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  8540. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  8541. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  8542. /*
  8543. * configuration and preset
  8544. */
  8545. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  8546. [ALC660VD_3ST] = "3stack-660",
  8547. [ALC861VD_3ST] = "3stack",
  8548. [ALC861VD_3ST_DIG] = "3stack-digout",
  8549. [ALC861VD_6ST_DIG] = "6stack-digout",
  8550. [ALC861VD_LENOVO] = "lenovo",
  8551. [ALC861VD_DALLAS] = "dallas",
  8552. [ALC861VD_AUTO] = "auto",
  8553. };
  8554. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  8555. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  8556. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  8557. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
  8558. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  8559. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  8560. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  8561. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  8562. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  8563. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  8564. {}
  8565. };
  8566. static struct alc_config_preset alc861vd_presets[] = {
  8567. [ALC660VD_3ST] = {
  8568. .mixers = { alc861vd_3st_mixer },
  8569. .init_verbs = { alc861vd_volume_init_verbs,
  8570. alc861vd_3stack_init_verbs },
  8571. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  8572. .dac_nids = alc660vd_dac_nids,
  8573. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8574. .adc_nids = alc861vd_adc_nids,
  8575. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8576. .channel_mode = alc861vd_3stack_2ch_modes,
  8577. .input_mux = &alc861vd_capture_source,
  8578. },
  8579. [ALC861VD_3ST] = {
  8580. .mixers = { alc861vd_3st_mixer },
  8581. .init_verbs = { alc861vd_volume_init_verbs,
  8582. alc861vd_3stack_init_verbs },
  8583. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8584. .dac_nids = alc861vd_dac_nids,
  8585. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8586. .channel_mode = alc861vd_3stack_2ch_modes,
  8587. .input_mux = &alc861vd_capture_source,
  8588. },
  8589. [ALC861VD_3ST_DIG] = {
  8590. .mixers = { alc861vd_3st_mixer },
  8591. .init_verbs = { alc861vd_volume_init_verbs,
  8592. alc861vd_3stack_init_verbs },
  8593. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8594. .dac_nids = alc861vd_dac_nids,
  8595. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8596. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8597. .channel_mode = alc861vd_3stack_2ch_modes,
  8598. .input_mux = &alc861vd_capture_source,
  8599. },
  8600. [ALC861VD_6ST_DIG] = {
  8601. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  8602. .init_verbs = { alc861vd_volume_init_verbs,
  8603. alc861vd_6stack_init_verbs },
  8604. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8605. .dac_nids = alc861vd_dac_nids,
  8606. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8607. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  8608. .channel_mode = alc861vd_6stack_modes,
  8609. .input_mux = &alc861vd_capture_source,
  8610. },
  8611. [ALC861VD_LENOVO] = {
  8612. .mixers = { alc861vd_lenovo_mixer },
  8613. .init_verbs = { alc861vd_volume_init_verbs,
  8614. alc861vd_3stack_init_verbs,
  8615. alc861vd_eapd_verbs,
  8616. alc861vd_lenovo_unsol_verbs },
  8617. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  8618. .dac_nids = alc660vd_dac_nids,
  8619. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8620. .adc_nids = alc861vd_adc_nids,
  8621. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8622. .channel_mode = alc861vd_3stack_2ch_modes,
  8623. .input_mux = &alc861vd_capture_source,
  8624. .unsol_event = alc861vd_lenovo_unsol_event,
  8625. .init_hook = alc861vd_lenovo_automute,
  8626. },
  8627. [ALC861VD_DALLAS] = {
  8628. .mixers = { alc861vd_dallas_mixer },
  8629. .init_verbs = { alc861vd_dallas_verbs },
  8630. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8631. .dac_nids = alc861vd_dac_nids,
  8632. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8633. .adc_nids = alc861vd_adc_nids,
  8634. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8635. .channel_mode = alc861vd_3stack_2ch_modes,
  8636. .input_mux = &alc861vd_dallas_capture_source,
  8637. .unsol_event = alc861vd_dallas_unsol_event,
  8638. .init_hook = alc861vd_dallas_automute,
  8639. },
  8640. };
  8641. /*
  8642. * BIOS auto configuration
  8643. */
  8644. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  8645. hda_nid_t nid, int pin_type, int dac_idx)
  8646. {
  8647. /* set as output */
  8648. snd_hda_codec_write(codec, nid, 0,
  8649. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8650. snd_hda_codec_write(codec, nid, 0,
  8651. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8652. }
  8653. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  8654. {
  8655. struct alc_spec *spec = codec->spec;
  8656. int i;
  8657. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  8658. for (i = 0; i <= HDA_SIDE; i++) {
  8659. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8660. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8661. if (nid)
  8662. alc861vd_auto_set_output_and_unmute(codec, nid,
  8663. pin_type, i);
  8664. }
  8665. }
  8666. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  8667. {
  8668. struct alc_spec *spec = codec->spec;
  8669. hda_nid_t pin;
  8670. pin = spec->autocfg.hp_pins[0];
  8671. if (pin) /* connect to front and use dac 0 */
  8672. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8673. }
  8674. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  8675. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  8676. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  8677. {
  8678. struct alc_spec *spec = codec->spec;
  8679. int i;
  8680. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8681. hda_nid_t nid = spec->autocfg.input_pins[i];
  8682. if (alc861vd_is_input_pin(nid)) {
  8683. snd_hda_codec_write(codec, nid, 0,
  8684. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8685. i <= AUTO_PIN_FRONT_MIC ?
  8686. PIN_VREF80 : PIN_IN);
  8687. if (nid != ALC861VD_PIN_CD_NID)
  8688. snd_hda_codec_write(codec, nid, 0,
  8689. AC_VERB_SET_AMP_GAIN_MUTE,
  8690. AMP_OUT_MUTE);
  8691. }
  8692. }
  8693. }
  8694. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  8695. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  8696. /* add playback controls from the parsed DAC table */
  8697. /* Based on ALC880 version. But ALC861VD has separate,
  8698. * different NIDs for mute/unmute switch and volume control */
  8699. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  8700. const struct auto_pin_cfg *cfg)
  8701. {
  8702. char name[32];
  8703. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  8704. hda_nid_t nid_v, nid_s;
  8705. int i, err;
  8706. for (i = 0; i < cfg->line_outs; i++) {
  8707. if (!spec->multiout.dac_nids[i])
  8708. continue;
  8709. nid_v = alc861vd_idx_to_mixer_vol(
  8710. alc880_dac_to_idx(
  8711. spec->multiout.dac_nids[i]));
  8712. nid_s = alc861vd_idx_to_mixer_switch(
  8713. alc880_dac_to_idx(
  8714. spec->multiout.dac_nids[i]));
  8715. if (i == 2) {
  8716. /* Center/LFE */
  8717. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8718. "Center Playback Volume",
  8719. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  8720. HDA_OUTPUT));
  8721. if (err < 0)
  8722. return err;
  8723. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8724. "LFE Playback Volume",
  8725. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  8726. HDA_OUTPUT));
  8727. if (err < 0)
  8728. return err;
  8729. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8730. "Center Playback Switch",
  8731. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  8732. HDA_INPUT));
  8733. if (err < 0)
  8734. return err;
  8735. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8736. "LFE Playback Switch",
  8737. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  8738. HDA_INPUT));
  8739. if (err < 0)
  8740. return err;
  8741. } else {
  8742. sprintf(name, "%s Playback Volume", chname[i]);
  8743. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8744. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  8745. HDA_OUTPUT));
  8746. if (err < 0)
  8747. return err;
  8748. sprintf(name, "%s Playback Switch", chname[i]);
  8749. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8750. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  8751. HDA_INPUT));
  8752. if (err < 0)
  8753. return err;
  8754. }
  8755. }
  8756. return 0;
  8757. }
  8758. /* add playback controls for speaker and HP outputs */
  8759. /* Based on ALC880 version. But ALC861VD has separate,
  8760. * different NIDs for mute/unmute switch and volume control */
  8761. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  8762. hda_nid_t pin, const char *pfx)
  8763. {
  8764. hda_nid_t nid_v, nid_s;
  8765. int err;
  8766. char name[32];
  8767. if (!pin)
  8768. return 0;
  8769. if (alc880_is_fixed_pin(pin)) {
  8770. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8771. /* specify the DAC as the extra output */
  8772. if (!spec->multiout.hp_nid)
  8773. spec->multiout.hp_nid = nid_v;
  8774. else
  8775. spec->multiout.extra_out_nid[0] = nid_v;
  8776. /* control HP volume/switch on the output mixer amp */
  8777. nid_v = alc861vd_idx_to_mixer_vol(
  8778. alc880_fixed_pin_idx(pin));
  8779. nid_s = alc861vd_idx_to_mixer_switch(
  8780. alc880_fixed_pin_idx(pin));
  8781. sprintf(name, "%s Playback Volume", pfx);
  8782. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8783. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  8784. if (err < 0)
  8785. return err;
  8786. sprintf(name, "%s Playback Switch", pfx);
  8787. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8788. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  8789. if (err < 0)
  8790. return err;
  8791. } else if (alc880_is_multi_pin(pin)) {
  8792. /* set manual connection */
  8793. /* we have only a switch on HP-out PIN */
  8794. sprintf(name, "%s Playback Switch", pfx);
  8795. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8796. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8797. if (err < 0)
  8798. return err;
  8799. }
  8800. return 0;
  8801. }
  8802. /* parse the BIOS configuration and set up the alc_spec
  8803. * return 1 if successful, 0 if the proper config is not found,
  8804. * or a negative error code
  8805. * Based on ALC880 version - had to change it to override
  8806. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  8807. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  8808. {
  8809. struct alc_spec *spec = codec->spec;
  8810. int err;
  8811. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  8812. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8813. alc861vd_ignore);
  8814. if (err < 0)
  8815. return err;
  8816. if (!spec->autocfg.line_outs)
  8817. return 0; /* can't find valid BIOS pin config */
  8818. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8819. if (err < 0)
  8820. return err;
  8821. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8822. if (err < 0)
  8823. return err;
  8824. err = alc861vd_auto_create_extra_out(spec,
  8825. spec->autocfg.speaker_pins[0],
  8826. "Speaker");
  8827. if (err < 0)
  8828. return err;
  8829. err = alc861vd_auto_create_extra_out(spec,
  8830. spec->autocfg.hp_pins[0],
  8831. "Headphone");
  8832. if (err < 0)
  8833. return err;
  8834. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8835. if (err < 0)
  8836. return err;
  8837. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8838. if (spec->autocfg.dig_out_pin)
  8839. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  8840. if (spec->kctl_alloc)
  8841. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8842. spec->init_verbs[spec->num_init_verbs++]
  8843. = alc861vd_volume_init_verbs;
  8844. spec->num_mux_defs = 1;
  8845. spec->input_mux = &spec->private_imux;
  8846. return 1;
  8847. }
  8848. /* additional initialization for auto-configuration model */
  8849. static void alc861vd_auto_init(struct hda_codec *codec)
  8850. {
  8851. alc861vd_auto_init_multi_out(codec);
  8852. alc861vd_auto_init_hp_out(codec);
  8853. alc861vd_auto_init_analog_input(codec);
  8854. }
  8855. static int patch_alc861vd(struct hda_codec *codec)
  8856. {
  8857. struct alc_spec *spec;
  8858. int err, board_config;
  8859. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8860. if (spec == NULL)
  8861. return -ENOMEM;
  8862. codec->spec = spec;
  8863. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  8864. alc861vd_models,
  8865. alc861vd_cfg_tbl);
  8866. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  8867. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  8868. "ALC861VD, trying auto-probe from BIOS...\n");
  8869. board_config = ALC861VD_AUTO;
  8870. }
  8871. if (board_config == ALC861VD_AUTO) {
  8872. /* automatic parse from the BIOS config */
  8873. err = alc861vd_parse_auto_config(codec);
  8874. if (err < 0) {
  8875. alc_free(codec);
  8876. return err;
  8877. } else if (!err) {
  8878. printk(KERN_INFO
  8879. "hda_codec: Cannot set up configuration "
  8880. "from BIOS. Using base mode...\n");
  8881. board_config = ALC861VD_3ST;
  8882. }
  8883. }
  8884. if (board_config != ALC861VD_AUTO)
  8885. setup_preset(spec, &alc861vd_presets[board_config]);
  8886. spec->stream_name_analog = "ALC861VD Analog";
  8887. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  8888. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  8889. spec->stream_name_digital = "ALC861VD Digital";
  8890. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  8891. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  8892. spec->adc_nids = alc861vd_adc_nids;
  8893. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  8894. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  8895. spec->num_mixers++;
  8896. codec->patch_ops = alc_patch_ops;
  8897. if (board_config == ALC861VD_AUTO)
  8898. spec->init_hook = alc861vd_auto_init;
  8899. return 0;
  8900. }
  8901. /*
  8902. * ALC662 support
  8903. *
  8904. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  8905. * configuration. Each pin widget can choose any input DACs and a mixer.
  8906. * Each ADC is connected from a mixer of all inputs. This makes possible
  8907. * 6-channel independent captures.
  8908. *
  8909. * In addition, an independent DAC for the multi-playback (not used in this
  8910. * driver yet).
  8911. */
  8912. #define ALC662_DIGOUT_NID 0x06
  8913. #define ALC662_DIGIN_NID 0x0a
  8914. static hda_nid_t alc662_dac_nids[4] = {
  8915. /* front, rear, clfe, rear_surr */
  8916. 0x02, 0x03, 0x04
  8917. };
  8918. static hda_nid_t alc662_adc_nids[1] = {
  8919. /* ADC1-2 */
  8920. 0x09,
  8921. };
  8922. /* input MUX */
  8923. /* FIXME: should be a matrix-type input source selection */
  8924. static struct hda_input_mux alc662_capture_source = {
  8925. .num_items = 4,
  8926. .items = {
  8927. { "Mic", 0x0 },
  8928. { "Front Mic", 0x1 },
  8929. { "Line", 0x2 },
  8930. { "CD", 0x4 },
  8931. },
  8932. };
  8933. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  8934. .num_items = 2,
  8935. .items = {
  8936. { "Mic", 0x1 },
  8937. { "Line", 0x2 },
  8938. },
  8939. };
  8940. #define alc662_mux_enum_info alc_mux_enum_info
  8941. #define alc662_mux_enum_get alc_mux_enum_get
  8942. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  8943. struct snd_ctl_elem_value *ucontrol)
  8944. {
  8945. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8946. struct alc_spec *spec = codec->spec;
  8947. const struct hda_input_mux *imux = spec->input_mux;
  8948. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8949. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  8950. hda_nid_t nid = capture_mixers[adc_idx];
  8951. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8952. unsigned int i, idx;
  8953. idx = ucontrol->value.enumerated.item[0];
  8954. if (idx >= imux->num_items)
  8955. idx = imux->num_items - 1;
  8956. if (*cur_val == idx && !codec->in_resume)
  8957. return 0;
  8958. for (i = 0; i < imux->num_items; i++) {
  8959. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8960. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8961. v | (imux->items[i].index << 8));
  8962. }
  8963. *cur_val = idx;
  8964. return 1;
  8965. }
  8966. /*
  8967. * 2ch mode
  8968. */
  8969. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  8970. { 2, NULL }
  8971. };
  8972. /*
  8973. * 2ch mode
  8974. */
  8975. static struct hda_verb alc662_3ST_ch2_init[] = {
  8976. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  8977. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8978. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  8979. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8980. { } /* end */
  8981. };
  8982. /*
  8983. * 6ch mode
  8984. */
  8985. static struct hda_verb alc662_3ST_ch6_init[] = {
  8986. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8987. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8988. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  8989. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8990. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8991. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8992. { } /* end */
  8993. };
  8994. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  8995. { 2, alc662_3ST_ch2_init },
  8996. { 6, alc662_3ST_ch6_init },
  8997. };
  8998. /*
  8999. * 2ch mode
  9000. */
  9001. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9002. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9003. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9004. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9005. { } /* end */
  9006. };
  9007. /*
  9008. * 6ch mode
  9009. */
  9010. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9011. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9012. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9013. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9014. { } /* end */
  9015. };
  9016. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9017. { 2, alc662_sixstack_ch6_init },
  9018. { 6, alc662_sixstack_ch8_init },
  9019. };
  9020. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9021. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9022. */
  9023. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9024. /* output mixer control */
  9025. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9026. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9027. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9028. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9029. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9030. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9031. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9032. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9033. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9034. /*Input mixer control */
  9035. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9036. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9037. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9038. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9039. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9040. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9041. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9042. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9043. /* Capture mixer control */
  9044. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9045. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9046. {
  9047. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9048. .name = "Capture Source",
  9049. .count = 1,
  9050. .info = alc_mux_enum_info,
  9051. .get = alc_mux_enum_get,
  9052. .put = alc_mux_enum_put,
  9053. },
  9054. { } /* end */
  9055. };
  9056. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9057. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9058. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9059. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9060. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9061. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9062. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9063. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9064. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9065. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9066. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9067. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9068. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9069. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9070. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9071. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9072. {
  9073. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9074. /* .name = "Capture Source", */
  9075. .name = "Input Source",
  9076. .count = 1,
  9077. .info = alc662_mux_enum_info,
  9078. .get = alc662_mux_enum_get,
  9079. .put = alc662_mux_enum_put,
  9080. },
  9081. { } /* end */
  9082. };
  9083. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9084. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9085. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9086. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9087. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9088. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9089. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9090. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9091. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9092. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9093. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9094. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9095. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9096. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9097. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9098. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9099. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9100. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9101. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9102. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9103. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9104. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9105. {
  9106. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9107. /* .name = "Capture Source", */
  9108. .name = "Input Source",
  9109. .count = 1,
  9110. .info = alc662_mux_enum_info,
  9111. .get = alc662_mux_enum_get,
  9112. .put = alc662_mux_enum_put,
  9113. },
  9114. { } /* end */
  9115. };
  9116. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9117. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9118. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9119. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9120. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9121. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9122. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9123. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9124. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9125. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9126. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9127. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9128. {
  9129. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9130. /* .name = "Capture Source", */
  9131. .name = "Input Source",
  9132. .count = 1,
  9133. .info = alc662_mux_enum_info,
  9134. .get = alc662_mux_enum_get,
  9135. .put = alc662_mux_enum_put,
  9136. },
  9137. { } /* end */
  9138. };
  9139. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9140. {
  9141. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9142. .name = "Channel Mode",
  9143. .info = alc_ch_mode_info,
  9144. .get = alc_ch_mode_get,
  9145. .put = alc_ch_mode_put,
  9146. },
  9147. { } /* end */
  9148. };
  9149. static struct hda_verb alc662_init_verbs[] = {
  9150. /* ADC: mute amp left and right */
  9151. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9152. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9153. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9154. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9155. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9156. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9157. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9158. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9159. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9160. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9161. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9162. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9163. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9164. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9165. /* Front Pin: output 0 (0x0c) */
  9166. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9167. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9168. /* Rear Pin: output 1 (0x0d) */
  9169. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9170. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9171. /* CLFE Pin: output 2 (0x0e) */
  9172. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9173. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9174. /* Mic (rear) pin: input vref at 80% */
  9175. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9176. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9177. /* Front Mic pin: input vref at 80% */
  9178. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9179. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9180. /* Line In pin: input */
  9181. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9182. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9183. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9184. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9185. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9186. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9187. /* CD pin widget for input */
  9188. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9189. /* FIXME: use matrix-type input source selection */
  9190. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9191. /* Input mixer */
  9192. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9193. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9194. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9195. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9196. { }
  9197. };
  9198. static struct hda_verb alc662_sue_init_verbs[] = {
  9199. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9200. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9201. {}
  9202. };
  9203. /*
  9204. * generic initialization of ADC, input mixers and output mixers
  9205. */
  9206. static struct hda_verb alc662_auto_init_verbs[] = {
  9207. /*
  9208. * Unmute ADC and set the default input to mic-in
  9209. */
  9210. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9211. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9212. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9213. * mixer widget
  9214. * Note: PASD motherboards uses the Line In 2 as the input for front
  9215. * panel mic (mic 2)
  9216. */
  9217. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9218. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9219. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9220. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9221. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9222. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9223. /*
  9224. * Set up output mixers (0x0c - 0x0f)
  9225. */
  9226. /* set vol=0 to output mixers */
  9227. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9228. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9229. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9230. /* set up input amps for analog loopback */
  9231. /* Amp Indices: DAC = 0, mixer = 1 */
  9232. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9233. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9234. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9235. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9236. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9237. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9238. /* FIXME: use matrix-type input source selection */
  9239. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9240. /* Input mixer */
  9241. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9242. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9243. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9244. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9245. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9246. { }
  9247. };
  9248. /* capture mixer elements */
  9249. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9250. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9251. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9252. {
  9253. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9254. /* The multiple "Capture Source" controls confuse alsamixer
  9255. * So call somewhat different..
  9256. * FIXME: the controls appear in the "playback" view!
  9257. */
  9258. /* .name = "Capture Source", */
  9259. .name = "Input Source",
  9260. .count = 1,
  9261. .info = alc882_mux_enum_info,
  9262. .get = alc882_mux_enum_get,
  9263. .put = alc882_mux_enum_put,
  9264. },
  9265. { } /* end */
  9266. };
  9267. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9268. {
  9269. unsigned int present;
  9270. unsigned char bits;
  9271. present = snd_hda_codec_read(codec, 0x14, 0,
  9272. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9273. bits = present ? 0x80 : 0;
  9274. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9275. 0x80, bits);
  9276. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9277. 0x80, bits);
  9278. }
  9279. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9280. {
  9281. unsigned int present;
  9282. unsigned char bits;
  9283. present = snd_hda_codec_read(codec, 0x1b, 0,
  9284. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9285. bits = present ? 0x80 : 0;
  9286. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9287. 0x80, bits);
  9288. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9289. 0x80, bits);
  9290. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9291. 0x80, bits);
  9292. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9293. 0x80, bits);
  9294. }
  9295. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9296. unsigned int res)
  9297. {
  9298. if ((res >> 26) == ALC880_HP_EVENT)
  9299. alc662_lenovo_101e_all_automute(codec);
  9300. if ((res >> 26) == ALC880_FRONT_EVENT)
  9301. alc662_lenovo_101e_ispeaker_automute(codec);
  9302. }
  9303. /* pcm configuration: identiacal with ALC880 */
  9304. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9305. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9306. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9307. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9308. /*
  9309. * configuration and preset
  9310. */
  9311. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9312. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9313. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9314. [ALC662_3ST_6ch] = "3stack-6ch",
  9315. [ALC662_5ST_DIG] = "6stack-dig",
  9316. [ALC662_LENOVO_101E] = "lenovo-101e",
  9317. [ALC662_AUTO] = "auto",
  9318. };
  9319. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9320. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9321. {}
  9322. };
  9323. static struct alc_config_preset alc662_presets[] = {
  9324. [ALC662_3ST_2ch_DIG] = {
  9325. .mixers = { alc662_3ST_2ch_mixer },
  9326. .init_verbs = { alc662_init_verbs },
  9327. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9328. .dac_nids = alc662_dac_nids,
  9329. .dig_out_nid = ALC662_DIGOUT_NID,
  9330. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9331. .adc_nids = alc662_adc_nids,
  9332. .dig_in_nid = ALC662_DIGIN_NID,
  9333. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9334. .channel_mode = alc662_3ST_2ch_modes,
  9335. .input_mux = &alc662_capture_source,
  9336. },
  9337. [ALC662_3ST_6ch_DIG] = {
  9338. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9339. .init_verbs = { alc662_init_verbs },
  9340. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9341. .dac_nids = alc662_dac_nids,
  9342. .dig_out_nid = ALC662_DIGOUT_NID,
  9343. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9344. .adc_nids = alc662_adc_nids,
  9345. .dig_in_nid = ALC662_DIGIN_NID,
  9346. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9347. .channel_mode = alc662_3ST_6ch_modes,
  9348. .need_dac_fix = 1,
  9349. .input_mux = &alc662_capture_source,
  9350. },
  9351. [ALC662_3ST_6ch] = {
  9352. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9353. .init_verbs = { alc662_init_verbs },
  9354. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9355. .dac_nids = alc662_dac_nids,
  9356. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9357. .adc_nids = alc662_adc_nids,
  9358. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9359. .channel_mode = alc662_3ST_6ch_modes,
  9360. .need_dac_fix = 1,
  9361. .input_mux = &alc662_capture_source,
  9362. },
  9363. [ALC662_5ST_DIG] = {
  9364. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9365. .init_verbs = { alc662_init_verbs },
  9366. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9367. .dac_nids = alc662_dac_nids,
  9368. .dig_out_nid = ALC662_DIGOUT_NID,
  9369. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9370. .adc_nids = alc662_adc_nids,
  9371. .dig_in_nid = ALC662_DIGIN_NID,
  9372. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9373. .channel_mode = alc662_5stack_modes,
  9374. .input_mux = &alc662_capture_source,
  9375. },
  9376. [ALC662_LENOVO_101E] = {
  9377. .mixers = { alc662_lenovo_101e_mixer },
  9378. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9379. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9380. .dac_nids = alc662_dac_nids,
  9381. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9382. .adc_nids = alc662_adc_nids,
  9383. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9384. .channel_mode = alc662_3ST_2ch_modes,
  9385. .input_mux = &alc662_lenovo_101e_capture_source,
  9386. .unsol_event = alc662_lenovo_101e_unsol_event,
  9387. .init_hook = alc662_lenovo_101e_all_automute,
  9388. },
  9389. };
  9390. /*
  9391. * BIOS auto configuration
  9392. */
  9393. /* add playback controls from the parsed DAC table */
  9394. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9395. const struct auto_pin_cfg *cfg)
  9396. {
  9397. char name[32];
  9398. static const char *chname[4] = {
  9399. "Front", "Surround", NULL /*CLFE*/, "Side"
  9400. };
  9401. hda_nid_t nid;
  9402. int i, err;
  9403. for (i = 0; i < cfg->line_outs; i++) {
  9404. if (!spec->multiout.dac_nids[i])
  9405. continue;
  9406. nid = alc880_idx_to_dac(i);
  9407. if (i == 2) {
  9408. /* Center/LFE */
  9409. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9410. "Center Playback Volume",
  9411. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9412. HDA_OUTPUT));
  9413. if (err < 0)
  9414. return err;
  9415. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9416. "LFE Playback Volume",
  9417. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9418. HDA_OUTPUT));
  9419. if (err < 0)
  9420. return err;
  9421. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9422. "Center Playback Switch",
  9423. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9424. HDA_INPUT));
  9425. if (err < 0)
  9426. return err;
  9427. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9428. "LFE Playback Switch",
  9429. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9430. HDA_INPUT));
  9431. if (err < 0)
  9432. return err;
  9433. } else {
  9434. sprintf(name, "%s Playback Volume", chname[i]);
  9435. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9436. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9437. HDA_OUTPUT));
  9438. if (err < 0)
  9439. return err;
  9440. sprintf(name, "%s Playback Switch", chname[i]);
  9441. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9442. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9443. HDA_INPUT));
  9444. if (err < 0)
  9445. return err;
  9446. }
  9447. }
  9448. return 0;
  9449. }
  9450. /* add playback controls for speaker and HP outputs */
  9451. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9452. const char *pfx)
  9453. {
  9454. hda_nid_t nid;
  9455. int err;
  9456. char name[32];
  9457. if (!pin)
  9458. return 0;
  9459. if (alc880_is_fixed_pin(pin)) {
  9460. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9461. /* printk("DAC nid=%x\n",nid); */
  9462. /* specify the DAC as the extra output */
  9463. if (!spec->multiout.hp_nid)
  9464. spec->multiout.hp_nid = nid;
  9465. else
  9466. spec->multiout.extra_out_nid[0] = nid;
  9467. /* control HP volume/switch on the output mixer amp */
  9468. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9469. sprintf(name, "%s Playback Volume", pfx);
  9470. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9471. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9472. if (err < 0)
  9473. return err;
  9474. sprintf(name, "%s Playback Switch", pfx);
  9475. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9476. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9477. if (err < 0)
  9478. return err;
  9479. } else if (alc880_is_multi_pin(pin)) {
  9480. /* set manual connection */
  9481. /* we have only a switch on HP-out PIN */
  9482. sprintf(name, "%s Playback Switch", pfx);
  9483. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9484. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9485. if (err < 0)
  9486. return err;
  9487. }
  9488. return 0;
  9489. }
  9490. /* create playback/capture controls for input pins */
  9491. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9492. const struct auto_pin_cfg *cfg)
  9493. {
  9494. struct hda_input_mux *imux = &spec->private_imux;
  9495. int i, err, idx;
  9496. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9497. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9498. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9499. err = new_analog_input(spec, cfg->input_pins[i],
  9500. auto_pin_cfg_labels[i],
  9501. idx, 0x0b);
  9502. if (err < 0)
  9503. return err;
  9504. imux->items[imux->num_items].label =
  9505. auto_pin_cfg_labels[i];
  9506. imux->items[imux->num_items].index =
  9507. alc880_input_pin_idx(cfg->input_pins[i]);
  9508. imux->num_items++;
  9509. }
  9510. }
  9511. return 0;
  9512. }
  9513. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9514. hda_nid_t nid, int pin_type,
  9515. int dac_idx)
  9516. {
  9517. /* set as output */
  9518. snd_hda_codec_write(codec, nid, 0,
  9519. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9520. snd_hda_codec_write(codec, nid, 0,
  9521. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9522. /* need the manual connection? */
  9523. if (alc880_is_multi_pin(nid)) {
  9524. struct alc_spec *spec = codec->spec;
  9525. int idx = alc880_multi_pin_idx(nid);
  9526. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  9527. AC_VERB_SET_CONNECT_SEL,
  9528. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  9529. }
  9530. }
  9531. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  9532. {
  9533. struct alc_spec *spec = codec->spec;
  9534. int i;
  9535. for (i = 0; i <= HDA_SIDE; i++) {
  9536. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9537. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9538. if (nid)
  9539. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  9540. i);
  9541. }
  9542. }
  9543. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  9544. {
  9545. struct alc_spec *spec = codec->spec;
  9546. hda_nid_t pin;
  9547. pin = spec->autocfg.hp_pins[0];
  9548. if (pin) /* connect to front */
  9549. /* use dac 0 */
  9550. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9551. }
  9552. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  9553. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  9554. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  9555. {
  9556. struct alc_spec *spec = codec->spec;
  9557. int i;
  9558. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9559. hda_nid_t nid = spec->autocfg.input_pins[i];
  9560. if (alc662_is_input_pin(nid)) {
  9561. snd_hda_codec_write(codec, nid, 0,
  9562. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9563. (i <= AUTO_PIN_FRONT_MIC ?
  9564. PIN_VREF80 : PIN_IN));
  9565. if (nid != ALC662_PIN_CD_NID)
  9566. snd_hda_codec_write(codec, nid, 0,
  9567. AC_VERB_SET_AMP_GAIN_MUTE,
  9568. AMP_OUT_MUTE);
  9569. }
  9570. }
  9571. }
  9572. static int alc662_parse_auto_config(struct hda_codec *codec)
  9573. {
  9574. struct alc_spec *spec = codec->spec;
  9575. int err;
  9576. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  9577. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9578. alc662_ignore);
  9579. if (err < 0)
  9580. return err;
  9581. if (!spec->autocfg.line_outs)
  9582. return 0; /* can't find valid BIOS pin config */
  9583. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9584. if (err < 0)
  9585. return err;
  9586. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9587. if (err < 0)
  9588. return err;
  9589. err = alc662_auto_create_extra_out(spec,
  9590. spec->autocfg.speaker_pins[0],
  9591. "Speaker");
  9592. if (err < 0)
  9593. return err;
  9594. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  9595. "Headphone");
  9596. if (err < 0)
  9597. return err;
  9598. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9599. if (err < 0)
  9600. return err;
  9601. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9602. if (spec->autocfg.dig_out_pin)
  9603. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  9604. if (spec->kctl_alloc)
  9605. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9606. spec->num_mux_defs = 1;
  9607. spec->input_mux = &spec->private_imux;
  9608. if (err < 0)
  9609. return err;
  9610. else if (err > 0)
  9611. /* hack - override the init verbs */
  9612. spec->init_verbs[0] = alc662_auto_init_verbs;
  9613. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  9614. spec->num_mixers++;
  9615. return err;
  9616. }
  9617. /* additional initialization for auto-configuration model */
  9618. static void alc662_auto_init(struct hda_codec *codec)
  9619. {
  9620. alc662_auto_init_multi_out(codec);
  9621. alc662_auto_init_hp_out(codec);
  9622. alc662_auto_init_analog_input(codec);
  9623. }
  9624. static int patch_alc662(struct hda_codec *codec)
  9625. {
  9626. struct alc_spec *spec;
  9627. int err, board_config;
  9628. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9629. if (!spec)
  9630. return -ENOMEM;
  9631. codec->spec = spec;
  9632. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  9633. alc662_models,
  9634. alc662_cfg_tbl);
  9635. if (board_config < 0) {
  9636. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  9637. "trying auto-probe from BIOS...\n");
  9638. board_config = ALC662_AUTO;
  9639. }
  9640. if (board_config == ALC662_AUTO) {
  9641. /* automatic parse from the BIOS config */
  9642. err = alc662_parse_auto_config(codec);
  9643. if (err < 0) {
  9644. alc_free(codec);
  9645. return err;
  9646. } else if (err) {
  9647. printk(KERN_INFO
  9648. "hda_codec: Cannot set up configuration "
  9649. "from BIOS. Using base mode...\n");
  9650. board_config = ALC662_3ST_2ch_DIG;
  9651. }
  9652. }
  9653. if (board_config != ALC662_AUTO)
  9654. setup_preset(spec, &alc662_presets[board_config]);
  9655. spec->stream_name_analog = "ALC662 Analog";
  9656. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  9657. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  9658. spec->stream_name_digital = "ALC662 Digital";
  9659. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  9660. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  9661. if (!spec->adc_nids && spec->input_mux) {
  9662. spec->adc_nids = alc662_adc_nids;
  9663. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  9664. }
  9665. codec->patch_ops = alc_patch_ops;
  9666. if (board_config == ALC662_AUTO)
  9667. spec->init_hook = alc662_auto_init;
  9668. return 0;
  9669. }
  9670. /*
  9671. * patch entries
  9672. */
  9673. struct hda_codec_preset snd_hda_preset_realtek[] = {
  9674. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  9675. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  9676. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  9677. .patch = patch_alc861 },
  9678. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  9679. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  9680. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  9681. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  9682. .patch = patch_alc883 },
  9683. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  9684. .patch = patch_alc662 },
  9685. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  9686. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  9687. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  9688. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  9689. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  9690. {} /* terminator */
  9691. };