patch_realtek.c 236 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916
  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. /* ALC880 board config type */
  34. enum {
  35. ALC880_3ST,
  36. ALC880_3ST_DIG,
  37. ALC880_5ST,
  38. ALC880_5ST_DIG,
  39. ALC880_W810,
  40. ALC880_Z71V,
  41. ALC880_6ST,
  42. ALC880_6ST_DIG,
  43. ALC880_F1734,
  44. ALC880_ASUS,
  45. ALC880_ASUS_DIG,
  46. ALC880_ASUS_W1V,
  47. ALC880_ASUS_DIG2,
  48. ALC880_UNIWILL_DIG,
  49. ALC880_CLEVO,
  50. ALC880_TCL_S700,
  51. ALC880_LG,
  52. ALC880_LG_LW,
  53. #ifdef CONFIG_SND_DEBUG
  54. ALC880_TEST,
  55. #endif
  56. ALC880_AUTO,
  57. ALC880_MODEL_LAST /* last tag */
  58. };
  59. /* ALC260 models */
  60. enum {
  61. ALC260_BASIC,
  62. ALC260_HP,
  63. ALC260_HP_3013,
  64. ALC260_FUJITSU_S702X,
  65. ALC260_ACER,
  66. #ifdef CONFIG_SND_DEBUG
  67. ALC260_TEST,
  68. #endif
  69. ALC260_AUTO,
  70. ALC260_MODEL_LAST /* last tag */
  71. };
  72. /* ALC262 models */
  73. enum {
  74. ALC262_BASIC,
  75. ALC262_FUJITSU,
  76. ALC262_HP_BPC,
  77. ALC262_BENQ_ED8,
  78. ALC262_AUTO,
  79. ALC262_MODEL_LAST /* last tag */
  80. };
  81. /* ALC861 models */
  82. enum {
  83. ALC861_3ST,
  84. ALC660_3ST,
  85. ALC861_3ST_DIG,
  86. ALC861_6ST_DIG,
  87. ALC861_UNIWILL_M31,
  88. ALC861_AUTO,
  89. ALC861_MODEL_LAST,
  90. };
  91. /* ALC882 models */
  92. enum {
  93. ALC882_3ST_DIG,
  94. ALC882_6ST_DIG,
  95. ALC882_ARIMA,
  96. ALC882_AUTO,
  97. ALC882_MODEL_LAST,
  98. };
  99. /* ALC883 models */
  100. enum {
  101. ALC883_3ST_2ch_DIG,
  102. ALC883_3ST_6ch_DIG,
  103. ALC883_3ST_6ch,
  104. ALC883_6ST_DIG,
  105. ALC888_DEMO_BOARD,
  106. ALC883_ACER,
  107. ALC883_MEDION,
  108. ALC883_AUTO,
  109. ALC883_MODEL_LAST,
  110. };
  111. /* for GPIO Poll */
  112. #define GPIO_MASK 0x03
  113. struct alc_spec {
  114. /* codec parameterization */
  115. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  116. unsigned int num_mixers;
  117. const struct hda_verb *init_verbs[5]; /* initialization verbs
  118. * don't forget NULL
  119. * termination!
  120. */
  121. unsigned int num_init_verbs;
  122. char *stream_name_analog; /* analog PCM stream */
  123. struct hda_pcm_stream *stream_analog_playback;
  124. struct hda_pcm_stream *stream_analog_capture;
  125. char *stream_name_digital; /* digital PCM stream */
  126. struct hda_pcm_stream *stream_digital_playback;
  127. struct hda_pcm_stream *stream_digital_capture;
  128. /* playback */
  129. struct hda_multi_out multiout; /* playback set-up
  130. * max_channels, dacs must be set
  131. * dig_out_nid and hp_nid are optional
  132. */
  133. /* capture */
  134. unsigned int num_adc_nids;
  135. hda_nid_t *adc_nids;
  136. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  137. /* capture source */
  138. unsigned int num_mux_defs;
  139. const struct hda_input_mux *input_mux;
  140. unsigned int cur_mux[3];
  141. /* channel model */
  142. const struct hda_channel_mode *channel_mode;
  143. int num_channel_mode;
  144. int need_dac_fix;
  145. /* PCM information */
  146. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  147. /* dynamic controls, init_verbs and input_mux */
  148. struct auto_pin_cfg autocfg;
  149. unsigned int num_kctl_alloc, num_kctl_used;
  150. struct snd_kcontrol_new *kctl_alloc;
  151. struct hda_input_mux private_imux;
  152. hda_nid_t private_dac_nids[5];
  153. /* hooks */
  154. void (*init_hook)(struct hda_codec *codec);
  155. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  156. /* for pin sensing */
  157. unsigned int sense_updated: 1;
  158. unsigned int jack_present: 1;
  159. };
  160. /*
  161. * configuration template - to be copied to the spec instance
  162. */
  163. struct alc_config_preset {
  164. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  165. * with spec
  166. */
  167. const struct hda_verb *init_verbs[5];
  168. unsigned int num_dacs;
  169. hda_nid_t *dac_nids;
  170. hda_nid_t dig_out_nid; /* optional */
  171. hda_nid_t hp_nid; /* optional */
  172. unsigned int num_adc_nids;
  173. hda_nid_t *adc_nids;
  174. hda_nid_t dig_in_nid;
  175. unsigned int num_channel_mode;
  176. const struct hda_channel_mode *channel_mode;
  177. int need_dac_fix;
  178. unsigned int num_mux_defs;
  179. const struct hda_input_mux *input_mux;
  180. void (*unsol_event)(struct hda_codec *, unsigned int);
  181. void (*init_hook)(struct hda_codec *);
  182. };
  183. /*
  184. * input MUX handling
  185. */
  186. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  187. struct snd_ctl_elem_info *uinfo)
  188. {
  189. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  190. struct alc_spec *spec = codec->spec;
  191. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  192. if (mux_idx >= spec->num_mux_defs)
  193. mux_idx = 0;
  194. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  195. }
  196. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  197. struct snd_ctl_elem_value *ucontrol)
  198. {
  199. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  200. struct alc_spec *spec = codec->spec;
  201. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  202. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  203. return 0;
  204. }
  205. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  206. struct snd_ctl_elem_value *ucontrol)
  207. {
  208. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  209. struct alc_spec *spec = codec->spec;
  210. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  211. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  212. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  213. spec->adc_nids[adc_idx],
  214. &spec->cur_mux[adc_idx]);
  215. }
  216. /*
  217. * channel mode setting
  218. */
  219. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  220. struct snd_ctl_elem_info *uinfo)
  221. {
  222. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  223. struct alc_spec *spec = codec->spec;
  224. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  225. spec->num_channel_mode);
  226. }
  227. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  228. struct snd_ctl_elem_value *ucontrol)
  229. {
  230. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  231. struct alc_spec *spec = codec->spec;
  232. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  233. spec->num_channel_mode,
  234. spec->multiout.max_channels);
  235. }
  236. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  237. struct snd_ctl_elem_value *ucontrol)
  238. {
  239. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  240. struct alc_spec *spec = codec->spec;
  241. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  242. spec->num_channel_mode,
  243. &spec->multiout.max_channels);
  244. if (err >= 0 && spec->need_dac_fix)
  245. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  246. return err;
  247. }
  248. /*
  249. * Control the mode of pin widget settings via the mixer. "pc" is used
  250. * instead of "%" to avoid consequences of accidently treating the % as
  251. * being part of a format specifier. Maximum allowed length of a value is
  252. * 63 characters plus NULL terminator.
  253. *
  254. * Note: some retasking pin complexes seem to ignore requests for input
  255. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  256. * are requested. Therefore order this list so that this behaviour will not
  257. * cause problems when mixer clients move through the enum sequentially.
  258. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  259. * March 2006.
  260. */
  261. static char *alc_pin_mode_names[] = {
  262. "Mic 50pc bias", "Mic 80pc bias",
  263. "Line in", "Line out", "Headphone out",
  264. };
  265. static unsigned char alc_pin_mode_values[] = {
  266. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  267. };
  268. /* The control can present all 5 options, or it can limit the options based
  269. * in the pin being assumed to be exclusively an input or an output pin. In
  270. * addition, "input" pins may or may not process the mic bias option
  271. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  272. * accept requests for bias as of chip versions up to March 2006) and/or
  273. * wiring in the computer.
  274. */
  275. #define ALC_PIN_DIR_IN 0x00
  276. #define ALC_PIN_DIR_OUT 0x01
  277. #define ALC_PIN_DIR_INOUT 0x02
  278. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  279. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  280. /* Info about the pin modes supported by the different pin direction modes.
  281. * For each direction the minimum and maximum values are given.
  282. */
  283. static signed char alc_pin_mode_dir_info[5][2] = {
  284. { 0, 2 }, /* ALC_PIN_DIR_IN */
  285. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  286. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  287. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  288. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  289. };
  290. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  291. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  292. #define alc_pin_mode_n_items(_dir) \
  293. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  294. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  295. struct snd_ctl_elem_info *uinfo)
  296. {
  297. unsigned int item_num = uinfo->value.enumerated.item;
  298. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  299. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  300. uinfo->count = 1;
  301. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  302. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  303. item_num = alc_pin_mode_min(dir);
  304. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  305. return 0;
  306. }
  307. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  308. struct snd_ctl_elem_value *ucontrol)
  309. {
  310. unsigned int i;
  311. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  312. hda_nid_t nid = kcontrol->private_value & 0xffff;
  313. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  314. long *valp = ucontrol->value.integer.value;
  315. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  316. AC_VERB_GET_PIN_WIDGET_CONTROL,
  317. 0x00);
  318. /* Find enumerated value for current pinctl setting */
  319. i = alc_pin_mode_min(dir);
  320. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  321. i++;
  322. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  323. return 0;
  324. }
  325. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  326. struct snd_ctl_elem_value *ucontrol)
  327. {
  328. signed int change;
  329. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  330. hda_nid_t nid = kcontrol->private_value & 0xffff;
  331. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  332. long val = *ucontrol->value.integer.value;
  333. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  334. AC_VERB_GET_PIN_WIDGET_CONTROL,
  335. 0x00);
  336. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  337. val = alc_pin_mode_min(dir);
  338. change = pinctl != alc_pin_mode_values[val];
  339. if (change) {
  340. /* Set pin mode to that requested */
  341. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  342. alc_pin_mode_values[val]);
  343. /* Also enable the retasking pin's input/output as required
  344. * for the requested pin mode. Enum values of 2 or less are
  345. * input modes.
  346. *
  347. * Dynamically switching the input/output buffers probably
  348. * reduces noise slightly (particularly on input) so we'll
  349. * do it. However, having both input and output buffers
  350. * enabled simultaneously doesn't seem to be problematic if
  351. * this turns out to be necessary in the future.
  352. */
  353. if (val <= 2) {
  354. snd_hda_codec_write(codec, nid, 0,
  355. AC_VERB_SET_AMP_GAIN_MUTE,
  356. AMP_OUT_MUTE);
  357. snd_hda_codec_write(codec, nid, 0,
  358. AC_VERB_SET_AMP_GAIN_MUTE,
  359. AMP_IN_UNMUTE(0));
  360. } else {
  361. snd_hda_codec_write(codec, nid, 0,
  362. AC_VERB_SET_AMP_GAIN_MUTE,
  363. AMP_IN_MUTE(0));
  364. snd_hda_codec_write(codec, nid, 0,
  365. AC_VERB_SET_AMP_GAIN_MUTE,
  366. AMP_OUT_UNMUTE);
  367. }
  368. }
  369. return change;
  370. }
  371. #define ALC_PIN_MODE(xname, nid, dir) \
  372. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  373. .info = alc_pin_mode_info, \
  374. .get = alc_pin_mode_get, \
  375. .put = alc_pin_mode_put, \
  376. .private_value = nid | (dir<<16) }
  377. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  378. * together using a mask with more than one bit set. This control is
  379. * currently used only by the ALC260 test model. At this stage they are not
  380. * needed for any "production" models.
  381. */
  382. #ifdef CONFIG_SND_DEBUG
  383. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  384. struct snd_ctl_elem_info *uinfo)
  385. {
  386. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  387. uinfo->count = 1;
  388. uinfo->value.integer.min = 0;
  389. uinfo->value.integer.max = 1;
  390. return 0;
  391. }
  392. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  393. struct snd_ctl_elem_value *ucontrol)
  394. {
  395. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  396. hda_nid_t nid = kcontrol->private_value & 0xffff;
  397. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  398. long *valp = ucontrol->value.integer.value;
  399. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  400. AC_VERB_GET_GPIO_DATA, 0x00);
  401. *valp = (val & mask) != 0;
  402. return 0;
  403. }
  404. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  405. struct snd_ctl_elem_value *ucontrol)
  406. {
  407. signed int change;
  408. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  409. hda_nid_t nid = kcontrol->private_value & 0xffff;
  410. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  411. long val = *ucontrol->value.integer.value;
  412. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  413. AC_VERB_GET_GPIO_DATA,
  414. 0x00);
  415. /* Set/unset the masked GPIO bit(s) as needed */
  416. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  417. if (val == 0)
  418. gpio_data &= ~mask;
  419. else
  420. gpio_data |= mask;
  421. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  422. return change;
  423. }
  424. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  425. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  426. .info = alc_gpio_data_info, \
  427. .get = alc_gpio_data_get, \
  428. .put = alc_gpio_data_put, \
  429. .private_value = nid | (mask<<16) }
  430. #endif /* CONFIG_SND_DEBUG */
  431. /* A switch control to allow the enabling of the digital IO pins on the
  432. * ALC260. This is incredibly simplistic; the intention of this control is
  433. * to provide something in the test model allowing digital outputs to be
  434. * identified if present. If models are found which can utilise these
  435. * outputs a more complete mixer control can be devised for those models if
  436. * necessary.
  437. */
  438. #ifdef CONFIG_SND_DEBUG
  439. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  440. struct snd_ctl_elem_info *uinfo)
  441. {
  442. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  443. uinfo->count = 1;
  444. uinfo->value.integer.min = 0;
  445. uinfo->value.integer.max = 1;
  446. return 0;
  447. }
  448. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  449. struct snd_ctl_elem_value *ucontrol)
  450. {
  451. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  452. hda_nid_t nid = kcontrol->private_value & 0xffff;
  453. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  454. long *valp = ucontrol->value.integer.value;
  455. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  456. AC_VERB_GET_DIGI_CONVERT, 0x00);
  457. *valp = (val & mask) != 0;
  458. return 0;
  459. }
  460. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  461. struct snd_ctl_elem_value *ucontrol)
  462. {
  463. signed int change;
  464. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  465. hda_nid_t nid = kcontrol->private_value & 0xffff;
  466. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  467. long val = *ucontrol->value.integer.value;
  468. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  469. AC_VERB_GET_DIGI_CONVERT,
  470. 0x00);
  471. /* Set/unset the masked control bit(s) as needed */
  472. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  473. if (val==0)
  474. ctrl_data &= ~mask;
  475. else
  476. ctrl_data |= mask;
  477. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  478. ctrl_data);
  479. return change;
  480. }
  481. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  482. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  483. .info = alc_spdif_ctrl_info, \
  484. .get = alc_spdif_ctrl_get, \
  485. .put = alc_spdif_ctrl_put, \
  486. .private_value = nid | (mask<<16) }
  487. #endif /* CONFIG_SND_DEBUG */
  488. /*
  489. * set up from the preset table
  490. */
  491. static void setup_preset(struct alc_spec *spec,
  492. const struct alc_config_preset *preset)
  493. {
  494. int i;
  495. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  496. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  497. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  498. i++)
  499. spec->init_verbs[spec->num_init_verbs++] =
  500. preset->init_verbs[i];
  501. spec->channel_mode = preset->channel_mode;
  502. spec->num_channel_mode = preset->num_channel_mode;
  503. spec->need_dac_fix = preset->need_dac_fix;
  504. spec->multiout.max_channels = spec->channel_mode[0].channels;
  505. spec->multiout.num_dacs = preset->num_dacs;
  506. spec->multiout.dac_nids = preset->dac_nids;
  507. spec->multiout.dig_out_nid = preset->dig_out_nid;
  508. spec->multiout.hp_nid = preset->hp_nid;
  509. spec->num_mux_defs = preset->num_mux_defs;
  510. if (! spec->num_mux_defs)
  511. spec->num_mux_defs = 1;
  512. spec->input_mux = preset->input_mux;
  513. spec->num_adc_nids = preset->num_adc_nids;
  514. spec->adc_nids = preset->adc_nids;
  515. spec->dig_in_nid = preset->dig_in_nid;
  516. spec->unsol_event = preset->unsol_event;
  517. spec->init_hook = preset->init_hook;
  518. }
  519. /*
  520. * ALC880 3-stack model
  521. *
  522. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  523. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  524. * F-Mic = 0x1b, HP = 0x19
  525. */
  526. static hda_nid_t alc880_dac_nids[4] = {
  527. /* front, rear, clfe, rear_surr */
  528. 0x02, 0x05, 0x04, 0x03
  529. };
  530. static hda_nid_t alc880_adc_nids[3] = {
  531. /* ADC0-2 */
  532. 0x07, 0x08, 0x09,
  533. };
  534. /* The datasheet says the node 0x07 is connected from inputs,
  535. * but it shows zero connection in the real implementation on some devices.
  536. * Note: this is a 915GAV bug, fixed on 915GLV
  537. */
  538. static hda_nid_t alc880_adc_nids_alt[2] = {
  539. /* ADC1-2 */
  540. 0x08, 0x09,
  541. };
  542. #define ALC880_DIGOUT_NID 0x06
  543. #define ALC880_DIGIN_NID 0x0a
  544. static struct hda_input_mux alc880_capture_source = {
  545. .num_items = 4,
  546. .items = {
  547. { "Mic", 0x0 },
  548. { "Front Mic", 0x3 },
  549. { "Line", 0x2 },
  550. { "CD", 0x4 },
  551. },
  552. };
  553. /* channel source setting (2/6 channel selection for 3-stack) */
  554. /* 2ch mode */
  555. static struct hda_verb alc880_threestack_ch2_init[] = {
  556. /* set line-in to input, mute it */
  557. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  558. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  559. /* set mic-in to input vref 80%, mute it */
  560. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  561. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  562. { } /* end */
  563. };
  564. /* 6ch mode */
  565. static struct hda_verb alc880_threestack_ch6_init[] = {
  566. /* set line-in to output, unmute it */
  567. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  568. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  569. /* set mic-in to output, unmute it */
  570. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  571. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  572. { } /* end */
  573. };
  574. static struct hda_channel_mode alc880_threestack_modes[2] = {
  575. { 2, alc880_threestack_ch2_init },
  576. { 6, alc880_threestack_ch6_init },
  577. };
  578. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  579. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  580. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  581. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  582. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  583. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  584. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  585. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  586. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  587. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  588. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  589. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  590. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  591. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  592. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  593. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  594. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  597. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  598. {
  599. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  600. .name = "Channel Mode",
  601. .info = alc_ch_mode_info,
  602. .get = alc_ch_mode_get,
  603. .put = alc_ch_mode_put,
  604. },
  605. { } /* end */
  606. };
  607. /* capture mixer elements */
  608. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  609. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  610. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  611. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  612. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  613. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  614. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  615. {
  616. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  617. /* The multiple "Capture Source" controls confuse alsamixer
  618. * So call somewhat different..
  619. * FIXME: the controls appear in the "playback" view!
  620. */
  621. /* .name = "Capture Source", */
  622. .name = "Input Source",
  623. .count = 3,
  624. .info = alc_mux_enum_info,
  625. .get = alc_mux_enum_get,
  626. .put = alc_mux_enum_put,
  627. },
  628. { } /* end */
  629. };
  630. /* capture mixer elements (in case NID 0x07 not available) */
  631. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  632. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  633. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  634. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  635. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  636. {
  637. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  638. /* The multiple "Capture Source" controls confuse alsamixer
  639. * So call somewhat different..
  640. * FIXME: the controls appear in the "playback" view!
  641. */
  642. /* .name = "Capture Source", */
  643. .name = "Input Source",
  644. .count = 2,
  645. .info = alc_mux_enum_info,
  646. .get = alc_mux_enum_get,
  647. .put = alc_mux_enum_put,
  648. },
  649. { } /* end */
  650. };
  651. /*
  652. * ALC880 5-stack model
  653. *
  654. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  655. * Side = 0x02 (0xd)
  656. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  657. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  658. */
  659. /* additional mixers to alc880_three_stack_mixer */
  660. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  661. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  662. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  663. { } /* end */
  664. };
  665. /* channel source setting (6/8 channel selection for 5-stack) */
  666. /* 6ch mode */
  667. static struct hda_verb alc880_fivestack_ch6_init[] = {
  668. /* set line-in to input, mute it */
  669. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  670. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  671. { } /* end */
  672. };
  673. /* 8ch mode */
  674. static struct hda_verb alc880_fivestack_ch8_init[] = {
  675. /* set line-in to output, unmute it */
  676. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  677. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  678. { } /* end */
  679. };
  680. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  681. { 6, alc880_fivestack_ch6_init },
  682. { 8, alc880_fivestack_ch8_init },
  683. };
  684. /*
  685. * ALC880 6-stack model
  686. *
  687. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  688. * Side = 0x05 (0x0f)
  689. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  690. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  691. */
  692. static hda_nid_t alc880_6st_dac_nids[4] = {
  693. /* front, rear, clfe, rear_surr */
  694. 0x02, 0x03, 0x04, 0x05
  695. };
  696. static struct hda_input_mux alc880_6stack_capture_source = {
  697. .num_items = 4,
  698. .items = {
  699. { "Mic", 0x0 },
  700. { "Front Mic", 0x1 },
  701. { "Line", 0x2 },
  702. { "CD", 0x4 },
  703. },
  704. };
  705. /* fixed 8-channels */
  706. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  707. { 8, NULL },
  708. };
  709. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  710. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  711. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  712. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  713. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  714. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  715. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  716. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  717. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  718. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  719. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  728. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  730. {
  731. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  732. .name = "Channel Mode",
  733. .info = alc_ch_mode_info,
  734. .get = alc_ch_mode_get,
  735. .put = alc_ch_mode_put,
  736. },
  737. { } /* end */
  738. };
  739. /*
  740. * ALC880 W810 model
  741. *
  742. * W810 has rear IO for:
  743. * Front (DAC 02)
  744. * Surround (DAC 03)
  745. * Center/LFE (DAC 04)
  746. * Digital out (06)
  747. *
  748. * The system also has a pair of internal speakers, and a headphone jack.
  749. * These are both connected to Line2 on the codec, hence to DAC 02.
  750. *
  751. * There is a variable resistor to control the speaker or headphone
  752. * volume. This is a hardware-only device without a software API.
  753. *
  754. * Plugging headphones in will disable the internal speakers. This is
  755. * implemented in hardware, not via the driver using jack sense. In
  756. * a similar fashion, plugging into the rear socket marked "front" will
  757. * disable both the speakers and headphones.
  758. *
  759. * For input, there's a microphone jack, and an "audio in" jack.
  760. * These may not do anything useful with this driver yet, because I
  761. * haven't setup any initialization verbs for these yet...
  762. */
  763. static hda_nid_t alc880_w810_dac_nids[3] = {
  764. /* front, rear/surround, clfe */
  765. 0x02, 0x03, 0x04
  766. };
  767. /* fixed 6 channels */
  768. static struct hda_channel_mode alc880_w810_modes[1] = {
  769. { 6, NULL }
  770. };
  771. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  772. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  773. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  774. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  775. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  776. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  777. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  778. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  779. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  780. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  781. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  782. { } /* end */
  783. };
  784. /*
  785. * Z710V model
  786. *
  787. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  788. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  789. * Line = 0x1a
  790. */
  791. static hda_nid_t alc880_z71v_dac_nids[1] = {
  792. 0x02
  793. };
  794. #define ALC880_Z71V_HP_DAC 0x03
  795. /* fixed 2 channels */
  796. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  797. { 2, NULL }
  798. };
  799. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  800. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  801. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  802. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  803. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  804. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  805. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  806. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  807. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  808. { } /* end */
  809. };
  810. /* FIXME! */
  811. /*
  812. * ALC880 F1734 model
  813. *
  814. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  815. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  816. */
  817. static hda_nid_t alc880_f1734_dac_nids[1] = {
  818. 0x03
  819. };
  820. #define ALC880_F1734_HP_DAC 0x02
  821. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  822. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  823. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  824. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  825. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  826. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  827. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  828. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  829. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  830. { } /* end */
  831. };
  832. /* FIXME! */
  833. /*
  834. * ALC880 ASUS model
  835. *
  836. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  837. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  838. * Mic = 0x18, Line = 0x1a
  839. */
  840. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  841. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  842. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  843. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  844. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  845. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  846. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  847. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  848. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  849. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  850. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  852. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  853. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  854. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  856. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  857. {
  858. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  859. .name = "Channel Mode",
  860. .info = alc_ch_mode_info,
  861. .get = alc_ch_mode_get,
  862. .put = alc_ch_mode_put,
  863. },
  864. { } /* end */
  865. };
  866. /* FIXME! */
  867. /*
  868. * ALC880 ASUS W1V model
  869. *
  870. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  871. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  872. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  873. */
  874. /* additional mixers to alc880_asus_mixer */
  875. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  876. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  877. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  878. { } /* end */
  879. };
  880. /* additional mixers to alc880_asus_mixer */
  881. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  882. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  883. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  884. { } /* end */
  885. };
  886. /* TCL S700 */
  887. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  888. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  889. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  890. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  891. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  892. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  893. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  894. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  895. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  896. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  897. {
  898. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  899. /* The multiple "Capture Source" controls confuse alsamixer
  900. * So call somewhat different..
  901. * FIXME: the controls appear in the "playback" view!
  902. */
  903. /* .name = "Capture Source", */
  904. .name = "Input Source",
  905. .count = 1,
  906. .info = alc_mux_enum_info,
  907. .get = alc_mux_enum_get,
  908. .put = alc_mux_enum_put,
  909. },
  910. { } /* end */
  911. };
  912. /*
  913. * build control elements
  914. */
  915. static int alc_build_controls(struct hda_codec *codec)
  916. {
  917. struct alc_spec *spec = codec->spec;
  918. int err;
  919. int i;
  920. for (i = 0; i < spec->num_mixers; i++) {
  921. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  922. if (err < 0)
  923. return err;
  924. }
  925. if (spec->multiout.dig_out_nid) {
  926. err = snd_hda_create_spdif_out_ctls(codec,
  927. spec->multiout.dig_out_nid);
  928. if (err < 0)
  929. return err;
  930. }
  931. if (spec->dig_in_nid) {
  932. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  933. if (err < 0)
  934. return err;
  935. }
  936. return 0;
  937. }
  938. /*
  939. * initialize the codec volumes, etc
  940. */
  941. /*
  942. * generic initialization of ADC, input mixers and output mixers
  943. */
  944. static struct hda_verb alc880_volume_init_verbs[] = {
  945. /*
  946. * Unmute ADC0-2 and set the default input to mic-in
  947. */
  948. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  949. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  950. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  951. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  952. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  953. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  954. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  955. * mixer widget
  956. * Note: PASD motherboards uses the Line In 2 as the input for front
  957. * panel mic (mic 2)
  958. */
  959. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  960. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  961. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  965. /*
  966. * Set up output mixers (0x0c - 0x0f)
  967. */
  968. /* set vol=0 to output mixers */
  969. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  970. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  971. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  972. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  973. /* set up input amps for analog loopback */
  974. /* Amp Indices: DAC = 0, mixer = 1 */
  975. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  976. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  977. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  978. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  979. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  980. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  981. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  982. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  983. { }
  984. };
  985. /*
  986. * 3-stack pin configuration:
  987. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  988. */
  989. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  990. /*
  991. * preset connection lists of input pins
  992. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  993. */
  994. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  995. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  996. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  997. /*
  998. * Set pin mode and muting
  999. */
  1000. /* set front pin widgets 0x14 for output */
  1001. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1002. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1003. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1004. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1005. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1006. /* Mic2 (as headphone out) for HP output */
  1007. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1008. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1009. /* Line In pin widget for input */
  1010. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1011. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1012. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1013. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1014. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1015. /* CD pin widget for input */
  1016. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1017. { }
  1018. };
  1019. /*
  1020. * 5-stack pin configuration:
  1021. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1022. * line-in/side = 0x1a, f-mic = 0x1b
  1023. */
  1024. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1025. /*
  1026. * preset connection lists of input pins
  1027. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1028. */
  1029. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1030. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1031. /*
  1032. * Set pin mode and muting
  1033. */
  1034. /* set pin widgets 0x14-0x17 for output */
  1035. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1036. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1037. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1038. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1039. /* unmute pins for output (no gain on this amp) */
  1040. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1041. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1042. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1043. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1044. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1045. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1046. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1047. /* Mic2 (as headphone out) for HP output */
  1048. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1049. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1050. /* Line In pin widget for input */
  1051. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1052. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1053. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1054. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1055. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1056. /* CD pin widget for input */
  1057. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1058. { }
  1059. };
  1060. /*
  1061. * W810 pin configuration:
  1062. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1063. */
  1064. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1065. /* hphone/speaker input selector: front DAC */
  1066. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1067. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1068. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1069. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1070. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1071. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1072. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1073. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1074. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1075. { }
  1076. };
  1077. /*
  1078. * Z71V pin configuration:
  1079. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1080. */
  1081. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1082. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1083. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1084. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1085. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1086. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1087. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1088. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1089. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1090. { }
  1091. };
  1092. /*
  1093. * 6-stack pin configuration:
  1094. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1095. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1096. */
  1097. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1098. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1099. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1100. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1101. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1102. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1103. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1104. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1105. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1106. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1107. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1108. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1109. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1110. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1111. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1112. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1113. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1114. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1115. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1116. { }
  1117. };
  1118. /* FIXME! */
  1119. /*
  1120. * F1734 pin configuration:
  1121. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1122. */
  1123. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1124. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1125. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1126. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1127. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1128. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1129. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1130. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1131. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1132. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1133. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1134. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1135. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1136. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1137. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1138. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1139. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1140. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1141. { }
  1142. };
  1143. /* FIXME! */
  1144. /*
  1145. * ASUS pin configuration:
  1146. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1147. */
  1148. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1149. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1150. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1151. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1152. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1153. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1154. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1155. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1156. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1157. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1158. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1159. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1160. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1161. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1162. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1163. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1164. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1165. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1166. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1167. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1168. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1169. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1170. { }
  1171. };
  1172. /* Enable GPIO mask and set output */
  1173. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1174. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1175. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1176. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1177. { }
  1178. };
  1179. /* Enable GPIO mask and set output */
  1180. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1181. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1182. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1183. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1184. { }
  1185. };
  1186. /* Clevo m520g init */
  1187. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1188. /* headphone output */
  1189. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1190. /* line-out */
  1191. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1192. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. /* Line-in */
  1194. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1195. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1196. /* CD */
  1197. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1198. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1199. /* Mic1 (rear panel) */
  1200. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1201. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1202. /* Mic2 (front panel) */
  1203. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1204. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1205. /* headphone */
  1206. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1207. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1208. /* change to EAPD mode */
  1209. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1210. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1211. { }
  1212. };
  1213. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1214. /* change to EAPD mode */
  1215. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1216. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1217. /* Headphone output */
  1218. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1219. /* Front output*/
  1220. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1222. /* Line In pin widget for input */
  1223. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1224. /* CD pin widget for input */
  1225. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1227. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. /* change to EAPD mode */
  1229. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1230. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1231. { }
  1232. };
  1233. /*
  1234. * LG m1 express dual
  1235. *
  1236. * Pin assignment:
  1237. * Rear Line-In/Out (blue): 0x14
  1238. * Build-in Mic-In: 0x15
  1239. * Speaker-out: 0x17
  1240. * HP-Out (green): 0x1b
  1241. * Mic-In/Out (red): 0x19
  1242. * SPDIF-Out: 0x1e
  1243. */
  1244. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1245. static hda_nid_t alc880_lg_dac_nids[3] = {
  1246. 0x05, 0x02, 0x03
  1247. };
  1248. /* seems analog CD is not working */
  1249. static struct hda_input_mux alc880_lg_capture_source = {
  1250. .num_items = 3,
  1251. .items = {
  1252. { "Mic", 0x1 },
  1253. { "Line", 0x5 },
  1254. { "Internal Mic", 0x6 },
  1255. },
  1256. };
  1257. /* 2,4,6 channel modes */
  1258. static struct hda_verb alc880_lg_ch2_init[] = {
  1259. /* set line-in and mic-in to input */
  1260. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1261. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1262. { }
  1263. };
  1264. static struct hda_verb alc880_lg_ch4_init[] = {
  1265. /* set line-in to out and mic-in to input */
  1266. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1267. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1268. { }
  1269. };
  1270. static struct hda_verb alc880_lg_ch6_init[] = {
  1271. /* set line-in and mic-in to output */
  1272. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1273. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1274. { }
  1275. };
  1276. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1277. { 2, alc880_lg_ch2_init },
  1278. { 4, alc880_lg_ch4_init },
  1279. { 6, alc880_lg_ch6_init },
  1280. };
  1281. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1282. /* FIXME: it's not really "master" but front channels */
  1283. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1284. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1285. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1286. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1287. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1288. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1289. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1290. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1291. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1292. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1293. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1294. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1295. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1296. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1297. {
  1298. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1299. .name = "Channel Mode",
  1300. .info = alc_ch_mode_info,
  1301. .get = alc_ch_mode_get,
  1302. .put = alc_ch_mode_put,
  1303. },
  1304. { } /* end */
  1305. };
  1306. static struct hda_verb alc880_lg_init_verbs[] = {
  1307. /* set capture source to mic-in */
  1308. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1309. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1310. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1311. /* mute all amp mixer inputs */
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1314. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1315. /* line-in to input */
  1316. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1317. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. /* built-in mic */
  1319. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1320. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. /* speaker-out */
  1322. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1323. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1324. /* mic-in to input */
  1325. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1326. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1327. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1328. /* HP-out */
  1329. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1330. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1331. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1332. /* jack sense */
  1333. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1334. { }
  1335. };
  1336. /* toggle speaker-output according to the hp-jack state */
  1337. static void alc880_lg_automute(struct hda_codec *codec)
  1338. {
  1339. unsigned int present;
  1340. present = snd_hda_codec_read(codec, 0x1b, 0,
  1341. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1342. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1343. 0x80, present ? 0x80 : 0);
  1344. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1345. 0x80, present ? 0x80 : 0);
  1346. }
  1347. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1348. {
  1349. /* Looks like the unsol event is incompatible with the standard
  1350. * definition. 4bit tag is placed at 28 bit!
  1351. */
  1352. if ((res >> 28) == 0x01)
  1353. alc880_lg_automute(codec);
  1354. }
  1355. /*
  1356. * LG LW20
  1357. *
  1358. * Pin assignment:
  1359. * Speaker-out: 0x14
  1360. * Mic-In: 0x18
  1361. * Built-in Mic-In: 0x19 (?)
  1362. * HP-Out: 0x1b
  1363. * SPDIF-Out: 0x1e
  1364. */
  1365. /* seems analog CD is not working */
  1366. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1367. .num_items = 2,
  1368. .items = {
  1369. { "Mic", 0x0 },
  1370. { "Internal Mic", 0x1 },
  1371. },
  1372. };
  1373. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1374. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1375. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1376. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1377. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1378. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1379. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1380. { } /* end */
  1381. };
  1382. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1383. /* set capture source to mic-in */
  1384. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1385. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1386. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1387. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1388. /* speaker-out */
  1389. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1390. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1391. /* HP-out */
  1392. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1393. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1394. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1395. /* mic-in to input */
  1396. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1397. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1398. /* built-in mic */
  1399. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1400. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. /* jack sense */
  1402. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1403. { }
  1404. };
  1405. /* toggle speaker-output according to the hp-jack state */
  1406. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1407. {
  1408. unsigned int present;
  1409. present = snd_hda_codec_read(codec, 0x1b, 0,
  1410. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1411. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1412. 0x80, present ? 0x80 : 0);
  1413. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1414. 0x80, present ? 0x80 : 0);
  1415. }
  1416. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1417. {
  1418. /* Looks like the unsol event is incompatible with the standard
  1419. * definition. 4bit tag is placed at 28 bit!
  1420. */
  1421. if ((res >> 28) == 0x01)
  1422. alc880_lg_lw_automute(codec);
  1423. }
  1424. /*
  1425. * Common callbacks
  1426. */
  1427. static int alc_init(struct hda_codec *codec)
  1428. {
  1429. struct alc_spec *spec = codec->spec;
  1430. unsigned int i;
  1431. for (i = 0; i < spec->num_init_verbs; i++)
  1432. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1433. if (spec->init_hook)
  1434. spec->init_hook(codec);
  1435. return 0;
  1436. }
  1437. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1438. {
  1439. struct alc_spec *spec = codec->spec;
  1440. if (spec->unsol_event)
  1441. spec->unsol_event(codec, res);
  1442. }
  1443. #ifdef CONFIG_PM
  1444. /*
  1445. * resume
  1446. */
  1447. static int alc_resume(struct hda_codec *codec)
  1448. {
  1449. struct alc_spec *spec = codec->spec;
  1450. int i;
  1451. alc_init(codec);
  1452. for (i = 0; i < spec->num_mixers; i++)
  1453. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1454. if (spec->multiout.dig_out_nid)
  1455. snd_hda_resume_spdif_out(codec);
  1456. if (spec->dig_in_nid)
  1457. snd_hda_resume_spdif_in(codec);
  1458. return 0;
  1459. }
  1460. #endif
  1461. /*
  1462. * Analog playback callbacks
  1463. */
  1464. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1465. struct hda_codec *codec,
  1466. struct snd_pcm_substream *substream)
  1467. {
  1468. struct alc_spec *spec = codec->spec;
  1469. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1470. }
  1471. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1472. struct hda_codec *codec,
  1473. unsigned int stream_tag,
  1474. unsigned int format,
  1475. struct snd_pcm_substream *substream)
  1476. {
  1477. struct alc_spec *spec = codec->spec;
  1478. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1479. stream_tag, format, substream);
  1480. }
  1481. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1482. struct hda_codec *codec,
  1483. struct snd_pcm_substream *substream)
  1484. {
  1485. struct alc_spec *spec = codec->spec;
  1486. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1487. }
  1488. /*
  1489. * Digital out
  1490. */
  1491. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1492. struct hda_codec *codec,
  1493. struct snd_pcm_substream *substream)
  1494. {
  1495. struct alc_spec *spec = codec->spec;
  1496. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1497. }
  1498. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1499. struct hda_codec *codec,
  1500. struct snd_pcm_substream *substream)
  1501. {
  1502. struct alc_spec *spec = codec->spec;
  1503. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1504. }
  1505. /*
  1506. * Analog capture
  1507. */
  1508. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1509. struct hda_codec *codec,
  1510. unsigned int stream_tag,
  1511. unsigned int format,
  1512. struct snd_pcm_substream *substream)
  1513. {
  1514. struct alc_spec *spec = codec->spec;
  1515. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1516. stream_tag, 0, format);
  1517. return 0;
  1518. }
  1519. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1520. struct hda_codec *codec,
  1521. struct snd_pcm_substream *substream)
  1522. {
  1523. struct alc_spec *spec = codec->spec;
  1524. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1525. 0, 0, 0);
  1526. return 0;
  1527. }
  1528. /*
  1529. */
  1530. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1531. .substreams = 1,
  1532. .channels_min = 2,
  1533. .channels_max = 8,
  1534. /* NID is set in alc_build_pcms */
  1535. .ops = {
  1536. .open = alc880_playback_pcm_open,
  1537. .prepare = alc880_playback_pcm_prepare,
  1538. .cleanup = alc880_playback_pcm_cleanup
  1539. },
  1540. };
  1541. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1542. .substreams = 2,
  1543. .channels_min = 2,
  1544. .channels_max = 2,
  1545. /* NID is set in alc_build_pcms */
  1546. .ops = {
  1547. .prepare = alc880_capture_pcm_prepare,
  1548. .cleanup = alc880_capture_pcm_cleanup
  1549. },
  1550. };
  1551. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1552. .substreams = 1,
  1553. .channels_min = 2,
  1554. .channels_max = 2,
  1555. /* NID is set in alc_build_pcms */
  1556. .ops = {
  1557. .open = alc880_dig_playback_pcm_open,
  1558. .close = alc880_dig_playback_pcm_close
  1559. },
  1560. };
  1561. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1562. .substreams = 1,
  1563. .channels_min = 2,
  1564. .channels_max = 2,
  1565. /* NID is set in alc_build_pcms */
  1566. };
  1567. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1568. static struct hda_pcm_stream alc_pcm_null_playback = {
  1569. .substreams = 0,
  1570. .channels_min = 0,
  1571. .channels_max = 0,
  1572. };
  1573. static int alc_build_pcms(struct hda_codec *codec)
  1574. {
  1575. struct alc_spec *spec = codec->spec;
  1576. struct hda_pcm *info = spec->pcm_rec;
  1577. int i;
  1578. codec->num_pcms = 1;
  1579. codec->pcm_info = info;
  1580. info->name = spec->stream_name_analog;
  1581. if (spec->stream_analog_playback) {
  1582. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1583. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1584. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1585. }
  1586. if (spec->stream_analog_capture) {
  1587. snd_assert(spec->adc_nids, return -EINVAL);
  1588. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1589. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1590. }
  1591. if (spec->channel_mode) {
  1592. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1593. for (i = 0; i < spec->num_channel_mode; i++) {
  1594. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1595. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1596. }
  1597. }
  1598. }
  1599. /* SPDIF for stream index #1 */
  1600. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1601. codec->num_pcms = 2;
  1602. info = spec->pcm_rec + 1;
  1603. info->name = spec->stream_name_digital;
  1604. if (spec->multiout.dig_out_nid &&
  1605. spec->stream_digital_playback) {
  1606. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1607. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1608. }
  1609. if (spec->dig_in_nid &&
  1610. spec->stream_digital_capture) {
  1611. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1612. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1613. }
  1614. }
  1615. /* If the use of more than one ADC is requested for the current
  1616. * model, configure a second analog capture-only PCM.
  1617. */
  1618. /* Additional Analaog capture for index #2 */
  1619. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1620. spec->adc_nids) {
  1621. codec->num_pcms = 3;
  1622. info = spec->pcm_rec + 2;
  1623. info->name = spec->stream_name_analog;
  1624. /* No playback stream for second PCM */
  1625. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1626. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1627. if (spec->stream_analog_capture) {
  1628. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1629. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1630. }
  1631. }
  1632. return 0;
  1633. }
  1634. static void alc_free(struct hda_codec *codec)
  1635. {
  1636. struct alc_spec *spec = codec->spec;
  1637. unsigned int i;
  1638. if (! spec)
  1639. return;
  1640. if (spec->kctl_alloc) {
  1641. for (i = 0; i < spec->num_kctl_used; i++)
  1642. kfree(spec->kctl_alloc[i].name);
  1643. kfree(spec->kctl_alloc);
  1644. }
  1645. kfree(spec);
  1646. }
  1647. /*
  1648. */
  1649. static struct hda_codec_ops alc_patch_ops = {
  1650. .build_controls = alc_build_controls,
  1651. .build_pcms = alc_build_pcms,
  1652. .init = alc_init,
  1653. .free = alc_free,
  1654. .unsol_event = alc_unsol_event,
  1655. #ifdef CONFIG_PM
  1656. .resume = alc_resume,
  1657. #endif
  1658. };
  1659. /*
  1660. * Test configuration for debugging
  1661. *
  1662. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1663. * enum controls.
  1664. */
  1665. #ifdef CONFIG_SND_DEBUG
  1666. static hda_nid_t alc880_test_dac_nids[4] = {
  1667. 0x02, 0x03, 0x04, 0x05
  1668. };
  1669. static struct hda_input_mux alc880_test_capture_source = {
  1670. .num_items = 7,
  1671. .items = {
  1672. { "In-1", 0x0 },
  1673. { "In-2", 0x1 },
  1674. { "In-3", 0x2 },
  1675. { "In-4", 0x3 },
  1676. { "CD", 0x4 },
  1677. { "Front", 0x5 },
  1678. { "Surround", 0x6 },
  1679. },
  1680. };
  1681. static struct hda_channel_mode alc880_test_modes[4] = {
  1682. { 2, NULL },
  1683. { 4, NULL },
  1684. { 6, NULL },
  1685. { 8, NULL },
  1686. };
  1687. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1688. struct snd_ctl_elem_info *uinfo)
  1689. {
  1690. static char *texts[] = {
  1691. "N/A", "Line Out", "HP Out",
  1692. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1693. };
  1694. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1695. uinfo->count = 1;
  1696. uinfo->value.enumerated.items = 8;
  1697. if (uinfo->value.enumerated.item >= 8)
  1698. uinfo->value.enumerated.item = 7;
  1699. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1700. return 0;
  1701. }
  1702. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1703. struct snd_ctl_elem_value *ucontrol)
  1704. {
  1705. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1706. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1707. unsigned int pin_ctl, item = 0;
  1708. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1709. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1710. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1711. if (pin_ctl & AC_PINCTL_HP_EN)
  1712. item = 2;
  1713. else
  1714. item = 1;
  1715. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1716. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1717. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1718. case AC_PINCTL_VREF_50: item = 4; break;
  1719. case AC_PINCTL_VREF_GRD: item = 5; break;
  1720. case AC_PINCTL_VREF_80: item = 6; break;
  1721. case AC_PINCTL_VREF_100: item = 7; break;
  1722. }
  1723. }
  1724. ucontrol->value.enumerated.item[0] = item;
  1725. return 0;
  1726. }
  1727. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1728. struct snd_ctl_elem_value *ucontrol)
  1729. {
  1730. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1731. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1732. static unsigned int ctls[] = {
  1733. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1734. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1735. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1736. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1737. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1738. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1739. };
  1740. unsigned int old_ctl, new_ctl;
  1741. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1742. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1743. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1744. if (old_ctl != new_ctl) {
  1745. snd_hda_codec_write(codec, nid, 0,
  1746. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1747. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1748. (ucontrol->value.enumerated.item[0] >= 3 ?
  1749. 0xb080 : 0xb000));
  1750. return 1;
  1751. }
  1752. return 0;
  1753. }
  1754. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1755. struct snd_ctl_elem_info *uinfo)
  1756. {
  1757. static char *texts[] = {
  1758. "Front", "Surround", "CLFE", "Side"
  1759. };
  1760. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1761. uinfo->count = 1;
  1762. uinfo->value.enumerated.items = 4;
  1763. if (uinfo->value.enumerated.item >= 4)
  1764. uinfo->value.enumerated.item = 3;
  1765. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1766. return 0;
  1767. }
  1768. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1769. struct snd_ctl_elem_value *ucontrol)
  1770. {
  1771. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1772. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1773. unsigned int sel;
  1774. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1775. ucontrol->value.enumerated.item[0] = sel & 3;
  1776. return 0;
  1777. }
  1778. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1779. struct snd_ctl_elem_value *ucontrol)
  1780. {
  1781. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1782. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1783. unsigned int sel;
  1784. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1785. if (ucontrol->value.enumerated.item[0] != sel) {
  1786. sel = ucontrol->value.enumerated.item[0] & 3;
  1787. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1788. return 1;
  1789. }
  1790. return 0;
  1791. }
  1792. #define PIN_CTL_TEST(xname,nid) { \
  1793. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1794. .name = xname, \
  1795. .info = alc_test_pin_ctl_info, \
  1796. .get = alc_test_pin_ctl_get, \
  1797. .put = alc_test_pin_ctl_put, \
  1798. .private_value = nid \
  1799. }
  1800. #define PIN_SRC_TEST(xname,nid) { \
  1801. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1802. .name = xname, \
  1803. .info = alc_test_pin_src_info, \
  1804. .get = alc_test_pin_src_get, \
  1805. .put = alc_test_pin_src_put, \
  1806. .private_value = nid \
  1807. }
  1808. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1809. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1810. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1811. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1812. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1813. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1814. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1815. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1816. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1817. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1818. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1819. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1820. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1821. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1822. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1823. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1824. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1825. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1826. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1827. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1828. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1829. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1830. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1831. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1832. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1833. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1834. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1835. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1836. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1837. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1838. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1839. {
  1840. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1841. .name = "Channel Mode",
  1842. .info = alc_ch_mode_info,
  1843. .get = alc_ch_mode_get,
  1844. .put = alc_ch_mode_put,
  1845. },
  1846. { } /* end */
  1847. };
  1848. static struct hda_verb alc880_test_init_verbs[] = {
  1849. /* Unmute inputs of 0x0c - 0x0f */
  1850. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1851. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1852. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1853. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1854. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1855. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1856. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1857. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1858. /* Vol output for 0x0c-0x0f */
  1859. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1860. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1861. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1862. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1863. /* Set output pins 0x14-0x17 */
  1864. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1865. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1866. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1867. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1868. /* Unmute output pins 0x14-0x17 */
  1869. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1870. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1871. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1872. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1873. /* Set input pins 0x18-0x1c */
  1874. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1875. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1876. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1877. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1878. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1879. /* Mute input pins 0x18-0x1b */
  1880. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1881. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1882. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1883. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1884. /* ADC set up */
  1885. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1886. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1887. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1888. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1889. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1890. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1891. /* Analog input/passthru */
  1892. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1893. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1894. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1895. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1896. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1897. { }
  1898. };
  1899. #endif
  1900. /*
  1901. */
  1902. static struct hda_board_config alc880_cfg_tbl[] = {
  1903. /* Back 3 jack, front 2 jack */
  1904. { .modelname = "3stack", .config = ALC880_3ST },
  1905. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1906. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1907. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1908. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1909. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1910. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1911. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1912. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1913. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1914. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1915. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1916. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1917. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1918. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1919. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1920. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1921. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1922. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1923. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
  1924. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
  1925. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1926. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
  1927. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1928. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1929. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1930. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1931. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1932. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1933. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1934. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1935. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1936. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1937. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1938. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1939. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1940. /* TCL S700 */
  1941. { .modelname = "tcl", .config = ALC880_TCL_S700 },
  1942. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1943. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1944. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1945. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1946. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1947. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1948. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1949. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1950. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1951. /* Clevo laptops */
  1952. { .modelname = "clevo", .config = ALC880_CLEVO },
  1953. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
  1954. .config = ALC880_CLEVO }, /* Clevo m520G NB */
  1955. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
  1956. .config = ALC880_CLEVO }, /* Clevo m665n */
  1957. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1958. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1959. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1960. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1961. /* Back 5 jack, front 2 jack */
  1962. { .modelname = "5stack", .config = ALC880_5ST },
  1963. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1964. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1965. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1966. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1967. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1968. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1969. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1970. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1971. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1972. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1973. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1974. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1975. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1976. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1977. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1978. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1979. { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
  1980. .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
  1981. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1982. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1983. /* note subvendor = 0 below */
  1984. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1985. { .modelname = "w810", .config = ALC880_W810 },
  1986. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1987. { .modelname = "z71v", .config = ALC880_Z71V },
  1988. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1989. { .modelname = "6stack", .config = ALC880_6ST },
  1990. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1991. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1992. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1993. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1994. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1995. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1996. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1997. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1998. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1999. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  2000. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  2001. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  2002. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  2003. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  2004. { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
  2005. { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
  2006. { .modelname = "asus", .config = ALC880_ASUS },
  2007. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  2008. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  2009. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  2010. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  2011. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  2012. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  2013. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
  2014. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  2015. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  2016. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  2017. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  2018. { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
  2019. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  2020. { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
  2021. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
  2022. { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
  2023. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  2024. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  2025. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  2026. { .modelname = "F1734", .config = ALC880_F1734 },
  2027. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  2028. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  2029. { .modelname = "lg", .config = ALC880_LG },
  2030. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  2031. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
  2032. { .modelname = "lg-lw", .config = ALC880_LG_LW },
  2033. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
  2034. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
  2035. #ifdef CONFIG_SND_DEBUG
  2036. { .modelname = "test", .config = ALC880_TEST },
  2037. #endif
  2038. { .modelname = "auto", .config = ALC880_AUTO },
  2039. {}
  2040. };
  2041. /*
  2042. * ALC880 codec presets
  2043. */
  2044. static struct alc_config_preset alc880_presets[] = {
  2045. [ALC880_3ST] = {
  2046. .mixers = { alc880_three_stack_mixer },
  2047. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2048. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2049. .dac_nids = alc880_dac_nids,
  2050. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2051. .channel_mode = alc880_threestack_modes,
  2052. .need_dac_fix = 1,
  2053. .input_mux = &alc880_capture_source,
  2054. },
  2055. [ALC880_3ST_DIG] = {
  2056. .mixers = { alc880_three_stack_mixer },
  2057. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2058. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2059. .dac_nids = alc880_dac_nids,
  2060. .dig_out_nid = ALC880_DIGOUT_NID,
  2061. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2062. .channel_mode = alc880_threestack_modes,
  2063. .need_dac_fix = 1,
  2064. .input_mux = &alc880_capture_source,
  2065. },
  2066. [ALC880_TCL_S700] = {
  2067. .mixers = { alc880_tcl_s700_mixer },
  2068. .init_verbs = { alc880_volume_init_verbs,
  2069. alc880_pin_tcl_S700_init_verbs,
  2070. alc880_gpio2_init_verbs },
  2071. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2072. .dac_nids = alc880_dac_nids,
  2073. .hp_nid = 0x03,
  2074. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2075. .channel_mode = alc880_2_jack_modes,
  2076. .input_mux = &alc880_capture_source,
  2077. },
  2078. [ALC880_5ST] = {
  2079. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2080. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2081. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2082. .dac_nids = alc880_dac_nids,
  2083. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2084. .channel_mode = alc880_fivestack_modes,
  2085. .input_mux = &alc880_capture_source,
  2086. },
  2087. [ALC880_5ST_DIG] = {
  2088. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2089. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2090. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2091. .dac_nids = alc880_dac_nids,
  2092. .dig_out_nid = ALC880_DIGOUT_NID,
  2093. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2094. .channel_mode = alc880_fivestack_modes,
  2095. .input_mux = &alc880_capture_source,
  2096. },
  2097. [ALC880_6ST] = {
  2098. .mixers = { alc880_six_stack_mixer },
  2099. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2100. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2101. .dac_nids = alc880_6st_dac_nids,
  2102. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2103. .channel_mode = alc880_sixstack_modes,
  2104. .input_mux = &alc880_6stack_capture_source,
  2105. },
  2106. [ALC880_6ST_DIG] = {
  2107. .mixers = { alc880_six_stack_mixer },
  2108. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2109. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2110. .dac_nids = alc880_6st_dac_nids,
  2111. .dig_out_nid = ALC880_DIGOUT_NID,
  2112. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2113. .channel_mode = alc880_sixstack_modes,
  2114. .input_mux = &alc880_6stack_capture_source,
  2115. },
  2116. [ALC880_W810] = {
  2117. .mixers = { alc880_w810_base_mixer },
  2118. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2119. alc880_gpio2_init_verbs },
  2120. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2121. .dac_nids = alc880_w810_dac_nids,
  2122. .dig_out_nid = ALC880_DIGOUT_NID,
  2123. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2124. .channel_mode = alc880_w810_modes,
  2125. .input_mux = &alc880_capture_source,
  2126. },
  2127. [ALC880_Z71V] = {
  2128. .mixers = { alc880_z71v_mixer },
  2129. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2130. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2131. .dac_nids = alc880_z71v_dac_nids,
  2132. .dig_out_nid = ALC880_DIGOUT_NID,
  2133. .hp_nid = 0x03,
  2134. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2135. .channel_mode = alc880_2_jack_modes,
  2136. .input_mux = &alc880_capture_source,
  2137. },
  2138. [ALC880_F1734] = {
  2139. .mixers = { alc880_f1734_mixer },
  2140. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2141. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2142. .dac_nids = alc880_f1734_dac_nids,
  2143. .hp_nid = 0x02,
  2144. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2145. .channel_mode = alc880_2_jack_modes,
  2146. .input_mux = &alc880_capture_source,
  2147. },
  2148. [ALC880_ASUS] = {
  2149. .mixers = { alc880_asus_mixer },
  2150. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2151. alc880_gpio1_init_verbs },
  2152. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2153. .dac_nids = alc880_asus_dac_nids,
  2154. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2155. .channel_mode = alc880_asus_modes,
  2156. .need_dac_fix = 1,
  2157. .input_mux = &alc880_capture_source,
  2158. },
  2159. [ALC880_ASUS_DIG] = {
  2160. .mixers = { alc880_asus_mixer },
  2161. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2162. alc880_gpio1_init_verbs },
  2163. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2164. .dac_nids = alc880_asus_dac_nids,
  2165. .dig_out_nid = ALC880_DIGOUT_NID,
  2166. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2167. .channel_mode = alc880_asus_modes,
  2168. .need_dac_fix = 1,
  2169. .input_mux = &alc880_capture_source,
  2170. },
  2171. [ALC880_ASUS_DIG2] = {
  2172. .mixers = { alc880_asus_mixer },
  2173. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2174. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2175. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2176. .dac_nids = alc880_asus_dac_nids,
  2177. .dig_out_nid = ALC880_DIGOUT_NID,
  2178. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2179. .channel_mode = alc880_asus_modes,
  2180. .need_dac_fix = 1,
  2181. .input_mux = &alc880_capture_source,
  2182. },
  2183. [ALC880_ASUS_W1V] = {
  2184. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2185. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2186. alc880_gpio1_init_verbs },
  2187. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2188. .dac_nids = alc880_asus_dac_nids,
  2189. .dig_out_nid = ALC880_DIGOUT_NID,
  2190. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2191. .channel_mode = alc880_asus_modes,
  2192. .need_dac_fix = 1,
  2193. .input_mux = &alc880_capture_source,
  2194. },
  2195. [ALC880_UNIWILL_DIG] = {
  2196. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2197. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2198. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2199. .dac_nids = alc880_asus_dac_nids,
  2200. .dig_out_nid = ALC880_DIGOUT_NID,
  2201. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2202. .channel_mode = alc880_asus_modes,
  2203. .need_dac_fix = 1,
  2204. .input_mux = &alc880_capture_source,
  2205. },
  2206. [ALC880_CLEVO] = {
  2207. .mixers = { alc880_three_stack_mixer },
  2208. .init_verbs = { alc880_volume_init_verbs,
  2209. alc880_pin_clevo_init_verbs },
  2210. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2211. .dac_nids = alc880_dac_nids,
  2212. .hp_nid = 0x03,
  2213. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2214. .channel_mode = alc880_threestack_modes,
  2215. .need_dac_fix = 1,
  2216. .input_mux = &alc880_capture_source,
  2217. },
  2218. [ALC880_LG] = {
  2219. .mixers = { alc880_lg_mixer },
  2220. .init_verbs = { alc880_volume_init_verbs,
  2221. alc880_lg_init_verbs },
  2222. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2223. .dac_nids = alc880_lg_dac_nids,
  2224. .dig_out_nid = ALC880_DIGOUT_NID,
  2225. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2226. .channel_mode = alc880_lg_ch_modes,
  2227. .need_dac_fix = 1,
  2228. .input_mux = &alc880_lg_capture_source,
  2229. .unsol_event = alc880_lg_unsol_event,
  2230. .init_hook = alc880_lg_automute,
  2231. },
  2232. [ALC880_LG_LW] = {
  2233. .mixers = { alc880_lg_lw_mixer },
  2234. .init_verbs = { alc880_volume_init_verbs,
  2235. alc880_lg_lw_init_verbs },
  2236. .num_dacs = 1,
  2237. .dac_nids = alc880_dac_nids,
  2238. .dig_out_nid = ALC880_DIGOUT_NID,
  2239. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2240. .channel_mode = alc880_2_jack_modes,
  2241. .input_mux = &alc880_lg_lw_capture_source,
  2242. .unsol_event = alc880_lg_lw_unsol_event,
  2243. .init_hook = alc880_lg_lw_automute,
  2244. },
  2245. #ifdef CONFIG_SND_DEBUG
  2246. [ALC880_TEST] = {
  2247. .mixers = { alc880_test_mixer },
  2248. .init_verbs = { alc880_test_init_verbs },
  2249. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2250. .dac_nids = alc880_test_dac_nids,
  2251. .dig_out_nid = ALC880_DIGOUT_NID,
  2252. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2253. .channel_mode = alc880_test_modes,
  2254. .input_mux = &alc880_test_capture_source,
  2255. },
  2256. #endif
  2257. };
  2258. /*
  2259. * Automatic parse of I/O pins from the BIOS configuration
  2260. */
  2261. #define NUM_CONTROL_ALLOC 32
  2262. #define NUM_VERB_ALLOC 32
  2263. enum {
  2264. ALC_CTL_WIDGET_VOL,
  2265. ALC_CTL_WIDGET_MUTE,
  2266. ALC_CTL_BIND_MUTE,
  2267. };
  2268. static struct snd_kcontrol_new alc880_control_templates[] = {
  2269. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2270. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2271. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2272. };
  2273. /* add dynamic controls */
  2274. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2275. {
  2276. struct snd_kcontrol_new *knew;
  2277. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2278. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2279. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2280. if (! knew)
  2281. return -ENOMEM;
  2282. if (spec->kctl_alloc) {
  2283. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2284. kfree(spec->kctl_alloc);
  2285. }
  2286. spec->kctl_alloc = knew;
  2287. spec->num_kctl_alloc = num;
  2288. }
  2289. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2290. *knew = alc880_control_templates[type];
  2291. knew->name = kstrdup(name, GFP_KERNEL);
  2292. if (! knew->name)
  2293. return -ENOMEM;
  2294. knew->private_value = val;
  2295. spec->num_kctl_used++;
  2296. return 0;
  2297. }
  2298. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2299. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2300. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2301. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2302. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2303. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2304. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2305. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2306. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2307. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2308. #define ALC880_PIN_CD_NID 0x1c
  2309. /* fill in the dac_nids table from the parsed pin configuration */
  2310. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2311. {
  2312. hda_nid_t nid;
  2313. int assigned[4];
  2314. int i, j;
  2315. memset(assigned, 0, sizeof(assigned));
  2316. spec->multiout.dac_nids = spec->private_dac_nids;
  2317. /* check the pins hardwired to audio widget */
  2318. for (i = 0; i < cfg->line_outs; i++) {
  2319. nid = cfg->line_out_pins[i];
  2320. if (alc880_is_fixed_pin(nid)) {
  2321. int idx = alc880_fixed_pin_idx(nid);
  2322. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2323. assigned[idx] = 1;
  2324. }
  2325. }
  2326. /* left pins can be connect to any audio widget */
  2327. for (i = 0; i < cfg->line_outs; i++) {
  2328. nid = cfg->line_out_pins[i];
  2329. if (alc880_is_fixed_pin(nid))
  2330. continue;
  2331. /* search for an empty channel */
  2332. for (j = 0; j < cfg->line_outs; j++) {
  2333. if (! assigned[j]) {
  2334. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2335. assigned[j] = 1;
  2336. break;
  2337. }
  2338. }
  2339. }
  2340. spec->multiout.num_dacs = cfg->line_outs;
  2341. return 0;
  2342. }
  2343. /* add playback controls from the parsed DAC table */
  2344. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2345. const struct auto_pin_cfg *cfg)
  2346. {
  2347. char name[32];
  2348. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2349. hda_nid_t nid;
  2350. int i, err;
  2351. for (i = 0; i < cfg->line_outs; i++) {
  2352. if (! spec->multiout.dac_nids[i])
  2353. continue;
  2354. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2355. if (i == 2) {
  2356. /* Center/LFE */
  2357. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2358. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2359. return err;
  2360. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2361. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2362. return err;
  2363. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2364. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2365. return err;
  2366. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2367. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2368. return err;
  2369. } else {
  2370. sprintf(name, "%s Playback Volume", chname[i]);
  2371. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2372. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2373. return err;
  2374. sprintf(name, "%s Playback Switch", chname[i]);
  2375. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2376. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2377. return err;
  2378. }
  2379. }
  2380. return 0;
  2381. }
  2382. /* add playback controls for speaker and HP outputs */
  2383. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2384. const char *pfx)
  2385. {
  2386. hda_nid_t nid;
  2387. int err;
  2388. char name[32];
  2389. if (! pin)
  2390. return 0;
  2391. if (alc880_is_fixed_pin(pin)) {
  2392. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2393. /* specify the DAC as the extra output */
  2394. if (! spec->multiout.hp_nid)
  2395. spec->multiout.hp_nid = nid;
  2396. else
  2397. spec->multiout.extra_out_nid[0] = nid;
  2398. /* control HP volume/switch on the output mixer amp */
  2399. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2400. sprintf(name, "%s Playback Volume", pfx);
  2401. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2402. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2403. return err;
  2404. sprintf(name, "%s Playback Switch", pfx);
  2405. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2406. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2407. return err;
  2408. } else if (alc880_is_multi_pin(pin)) {
  2409. /* set manual connection */
  2410. /* we have only a switch on HP-out PIN */
  2411. sprintf(name, "%s Playback Switch", pfx);
  2412. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2413. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2414. return err;
  2415. }
  2416. return 0;
  2417. }
  2418. /* create input playback/capture controls for the given pin */
  2419. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2420. int idx, hda_nid_t mix_nid)
  2421. {
  2422. char name[32];
  2423. int err;
  2424. sprintf(name, "%s Playback Volume", ctlname);
  2425. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2426. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2427. return err;
  2428. sprintf(name, "%s Playback Switch", ctlname);
  2429. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2430. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2431. return err;
  2432. return 0;
  2433. }
  2434. /* create playback/capture controls for input pins */
  2435. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2436. const struct auto_pin_cfg *cfg)
  2437. {
  2438. struct hda_input_mux *imux = &spec->private_imux;
  2439. int i, err, idx;
  2440. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2441. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2442. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2443. err = new_analog_input(spec, cfg->input_pins[i],
  2444. auto_pin_cfg_labels[i],
  2445. idx, 0x0b);
  2446. if (err < 0)
  2447. return err;
  2448. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2449. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2450. imux->num_items++;
  2451. }
  2452. }
  2453. return 0;
  2454. }
  2455. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2456. hda_nid_t nid, int pin_type,
  2457. int dac_idx)
  2458. {
  2459. /* set as output */
  2460. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2461. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2462. /* need the manual connection? */
  2463. if (alc880_is_multi_pin(nid)) {
  2464. struct alc_spec *spec = codec->spec;
  2465. int idx = alc880_multi_pin_idx(nid);
  2466. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2467. AC_VERB_SET_CONNECT_SEL,
  2468. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2469. }
  2470. }
  2471. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2472. {
  2473. struct alc_spec *spec = codec->spec;
  2474. int i;
  2475. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2476. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2477. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2478. }
  2479. }
  2480. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2481. {
  2482. struct alc_spec *spec = codec->spec;
  2483. hda_nid_t pin;
  2484. pin = spec->autocfg.speaker_pins[0];
  2485. if (pin) /* connect to front */
  2486. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2487. pin = spec->autocfg.hp_pins[0];
  2488. if (pin) /* connect to front */
  2489. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2490. }
  2491. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2492. {
  2493. struct alc_spec *spec = codec->spec;
  2494. int i;
  2495. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2496. hda_nid_t nid = spec->autocfg.input_pins[i];
  2497. if (alc880_is_input_pin(nid)) {
  2498. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2499. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2500. if (nid != ALC880_PIN_CD_NID)
  2501. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2502. AMP_OUT_MUTE);
  2503. }
  2504. }
  2505. }
  2506. /* parse the BIOS configuration and set up the alc_spec */
  2507. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2508. static int alc880_parse_auto_config(struct hda_codec *codec)
  2509. {
  2510. struct alc_spec *spec = codec->spec;
  2511. int err;
  2512. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2513. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2514. alc880_ignore)) < 0)
  2515. return err;
  2516. if (! spec->autocfg.line_outs)
  2517. return 0; /* can't find valid BIOS pin config */
  2518. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2519. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2520. (err = alc880_auto_create_extra_out(spec,
  2521. spec->autocfg.speaker_pins[0],
  2522. "Speaker")) < 0 ||
  2523. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2524. "Headphone")) < 0 ||
  2525. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2526. return err;
  2527. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2528. if (spec->autocfg.dig_out_pin)
  2529. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2530. if (spec->autocfg.dig_in_pin)
  2531. spec->dig_in_nid = ALC880_DIGIN_NID;
  2532. if (spec->kctl_alloc)
  2533. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2534. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2535. spec->num_mux_defs = 1;
  2536. spec->input_mux = &spec->private_imux;
  2537. return 1;
  2538. }
  2539. /* additional initialization for auto-configuration model */
  2540. static void alc880_auto_init(struct hda_codec *codec)
  2541. {
  2542. alc880_auto_init_multi_out(codec);
  2543. alc880_auto_init_extra_out(codec);
  2544. alc880_auto_init_analog_input(codec);
  2545. }
  2546. /*
  2547. * OK, here we have finally the patch for ALC880
  2548. */
  2549. static int patch_alc880(struct hda_codec *codec)
  2550. {
  2551. struct alc_spec *spec;
  2552. int board_config;
  2553. int err;
  2554. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2555. if (spec == NULL)
  2556. return -ENOMEM;
  2557. codec->spec = spec;
  2558. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2559. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2560. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2561. "trying auto-probe from BIOS...\n");
  2562. board_config = ALC880_AUTO;
  2563. }
  2564. if (board_config == ALC880_AUTO) {
  2565. /* automatic parse from the BIOS config */
  2566. err = alc880_parse_auto_config(codec);
  2567. if (err < 0) {
  2568. alc_free(codec);
  2569. return err;
  2570. } else if (! err) {
  2571. printk(KERN_INFO
  2572. "hda_codec: Cannot set up configuration "
  2573. "from BIOS. Using 3-stack mode...\n");
  2574. board_config = ALC880_3ST;
  2575. }
  2576. }
  2577. if (board_config != ALC880_AUTO)
  2578. setup_preset(spec, &alc880_presets[board_config]);
  2579. spec->stream_name_analog = "ALC880 Analog";
  2580. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2581. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2582. spec->stream_name_digital = "ALC880 Digital";
  2583. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2584. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2585. if (! spec->adc_nids && spec->input_mux) {
  2586. /* check whether NID 0x07 is valid */
  2587. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2588. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2589. if (wcap != AC_WID_AUD_IN) {
  2590. spec->adc_nids = alc880_adc_nids_alt;
  2591. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2592. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2593. spec->num_mixers++;
  2594. } else {
  2595. spec->adc_nids = alc880_adc_nids;
  2596. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2597. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2598. spec->num_mixers++;
  2599. }
  2600. }
  2601. codec->patch_ops = alc_patch_ops;
  2602. if (board_config == ALC880_AUTO)
  2603. spec->init_hook = alc880_auto_init;
  2604. return 0;
  2605. }
  2606. /*
  2607. * ALC260 support
  2608. */
  2609. static hda_nid_t alc260_dac_nids[1] = {
  2610. /* front */
  2611. 0x02,
  2612. };
  2613. static hda_nid_t alc260_adc_nids[1] = {
  2614. /* ADC0 */
  2615. 0x04,
  2616. };
  2617. static hda_nid_t alc260_adc_nids_alt[1] = {
  2618. /* ADC1 */
  2619. 0x05,
  2620. };
  2621. static hda_nid_t alc260_hp_adc_nids[2] = {
  2622. /* ADC1, 0 */
  2623. 0x05, 0x04
  2624. };
  2625. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2626. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2627. */
  2628. static hda_nid_t alc260_dual_adc_nids[2] = {
  2629. /* ADC0, ADC1 */
  2630. 0x04, 0x05
  2631. };
  2632. #define ALC260_DIGOUT_NID 0x03
  2633. #define ALC260_DIGIN_NID 0x06
  2634. static struct hda_input_mux alc260_capture_source = {
  2635. .num_items = 4,
  2636. .items = {
  2637. { "Mic", 0x0 },
  2638. { "Front Mic", 0x1 },
  2639. { "Line", 0x2 },
  2640. { "CD", 0x4 },
  2641. },
  2642. };
  2643. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2644. * headphone jack and the internal CD lines since these are the only pins at
  2645. * which audio can appear. For flexibility, also allow the option of
  2646. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2647. * connection to the mixer output).
  2648. */
  2649. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2650. {
  2651. .num_items = 3,
  2652. .items = {
  2653. { "Mic/Line", 0x0 },
  2654. { "CD", 0x4 },
  2655. { "Headphone", 0x2 },
  2656. },
  2657. },
  2658. {
  2659. .num_items = 4,
  2660. .items = {
  2661. { "Mic/Line", 0x0 },
  2662. { "CD", 0x4 },
  2663. { "Headphone", 0x2 },
  2664. { "Mixer", 0x5 },
  2665. },
  2666. },
  2667. };
  2668. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2669. * the Fujitsu S702x, but jacks are marked differently.
  2670. */
  2671. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2672. {
  2673. .num_items = 4,
  2674. .items = {
  2675. { "Mic", 0x0 },
  2676. { "Line", 0x2 },
  2677. { "CD", 0x4 },
  2678. { "Headphone", 0x5 },
  2679. },
  2680. },
  2681. {
  2682. .num_items = 5,
  2683. .items = {
  2684. { "Mic", 0x0 },
  2685. { "Line", 0x2 },
  2686. { "CD", 0x4 },
  2687. { "Headphone", 0x6 },
  2688. { "Mixer", 0x5 },
  2689. },
  2690. },
  2691. };
  2692. /*
  2693. * This is just place-holder, so there's something for alc_build_pcms to look
  2694. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2695. * element which allows changing the channel mode, so the verb list is
  2696. * never used.
  2697. */
  2698. static struct hda_channel_mode alc260_modes[1] = {
  2699. { 2, NULL },
  2700. };
  2701. /* Mixer combinations
  2702. *
  2703. * basic: base_output + input + pc_beep + capture
  2704. * HP: base_output + input + capture_alt
  2705. * HP_3013: hp_3013 + input + capture
  2706. * fujitsu: fujitsu + capture
  2707. * acer: acer + capture
  2708. */
  2709. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2710. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2711. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2712. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2713. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2714. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2715. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2716. { } /* end */
  2717. };
  2718. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2719. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2720. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2721. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2722. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2724. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2725. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2727. { } /* end */
  2728. };
  2729. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2730. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2731. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2732. { } /* end */
  2733. };
  2734. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2735. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2736. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2737. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2738. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2739. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2740. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2741. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2742. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2743. { } /* end */
  2744. };
  2745. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2746. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2747. */
  2748. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2749. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2750. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2751. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2752. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2753. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2754. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2755. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2756. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2757. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2758. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2759. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2760. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2761. { } /* end */
  2762. };
  2763. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2764. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2765. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2766. * datasheet doesn't mention this restriction. At this stage it's not clear
  2767. * whether this behaviour is intentional or is a hardware bug in chip
  2768. * revisions available in early 2006. Therefore for now allow the
  2769. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2770. * that the lack of mic bias for this NID is intentional we could change the
  2771. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2772. *
  2773. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2774. * don't appear to make the mic bias available from the "line" jack, even
  2775. * though the NID used for this jack (0x14) can supply it. The theory is
  2776. * that perhaps Acer have included blocking capacitors between the ALC260
  2777. * and the output jack. If this turns out to be the case for all such
  2778. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2779. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2780. */
  2781. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2782. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2783. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2784. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2785. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2786. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2787. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2788. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2789. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2790. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2791. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2792. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2793. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2794. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2795. { } /* end */
  2796. };
  2797. /* capture mixer elements */
  2798. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2799. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2800. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2801. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2802. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2803. {
  2804. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2805. /* The multiple "Capture Source" controls confuse alsamixer
  2806. * So call somewhat different..
  2807. * FIXME: the controls appear in the "playback" view!
  2808. */
  2809. /* .name = "Capture Source", */
  2810. .name = "Input Source",
  2811. .count = 2,
  2812. .info = alc_mux_enum_info,
  2813. .get = alc_mux_enum_get,
  2814. .put = alc_mux_enum_put,
  2815. },
  2816. { } /* end */
  2817. };
  2818. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2819. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2820. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2821. {
  2822. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2823. /* The multiple "Capture Source" controls confuse alsamixer
  2824. * So call somewhat different..
  2825. * FIXME: the controls appear in the "playback" view!
  2826. */
  2827. /* .name = "Capture Source", */
  2828. .name = "Input Source",
  2829. .count = 1,
  2830. .info = alc_mux_enum_info,
  2831. .get = alc_mux_enum_get,
  2832. .put = alc_mux_enum_put,
  2833. },
  2834. { } /* end */
  2835. };
  2836. /*
  2837. * initialization verbs
  2838. */
  2839. static struct hda_verb alc260_init_verbs[] = {
  2840. /* Line In pin widget for input */
  2841. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2842. /* CD pin widget for input */
  2843. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2844. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2845. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2846. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2847. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2848. /* LINE-2 is used for line-out in rear */
  2849. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2850. /* select line-out */
  2851. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2852. /* LINE-OUT pin */
  2853. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2854. /* enable HP */
  2855. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2856. /* enable Mono */
  2857. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2858. /* mute capture amp left and right */
  2859. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2860. /* set connection select to line in (default select for this ADC) */
  2861. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2862. /* mute capture amp left and right */
  2863. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2864. /* set connection select to line in (default select for this ADC) */
  2865. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2866. /* set vol=0 Line-Out mixer amp left and right */
  2867. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2868. /* unmute pin widget amp left and right (no gain on this amp) */
  2869. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2870. /* set vol=0 HP mixer amp left and right */
  2871. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2872. /* unmute pin widget amp left and right (no gain on this amp) */
  2873. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2874. /* set vol=0 Mono mixer amp left and right */
  2875. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2876. /* unmute pin widget amp left and right (no gain on this amp) */
  2877. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2878. /* unmute LINE-2 out pin */
  2879. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2880. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2881. /* mute CD */
  2882. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2883. /* mute Line In */
  2884. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2885. /* mute Mic */
  2886. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2887. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2888. /* mute Front out path */
  2889. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2890. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2891. /* mute Headphone out path */
  2892. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2893. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2894. /* mute Mono out path */
  2895. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2896. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2897. { }
  2898. };
  2899. #if 0 /* should be identical with alc260_init_verbs? */
  2900. static struct hda_verb alc260_hp_init_verbs[] = {
  2901. /* Headphone and output */
  2902. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2903. /* mono output */
  2904. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2905. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2906. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2907. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2908. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2909. /* Line In pin widget for input */
  2910. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2911. /* Line-2 pin widget for output */
  2912. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2913. /* CD pin widget for input */
  2914. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2915. /* unmute amp left and right */
  2916. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2917. /* set connection select to line in (default select for this ADC) */
  2918. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2919. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2920. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2921. /* mute pin widget amp left and right (no gain on this amp) */
  2922. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2923. /* unmute HP mixer amp left and right (volume = 0) */
  2924. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2925. /* mute pin widget amp left and right (no gain on this amp) */
  2926. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2927. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2928. /* unmute CD */
  2929. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2930. /* unmute Line In */
  2931. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2932. /* unmute Mic */
  2933. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2934. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2935. /* Unmute Front out path */
  2936. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2937. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2938. /* Unmute Headphone out path */
  2939. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2940. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2941. /* Unmute Mono out path */
  2942. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2943. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2944. { }
  2945. };
  2946. #endif
  2947. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2948. /* Line out and output */
  2949. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2950. /* mono output */
  2951. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2952. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2953. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2954. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2955. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2956. /* Line In pin widget for input */
  2957. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2958. /* Headphone pin widget for output */
  2959. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2960. /* CD pin widget for input */
  2961. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2962. /* unmute amp left and right */
  2963. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2964. /* set connection select to line in (default select for this ADC) */
  2965. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2966. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2967. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2968. /* mute pin widget amp left and right (no gain on this amp) */
  2969. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2970. /* unmute HP mixer amp left and right (volume = 0) */
  2971. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2972. /* mute pin widget amp left and right (no gain on this amp) */
  2973. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2974. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2975. /* unmute CD */
  2976. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2977. /* unmute Line In */
  2978. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2979. /* unmute Mic */
  2980. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2981. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2982. /* Unmute Front out path */
  2983. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2984. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2985. /* Unmute Headphone out path */
  2986. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2987. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2988. /* Unmute Mono out path */
  2989. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2990. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2991. { }
  2992. };
  2993. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2994. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  2995. * audio = 0x16, internal speaker = 0x10.
  2996. */
  2997. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2998. /* Disable all GPIOs */
  2999. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3000. /* Internal speaker is connected to headphone pin */
  3001. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3002. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3003. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3004. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3005. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3006. /* Ensure all other unused pins are disabled and muted. */
  3007. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3008. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3009. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3010. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3011. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3012. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3013. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3014. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3015. /* Disable digital (SPDIF) pins */
  3016. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3017. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3018. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3019. * when acting as an output.
  3020. */
  3021. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3022. /* Start with output sum widgets muted and their output gains at min */
  3023. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3024. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3025. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3026. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3027. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3028. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3029. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3030. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3031. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3032. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3033. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3034. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3035. * If the pin mode is changed by the user the pin mode control will
  3036. * take care of enabling the pin's input/output buffers as needed.
  3037. * Therefore there's no need to enable the input buffer at this
  3038. * stage.
  3039. */
  3040. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3041. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3042. * mixer ctrl)
  3043. */
  3044. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3045. /* Mute capture amp left and right */
  3046. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3047. /* Set ADC connection select to match default mixer setting - line
  3048. * in (on mic1 pin)
  3049. */
  3050. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3051. /* Do the same for the second ADC: mute capture input amp and
  3052. * set ADC connection to line in (on mic1 pin)
  3053. */
  3054. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3055. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3056. /* Mute all inputs to mixer widget (even unconnected ones) */
  3057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3064. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3065. { }
  3066. };
  3067. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3068. * similar laptops (adapted from Fujitsu init verbs).
  3069. */
  3070. static struct hda_verb alc260_acer_init_verbs[] = {
  3071. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3072. * the headphone jack. Turn this on and rely on the standard mute
  3073. * methods whenever the user wants to turn these outputs off.
  3074. */
  3075. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3076. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3077. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3078. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3079. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3080. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3081. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3082. /* Line In jack is connected to Line1 pin */
  3083. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3084. /* Ensure all other unused pins are disabled and muted. */
  3085. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3086. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3087. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3088. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3089. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3090. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3091. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3092. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3093. /* Disable digital (SPDIF) pins */
  3094. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3095. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3096. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3097. * bus when acting as outputs.
  3098. */
  3099. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3100. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3101. /* Start with output sum widgets muted and their output gains at min */
  3102. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3103. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3104. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3105. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3106. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3107. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3108. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3109. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3110. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3111. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3112. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3113. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3114. * inputs. If the pin mode is changed by the user the pin mode control
  3115. * will take care of enabling the pin's input/output buffers as needed.
  3116. * Therefore there's no need to enable the input buffer at this
  3117. * stage.
  3118. */
  3119. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3120. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3121. /* Mute capture amp left and right */
  3122. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3123. /* Set ADC connection select to match default mixer setting - mic
  3124. * (on mic1 pin)
  3125. */
  3126. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3127. /* Do similar with the second ADC: mute capture input amp and
  3128. * set ADC connection to mic to match ALSA's default state.
  3129. */
  3130. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3131. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3132. /* Mute all inputs to mixer widget (even unconnected ones) */
  3133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3134. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3135. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3136. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3137. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3138. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3139. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3140. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3141. { }
  3142. };
  3143. /* Test configuration for debugging, modelled after the ALC880 test
  3144. * configuration.
  3145. */
  3146. #ifdef CONFIG_SND_DEBUG
  3147. static hda_nid_t alc260_test_dac_nids[1] = {
  3148. 0x02,
  3149. };
  3150. static hda_nid_t alc260_test_adc_nids[2] = {
  3151. 0x04, 0x05,
  3152. };
  3153. /* For testing the ALC260, each input MUX needs its own definition since
  3154. * the signal assignments are different. This assumes that the first ADC
  3155. * is NID 0x04.
  3156. */
  3157. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3158. {
  3159. .num_items = 7,
  3160. .items = {
  3161. { "MIC1 pin", 0x0 },
  3162. { "MIC2 pin", 0x1 },
  3163. { "LINE1 pin", 0x2 },
  3164. { "LINE2 pin", 0x3 },
  3165. { "CD pin", 0x4 },
  3166. { "LINE-OUT pin", 0x5 },
  3167. { "HP-OUT pin", 0x6 },
  3168. },
  3169. },
  3170. {
  3171. .num_items = 8,
  3172. .items = {
  3173. { "MIC1 pin", 0x0 },
  3174. { "MIC2 pin", 0x1 },
  3175. { "LINE1 pin", 0x2 },
  3176. { "LINE2 pin", 0x3 },
  3177. { "CD pin", 0x4 },
  3178. { "Mixer", 0x5 },
  3179. { "LINE-OUT pin", 0x6 },
  3180. { "HP-OUT pin", 0x7 },
  3181. },
  3182. },
  3183. };
  3184. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3185. /* Output driver widgets */
  3186. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3187. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3189. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3191. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3192. /* Modes for retasking pin widgets
  3193. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3194. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3195. * mention this restriction. At this stage it's not clear whether
  3196. * this behaviour is intentional or is a hardware bug in chip
  3197. * revisions available at least up until early 2006. Therefore for
  3198. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3199. * choices, but if it turns out that the lack of mic bias for these
  3200. * NIDs is intentional we could change their modes from
  3201. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3202. */
  3203. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3204. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3205. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3206. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3207. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3208. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3209. /* Loopback mixer controls */
  3210. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3211. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3212. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3213. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3214. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3215. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3216. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3217. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3218. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3219. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3221. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3222. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3223. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3224. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3225. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3226. /* Controls for GPIO pins, assuming they are configured as outputs */
  3227. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3228. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3229. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3230. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3231. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3232. * is ambigious as to which NID is which; testing on laptops which
  3233. * make this output available should provide clarification.
  3234. */
  3235. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3236. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3237. { } /* end */
  3238. };
  3239. static struct hda_verb alc260_test_init_verbs[] = {
  3240. /* Enable all GPIOs as outputs with an initial value of 0 */
  3241. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3242. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3243. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3244. /* Enable retasking pins as output, initially without power amp */
  3245. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3246. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3248. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3249. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3250. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3251. /* Disable digital (SPDIF) pins initially, but users can enable
  3252. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3253. * payload also sets the generation to 0, output to be in "consumer"
  3254. * PCM format, copyright asserted, no pre-emphasis and no validity
  3255. * control.
  3256. */
  3257. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3258. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3259. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3260. * OUT1 sum bus when acting as an output.
  3261. */
  3262. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3263. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3264. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3265. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3266. /* Start with output sum widgets muted and their output gains at min */
  3267. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3268. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3269. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3270. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3272. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3273. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3274. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3275. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3276. /* Unmute retasking pin widget output buffers since the default
  3277. * state appears to be output. As the pin mode is changed by the
  3278. * user the pin mode control will take care of enabling the pin's
  3279. * input/output buffers as needed.
  3280. */
  3281. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3282. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3283. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3284. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3285. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3286. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3287. /* Also unmute the mono-out pin widget */
  3288. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3289. /* Mute capture amp left and right */
  3290. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3291. /* Set ADC connection select to match default mixer setting (mic1
  3292. * pin)
  3293. */
  3294. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3295. /* Do the same for the second ADC: mute capture input amp and
  3296. * set ADC connection to mic1 pin
  3297. */
  3298. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3299. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3300. /* Mute all inputs to mixer widget (even unconnected ones) */
  3301. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3302. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3303. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3304. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3305. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3306. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3308. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3309. { }
  3310. };
  3311. #endif
  3312. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3313. .substreams = 1,
  3314. .channels_min = 2,
  3315. .channels_max = 2,
  3316. };
  3317. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3318. .substreams = 1,
  3319. .channels_min = 2,
  3320. .channels_max = 2,
  3321. };
  3322. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3323. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3324. /*
  3325. * for BIOS auto-configuration
  3326. */
  3327. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3328. const char *pfx)
  3329. {
  3330. hda_nid_t nid_vol;
  3331. unsigned long vol_val, sw_val;
  3332. char name[32];
  3333. int err;
  3334. if (nid >= 0x0f && nid < 0x11) {
  3335. nid_vol = nid - 0x7;
  3336. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3337. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3338. } else if (nid == 0x11) {
  3339. nid_vol = nid - 0x7;
  3340. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3341. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3342. } else if (nid >= 0x12 && nid <= 0x15) {
  3343. nid_vol = 0x08;
  3344. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3345. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3346. } else
  3347. return 0; /* N/A */
  3348. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3349. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3350. return err;
  3351. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3352. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3353. return err;
  3354. return 1;
  3355. }
  3356. /* add playback controls from the parsed DAC table */
  3357. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3358. const struct auto_pin_cfg *cfg)
  3359. {
  3360. hda_nid_t nid;
  3361. int err;
  3362. spec->multiout.num_dacs = 1;
  3363. spec->multiout.dac_nids = spec->private_dac_nids;
  3364. spec->multiout.dac_nids[0] = 0x02;
  3365. nid = cfg->line_out_pins[0];
  3366. if (nid) {
  3367. err = alc260_add_playback_controls(spec, nid, "Front");
  3368. if (err < 0)
  3369. return err;
  3370. }
  3371. nid = cfg->speaker_pins[0];
  3372. if (nid) {
  3373. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3374. if (err < 0)
  3375. return err;
  3376. }
  3377. nid = cfg->hp_pins[0];
  3378. if (nid) {
  3379. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3380. if (err < 0)
  3381. return err;
  3382. }
  3383. return 0;
  3384. }
  3385. /* create playback/capture controls for input pins */
  3386. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3387. const struct auto_pin_cfg *cfg)
  3388. {
  3389. struct hda_input_mux *imux = &spec->private_imux;
  3390. int i, err, idx;
  3391. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3392. if (cfg->input_pins[i] >= 0x12) {
  3393. idx = cfg->input_pins[i] - 0x12;
  3394. err = new_analog_input(spec, cfg->input_pins[i],
  3395. auto_pin_cfg_labels[i], idx, 0x07);
  3396. if (err < 0)
  3397. return err;
  3398. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3399. imux->items[imux->num_items].index = idx;
  3400. imux->num_items++;
  3401. }
  3402. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3403. idx = cfg->input_pins[i] - 0x09;
  3404. err = new_analog_input(spec, cfg->input_pins[i],
  3405. auto_pin_cfg_labels[i], idx, 0x07);
  3406. if (err < 0)
  3407. return err;
  3408. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3409. imux->items[imux->num_items].index = idx;
  3410. imux->num_items++;
  3411. }
  3412. }
  3413. return 0;
  3414. }
  3415. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3416. hda_nid_t nid, int pin_type,
  3417. int sel_idx)
  3418. {
  3419. /* set as output */
  3420. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3421. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3422. /* need the manual connection? */
  3423. if (nid >= 0x12) {
  3424. int idx = nid - 0x12;
  3425. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3426. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3427. }
  3428. }
  3429. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3430. {
  3431. struct alc_spec *spec = codec->spec;
  3432. hda_nid_t nid;
  3433. nid = spec->autocfg.line_out_pins[0];
  3434. if (nid)
  3435. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3436. nid = spec->autocfg.speaker_pins[0];
  3437. if (nid)
  3438. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3439. nid = spec->autocfg.hp_pins[0];
  3440. if (nid)
  3441. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3442. }
  3443. #define ALC260_PIN_CD_NID 0x16
  3444. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3445. {
  3446. struct alc_spec *spec = codec->spec;
  3447. int i;
  3448. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3449. hda_nid_t nid = spec->autocfg.input_pins[i];
  3450. if (nid >= 0x12) {
  3451. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3452. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3453. if (nid != ALC260_PIN_CD_NID)
  3454. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3455. AMP_OUT_MUTE);
  3456. }
  3457. }
  3458. }
  3459. /*
  3460. * generic initialization of ADC, input mixers and output mixers
  3461. */
  3462. static struct hda_verb alc260_volume_init_verbs[] = {
  3463. /*
  3464. * Unmute ADC0-1 and set the default input to mic-in
  3465. */
  3466. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3467. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3468. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3469. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3470. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3471. * mixer widget
  3472. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3473. * mic (mic 2)
  3474. */
  3475. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3476. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3480. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3481. /*
  3482. * Set up output mixers (0x08 - 0x0a)
  3483. */
  3484. /* set vol=0 to output mixers */
  3485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3487. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3488. /* set up input amps for analog loopback */
  3489. /* Amp Indices: DAC = 0, mixer = 1 */
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3494. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3495. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3496. { }
  3497. };
  3498. static int alc260_parse_auto_config(struct hda_codec *codec)
  3499. {
  3500. struct alc_spec *spec = codec->spec;
  3501. unsigned int wcap;
  3502. int err;
  3503. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3504. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3505. alc260_ignore)) < 0)
  3506. return err;
  3507. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3508. return err;
  3509. if (! spec->kctl_alloc)
  3510. return 0; /* can't find valid BIOS pin config */
  3511. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3512. return err;
  3513. spec->multiout.max_channels = 2;
  3514. if (spec->autocfg.dig_out_pin)
  3515. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3516. if (spec->kctl_alloc)
  3517. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3518. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3519. spec->num_mux_defs = 1;
  3520. spec->input_mux = &spec->private_imux;
  3521. /* check whether NID 0x04 is valid */
  3522. wcap = get_wcaps(codec, 0x04);
  3523. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3524. if (wcap != AC_WID_AUD_IN) {
  3525. spec->adc_nids = alc260_adc_nids_alt;
  3526. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3527. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3528. } else {
  3529. spec->adc_nids = alc260_adc_nids;
  3530. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3531. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3532. }
  3533. spec->num_mixers++;
  3534. return 1;
  3535. }
  3536. /* additional initialization for auto-configuration model */
  3537. static void alc260_auto_init(struct hda_codec *codec)
  3538. {
  3539. alc260_auto_init_multi_out(codec);
  3540. alc260_auto_init_analog_input(codec);
  3541. }
  3542. /*
  3543. * ALC260 configurations
  3544. */
  3545. static struct hda_board_config alc260_cfg_tbl[] = {
  3546. { .modelname = "basic", .config = ALC260_BASIC },
  3547. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3548. .config = ALC260_BASIC }, /* Sony VAIO */
  3549. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
  3550. .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
  3551. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
  3552. .config = ALC260_BASIC }, /* Sony VAIO */
  3553. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3554. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3555. { .modelname = "hp", .config = ALC260_HP },
  3556. { .modelname = "hp-3013", .config = ALC260_HP_3013 },
  3557. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
  3558. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3559. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
  3560. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3561. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3562. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3563. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3564. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3565. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3566. { .modelname = "acer", .config = ALC260_ACER },
  3567. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3568. #ifdef CONFIG_SND_DEBUG
  3569. { .modelname = "test", .config = ALC260_TEST },
  3570. #endif
  3571. { .modelname = "auto", .config = ALC260_AUTO },
  3572. {}
  3573. };
  3574. static struct alc_config_preset alc260_presets[] = {
  3575. [ALC260_BASIC] = {
  3576. .mixers = { alc260_base_output_mixer,
  3577. alc260_input_mixer,
  3578. alc260_pc_beep_mixer,
  3579. alc260_capture_mixer },
  3580. .init_verbs = { alc260_init_verbs },
  3581. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3582. .dac_nids = alc260_dac_nids,
  3583. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3584. .adc_nids = alc260_adc_nids,
  3585. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3586. .channel_mode = alc260_modes,
  3587. .input_mux = &alc260_capture_source,
  3588. },
  3589. [ALC260_HP] = {
  3590. .mixers = { alc260_base_output_mixer,
  3591. alc260_input_mixer,
  3592. alc260_capture_alt_mixer },
  3593. .init_verbs = { alc260_init_verbs },
  3594. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3595. .dac_nids = alc260_dac_nids,
  3596. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3597. .adc_nids = alc260_hp_adc_nids,
  3598. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3599. .channel_mode = alc260_modes,
  3600. .input_mux = &alc260_capture_source,
  3601. },
  3602. [ALC260_HP_3013] = {
  3603. .mixers = { alc260_hp_3013_mixer,
  3604. alc260_input_mixer,
  3605. alc260_capture_alt_mixer },
  3606. .init_verbs = { alc260_hp_3013_init_verbs },
  3607. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3608. .dac_nids = alc260_dac_nids,
  3609. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3610. .adc_nids = alc260_hp_adc_nids,
  3611. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3612. .channel_mode = alc260_modes,
  3613. .input_mux = &alc260_capture_source,
  3614. },
  3615. [ALC260_FUJITSU_S702X] = {
  3616. .mixers = { alc260_fujitsu_mixer,
  3617. alc260_capture_mixer },
  3618. .init_verbs = { alc260_fujitsu_init_verbs },
  3619. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3620. .dac_nids = alc260_dac_nids,
  3621. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3622. .adc_nids = alc260_dual_adc_nids,
  3623. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3624. .channel_mode = alc260_modes,
  3625. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3626. .input_mux = alc260_fujitsu_capture_sources,
  3627. },
  3628. [ALC260_ACER] = {
  3629. .mixers = { alc260_acer_mixer,
  3630. alc260_capture_mixer },
  3631. .init_verbs = { alc260_acer_init_verbs },
  3632. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3633. .dac_nids = alc260_dac_nids,
  3634. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3635. .adc_nids = alc260_dual_adc_nids,
  3636. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3637. .channel_mode = alc260_modes,
  3638. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3639. .input_mux = alc260_acer_capture_sources,
  3640. },
  3641. #ifdef CONFIG_SND_DEBUG
  3642. [ALC260_TEST] = {
  3643. .mixers = { alc260_test_mixer,
  3644. alc260_capture_mixer },
  3645. .init_verbs = { alc260_test_init_verbs },
  3646. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3647. .dac_nids = alc260_test_dac_nids,
  3648. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3649. .adc_nids = alc260_test_adc_nids,
  3650. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3651. .channel_mode = alc260_modes,
  3652. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3653. .input_mux = alc260_test_capture_sources,
  3654. },
  3655. #endif
  3656. };
  3657. static int patch_alc260(struct hda_codec *codec)
  3658. {
  3659. struct alc_spec *spec;
  3660. int err, board_config;
  3661. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3662. if (spec == NULL)
  3663. return -ENOMEM;
  3664. codec->spec = spec;
  3665. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3666. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3667. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3668. "trying auto-probe from BIOS...\n");
  3669. board_config = ALC260_AUTO;
  3670. }
  3671. if (board_config == ALC260_AUTO) {
  3672. /* automatic parse from the BIOS config */
  3673. err = alc260_parse_auto_config(codec);
  3674. if (err < 0) {
  3675. alc_free(codec);
  3676. return err;
  3677. } else if (! err) {
  3678. printk(KERN_INFO
  3679. "hda_codec: Cannot set up configuration "
  3680. "from BIOS. Using base mode...\n");
  3681. board_config = ALC260_BASIC;
  3682. }
  3683. }
  3684. if (board_config != ALC260_AUTO)
  3685. setup_preset(spec, &alc260_presets[board_config]);
  3686. spec->stream_name_analog = "ALC260 Analog";
  3687. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3688. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3689. spec->stream_name_digital = "ALC260 Digital";
  3690. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3691. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3692. codec->patch_ops = alc_patch_ops;
  3693. if (board_config == ALC260_AUTO)
  3694. spec->init_hook = alc260_auto_init;
  3695. return 0;
  3696. }
  3697. /*
  3698. * ALC882 support
  3699. *
  3700. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3701. * configuration. Each pin widget can choose any input DACs and a mixer.
  3702. * Each ADC is connected from a mixer of all inputs. This makes possible
  3703. * 6-channel independent captures.
  3704. *
  3705. * In addition, an independent DAC for the multi-playback (not used in this
  3706. * driver yet).
  3707. */
  3708. #define ALC882_DIGOUT_NID 0x06
  3709. #define ALC882_DIGIN_NID 0x0a
  3710. static struct hda_channel_mode alc882_ch_modes[1] = {
  3711. { 8, NULL }
  3712. };
  3713. static hda_nid_t alc882_dac_nids[4] = {
  3714. /* front, rear, clfe, rear_surr */
  3715. 0x02, 0x03, 0x04, 0x05
  3716. };
  3717. /* identical with ALC880 */
  3718. #define alc882_adc_nids alc880_adc_nids
  3719. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3720. /* input MUX */
  3721. /* FIXME: should be a matrix-type input source selection */
  3722. static struct hda_input_mux alc882_capture_source = {
  3723. .num_items = 4,
  3724. .items = {
  3725. { "Mic", 0x0 },
  3726. { "Front Mic", 0x1 },
  3727. { "Line", 0x2 },
  3728. { "CD", 0x4 },
  3729. },
  3730. };
  3731. #define alc882_mux_enum_info alc_mux_enum_info
  3732. #define alc882_mux_enum_get alc_mux_enum_get
  3733. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3734. {
  3735. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3736. struct alc_spec *spec = codec->spec;
  3737. const struct hda_input_mux *imux = spec->input_mux;
  3738. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3739. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3740. hda_nid_t nid = capture_mixers[adc_idx];
  3741. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3742. unsigned int i, idx;
  3743. idx = ucontrol->value.enumerated.item[0];
  3744. if (idx >= imux->num_items)
  3745. idx = imux->num_items - 1;
  3746. if (*cur_val == idx && ! codec->in_resume)
  3747. return 0;
  3748. for (i = 0; i < imux->num_items; i++) {
  3749. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3750. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3751. v | (imux->items[i].index << 8));
  3752. }
  3753. *cur_val = idx;
  3754. return 1;
  3755. }
  3756. /*
  3757. * 6ch mode
  3758. */
  3759. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3760. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3761. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3762. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3763. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3764. { } /* end */
  3765. };
  3766. /*
  3767. * 8ch mode
  3768. */
  3769. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3770. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3771. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3772. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3773. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3774. { } /* end */
  3775. };
  3776. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3777. { 6, alc882_sixstack_ch6_init },
  3778. { 8, alc882_sixstack_ch8_init },
  3779. };
  3780. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3781. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3782. */
  3783. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3784. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3785. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3787. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3788. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3789. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3790. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3791. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3792. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3793. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3794. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3795. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3796. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3797. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3798. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3799. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3800. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3801. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3802. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3803. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3804. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3805. { } /* end */
  3806. };
  3807. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3808. {
  3809. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3810. .name = "Channel Mode",
  3811. .info = alc_ch_mode_info,
  3812. .get = alc_ch_mode_get,
  3813. .put = alc_ch_mode_put,
  3814. },
  3815. { } /* end */
  3816. };
  3817. static struct hda_verb alc882_init_verbs[] = {
  3818. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3821. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3822. /* Rear mixer */
  3823. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3824. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3825. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3826. /* CLFE mixer */
  3827. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3828. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3829. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3830. /* Side mixer */
  3831. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3832. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3833. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3834. /* Front Pin: output 0 (0x0c) */
  3835. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3836. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3837. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3838. /* Rear Pin: output 1 (0x0d) */
  3839. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3840. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3841. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3842. /* CLFE Pin: output 2 (0x0e) */
  3843. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3844. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3846. /* Side Pin: output 3 (0x0f) */
  3847. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3848. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3850. /* Mic (rear) pin: input vref at 80% */
  3851. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3852. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3853. /* Front Mic pin: input vref at 80% */
  3854. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3855. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3856. /* Line In pin: input */
  3857. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3858. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3859. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3860. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3861. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3862. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3863. /* CD pin widget for input */
  3864. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3865. /* FIXME: use matrix-type input source selection */
  3866. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3867. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3868. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3869. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3870. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3871. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3872. /* Input mixer2 */
  3873. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3874. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3875. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3876. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3877. /* Input mixer3 */
  3878. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3879. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3880. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3881. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3882. /* ADC1: mute amp left and right */
  3883. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3884. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3885. /* ADC2: mute amp left and right */
  3886. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3887. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3888. /* ADC3: mute amp left and right */
  3889. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3890. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3891. { }
  3892. };
  3893. static struct hda_verb alc882_eapd_verbs[] = {
  3894. /* change to EAPD mode */
  3895. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  3896. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  3897. { }
  3898. };
  3899. /*
  3900. * generic initialization of ADC, input mixers and output mixers
  3901. */
  3902. static struct hda_verb alc882_auto_init_verbs[] = {
  3903. /*
  3904. * Unmute ADC0-2 and set the default input to mic-in
  3905. */
  3906. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3907. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3908. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3909. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3910. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3911. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3912. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3913. * mixer widget
  3914. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3915. * mic (mic 2)
  3916. */
  3917. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3920. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3921. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3922. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3923. /*
  3924. * Set up output mixers (0x0c - 0x0f)
  3925. */
  3926. /* set vol=0 to output mixers */
  3927. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3928. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3929. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3930. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3931. /* set up input amps for analog loopback */
  3932. /* Amp Indices: DAC = 0, mixer = 1 */
  3933. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3934. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3935. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3936. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3938. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3939. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3940. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3941. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3942. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3943. /* FIXME: use matrix-type input source selection */
  3944. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3945. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3946. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3947. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3949. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3950. /* Input mixer2 */
  3951. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3954. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3955. /* Input mixer3 */
  3956. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3960. { }
  3961. };
  3962. /* capture mixer elements */
  3963. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3964. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3965. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3966. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3967. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3968. {
  3969. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3970. /* The multiple "Capture Source" controls confuse alsamixer
  3971. * So call somewhat different..
  3972. * FIXME: the controls appear in the "playback" view!
  3973. */
  3974. /* .name = "Capture Source", */
  3975. .name = "Input Source",
  3976. .count = 2,
  3977. .info = alc882_mux_enum_info,
  3978. .get = alc882_mux_enum_get,
  3979. .put = alc882_mux_enum_put,
  3980. },
  3981. { } /* end */
  3982. };
  3983. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3984. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3985. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3986. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3987. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3988. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3989. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3990. {
  3991. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3992. /* The multiple "Capture Source" controls confuse alsamixer
  3993. * So call somewhat different..
  3994. * FIXME: the controls appear in the "playback" view!
  3995. */
  3996. /* .name = "Capture Source", */
  3997. .name = "Input Source",
  3998. .count = 3,
  3999. .info = alc882_mux_enum_info,
  4000. .get = alc882_mux_enum_get,
  4001. .put = alc882_mux_enum_put,
  4002. },
  4003. { } /* end */
  4004. };
  4005. /* pcm configuration: identiacal with ALC880 */
  4006. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4007. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4008. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4009. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4010. /*
  4011. * configuration and preset
  4012. */
  4013. static struct hda_board_config alc882_cfg_tbl[] = {
  4014. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  4015. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  4016. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4017. .config = ALC882_6ST_DIG }, /* MSI */
  4018. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4019. .config = ALC882_6ST_DIG }, /* Foxconn */
  4020. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4021. .config = ALC882_6ST_DIG }, /* ECS to Intel*/
  4022. { .modelname = "arima", .config = ALC882_ARIMA },
  4023. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4024. .config = ALC882_ARIMA }, /* Arima W820Di1 */
  4025. { .modelname = "auto", .config = ALC882_AUTO },
  4026. {}
  4027. };
  4028. static struct alc_config_preset alc882_presets[] = {
  4029. [ALC882_3ST_DIG] = {
  4030. .mixers = { alc882_base_mixer },
  4031. .init_verbs = { alc882_init_verbs },
  4032. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4033. .dac_nids = alc882_dac_nids,
  4034. .dig_out_nid = ALC882_DIGOUT_NID,
  4035. .dig_in_nid = ALC882_DIGIN_NID,
  4036. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4037. .channel_mode = alc882_ch_modes,
  4038. .need_dac_fix = 1,
  4039. .input_mux = &alc882_capture_source,
  4040. },
  4041. [ALC882_6ST_DIG] = {
  4042. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4043. .init_verbs = { alc882_init_verbs },
  4044. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4045. .dac_nids = alc882_dac_nids,
  4046. .dig_out_nid = ALC882_DIGOUT_NID,
  4047. .dig_in_nid = ALC882_DIGIN_NID,
  4048. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4049. .channel_mode = alc882_sixstack_modes,
  4050. .input_mux = &alc882_capture_source,
  4051. },
  4052. [ALC882_ARIMA] = {
  4053. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4054. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4055. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4056. .dac_nids = alc882_dac_nids,
  4057. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4058. .channel_mode = alc882_sixstack_modes,
  4059. .input_mux = &alc882_capture_source,
  4060. },
  4061. };
  4062. /*
  4063. * BIOS auto configuration
  4064. */
  4065. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4066. hda_nid_t nid, int pin_type,
  4067. int dac_idx)
  4068. {
  4069. /* set as output */
  4070. struct alc_spec *spec = codec->spec;
  4071. int idx;
  4072. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4073. idx = 4;
  4074. else
  4075. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4076. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4077. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4078. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4079. }
  4080. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4081. {
  4082. struct alc_spec *spec = codec->spec;
  4083. int i;
  4084. for (i = 0; i <= HDA_SIDE; i++) {
  4085. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4086. if (nid)
  4087. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4088. }
  4089. }
  4090. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4091. {
  4092. struct alc_spec *spec = codec->spec;
  4093. hda_nid_t pin;
  4094. pin = spec->autocfg.hp_pins[0];
  4095. if (pin) /* connect to front */
  4096. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4097. }
  4098. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4099. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4100. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4101. {
  4102. struct alc_spec *spec = codec->spec;
  4103. int i;
  4104. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4105. hda_nid_t nid = spec->autocfg.input_pins[i];
  4106. if (alc882_is_input_pin(nid)) {
  4107. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4108. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4109. if (nid != ALC882_PIN_CD_NID)
  4110. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4111. AMP_OUT_MUTE);
  4112. }
  4113. }
  4114. }
  4115. /* almost identical with ALC880 parser... */
  4116. static int alc882_parse_auto_config(struct hda_codec *codec)
  4117. {
  4118. struct alc_spec *spec = codec->spec;
  4119. int err = alc880_parse_auto_config(codec);
  4120. if (err < 0)
  4121. return err;
  4122. else if (err > 0)
  4123. /* hack - override the init verbs */
  4124. spec->init_verbs[0] = alc882_auto_init_verbs;
  4125. return err;
  4126. }
  4127. /* additional initialization for auto-configuration model */
  4128. static void alc882_auto_init(struct hda_codec *codec)
  4129. {
  4130. alc882_auto_init_multi_out(codec);
  4131. alc882_auto_init_hp_out(codec);
  4132. alc882_auto_init_analog_input(codec);
  4133. }
  4134. static int patch_alc882(struct hda_codec *codec)
  4135. {
  4136. struct alc_spec *spec;
  4137. int err, board_config;
  4138. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4139. if (spec == NULL)
  4140. return -ENOMEM;
  4141. codec->spec = spec;
  4142. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  4143. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4144. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4145. "trying auto-probe from BIOS...\n");
  4146. board_config = ALC882_AUTO;
  4147. }
  4148. if (board_config == ALC882_AUTO) {
  4149. /* automatic parse from the BIOS config */
  4150. err = alc882_parse_auto_config(codec);
  4151. if (err < 0) {
  4152. alc_free(codec);
  4153. return err;
  4154. } else if (! err) {
  4155. printk(KERN_INFO
  4156. "hda_codec: Cannot set up configuration "
  4157. "from BIOS. Using base mode...\n");
  4158. board_config = ALC882_3ST_DIG;
  4159. }
  4160. }
  4161. if (board_config != ALC882_AUTO)
  4162. setup_preset(spec, &alc882_presets[board_config]);
  4163. spec->stream_name_analog = "ALC882 Analog";
  4164. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4165. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4166. spec->stream_name_digital = "ALC882 Digital";
  4167. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4168. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4169. if (! spec->adc_nids && spec->input_mux) {
  4170. /* check whether NID 0x07 is valid */
  4171. unsigned int wcap = get_wcaps(codec, 0x07);
  4172. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4173. if (wcap != AC_WID_AUD_IN) {
  4174. spec->adc_nids = alc882_adc_nids_alt;
  4175. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4176. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4177. spec->num_mixers++;
  4178. } else {
  4179. spec->adc_nids = alc882_adc_nids;
  4180. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4181. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4182. spec->num_mixers++;
  4183. }
  4184. }
  4185. codec->patch_ops = alc_patch_ops;
  4186. if (board_config == ALC882_AUTO)
  4187. spec->init_hook = alc882_auto_init;
  4188. return 0;
  4189. }
  4190. /*
  4191. * ALC883 support
  4192. *
  4193. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4194. * configuration. Each pin widget can choose any input DACs and a mixer.
  4195. * Each ADC is connected from a mixer of all inputs. This makes possible
  4196. * 6-channel independent captures.
  4197. *
  4198. * In addition, an independent DAC for the multi-playback (not used in this
  4199. * driver yet).
  4200. */
  4201. #define ALC883_DIGOUT_NID 0x06
  4202. #define ALC883_DIGIN_NID 0x0a
  4203. static hda_nid_t alc883_dac_nids[4] = {
  4204. /* front, rear, clfe, rear_surr */
  4205. 0x02, 0x04, 0x03, 0x05
  4206. };
  4207. static hda_nid_t alc883_adc_nids[2] = {
  4208. /* ADC1-2 */
  4209. 0x08, 0x09,
  4210. };
  4211. /* input MUX */
  4212. /* FIXME: should be a matrix-type input source selection */
  4213. static struct hda_input_mux alc883_capture_source = {
  4214. .num_items = 4,
  4215. .items = {
  4216. { "Mic", 0x0 },
  4217. { "Front Mic", 0x1 },
  4218. { "Line", 0x2 },
  4219. { "CD", 0x4 },
  4220. },
  4221. };
  4222. #define alc883_mux_enum_info alc_mux_enum_info
  4223. #define alc883_mux_enum_get alc_mux_enum_get
  4224. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4225. struct snd_ctl_elem_value *ucontrol)
  4226. {
  4227. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4228. struct alc_spec *spec = codec->spec;
  4229. const struct hda_input_mux *imux = spec->input_mux;
  4230. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4231. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4232. hda_nid_t nid = capture_mixers[adc_idx];
  4233. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4234. unsigned int i, idx;
  4235. idx = ucontrol->value.enumerated.item[0];
  4236. if (idx >= imux->num_items)
  4237. idx = imux->num_items - 1;
  4238. if (*cur_val == idx && ! codec->in_resume)
  4239. return 0;
  4240. for (i = 0; i < imux->num_items; i++) {
  4241. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4242. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4243. v | (imux->items[i].index << 8));
  4244. }
  4245. *cur_val = idx;
  4246. return 1;
  4247. }
  4248. /*
  4249. * 2ch mode
  4250. */
  4251. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4252. { 2, NULL }
  4253. };
  4254. /*
  4255. * 2ch mode
  4256. */
  4257. static struct hda_verb alc883_3ST_ch2_init[] = {
  4258. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4259. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4260. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4261. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4262. { } /* end */
  4263. };
  4264. /*
  4265. * 6ch mode
  4266. */
  4267. static struct hda_verb alc883_3ST_ch6_init[] = {
  4268. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4269. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4270. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4271. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4272. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4273. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4274. { } /* end */
  4275. };
  4276. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4277. { 2, alc883_3ST_ch2_init },
  4278. { 6, alc883_3ST_ch6_init },
  4279. };
  4280. /*
  4281. * 6ch mode
  4282. */
  4283. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4284. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4285. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4286. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4287. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4288. { } /* end */
  4289. };
  4290. /*
  4291. * 8ch mode
  4292. */
  4293. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4294. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4295. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4296. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4297. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4298. { } /* end */
  4299. };
  4300. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4301. { 6, alc883_sixstack_ch6_init },
  4302. { 8, alc883_sixstack_ch8_init },
  4303. };
  4304. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4305. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4306. */
  4307. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4308. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4309. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4310. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4311. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4312. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4313. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4314. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4315. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4316. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4317. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4318. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4319. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4320. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4321. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4322. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4323. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4324. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4325. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4326. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4327. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4328. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4329. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4330. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4331. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4332. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4333. {
  4334. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4335. /* .name = "Capture Source", */
  4336. .name = "Input Source",
  4337. .count = 2,
  4338. .info = alc883_mux_enum_info,
  4339. .get = alc883_mux_enum_get,
  4340. .put = alc883_mux_enum_put,
  4341. },
  4342. { } /* end */
  4343. };
  4344. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4345. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4346. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 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_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4354. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4355. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4356. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4357. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4358. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4359. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4360. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4361. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4362. {
  4363. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4364. /* .name = "Capture Source", */
  4365. .name = "Input Source",
  4366. .count = 2,
  4367. .info = alc883_mux_enum_info,
  4368. .get = alc883_mux_enum_get,
  4369. .put = alc883_mux_enum_put,
  4370. },
  4371. { } /* end */
  4372. };
  4373. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4374. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4375. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4376. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4377. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4378. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4379. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4380. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4381. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4382. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4383. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4384. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4385. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4386. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4387. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4388. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4389. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4390. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4391. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4392. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4393. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4394. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4395. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4396. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4397. {
  4398. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4399. /* .name = "Capture Source", */
  4400. .name = "Input Source",
  4401. .count = 2,
  4402. .info = alc883_mux_enum_info,
  4403. .get = alc883_mux_enum_get,
  4404. .put = alc883_mux_enum_put,
  4405. },
  4406. { } /* end */
  4407. };
  4408. static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
  4409. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4410. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4411. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4412. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4413. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4414. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4415. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4416. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4417. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4418. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4419. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4420. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4421. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4422. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4423. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4424. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4425. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4426. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4427. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4428. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4429. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4430. {
  4431. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4432. /* .name = "Capture Source", */
  4433. .name = "Input Source",
  4434. .count = 1,
  4435. .info = alc883_mux_enum_info,
  4436. .get = alc883_mux_enum_get,
  4437. .put = alc883_mux_enum_put,
  4438. },
  4439. { } /* end */
  4440. };
  4441. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4442. {
  4443. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4444. .name = "Channel Mode",
  4445. .info = alc_ch_mode_info,
  4446. .get = alc_ch_mode_get,
  4447. .put = alc_ch_mode_put,
  4448. },
  4449. { } /* end */
  4450. };
  4451. static struct hda_verb alc883_init_verbs[] = {
  4452. /* ADC1: mute amp left and right */
  4453. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4454. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4455. /* ADC2: mute amp left and right */
  4456. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4457. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4458. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4459. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4461. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4462. /* Rear mixer */
  4463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4464. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4465. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4466. /* CLFE mixer */
  4467. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4468. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4469. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4470. /* Side mixer */
  4471. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4472. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4473. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4474. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4475. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4476. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4477. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4478. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4479. /* Front Pin: output 0 (0x0c) */
  4480. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4481. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4482. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4483. /* Rear Pin: output 1 (0x0d) */
  4484. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4486. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4487. /* CLFE Pin: output 2 (0x0e) */
  4488. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4489. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4490. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4491. /* Side Pin: output 3 (0x0f) */
  4492. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4493. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4494. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4495. /* Mic (rear) pin: input vref at 80% */
  4496. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4497. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4498. /* Front Mic pin: input vref at 80% */
  4499. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4500. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4501. /* Line In pin: input */
  4502. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4503. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4504. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4505. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4506. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4507. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4508. /* CD pin widget for input */
  4509. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4510. /* FIXME: use matrix-type input source selection */
  4511. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4512. /* Input mixer2 */
  4513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4517. /* Input mixer3 */
  4518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4522. { }
  4523. };
  4524. /*
  4525. * generic initialization of ADC, input mixers and output mixers
  4526. */
  4527. static struct hda_verb alc883_auto_init_verbs[] = {
  4528. /*
  4529. * Unmute ADC0-2 and set the default input to mic-in
  4530. */
  4531. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4532. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4533. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4534. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4535. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4536. * mixer widget
  4537. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4538. * mic (mic 2)
  4539. */
  4540. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4541. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4542. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4543. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4544. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4546. /*
  4547. * Set up output mixers (0x0c - 0x0f)
  4548. */
  4549. /* set vol=0 to output mixers */
  4550. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4551. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4552. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4553. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4554. /* set up input amps for analog loopback */
  4555. /* Amp Indices: DAC = 0, mixer = 1 */
  4556. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4557. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4558. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4559. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4560. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4561. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4562. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4563. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4564. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4565. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4566. /* FIXME: use matrix-type input source selection */
  4567. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4568. /* Input mixer1 */
  4569. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4570. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4571. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4572. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4573. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4574. /* Input mixer2 */
  4575. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4576. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4577. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4578. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4580. { }
  4581. };
  4582. /* capture mixer elements */
  4583. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4584. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4585. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4586. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4587. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4588. {
  4589. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4590. /* The multiple "Capture Source" controls confuse alsamixer
  4591. * So call somewhat different..
  4592. * FIXME: the controls appear in the "playback" view!
  4593. */
  4594. /* .name = "Capture Source", */
  4595. .name = "Input Source",
  4596. .count = 2,
  4597. .info = alc882_mux_enum_info,
  4598. .get = alc882_mux_enum_get,
  4599. .put = alc882_mux_enum_put,
  4600. },
  4601. { } /* end */
  4602. };
  4603. /* pcm configuration: identiacal with ALC880 */
  4604. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4605. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4606. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4607. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4608. /*
  4609. * configuration and preset
  4610. */
  4611. static struct hda_board_config alc883_cfg_tbl[] = {
  4612. { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
  4613. { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
  4614. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4615. .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
  4616. { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
  4617. { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
  4618. .config = ALC883_3ST_6ch },
  4619. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
  4620. .config = ALC883_3ST_6ch }, /* D102GGC */
  4621. { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
  4622. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4623. .config = ALC883_6ST_DIG }, /* MSI */
  4624. { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
  4625. .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
  4626. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4627. .config = ALC883_6ST_DIG }, /* Foxconn */
  4628. { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
  4629. { .modelname = "acer", .config = ALC883_ACER },
  4630. { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
  4631. .config = ALC883_ACER },
  4632. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
  4633. .config = ALC883_ACER },
  4634. { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
  4635. .config = ALC883_ACER },
  4636. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4637. .modelname = "medion", .config = ALC883_MEDION }
  4638. { .modelname = "auto", .config = ALC883_AUTO },
  4639. {}
  4640. };
  4641. static struct alc_config_preset alc883_presets[] = {
  4642. [ALC883_3ST_2ch_DIG] = {
  4643. .mixers = { alc883_3ST_2ch_mixer },
  4644. .init_verbs = { alc883_init_verbs },
  4645. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4646. .dac_nids = alc883_dac_nids,
  4647. .dig_out_nid = ALC883_DIGOUT_NID,
  4648. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4649. .adc_nids = alc883_adc_nids,
  4650. .dig_in_nid = ALC883_DIGIN_NID,
  4651. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4652. .channel_mode = alc883_3ST_2ch_modes,
  4653. .input_mux = &alc883_capture_source,
  4654. },
  4655. [ALC883_3ST_6ch_DIG] = {
  4656. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4657. .init_verbs = { alc883_init_verbs },
  4658. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4659. .dac_nids = alc883_dac_nids,
  4660. .dig_out_nid = ALC883_DIGOUT_NID,
  4661. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4662. .adc_nids = alc883_adc_nids,
  4663. .dig_in_nid = ALC883_DIGIN_NID,
  4664. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4665. .channel_mode = alc883_3ST_6ch_modes,
  4666. .need_dac_fix = 1,
  4667. .input_mux = &alc883_capture_source,
  4668. },
  4669. [ALC883_3ST_6ch] = {
  4670. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4671. .init_verbs = { alc883_init_verbs },
  4672. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4673. .dac_nids = alc883_dac_nids,
  4674. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4675. .adc_nids = alc883_adc_nids,
  4676. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4677. .channel_mode = alc883_3ST_6ch_modes,
  4678. .need_dac_fix = 1,
  4679. .input_mux = &alc883_capture_source,
  4680. },
  4681. [ALC883_6ST_DIG] = {
  4682. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4683. .init_verbs = { alc883_init_verbs },
  4684. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4685. .dac_nids = alc883_dac_nids,
  4686. .dig_out_nid = ALC883_DIGOUT_NID,
  4687. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4688. .adc_nids = alc883_adc_nids,
  4689. .dig_in_nid = ALC883_DIGIN_NID,
  4690. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4691. .channel_mode = alc883_sixstack_modes,
  4692. .input_mux = &alc883_capture_source,
  4693. },
  4694. [ALC888_DEMO_BOARD] = {
  4695. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4696. .init_verbs = { alc883_init_verbs },
  4697. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4698. .dac_nids = alc883_dac_nids,
  4699. .dig_out_nid = ALC883_DIGOUT_NID,
  4700. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4701. .adc_nids = alc883_adc_nids,
  4702. .dig_in_nid = ALC883_DIGIN_NID,
  4703. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4704. .channel_mode = alc883_sixstack_modes,
  4705. .input_mux = &alc883_capture_source,
  4706. },
  4707. [ALC883_ACER] = {
  4708. .mixers = { alc883_base_mixer,
  4709. alc883_chmode_mixer },
  4710. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  4711. * and the headphone jack. Turn this on and rely on the
  4712. * standard mute methods whenever the user wants to turn
  4713. * these outputs off.
  4714. */
  4715. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  4716. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4717. .dac_nids = alc883_dac_nids,
  4718. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4719. .adc_nids = alc883_adc_nids,
  4720. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4721. .channel_mode = alc883_3ST_2ch_modes,
  4722. .input_mux = &alc883_capture_source,
  4723. },
  4724. [ALC883_MEDION] = {
  4725. .mixers = { alc883_fivestack_mixer,
  4726. alc883_chmode_mixer },
  4727. .init_verbs = { alc883_init_verbs,
  4728. alc882_eapd_verbs },
  4729. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4730. .dac_nids = alc883_dac_nids,
  4731. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4732. .adc_nids = alc883_adc_nids,
  4733. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4734. .channel_mode = alc883_sixstack_modes,
  4735. .input_mux = &alc883_capture_source,
  4736. }
  4737. };
  4738. /*
  4739. * BIOS auto configuration
  4740. */
  4741. static void alc883_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 alc883_auto_init_multi_out(struct hda_codec *codec)
  4759. {
  4760. struct alc_spec *spec = codec->spec;
  4761. int i;
  4762. for (i = 0; i <= HDA_SIDE; i++) {
  4763. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4764. if (nid)
  4765. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4766. }
  4767. }
  4768. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  4769. {
  4770. struct alc_spec *spec = codec->spec;
  4771. hda_nid_t pin;
  4772. pin = spec->autocfg.hp_pins[0];
  4773. if (pin) /* connect to front */
  4774. /* use dac 0 */
  4775. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4776. }
  4777. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  4778. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  4779. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  4780. {
  4781. struct alc_spec *spec = codec->spec;
  4782. int i;
  4783. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4784. hda_nid_t nid = spec->autocfg.input_pins[i];
  4785. if (alc883_is_input_pin(nid)) {
  4786. snd_hda_codec_write(codec, nid, 0,
  4787. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4788. (i <= AUTO_PIN_FRONT_MIC ?
  4789. PIN_VREF80 : PIN_IN));
  4790. if (nid != ALC883_PIN_CD_NID)
  4791. snd_hda_codec_write(codec, nid, 0,
  4792. AC_VERB_SET_AMP_GAIN_MUTE,
  4793. AMP_OUT_MUTE);
  4794. }
  4795. }
  4796. }
  4797. /* almost identical with ALC880 parser... */
  4798. static int alc883_parse_auto_config(struct hda_codec *codec)
  4799. {
  4800. struct alc_spec *spec = codec->spec;
  4801. int err = alc880_parse_auto_config(codec);
  4802. if (err < 0)
  4803. return err;
  4804. else if (err > 0)
  4805. /* hack - override the init verbs */
  4806. spec->init_verbs[0] = alc883_auto_init_verbs;
  4807. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  4808. spec->num_mixers++;
  4809. return err;
  4810. }
  4811. /* additional initialization for auto-configuration model */
  4812. static void alc883_auto_init(struct hda_codec *codec)
  4813. {
  4814. alc883_auto_init_multi_out(codec);
  4815. alc883_auto_init_hp_out(codec);
  4816. alc883_auto_init_analog_input(codec);
  4817. }
  4818. static int patch_alc883(struct hda_codec *codec)
  4819. {
  4820. struct alc_spec *spec;
  4821. int err, board_config;
  4822. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4823. if (spec == NULL)
  4824. return -ENOMEM;
  4825. codec->spec = spec;
  4826. board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
  4827. if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
  4828. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  4829. "trying auto-probe from BIOS...\n");
  4830. board_config = ALC883_AUTO;
  4831. }
  4832. if (board_config == ALC883_AUTO) {
  4833. /* automatic parse from the BIOS config */
  4834. err = alc883_parse_auto_config(codec);
  4835. if (err < 0) {
  4836. alc_free(codec);
  4837. return err;
  4838. } else if (! err) {
  4839. printk(KERN_INFO
  4840. "hda_codec: Cannot set up configuration "
  4841. "from BIOS. Using base mode...\n");
  4842. board_config = ALC883_3ST_2ch_DIG;
  4843. }
  4844. }
  4845. if (board_config != ALC883_AUTO)
  4846. setup_preset(spec, &alc883_presets[board_config]);
  4847. spec->stream_name_analog = "ALC883 Analog";
  4848. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  4849. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  4850. spec->stream_name_digital = "ALC883 Digital";
  4851. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  4852. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  4853. if (! spec->adc_nids && spec->input_mux) {
  4854. spec->adc_nids = alc883_adc_nids;
  4855. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  4856. }
  4857. codec->patch_ops = alc_patch_ops;
  4858. if (board_config == ALC883_AUTO)
  4859. spec->init_hook = alc883_auto_init;
  4860. return 0;
  4861. }
  4862. /*
  4863. * ALC262 support
  4864. */
  4865. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  4866. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  4867. #define alc262_dac_nids alc260_dac_nids
  4868. #define alc262_adc_nids alc882_adc_nids
  4869. #define alc262_adc_nids_alt alc882_adc_nids_alt
  4870. #define alc262_modes alc260_modes
  4871. #define alc262_capture_source alc882_capture_source
  4872. static struct snd_kcontrol_new alc262_base_mixer[] = {
  4873. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4874. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4875. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4876. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4877. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4878. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4879. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4880. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4881. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4882. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4883. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4884. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  4885. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  4886. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4887. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4888. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4889. { } /* end */
  4890. };
  4891. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  4892. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4893. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4894. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4895. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4896. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4897. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4898. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4899. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4900. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4901. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4902. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4903. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4904. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4905. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4906. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4907. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  4908. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  4909. { } /* end */
  4910. };
  4911. #define alc262_capture_mixer alc882_capture_mixer
  4912. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  4913. /*
  4914. * generic initialization of ADC, input mixers and output mixers
  4915. */
  4916. static struct hda_verb alc262_init_verbs[] = {
  4917. /*
  4918. * Unmute ADC0-2 and set the default input to mic-in
  4919. */
  4920. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4921. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4922. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4923. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4924. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4925. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4926. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4927. * mixer widget
  4928. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4929. * mic (mic 2)
  4930. */
  4931. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4933. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4934. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4937. /*
  4938. * Set up output mixers (0x0c - 0x0e)
  4939. */
  4940. /* set vol=0 to output mixers */
  4941. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4942. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4943. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4944. /* set up input amps for analog loopback */
  4945. /* Amp Indices: DAC = 0, mixer = 1 */
  4946. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4947. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4948. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4949. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4950. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4951. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4952. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4953. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  4954. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4955. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  4956. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4957. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4958. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4959. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4960. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4961. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4962. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4963. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4964. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4965. /* FIXME: use matrix-type input source selection */
  4966. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4967. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4968. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4969. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4970. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4971. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4972. /* Input mixer2 */
  4973. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4974. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4975. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4976. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4977. /* Input mixer3 */
  4978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4981. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4982. { }
  4983. };
  4984. /*
  4985. * fujitsu model
  4986. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  4987. */
  4988. #define ALC_HP_EVENT 0x37
  4989. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4990. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4991. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4992. {}
  4993. };
  4994. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4995. .num_items = 2,
  4996. .items = {
  4997. { "Mic", 0x0 },
  4998. { "CD", 0x4 },
  4999. },
  5000. };
  5001. static struct hda_input_mux alc262_HP_capture_source = {
  5002. .num_items = 5,
  5003. .items = {
  5004. { "Mic", 0x0 },
  5005. { "Front Mic", 0x3 },
  5006. { "Line", 0x2 },
  5007. { "CD", 0x4 },
  5008. { "AUX IN", 0x6 },
  5009. },
  5010. };
  5011. /* mute/unmute internal speaker according to the hp jack and mute state */
  5012. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5013. {
  5014. struct alc_spec *spec = codec->spec;
  5015. unsigned int mute;
  5016. if (force || ! spec->sense_updated) {
  5017. unsigned int present;
  5018. /* need to execute and sync at first */
  5019. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5020. present = snd_hda_codec_read(codec, 0x14, 0,
  5021. AC_VERB_GET_PIN_SENSE, 0);
  5022. spec->jack_present = (present & 0x80000000) != 0;
  5023. spec->sense_updated = 1;
  5024. }
  5025. if (spec->jack_present) {
  5026. /* mute internal speaker */
  5027. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5028. 0x80, 0x80);
  5029. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5030. 0x80, 0x80);
  5031. } else {
  5032. /* unmute internal speaker if necessary */
  5033. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5034. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5035. 0x80, mute & 0x80);
  5036. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5037. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5038. 0x80, mute & 0x80);
  5039. }
  5040. }
  5041. /* unsolicited event for HP jack sensing */
  5042. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5043. unsigned int res)
  5044. {
  5045. if ((res >> 26) != ALC_HP_EVENT)
  5046. return;
  5047. alc262_fujitsu_automute(codec, 1);
  5048. }
  5049. /* bind volumes of both NID 0x0c and 0x0d */
  5050. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5051. struct snd_ctl_elem_value *ucontrol)
  5052. {
  5053. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5054. long *valp = ucontrol->value.integer.value;
  5055. int change;
  5056. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5057. 0x7f, valp[0] & 0x7f);
  5058. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5059. 0x7f, valp[1] & 0x7f);
  5060. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5061. 0x7f, valp[0] & 0x7f);
  5062. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5063. 0x7f, valp[1] & 0x7f);
  5064. return change;
  5065. }
  5066. /* bind hp and internal speaker mute (with plug check) */
  5067. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5068. struct snd_ctl_elem_value *ucontrol)
  5069. {
  5070. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5071. long *valp = ucontrol->value.integer.value;
  5072. int change;
  5073. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5074. 0x80, valp[0] ? 0 : 0x80);
  5075. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5076. 0x80, valp[1] ? 0 : 0x80);
  5077. if (change || codec->in_resume)
  5078. alc262_fujitsu_automute(codec, codec->in_resume);
  5079. return change;
  5080. }
  5081. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5082. {
  5083. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5084. .name = "Master Playback Volume",
  5085. .info = snd_hda_mixer_amp_volume_info,
  5086. .get = snd_hda_mixer_amp_volume_get,
  5087. .put = alc262_fujitsu_master_vol_put,
  5088. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5089. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5090. },
  5091. {
  5092. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5093. .name = "Master Playback Switch",
  5094. .info = snd_hda_mixer_amp_switch_info,
  5095. .get = snd_hda_mixer_amp_switch_get,
  5096. .put = alc262_fujitsu_master_sw_put,
  5097. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5098. },
  5099. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5100. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5101. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5102. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5103. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5104. { } /* end */
  5105. };
  5106. /* additional init verbs for Benq laptops */
  5107. static struct hda_verb alc262_EAPD_verbs[] = {
  5108. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5109. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5110. {}
  5111. };
  5112. /* add playback controls from the parsed DAC table */
  5113. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5114. {
  5115. hda_nid_t nid;
  5116. int err;
  5117. spec->multiout.num_dacs = 1; /* only use one dac */
  5118. spec->multiout.dac_nids = spec->private_dac_nids;
  5119. spec->multiout.dac_nids[0] = 2;
  5120. nid = cfg->line_out_pins[0];
  5121. if (nid) {
  5122. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5123. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5124. return err;
  5125. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5126. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5127. return err;
  5128. }
  5129. nid = cfg->speaker_pins[0];
  5130. if (nid) {
  5131. if (nid == 0x16) {
  5132. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5133. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5134. return err;
  5135. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5136. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5137. return err;
  5138. } else {
  5139. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5140. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5141. return err;
  5142. }
  5143. }
  5144. nid = cfg->hp_pins[0];
  5145. if (nid) {
  5146. /* spec->multiout.hp_nid = 2; */
  5147. if (nid == 0x16) {
  5148. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5149. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5150. return err;
  5151. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5152. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5153. return err;
  5154. } else {
  5155. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5156. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5157. return err;
  5158. }
  5159. }
  5160. return 0;
  5161. }
  5162. /* identical with ALC880 */
  5163. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5164. /*
  5165. * generic initialization of ADC, input mixers and output mixers
  5166. */
  5167. static struct hda_verb alc262_volume_init_verbs[] = {
  5168. /*
  5169. * Unmute ADC0-2 and set the default input to mic-in
  5170. */
  5171. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5172. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5173. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5174. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5175. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5176. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5177. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5178. * mixer widget
  5179. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5180. * mic (mic 2)
  5181. */
  5182. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5183. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5184. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5185. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5186. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5187. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5188. /*
  5189. * Set up output mixers (0x0c - 0x0f)
  5190. */
  5191. /* set vol=0 to output mixers */
  5192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5195. /* set up input amps for analog loopback */
  5196. /* Amp Indices: DAC = 0, mixer = 1 */
  5197. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5198. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5199. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5200. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5201. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5202. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5203. /* FIXME: use matrix-type input source selection */
  5204. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5205. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5206. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5207. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5208. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5209. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5210. /* Input mixer2 */
  5211. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5212. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5213. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5214. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5215. /* Input mixer3 */
  5216. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5217. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5218. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5219. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5220. { }
  5221. };
  5222. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5223. /*
  5224. * Unmute ADC0-2 and set the default input to mic-in
  5225. */
  5226. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5227. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5228. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5229. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5230. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5231. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5232. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5233. * mixer widget
  5234. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5235. * mic (mic 2)
  5236. */
  5237. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5238. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5239. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5240. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5241. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5242. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5243. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5244. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5245. /*
  5246. * Set up output mixers (0x0c - 0x0e)
  5247. */
  5248. /* set vol=0 to output mixers */
  5249. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5250. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5251. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5252. /* set up input amps for analog loopback */
  5253. /* Amp Indices: DAC = 0, mixer = 1 */
  5254. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5255. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5256. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5257. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5258. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5259. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5260. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5261. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5262. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5263. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5264. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5265. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5266. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5267. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5268. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5269. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5270. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5272. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5273. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5274. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5275. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5276. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5277. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5278. /* FIXME: use matrix-type input source selection */
  5279. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5280. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5281. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5282. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5283. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5284. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5285. /* Input mixer2 */
  5286. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5287. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5288. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5289. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5290. /* Input mixer3 */
  5291. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5292. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5293. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5294. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5295. { }
  5296. };
  5297. /* pcm configuration: identiacal with ALC880 */
  5298. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5299. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5300. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5301. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5302. /*
  5303. * BIOS auto configuration
  5304. */
  5305. static int alc262_parse_auto_config(struct hda_codec *codec)
  5306. {
  5307. struct alc_spec *spec = codec->spec;
  5308. int err;
  5309. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5310. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5311. alc262_ignore)) < 0)
  5312. return err;
  5313. if (! spec->autocfg.line_outs)
  5314. return 0; /* can't find valid BIOS pin config */
  5315. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5316. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5317. return err;
  5318. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5319. if (spec->autocfg.dig_out_pin)
  5320. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5321. if (spec->autocfg.dig_in_pin)
  5322. spec->dig_in_nid = ALC262_DIGIN_NID;
  5323. if (spec->kctl_alloc)
  5324. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5325. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5326. spec->num_mux_defs = 1;
  5327. spec->input_mux = &spec->private_imux;
  5328. return 1;
  5329. }
  5330. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5331. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5332. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5333. /* init callback for auto-configuration model -- overriding the default init */
  5334. static void alc262_auto_init(struct hda_codec *codec)
  5335. {
  5336. alc262_auto_init_multi_out(codec);
  5337. alc262_auto_init_hp_out(codec);
  5338. alc262_auto_init_analog_input(codec);
  5339. }
  5340. /*
  5341. * configuration and preset
  5342. */
  5343. static struct hda_board_config alc262_cfg_tbl[] = {
  5344. { .modelname = "basic", .config = ALC262_BASIC },
  5345. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  5346. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
  5347. .config = ALC262_FUJITSU },
  5348. { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
  5349. { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
  5350. .config = ALC262_HP_BPC }, /* xw4400 */
  5351. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
  5352. .config = ALC262_HP_BPC }, /* q965 */
  5353. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
  5354. .config = ALC262_HP_BPC }, /* xw6400 */
  5355. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
  5356. .config = ALC262_HP_BPC }, /* xw8400 */
  5357. { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
  5358. .config = ALC262_HP_BPC }, /* xw9400 */
  5359. { .modelname = "benq", .config = ALC262_BENQ_ED8 },
  5360. { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
  5361. .config = ALC262_BENQ_ED8 },
  5362. { .modelname = "auto", .config = ALC262_AUTO },
  5363. {}
  5364. };
  5365. static struct alc_config_preset alc262_presets[] = {
  5366. [ALC262_BASIC] = {
  5367. .mixers = { alc262_base_mixer },
  5368. .init_verbs = { alc262_init_verbs },
  5369. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5370. .dac_nids = alc262_dac_nids,
  5371. .hp_nid = 0x03,
  5372. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5373. .channel_mode = alc262_modes,
  5374. .input_mux = &alc262_capture_source,
  5375. },
  5376. [ALC262_FUJITSU] = {
  5377. .mixers = { alc262_fujitsu_mixer },
  5378. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5379. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5380. .dac_nids = alc262_dac_nids,
  5381. .hp_nid = 0x03,
  5382. .dig_out_nid = ALC262_DIGOUT_NID,
  5383. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5384. .channel_mode = alc262_modes,
  5385. .input_mux = &alc262_fujitsu_capture_source,
  5386. .unsol_event = alc262_fujitsu_unsol_event,
  5387. },
  5388. [ALC262_HP_BPC] = {
  5389. .mixers = { alc262_HP_BPC_mixer },
  5390. .init_verbs = { alc262_HP_BPC_init_verbs },
  5391. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5392. .dac_nids = alc262_dac_nids,
  5393. .hp_nid = 0x03,
  5394. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5395. .channel_mode = alc262_modes,
  5396. .input_mux = &alc262_HP_capture_source,
  5397. },
  5398. [ALC262_BENQ_ED8] = {
  5399. .mixers = { alc262_base_mixer },
  5400. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5401. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5402. .dac_nids = alc262_dac_nids,
  5403. .hp_nid = 0x03,
  5404. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5405. .channel_mode = alc262_modes,
  5406. .input_mux = &alc262_capture_source,
  5407. },
  5408. };
  5409. static int patch_alc262(struct hda_codec *codec)
  5410. {
  5411. struct alc_spec *spec;
  5412. int board_config;
  5413. int err;
  5414. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  5415. if (spec == NULL)
  5416. return -ENOMEM;
  5417. codec->spec = spec;
  5418. #if 0
  5419. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5420. {
  5421. int tmp;
  5422. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5423. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5424. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5425. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5426. }
  5427. #endif
  5428. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  5429. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  5430. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5431. "trying auto-probe from BIOS...\n");
  5432. board_config = ALC262_AUTO;
  5433. }
  5434. if (board_config == ALC262_AUTO) {
  5435. /* automatic parse from the BIOS config */
  5436. err = alc262_parse_auto_config(codec);
  5437. if (err < 0) {
  5438. alc_free(codec);
  5439. return err;
  5440. } else if (! err) {
  5441. printk(KERN_INFO
  5442. "hda_codec: Cannot set up configuration "
  5443. "from BIOS. Using base mode...\n");
  5444. board_config = ALC262_BASIC;
  5445. }
  5446. }
  5447. if (board_config != ALC262_AUTO)
  5448. setup_preset(spec, &alc262_presets[board_config]);
  5449. spec->stream_name_analog = "ALC262 Analog";
  5450. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5451. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5452. spec->stream_name_digital = "ALC262 Digital";
  5453. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  5454. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  5455. if (! spec->adc_nids && spec->input_mux) {
  5456. /* check whether NID 0x07 is valid */
  5457. unsigned int wcap = get_wcaps(codec, 0x07);
  5458. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  5459. if (wcap != AC_WID_AUD_IN) {
  5460. spec->adc_nids = alc262_adc_nids_alt;
  5461. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  5462. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  5463. spec->num_mixers++;
  5464. } else {
  5465. spec->adc_nids = alc262_adc_nids;
  5466. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  5467. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  5468. spec->num_mixers++;
  5469. }
  5470. }
  5471. codec->patch_ops = alc_patch_ops;
  5472. if (board_config == ALC262_AUTO)
  5473. spec->init_hook = alc262_auto_init;
  5474. return 0;
  5475. }
  5476. /*
  5477. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  5478. */
  5479. /*
  5480. * set the path ways for 2 channel output
  5481. * need to set the codec line out and mic 1 pin widgets to inputs
  5482. */
  5483. static struct hda_verb alc861_threestack_ch2_init[] = {
  5484. /* set pin widget 1Ah (line in) for input */
  5485. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5486. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  5487. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5488. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  5489. #if 0
  5490. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5491. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  5492. #endif
  5493. { } /* end */
  5494. };
  5495. /*
  5496. * 6ch mode
  5497. * need to set the codec line out and mic 1 pin widgets to outputs
  5498. */
  5499. static struct hda_verb alc861_threestack_ch6_init[] = {
  5500. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  5501. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5502. /* set pin widget 18h (mic1) for output (CLFE)*/
  5503. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5504. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5505. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5506. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  5507. #if 0
  5508. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5509. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  5510. #endif
  5511. { } /* end */
  5512. };
  5513. static struct hda_channel_mode alc861_threestack_modes[2] = {
  5514. { 2, alc861_threestack_ch2_init },
  5515. { 6, alc861_threestack_ch6_init },
  5516. };
  5517. /* Set mic1 as input and unmute the mixer */
  5518. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  5519. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5520. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5521. { } /* end */
  5522. };
  5523. /* Set mic1 as output and mute mixer */
  5524. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  5525. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5526. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5527. { } /* end */
  5528. };
  5529. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  5530. { 2, alc861_uniwill_m31_ch2_init },
  5531. { 4, alc861_uniwill_m31_ch4_init },
  5532. };
  5533. /* patch-ALC861 */
  5534. static struct snd_kcontrol_new alc861_base_mixer[] = {
  5535. /* output mixer control */
  5536. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5537. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5538. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5539. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5540. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  5541. /*Input mixer control */
  5542. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5543. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5544. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5545. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5546. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5547. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5548. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5549. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5550. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5551. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5552. /* Capture mixer control */
  5553. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5554. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5555. {
  5556. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5557. .name = "Capture Source",
  5558. .count = 1,
  5559. .info = alc_mux_enum_info,
  5560. .get = alc_mux_enum_get,
  5561. .put = alc_mux_enum_put,
  5562. },
  5563. { } /* end */
  5564. };
  5565. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  5566. /* output mixer control */
  5567. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5568. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5569. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5570. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5571. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5572. /* Input mixer control */
  5573. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5574. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5575. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5576. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5577. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5578. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5579. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5580. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5581. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5582. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5583. /* Capture mixer control */
  5584. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5585. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5586. {
  5587. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5588. .name = "Capture Source",
  5589. .count = 1,
  5590. .info = alc_mux_enum_info,
  5591. .get = alc_mux_enum_get,
  5592. .put = alc_mux_enum_put,
  5593. },
  5594. {
  5595. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5596. .name = "Channel Mode",
  5597. .info = alc_ch_mode_info,
  5598. .get = alc_ch_mode_get,
  5599. .put = alc_ch_mode_put,
  5600. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  5601. },
  5602. { } /* end */
  5603. };
  5604. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  5605. /* output mixer control */
  5606. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5607. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5608. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5609. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5610. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5611. /* Input mixer control */
  5612. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5613. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5614. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5615. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5616. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5617. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5619. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5620. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5621. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5622. /* Capture mixer control */
  5623. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5624. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5625. {
  5626. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5627. .name = "Capture Source",
  5628. .count = 1,
  5629. .info = alc_mux_enum_info,
  5630. .get = alc_mux_enum_get,
  5631. .put = alc_mux_enum_put,
  5632. },
  5633. {
  5634. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5635. .name = "Channel Mode",
  5636. .info = alc_ch_mode_info,
  5637. .get = alc_ch_mode_get,
  5638. .put = alc_ch_mode_put,
  5639. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  5640. },
  5641. { } /* end */
  5642. };
  5643. /*
  5644. * generic initialization of ADC, input mixers and output mixers
  5645. */
  5646. static struct hda_verb alc861_base_init_verbs[] = {
  5647. /*
  5648. * Unmute ADC0 and set the default input to mic-in
  5649. */
  5650. /* port-A for surround (rear panel) */
  5651. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5652. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5653. /* port-B for mic-in (rear panel) with vref */
  5654. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5655. /* port-C for line-in (rear panel) */
  5656. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5657. /* port-D for Front */
  5658. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5659. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5660. /* port-E for HP out (front panel) */
  5661. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5662. /* route front PCM to HP */
  5663. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5664. /* port-F for mic-in (front panel) with vref */
  5665. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5666. /* port-G for CLFE (rear panel) */
  5667. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5668. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5669. /* port-H for side (rear panel) */
  5670. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5671. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5672. /* CD-in */
  5673. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5674. /* route front mic to ADC1*/
  5675. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5677. /* Unmute DAC0~3 & spdif out*/
  5678. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5679. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5680. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5681. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5682. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5683. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5684. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5685. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5686. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5687. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5688. /* Unmute Stereo Mixer 15 */
  5689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5690. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5691. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5692. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5693. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5695. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5696. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5698. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5699. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5700. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5701. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5702. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5703. { }
  5704. };
  5705. static struct hda_verb alc861_threestack_init_verbs[] = {
  5706. /*
  5707. * Unmute ADC0 and set the default input to mic-in
  5708. */
  5709. /* port-A for surround (rear panel) */
  5710. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5711. /* port-B for mic-in (rear panel) with vref */
  5712. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5713. /* port-C for line-in (rear panel) */
  5714. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5715. /* port-D for Front */
  5716. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5717. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5718. /* port-E for HP out (front panel) */
  5719. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5720. /* route front PCM to HP */
  5721. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5722. /* port-F for mic-in (front panel) with vref */
  5723. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5724. /* port-G for CLFE (rear panel) */
  5725. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5726. /* port-H for side (rear panel) */
  5727. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5728. /* CD-in */
  5729. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5730. /* route front mic to ADC1*/
  5731. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5733. /* Unmute DAC0~3 & spdif out*/
  5734. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5735. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5736. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5737. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5738. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5739. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5740. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5741. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5742. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5743. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5744. /* Unmute Stereo Mixer 15 */
  5745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5748. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5750. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5751. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5752. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5753. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5754. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5755. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5756. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5758. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5759. { }
  5760. };
  5761. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  5762. /*
  5763. * Unmute ADC0 and set the default input to mic-in
  5764. */
  5765. /* port-A for surround (rear panel) */
  5766. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5767. /* port-B for mic-in (rear panel) with vref */
  5768. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5769. /* port-C for line-in (rear panel) */
  5770. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5771. /* port-D for Front */
  5772. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5773. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5774. /* port-E for HP out (front panel) */
  5775. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  5776. /* route front PCM to HP */
  5777. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5778. /* port-F for mic-in (front panel) with vref */
  5779. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5780. /* port-G for CLFE (rear panel) */
  5781. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5782. /* port-H for side (rear panel) */
  5783. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5784. /* CD-in */
  5785. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5786. /* route front mic to ADC1*/
  5787. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5788. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5789. /* Unmute DAC0~3 & spdif out*/
  5790. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5791. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5792. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5793. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5795. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5796. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5797. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5798. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5799. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5800. /* Unmute Stereo Mixer 15 */
  5801. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5802. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5804. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5805. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5806. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5807. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5808. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5809. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5810. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5811. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5812. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5813. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5814. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5815. { }
  5816. };
  5817. /*
  5818. * generic initialization of ADC, input mixers and output mixers
  5819. */
  5820. static struct hda_verb alc861_auto_init_verbs[] = {
  5821. /*
  5822. * Unmute ADC0 and set the default input to mic-in
  5823. */
  5824. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5825. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5826. /* Unmute DAC0~3 & spdif out*/
  5827. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5828. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5829. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5830. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5831. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5832. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5833. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5834. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5835. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5836. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5837. /* Unmute Stereo Mixer 15 */
  5838. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5839. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5840. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5841. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  5842. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5843. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5844. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5845. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5846. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5847. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5848. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5849. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5850. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5851. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5852. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5853. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5854. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5855. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5856. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5857. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5858. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  5859. { }
  5860. };
  5861. /* pcm configuration: identiacal with ALC880 */
  5862. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  5863. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  5864. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  5865. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  5866. #define ALC861_DIGOUT_NID 0x07
  5867. static struct hda_channel_mode alc861_8ch_modes[1] = {
  5868. { 8, NULL }
  5869. };
  5870. static hda_nid_t alc861_dac_nids[4] = {
  5871. /* front, surround, clfe, side */
  5872. 0x03, 0x06, 0x05, 0x04
  5873. };
  5874. static hda_nid_t alc660_dac_nids[3] = {
  5875. /* front, clfe, surround */
  5876. 0x03, 0x05, 0x06
  5877. };
  5878. static hda_nid_t alc861_adc_nids[1] = {
  5879. /* ADC0-2 */
  5880. 0x08,
  5881. };
  5882. static struct hda_input_mux alc861_capture_source = {
  5883. .num_items = 5,
  5884. .items = {
  5885. { "Mic", 0x0 },
  5886. { "Front Mic", 0x3 },
  5887. { "Line", 0x1 },
  5888. { "CD", 0x4 },
  5889. { "Mixer", 0x5 },
  5890. },
  5891. };
  5892. /* fill in the dac_nids table from the parsed pin configuration */
  5893. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5894. {
  5895. int i;
  5896. hda_nid_t nid;
  5897. spec->multiout.dac_nids = spec->private_dac_nids;
  5898. for (i = 0; i < cfg->line_outs; i++) {
  5899. nid = cfg->line_out_pins[i];
  5900. if (nid) {
  5901. if (i >= ARRAY_SIZE(alc861_dac_nids))
  5902. continue;
  5903. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  5904. }
  5905. }
  5906. spec->multiout.num_dacs = cfg->line_outs;
  5907. return 0;
  5908. }
  5909. /* add playback controls from the parsed DAC table */
  5910. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  5911. const struct auto_pin_cfg *cfg)
  5912. {
  5913. char name[32];
  5914. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  5915. hda_nid_t nid;
  5916. int i, idx, err;
  5917. for (i = 0; i < cfg->line_outs; i++) {
  5918. nid = spec->multiout.dac_nids[i];
  5919. if (! nid)
  5920. continue;
  5921. if (nid == 0x05) {
  5922. /* Center/LFE */
  5923. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  5924. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  5925. return err;
  5926. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  5927. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5928. return err;
  5929. } else {
  5930. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  5931. if (nid == alc861_dac_nids[idx])
  5932. break;
  5933. sprintf(name, "%s Playback Switch", chname[idx]);
  5934. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  5935. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5936. return err;
  5937. }
  5938. }
  5939. return 0;
  5940. }
  5941. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  5942. {
  5943. int err;
  5944. hda_nid_t nid;
  5945. if (! pin)
  5946. return 0;
  5947. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  5948. nid = 0x03;
  5949. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5950. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5951. return err;
  5952. spec->multiout.hp_nid = nid;
  5953. }
  5954. return 0;
  5955. }
  5956. /* create playback/capture controls for input pins */
  5957. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5958. {
  5959. struct hda_input_mux *imux = &spec->private_imux;
  5960. int i, err, idx, idx1;
  5961. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5962. switch(cfg->input_pins[i]) {
  5963. case 0x0c:
  5964. idx1 = 1;
  5965. idx = 2; // Line In
  5966. break;
  5967. case 0x0f:
  5968. idx1 = 2;
  5969. idx = 2; // Line In
  5970. break;
  5971. case 0x0d:
  5972. idx1 = 0;
  5973. idx = 1; // Mic In
  5974. break;
  5975. case 0x10:
  5976. idx1 = 3;
  5977. idx = 1; // Mic In
  5978. break;
  5979. case 0x11:
  5980. idx1 = 4;
  5981. idx = 0; // CD
  5982. break;
  5983. default:
  5984. continue;
  5985. }
  5986. err = new_analog_input(spec, cfg->input_pins[i],
  5987. auto_pin_cfg_labels[i], idx, 0x15);
  5988. if (err < 0)
  5989. return err;
  5990. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  5991. imux->items[imux->num_items].index = idx1;
  5992. imux->num_items++;
  5993. }
  5994. return 0;
  5995. }
  5996. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  5997. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5998. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5999. {
  6000. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6001. /* The multiple "Capture Source" controls confuse alsamixer
  6002. * So call somewhat different..
  6003. *FIXME: the controls appear in the "playback" view!
  6004. */
  6005. /* .name = "Capture Source", */
  6006. .name = "Input Source",
  6007. .count = 1,
  6008. .info = alc_mux_enum_info,
  6009. .get = alc_mux_enum_get,
  6010. .put = alc_mux_enum_put,
  6011. },
  6012. { } /* end */
  6013. };
  6014. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6015. int pin_type, int dac_idx)
  6016. {
  6017. /* set as output */
  6018. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6019. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6020. }
  6021. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6022. {
  6023. struct alc_spec *spec = codec->spec;
  6024. int i;
  6025. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6026. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6027. if (nid)
  6028. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6029. }
  6030. }
  6031. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6032. {
  6033. struct alc_spec *spec = codec->spec;
  6034. hda_nid_t pin;
  6035. pin = spec->autocfg.hp_pins[0];
  6036. if (pin) /* connect to front */
  6037. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6038. }
  6039. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6040. {
  6041. struct alc_spec *spec = codec->spec;
  6042. int i;
  6043. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6044. hda_nid_t nid = spec->autocfg.input_pins[i];
  6045. if ((nid>=0x0c) && (nid <=0x11)) {
  6046. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6047. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6048. }
  6049. }
  6050. }
  6051. /* parse the BIOS configuration and set up the alc_spec */
  6052. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6053. static int alc861_parse_auto_config(struct hda_codec *codec)
  6054. {
  6055. struct alc_spec *spec = codec->spec;
  6056. int err;
  6057. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6058. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6059. alc861_ignore)) < 0)
  6060. return err;
  6061. if (! spec->autocfg.line_outs)
  6062. return 0; /* can't find valid BIOS pin config */
  6063. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6064. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6065. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6066. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6067. return err;
  6068. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6069. if (spec->autocfg.dig_out_pin)
  6070. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6071. if (spec->kctl_alloc)
  6072. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6073. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6074. spec->num_mux_defs = 1;
  6075. spec->input_mux = &spec->private_imux;
  6076. spec->adc_nids = alc861_adc_nids;
  6077. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6078. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6079. spec->num_mixers++;
  6080. return 1;
  6081. }
  6082. /* additional initialization for auto-configuration model */
  6083. static void alc861_auto_init(struct hda_codec *codec)
  6084. {
  6085. alc861_auto_init_multi_out(codec);
  6086. alc861_auto_init_hp_out(codec);
  6087. alc861_auto_init_analog_input(codec);
  6088. }
  6089. /*
  6090. * configuration and preset
  6091. */
  6092. static struct hda_board_config alc861_cfg_tbl[] = {
  6093. { .modelname = "3stack", .config = ALC861_3ST },
  6094. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
  6095. .config = ALC861_3ST },
  6096. { .modelname = "3stack-660", .config = ALC660_3ST },
  6097. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
  6098. .config = ALC660_3ST },
  6099. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  6100. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  6101. { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
  6102. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
  6103. .config = ALC861_UNIWILL_M31 },
  6104. { .modelname = "auto", .config = ALC861_AUTO },
  6105. {}
  6106. };
  6107. static struct alc_config_preset alc861_presets[] = {
  6108. [ALC861_3ST] = {
  6109. .mixers = { alc861_3ST_mixer },
  6110. .init_verbs = { alc861_threestack_init_verbs },
  6111. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6112. .dac_nids = alc861_dac_nids,
  6113. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6114. .channel_mode = alc861_threestack_modes,
  6115. .need_dac_fix = 1,
  6116. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6117. .adc_nids = alc861_adc_nids,
  6118. .input_mux = &alc861_capture_source,
  6119. },
  6120. [ALC861_3ST_DIG] = {
  6121. .mixers = { alc861_base_mixer },
  6122. .init_verbs = { alc861_threestack_init_verbs },
  6123. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6124. .dac_nids = alc861_dac_nids,
  6125. .dig_out_nid = ALC861_DIGOUT_NID,
  6126. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6127. .channel_mode = alc861_threestack_modes,
  6128. .need_dac_fix = 1,
  6129. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6130. .adc_nids = alc861_adc_nids,
  6131. .input_mux = &alc861_capture_source,
  6132. },
  6133. [ALC861_6ST_DIG] = {
  6134. .mixers = { alc861_base_mixer },
  6135. .init_verbs = { alc861_base_init_verbs },
  6136. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6137. .dac_nids = alc861_dac_nids,
  6138. .dig_out_nid = ALC861_DIGOUT_NID,
  6139. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6140. .channel_mode = alc861_8ch_modes,
  6141. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6142. .adc_nids = alc861_adc_nids,
  6143. .input_mux = &alc861_capture_source,
  6144. },
  6145. [ALC660_3ST] = {
  6146. .mixers = { alc861_3ST_mixer },
  6147. .init_verbs = { alc861_threestack_init_verbs },
  6148. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6149. .dac_nids = alc660_dac_nids,
  6150. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6151. .channel_mode = alc861_threestack_modes,
  6152. .need_dac_fix = 1,
  6153. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6154. .adc_nids = alc861_adc_nids,
  6155. .input_mux = &alc861_capture_source,
  6156. },
  6157. [ALC861_UNIWILL_M31] = {
  6158. .mixers = { alc861_uniwill_m31_mixer },
  6159. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6160. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6161. .dac_nids = alc861_dac_nids,
  6162. .dig_out_nid = ALC861_DIGOUT_NID,
  6163. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6164. .channel_mode = alc861_uniwill_m31_modes,
  6165. .need_dac_fix = 1,
  6166. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6167. .adc_nids = alc861_adc_nids,
  6168. .input_mux = &alc861_capture_source,
  6169. },
  6170. };
  6171. static int patch_alc861(struct hda_codec *codec)
  6172. {
  6173. struct alc_spec *spec;
  6174. int board_config;
  6175. int err;
  6176. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  6177. if (spec == NULL)
  6178. return -ENOMEM;
  6179. codec->spec = spec;
  6180. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  6181. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  6182. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6183. "trying auto-probe from BIOS...\n");
  6184. board_config = ALC861_AUTO;
  6185. }
  6186. if (board_config == ALC861_AUTO) {
  6187. /* automatic parse from the BIOS config */
  6188. err = alc861_parse_auto_config(codec);
  6189. if (err < 0) {
  6190. alc_free(codec);
  6191. return err;
  6192. } else if (! err) {
  6193. printk(KERN_INFO
  6194. "hda_codec: Cannot set up configuration "
  6195. "from BIOS. Using base mode...\n");
  6196. board_config = ALC861_3ST_DIG;
  6197. }
  6198. }
  6199. if (board_config != ALC861_AUTO)
  6200. setup_preset(spec, &alc861_presets[board_config]);
  6201. spec->stream_name_analog = "ALC861 Analog";
  6202. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6203. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6204. spec->stream_name_digital = "ALC861 Digital";
  6205. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6206. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6207. codec->patch_ops = alc_patch_ops;
  6208. if (board_config == ALC861_AUTO)
  6209. spec->init_hook = alc861_auto_init;
  6210. return 0;
  6211. }
  6212. /*
  6213. * patch entries
  6214. */
  6215. struct hda_codec_preset snd_hda_preset_realtek[] = {
  6216. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  6217. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  6218. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  6219. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  6220. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  6221. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  6222. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  6223. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  6224. .patch = patch_alc861 },
  6225. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  6226. .patch = patch_alc861 },
  6227. {} /* terminator */
  6228. };