patch_realtek.c 233 KB

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