patch_realtek.c 338 KB

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