patch_realtek.c 233 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856
  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. /* SPDIF for stream index #1 */
  1599. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1600. codec->num_pcms = 2;
  1601. info++;
  1602. info->name = spec->stream_name_digital;
  1603. if (spec->multiout.dig_out_nid &&
  1604. spec->stream_digital_playback) {
  1605. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1606. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1607. }
  1608. if (spec->dig_in_nid &&
  1609. spec->stream_digital_capture) {
  1610. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1611. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1612. }
  1613. }
  1614. /* If the use of more than one ADC is requested for the current
  1615. * model, configure a second analog capture-only PCM.
  1616. */
  1617. /* Additional Analaog capture for index #2 */
  1618. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1619. spec->adc_nids) {
  1620. codec->num_pcms = 3;
  1621. info++;
  1622. info->name = spec->stream_name_analog;
  1623. /* No playback stream for second PCM */
  1624. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1625. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1626. if (spec->stream_analog_capture) {
  1627. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1628. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1629. }
  1630. }
  1631. return 0;
  1632. }
  1633. static void alc_free(struct hda_codec *codec)
  1634. {
  1635. struct alc_spec *spec = codec->spec;
  1636. unsigned int i;
  1637. if (! spec)
  1638. return;
  1639. if (spec->kctl_alloc) {
  1640. for (i = 0; i < spec->num_kctl_used; i++)
  1641. kfree(spec->kctl_alloc[i].name);
  1642. kfree(spec->kctl_alloc);
  1643. }
  1644. kfree(spec);
  1645. }
  1646. /*
  1647. */
  1648. static struct hda_codec_ops alc_patch_ops = {
  1649. .build_controls = alc_build_controls,
  1650. .build_pcms = alc_build_pcms,
  1651. .init = alc_init,
  1652. .free = alc_free,
  1653. .unsol_event = alc_unsol_event,
  1654. #ifdef CONFIG_PM
  1655. .resume = alc_resume,
  1656. #endif
  1657. };
  1658. /*
  1659. * Test configuration for debugging
  1660. *
  1661. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1662. * enum controls.
  1663. */
  1664. #ifdef CONFIG_SND_DEBUG
  1665. static hda_nid_t alc880_test_dac_nids[4] = {
  1666. 0x02, 0x03, 0x04, 0x05
  1667. };
  1668. static struct hda_input_mux alc880_test_capture_source = {
  1669. .num_items = 7,
  1670. .items = {
  1671. { "In-1", 0x0 },
  1672. { "In-2", 0x1 },
  1673. { "In-3", 0x2 },
  1674. { "In-4", 0x3 },
  1675. { "CD", 0x4 },
  1676. { "Front", 0x5 },
  1677. { "Surround", 0x6 },
  1678. },
  1679. };
  1680. static struct hda_channel_mode alc880_test_modes[4] = {
  1681. { 2, NULL },
  1682. { 4, NULL },
  1683. { 6, NULL },
  1684. { 8, NULL },
  1685. };
  1686. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1687. struct snd_ctl_elem_info *uinfo)
  1688. {
  1689. static char *texts[] = {
  1690. "N/A", "Line Out", "HP Out",
  1691. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1692. };
  1693. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1694. uinfo->count = 1;
  1695. uinfo->value.enumerated.items = 8;
  1696. if (uinfo->value.enumerated.item >= 8)
  1697. uinfo->value.enumerated.item = 7;
  1698. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1699. return 0;
  1700. }
  1701. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1702. struct snd_ctl_elem_value *ucontrol)
  1703. {
  1704. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1705. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1706. unsigned int pin_ctl, item = 0;
  1707. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1708. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1709. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1710. if (pin_ctl & AC_PINCTL_HP_EN)
  1711. item = 2;
  1712. else
  1713. item = 1;
  1714. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1715. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1716. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1717. case AC_PINCTL_VREF_50: item = 4; break;
  1718. case AC_PINCTL_VREF_GRD: item = 5; break;
  1719. case AC_PINCTL_VREF_80: item = 6; break;
  1720. case AC_PINCTL_VREF_100: item = 7; break;
  1721. }
  1722. }
  1723. ucontrol->value.enumerated.item[0] = item;
  1724. return 0;
  1725. }
  1726. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1727. struct snd_ctl_elem_value *ucontrol)
  1728. {
  1729. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1730. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1731. static unsigned int ctls[] = {
  1732. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1733. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1734. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1735. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1736. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1737. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1738. };
  1739. unsigned int old_ctl, new_ctl;
  1740. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1741. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1742. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1743. if (old_ctl != new_ctl) {
  1744. snd_hda_codec_write(codec, nid, 0,
  1745. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1746. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1747. (ucontrol->value.enumerated.item[0] >= 3 ?
  1748. 0xb080 : 0xb000));
  1749. return 1;
  1750. }
  1751. return 0;
  1752. }
  1753. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1754. struct snd_ctl_elem_info *uinfo)
  1755. {
  1756. static char *texts[] = {
  1757. "Front", "Surround", "CLFE", "Side"
  1758. };
  1759. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1760. uinfo->count = 1;
  1761. uinfo->value.enumerated.items = 4;
  1762. if (uinfo->value.enumerated.item >= 4)
  1763. uinfo->value.enumerated.item = 3;
  1764. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1765. return 0;
  1766. }
  1767. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1768. struct snd_ctl_elem_value *ucontrol)
  1769. {
  1770. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1771. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1772. unsigned int sel;
  1773. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1774. ucontrol->value.enumerated.item[0] = sel & 3;
  1775. return 0;
  1776. }
  1777. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1778. struct snd_ctl_elem_value *ucontrol)
  1779. {
  1780. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1781. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1782. unsigned int sel;
  1783. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1784. if (ucontrol->value.enumerated.item[0] != sel) {
  1785. sel = ucontrol->value.enumerated.item[0] & 3;
  1786. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1787. return 1;
  1788. }
  1789. return 0;
  1790. }
  1791. #define PIN_CTL_TEST(xname,nid) { \
  1792. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1793. .name = xname, \
  1794. .info = alc_test_pin_ctl_info, \
  1795. .get = alc_test_pin_ctl_get, \
  1796. .put = alc_test_pin_ctl_put, \
  1797. .private_value = nid \
  1798. }
  1799. #define PIN_SRC_TEST(xname,nid) { \
  1800. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1801. .name = xname, \
  1802. .info = alc_test_pin_src_info, \
  1803. .get = alc_test_pin_src_get, \
  1804. .put = alc_test_pin_src_put, \
  1805. .private_value = nid \
  1806. }
  1807. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1808. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1809. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1810. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1811. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1812. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1813. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1814. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1815. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1816. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1817. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1818. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1819. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1820. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1821. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1822. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1823. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1824. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1825. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1826. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1827. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1828. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1829. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1830. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1831. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1832. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1833. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1834. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1835. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1836. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1837. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1838. {
  1839. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1840. .name = "Channel Mode",
  1841. .info = alc_ch_mode_info,
  1842. .get = alc_ch_mode_get,
  1843. .put = alc_ch_mode_put,
  1844. },
  1845. { } /* end */
  1846. };
  1847. static struct hda_verb alc880_test_init_verbs[] = {
  1848. /* Unmute inputs of 0x0c - 0x0f */
  1849. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1850. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1851. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1852. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1853. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1854. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1855. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1856. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1857. /* Vol output for 0x0c-0x0f */
  1858. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1859. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1860. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1861. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1862. /* Set output pins 0x14-0x17 */
  1863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1864. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1866. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1867. /* Unmute output pins 0x14-0x17 */
  1868. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1869. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1870. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1871. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1872. /* Set input pins 0x18-0x1c */
  1873. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1874. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1875. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1876. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1877. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1878. /* Mute input pins 0x18-0x1b */
  1879. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1880. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1881. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1882. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1883. /* ADC set up */
  1884. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1885. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1886. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1887. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1888. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1889. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1890. /* Analog input/passthru */
  1891. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1892. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1893. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1894. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1895. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1896. { }
  1897. };
  1898. #endif
  1899. /*
  1900. */
  1901. static struct hda_board_config alc880_cfg_tbl[] = {
  1902. /* Back 3 jack, front 2 jack */
  1903. { .modelname = "3stack", .config = ALC880_3ST },
  1904. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1905. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1906. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1907. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1908. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1909. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1910. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1911. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1912. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1913. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1914. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1915. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1916. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1917. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1918. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1919. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1920. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1921. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1922. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
  1923. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
  1924. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1925. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
  1926. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1927. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1928. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1929. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1930. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1931. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1932. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1933. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1934. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1935. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1936. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1937. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1938. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1939. /* TCL S700 */
  1940. { .modelname = "tcl", .config = ALC880_TCL_S700 },
  1941. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1942. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1943. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1944. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1945. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1946. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1947. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1948. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1949. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1950. /* Clevo laptops */
  1951. { .modelname = "clevo", .config = ALC880_CLEVO },
  1952. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
  1953. .config = ALC880_CLEVO }, /* Clevo m520G NB */
  1954. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
  1955. .config = ALC880_CLEVO }, /* Clevo m665n */
  1956. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1957. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1958. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1959. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1960. /* Back 5 jack, front 2 jack */
  1961. { .modelname = "5stack", .config = ALC880_5ST },
  1962. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1963. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1964. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1965. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1966. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1967. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1968. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1969. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1970. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1971. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1972. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1973. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1974. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1975. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1976. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1977. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1978. { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
  1979. .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
  1980. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1981. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1982. /* note subvendor = 0 below */
  1983. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1984. { .modelname = "w810", .config = ALC880_W810 },
  1985. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1986. { .modelname = "z71v", .config = ALC880_Z71V },
  1987. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1988. { .modelname = "6stack", .config = ALC880_6ST },
  1989. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1990. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1991. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1992. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1993. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1994. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1995. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1996. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1997. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1998. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  1999. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  2000. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  2001. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  2002. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  2003. { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
  2004. { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
  2005. { .modelname = "asus", .config = ALC880_ASUS },
  2006. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  2007. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  2008. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  2009. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  2010. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  2011. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  2012. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
  2013. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  2014. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  2015. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  2016. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  2017. { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
  2018. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  2019. { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
  2020. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
  2021. { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
  2022. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  2023. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  2024. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  2025. { .modelname = "F1734", .config = ALC880_F1734 },
  2026. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  2027. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  2028. { .modelname = "lg", .config = ALC880_LG },
  2029. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  2030. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
  2031. { .modelname = "lg-lw", .config = ALC880_LG_LW },
  2032. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
  2033. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
  2034. #ifdef CONFIG_SND_DEBUG
  2035. { .modelname = "test", .config = ALC880_TEST },
  2036. #endif
  2037. { .modelname = "auto", .config = ALC880_AUTO },
  2038. {}
  2039. };
  2040. /*
  2041. * ALC880 codec presets
  2042. */
  2043. static struct alc_config_preset alc880_presets[] = {
  2044. [ALC880_3ST] = {
  2045. .mixers = { alc880_three_stack_mixer },
  2046. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2047. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2048. .dac_nids = alc880_dac_nids,
  2049. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2050. .channel_mode = alc880_threestack_modes,
  2051. .need_dac_fix = 1,
  2052. .input_mux = &alc880_capture_source,
  2053. },
  2054. [ALC880_3ST_DIG] = {
  2055. .mixers = { alc880_three_stack_mixer },
  2056. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2057. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2058. .dac_nids = alc880_dac_nids,
  2059. .dig_out_nid = ALC880_DIGOUT_NID,
  2060. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2061. .channel_mode = alc880_threestack_modes,
  2062. .need_dac_fix = 1,
  2063. .input_mux = &alc880_capture_source,
  2064. },
  2065. [ALC880_TCL_S700] = {
  2066. .mixers = { alc880_tcl_s700_mixer },
  2067. .init_verbs = { alc880_volume_init_verbs,
  2068. alc880_pin_tcl_S700_init_verbs,
  2069. alc880_gpio2_init_verbs },
  2070. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2071. .dac_nids = alc880_dac_nids,
  2072. .hp_nid = 0x03,
  2073. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2074. .channel_mode = alc880_2_jack_modes,
  2075. .input_mux = &alc880_capture_source,
  2076. },
  2077. [ALC880_5ST] = {
  2078. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2079. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2080. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2081. .dac_nids = alc880_dac_nids,
  2082. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2083. .channel_mode = alc880_fivestack_modes,
  2084. .input_mux = &alc880_capture_source,
  2085. },
  2086. [ALC880_5ST_DIG] = {
  2087. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2088. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2089. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2090. .dac_nids = alc880_dac_nids,
  2091. .dig_out_nid = ALC880_DIGOUT_NID,
  2092. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2093. .channel_mode = alc880_fivestack_modes,
  2094. .input_mux = &alc880_capture_source,
  2095. },
  2096. [ALC880_6ST] = {
  2097. .mixers = { alc880_six_stack_mixer },
  2098. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2099. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2100. .dac_nids = alc880_6st_dac_nids,
  2101. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2102. .channel_mode = alc880_sixstack_modes,
  2103. .input_mux = &alc880_6stack_capture_source,
  2104. },
  2105. [ALC880_6ST_DIG] = {
  2106. .mixers = { alc880_six_stack_mixer },
  2107. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2108. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2109. .dac_nids = alc880_6st_dac_nids,
  2110. .dig_out_nid = ALC880_DIGOUT_NID,
  2111. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2112. .channel_mode = alc880_sixstack_modes,
  2113. .input_mux = &alc880_6stack_capture_source,
  2114. },
  2115. [ALC880_W810] = {
  2116. .mixers = { alc880_w810_base_mixer },
  2117. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2118. alc880_gpio2_init_verbs },
  2119. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2120. .dac_nids = alc880_w810_dac_nids,
  2121. .dig_out_nid = ALC880_DIGOUT_NID,
  2122. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2123. .channel_mode = alc880_w810_modes,
  2124. .input_mux = &alc880_capture_source,
  2125. },
  2126. [ALC880_Z71V] = {
  2127. .mixers = { alc880_z71v_mixer },
  2128. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2129. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2130. .dac_nids = alc880_z71v_dac_nids,
  2131. .dig_out_nid = ALC880_DIGOUT_NID,
  2132. .hp_nid = 0x03,
  2133. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2134. .channel_mode = alc880_2_jack_modes,
  2135. .input_mux = &alc880_capture_source,
  2136. },
  2137. [ALC880_F1734] = {
  2138. .mixers = { alc880_f1734_mixer },
  2139. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2140. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2141. .dac_nids = alc880_f1734_dac_nids,
  2142. .hp_nid = 0x02,
  2143. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2144. .channel_mode = alc880_2_jack_modes,
  2145. .input_mux = &alc880_capture_source,
  2146. },
  2147. [ALC880_ASUS] = {
  2148. .mixers = { alc880_asus_mixer },
  2149. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2150. alc880_gpio1_init_verbs },
  2151. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2152. .dac_nids = alc880_asus_dac_nids,
  2153. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2154. .channel_mode = alc880_asus_modes,
  2155. .need_dac_fix = 1,
  2156. .input_mux = &alc880_capture_source,
  2157. },
  2158. [ALC880_ASUS_DIG] = {
  2159. .mixers = { alc880_asus_mixer },
  2160. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2161. alc880_gpio1_init_verbs },
  2162. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2163. .dac_nids = alc880_asus_dac_nids,
  2164. .dig_out_nid = ALC880_DIGOUT_NID,
  2165. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2166. .channel_mode = alc880_asus_modes,
  2167. .need_dac_fix = 1,
  2168. .input_mux = &alc880_capture_source,
  2169. },
  2170. [ALC880_ASUS_DIG2] = {
  2171. .mixers = { alc880_asus_mixer },
  2172. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2173. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2174. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2175. .dac_nids = alc880_asus_dac_nids,
  2176. .dig_out_nid = ALC880_DIGOUT_NID,
  2177. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2178. .channel_mode = alc880_asus_modes,
  2179. .need_dac_fix = 1,
  2180. .input_mux = &alc880_capture_source,
  2181. },
  2182. [ALC880_ASUS_W1V] = {
  2183. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2184. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2185. alc880_gpio1_init_verbs },
  2186. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2187. .dac_nids = alc880_asus_dac_nids,
  2188. .dig_out_nid = ALC880_DIGOUT_NID,
  2189. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2190. .channel_mode = alc880_asus_modes,
  2191. .need_dac_fix = 1,
  2192. .input_mux = &alc880_capture_source,
  2193. },
  2194. [ALC880_UNIWILL_DIG] = {
  2195. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2196. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2197. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2198. .dac_nids = alc880_asus_dac_nids,
  2199. .dig_out_nid = ALC880_DIGOUT_NID,
  2200. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2201. .channel_mode = alc880_asus_modes,
  2202. .need_dac_fix = 1,
  2203. .input_mux = &alc880_capture_source,
  2204. },
  2205. [ALC880_CLEVO] = {
  2206. .mixers = { alc880_three_stack_mixer },
  2207. .init_verbs = { alc880_volume_init_verbs,
  2208. alc880_pin_clevo_init_verbs },
  2209. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2210. .dac_nids = alc880_dac_nids,
  2211. .hp_nid = 0x03,
  2212. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2213. .channel_mode = alc880_threestack_modes,
  2214. .need_dac_fix = 1,
  2215. .input_mux = &alc880_capture_source,
  2216. },
  2217. [ALC880_LG] = {
  2218. .mixers = { alc880_lg_mixer },
  2219. .init_verbs = { alc880_volume_init_verbs,
  2220. alc880_lg_init_verbs },
  2221. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2222. .dac_nids = alc880_lg_dac_nids,
  2223. .dig_out_nid = ALC880_DIGOUT_NID,
  2224. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2225. .channel_mode = alc880_lg_ch_modes,
  2226. .need_dac_fix = 1,
  2227. .input_mux = &alc880_lg_capture_source,
  2228. .unsol_event = alc880_lg_unsol_event,
  2229. .init_hook = alc880_lg_automute,
  2230. },
  2231. [ALC880_LG_LW] = {
  2232. .mixers = { alc880_lg_lw_mixer },
  2233. .init_verbs = { alc880_volume_init_verbs,
  2234. alc880_lg_lw_init_verbs },
  2235. .num_dacs = 1,
  2236. .dac_nids = alc880_dac_nids,
  2237. .dig_out_nid = ALC880_DIGOUT_NID,
  2238. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2239. .channel_mode = alc880_2_jack_modes,
  2240. .input_mux = &alc880_lg_lw_capture_source,
  2241. .unsol_event = alc880_lg_lw_unsol_event,
  2242. .init_hook = alc880_lg_lw_automute,
  2243. },
  2244. #ifdef CONFIG_SND_DEBUG
  2245. [ALC880_TEST] = {
  2246. .mixers = { alc880_test_mixer },
  2247. .init_verbs = { alc880_test_init_verbs },
  2248. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2249. .dac_nids = alc880_test_dac_nids,
  2250. .dig_out_nid = ALC880_DIGOUT_NID,
  2251. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2252. .channel_mode = alc880_test_modes,
  2253. .input_mux = &alc880_test_capture_source,
  2254. },
  2255. #endif
  2256. };
  2257. /*
  2258. * Automatic parse of I/O pins from the BIOS configuration
  2259. */
  2260. #define NUM_CONTROL_ALLOC 32
  2261. #define NUM_VERB_ALLOC 32
  2262. enum {
  2263. ALC_CTL_WIDGET_VOL,
  2264. ALC_CTL_WIDGET_MUTE,
  2265. ALC_CTL_BIND_MUTE,
  2266. };
  2267. static struct snd_kcontrol_new alc880_control_templates[] = {
  2268. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2269. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2270. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2271. };
  2272. /* add dynamic controls */
  2273. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2274. {
  2275. struct snd_kcontrol_new *knew;
  2276. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2277. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2278. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2279. if (! knew)
  2280. return -ENOMEM;
  2281. if (spec->kctl_alloc) {
  2282. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2283. kfree(spec->kctl_alloc);
  2284. }
  2285. spec->kctl_alloc = knew;
  2286. spec->num_kctl_alloc = num;
  2287. }
  2288. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2289. *knew = alc880_control_templates[type];
  2290. knew->name = kstrdup(name, GFP_KERNEL);
  2291. if (! knew->name)
  2292. return -ENOMEM;
  2293. knew->private_value = val;
  2294. spec->num_kctl_used++;
  2295. return 0;
  2296. }
  2297. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2298. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2299. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2300. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2301. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2302. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2303. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2304. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2305. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2306. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2307. #define ALC880_PIN_CD_NID 0x1c
  2308. /* fill in the dac_nids table from the parsed pin configuration */
  2309. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2310. {
  2311. hda_nid_t nid;
  2312. int assigned[4];
  2313. int i, j;
  2314. memset(assigned, 0, sizeof(assigned));
  2315. spec->multiout.dac_nids = spec->private_dac_nids;
  2316. /* check the pins hardwired to audio widget */
  2317. for (i = 0; i < cfg->line_outs; i++) {
  2318. nid = cfg->line_out_pins[i];
  2319. if (alc880_is_fixed_pin(nid)) {
  2320. int idx = alc880_fixed_pin_idx(nid);
  2321. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2322. assigned[idx] = 1;
  2323. }
  2324. }
  2325. /* left pins can be connect to any audio widget */
  2326. for (i = 0; i < cfg->line_outs; i++) {
  2327. nid = cfg->line_out_pins[i];
  2328. if (alc880_is_fixed_pin(nid))
  2329. continue;
  2330. /* search for an empty channel */
  2331. for (j = 0; j < cfg->line_outs; j++) {
  2332. if (! assigned[j]) {
  2333. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2334. assigned[j] = 1;
  2335. break;
  2336. }
  2337. }
  2338. }
  2339. spec->multiout.num_dacs = cfg->line_outs;
  2340. return 0;
  2341. }
  2342. /* add playback controls from the parsed DAC table */
  2343. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2344. const struct auto_pin_cfg *cfg)
  2345. {
  2346. char name[32];
  2347. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2348. hda_nid_t nid;
  2349. int i, err;
  2350. for (i = 0; i < cfg->line_outs; i++) {
  2351. if (! spec->multiout.dac_nids[i])
  2352. continue;
  2353. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2354. if (i == 2) {
  2355. /* Center/LFE */
  2356. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2357. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2358. return err;
  2359. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2360. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2361. return err;
  2362. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2363. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2364. return err;
  2365. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2366. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2367. return err;
  2368. } else {
  2369. sprintf(name, "%s Playback Volume", chname[i]);
  2370. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2371. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2372. return err;
  2373. sprintf(name, "%s Playback Switch", chname[i]);
  2374. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2375. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2376. return err;
  2377. }
  2378. }
  2379. return 0;
  2380. }
  2381. /* add playback controls for speaker and HP outputs */
  2382. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2383. const char *pfx)
  2384. {
  2385. hda_nid_t nid;
  2386. int err;
  2387. char name[32];
  2388. if (! pin)
  2389. return 0;
  2390. if (alc880_is_fixed_pin(pin)) {
  2391. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2392. /* specify the DAC as the extra output */
  2393. if (! spec->multiout.hp_nid)
  2394. spec->multiout.hp_nid = nid;
  2395. else
  2396. spec->multiout.extra_out_nid[0] = nid;
  2397. /* control HP volume/switch on the output mixer amp */
  2398. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2399. sprintf(name, "%s Playback Volume", pfx);
  2400. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2401. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2402. return err;
  2403. sprintf(name, "%s Playback Switch", pfx);
  2404. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2405. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2406. return err;
  2407. } else if (alc880_is_multi_pin(pin)) {
  2408. /* set manual connection */
  2409. /* we have only a switch on HP-out PIN */
  2410. sprintf(name, "%s Playback Switch", pfx);
  2411. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2412. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2413. return err;
  2414. }
  2415. return 0;
  2416. }
  2417. /* create input playback/capture controls for the given pin */
  2418. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2419. int idx, hda_nid_t mix_nid)
  2420. {
  2421. char name[32];
  2422. int err;
  2423. sprintf(name, "%s Playback Volume", ctlname);
  2424. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2425. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2426. return err;
  2427. sprintf(name, "%s Playback Switch", ctlname);
  2428. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2429. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2430. return err;
  2431. return 0;
  2432. }
  2433. /* create playback/capture controls for input pins */
  2434. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2435. const struct auto_pin_cfg *cfg)
  2436. {
  2437. struct hda_input_mux *imux = &spec->private_imux;
  2438. int i, err, idx;
  2439. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2440. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2441. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2442. err = new_analog_input(spec, cfg->input_pins[i],
  2443. auto_pin_cfg_labels[i],
  2444. idx, 0x0b);
  2445. if (err < 0)
  2446. return err;
  2447. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2448. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2449. imux->num_items++;
  2450. }
  2451. }
  2452. return 0;
  2453. }
  2454. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2455. hda_nid_t nid, int pin_type,
  2456. int dac_idx)
  2457. {
  2458. /* set as output */
  2459. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2460. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2461. /* need the manual connection? */
  2462. if (alc880_is_multi_pin(nid)) {
  2463. struct alc_spec *spec = codec->spec;
  2464. int idx = alc880_multi_pin_idx(nid);
  2465. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2466. AC_VERB_SET_CONNECT_SEL,
  2467. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2468. }
  2469. }
  2470. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2471. {
  2472. struct alc_spec *spec = codec->spec;
  2473. int i;
  2474. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2475. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2476. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2477. }
  2478. }
  2479. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2480. {
  2481. struct alc_spec *spec = codec->spec;
  2482. hda_nid_t pin;
  2483. pin = spec->autocfg.speaker_pins[0];
  2484. if (pin) /* connect to front */
  2485. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2486. pin = spec->autocfg.hp_pins[0];
  2487. if (pin) /* connect to front */
  2488. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2489. }
  2490. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2491. {
  2492. struct alc_spec *spec = codec->spec;
  2493. int i;
  2494. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2495. hda_nid_t nid = spec->autocfg.input_pins[i];
  2496. if (alc880_is_input_pin(nid)) {
  2497. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2498. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2499. if (nid != ALC880_PIN_CD_NID)
  2500. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2501. AMP_OUT_MUTE);
  2502. }
  2503. }
  2504. }
  2505. /* parse the BIOS configuration and set up the alc_spec */
  2506. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2507. static int alc880_parse_auto_config(struct hda_codec *codec)
  2508. {
  2509. struct alc_spec *spec = codec->spec;
  2510. int err;
  2511. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2512. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2513. alc880_ignore)) < 0)
  2514. return err;
  2515. if (! spec->autocfg.line_outs)
  2516. return 0; /* can't find valid BIOS pin config */
  2517. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2518. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2519. (err = alc880_auto_create_extra_out(spec,
  2520. spec->autocfg.speaker_pins[0],
  2521. "Speaker")) < 0 ||
  2522. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2523. "Headphone")) < 0 ||
  2524. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2525. return err;
  2526. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2527. if (spec->autocfg.dig_out_pin)
  2528. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2529. if (spec->autocfg.dig_in_pin)
  2530. spec->dig_in_nid = ALC880_DIGIN_NID;
  2531. if (spec->kctl_alloc)
  2532. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2533. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2534. spec->num_mux_defs = 1;
  2535. spec->input_mux = &spec->private_imux;
  2536. return 1;
  2537. }
  2538. /* additional initialization for auto-configuration model */
  2539. static void alc880_auto_init(struct hda_codec *codec)
  2540. {
  2541. alc880_auto_init_multi_out(codec);
  2542. alc880_auto_init_extra_out(codec);
  2543. alc880_auto_init_analog_input(codec);
  2544. }
  2545. /*
  2546. * OK, here we have finally the patch for ALC880
  2547. */
  2548. static int patch_alc880(struct hda_codec *codec)
  2549. {
  2550. struct alc_spec *spec;
  2551. int board_config;
  2552. int err;
  2553. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2554. if (spec == NULL)
  2555. return -ENOMEM;
  2556. codec->spec = spec;
  2557. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2558. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2559. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2560. "trying auto-probe from BIOS...\n");
  2561. board_config = ALC880_AUTO;
  2562. }
  2563. if (board_config == ALC880_AUTO) {
  2564. /* automatic parse from the BIOS config */
  2565. err = alc880_parse_auto_config(codec);
  2566. if (err < 0) {
  2567. alc_free(codec);
  2568. return err;
  2569. } else if (! err) {
  2570. printk(KERN_INFO
  2571. "hda_codec: Cannot set up configuration "
  2572. "from BIOS. Using 3-stack mode...\n");
  2573. board_config = ALC880_3ST;
  2574. }
  2575. }
  2576. if (board_config != ALC880_AUTO)
  2577. setup_preset(spec, &alc880_presets[board_config]);
  2578. spec->stream_name_analog = "ALC880 Analog";
  2579. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2580. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2581. spec->stream_name_digital = "ALC880 Digital";
  2582. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2583. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2584. if (! spec->adc_nids && spec->input_mux) {
  2585. /* check whether NID 0x07 is valid */
  2586. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2587. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2588. if (wcap != AC_WID_AUD_IN) {
  2589. spec->adc_nids = alc880_adc_nids_alt;
  2590. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2591. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2592. spec->num_mixers++;
  2593. } else {
  2594. spec->adc_nids = alc880_adc_nids;
  2595. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2596. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2597. spec->num_mixers++;
  2598. }
  2599. }
  2600. codec->patch_ops = alc_patch_ops;
  2601. if (board_config == ALC880_AUTO)
  2602. spec->init_hook = alc880_auto_init;
  2603. return 0;
  2604. }
  2605. /*
  2606. * ALC260 support
  2607. */
  2608. static hda_nid_t alc260_dac_nids[1] = {
  2609. /* front */
  2610. 0x02,
  2611. };
  2612. static hda_nid_t alc260_adc_nids[1] = {
  2613. /* ADC0 */
  2614. 0x04,
  2615. };
  2616. static hda_nid_t alc260_adc_nids_alt[1] = {
  2617. /* ADC1 */
  2618. 0x05,
  2619. };
  2620. static hda_nid_t alc260_hp_adc_nids[2] = {
  2621. /* ADC1, 0 */
  2622. 0x05, 0x04
  2623. };
  2624. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2625. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2626. */
  2627. static hda_nid_t alc260_dual_adc_nids[2] = {
  2628. /* ADC0, ADC1 */
  2629. 0x04, 0x05
  2630. };
  2631. #define ALC260_DIGOUT_NID 0x03
  2632. #define ALC260_DIGIN_NID 0x06
  2633. static struct hda_input_mux alc260_capture_source = {
  2634. .num_items = 4,
  2635. .items = {
  2636. { "Mic", 0x0 },
  2637. { "Front Mic", 0x1 },
  2638. { "Line", 0x2 },
  2639. { "CD", 0x4 },
  2640. },
  2641. };
  2642. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2643. * headphone jack and the internal CD lines since these are the only pins at
  2644. * which audio can appear. For flexibility, also allow the option of
  2645. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2646. * connection to the mixer output).
  2647. */
  2648. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2649. {
  2650. .num_items = 3,
  2651. .items = {
  2652. { "Mic/Line", 0x0 },
  2653. { "CD", 0x4 },
  2654. { "Headphone", 0x2 },
  2655. },
  2656. },
  2657. {
  2658. .num_items = 4,
  2659. .items = {
  2660. { "Mic/Line", 0x0 },
  2661. { "CD", 0x4 },
  2662. { "Headphone", 0x2 },
  2663. { "Mixer", 0x5 },
  2664. },
  2665. },
  2666. };
  2667. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2668. * the Fujitsu S702x, but jacks are marked differently.
  2669. */
  2670. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2671. {
  2672. .num_items = 4,
  2673. .items = {
  2674. { "Mic", 0x0 },
  2675. { "Line", 0x2 },
  2676. { "CD", 0x4 },
  2677. { "Headphone", 0x5 },
  2678. },
  2679. },
  2680. {
  2681. .num_items = 5,
  2682. .items = {
  2683. { "Mic", 0x0 },
  2684. { "Line", 0x2 },
  2685. { "CD", 0x4 },
  2686. { "Headphone", 0x6 },
  2687. { "Mixer", 0x5 },
  2688. },
  2689. },
  2690. };
  2691. /*
  2692. * This is just place-holder, so there's something for alc_build_pcms to look
  2693. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2694. * element which allows changing the channel mode, so the verb list is
  2695. * never used.
  2696. */
  2697. static struct hda_channel_mode alc260_modes[1] = {
  2698. { 2, NULL },
  2699. };
  2700. /* Mixer combinations
  2701. *
  2702. * basic: base_output + input + pc_beep + capture
  2703. * HP: base_output + input + capture_alt
  2704. * HP_3013: hp_3013 + input + capture
  2705. * fujitsu: fujitsu + capture
  2706. * acer: acer + capture
  2707. */
  2708. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2709. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2710. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2711. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2712. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2713. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2714. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2715. { } /* end */
  2716. };
  2717. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2718. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2719. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2720. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2721. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2722. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2723. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2724. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2725. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2726. { } /* end */
  2727. };
  2728. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2729. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2730. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2731. { } /* end */
  2732. };
  2733. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2734. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2735. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2736. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2737. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2738. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2739. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2740. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2741. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2742. { } /* end */
  2743. };
  2744. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2745. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2746. */
  2747. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2748. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2749. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2750. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2751. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2752. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2753. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2754. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2755. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2756. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2757. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2758. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2759. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2760. { } /* end */
  2761. };
  2762. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2763. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2764. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2765. * datasheet doesn't mention this restriction. At this stage it's not clear
  2766. * whether this behaviour is intentional or is a hardware bug in chip
  2767. * revisions available in early 2006. Therefore for now allow the
  2768. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2769. * that the lack of mic bias for this NID is intentional we could change the
  2770. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2771. *
  2772. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2773. * don't appear to make the mic bias available from the "line" jack, even
  2774. * though the NID used for this jack (0x14) can supply it. The theory is
  2775. * that perhaps Acer have included blocking capacitors between the ALC260
  2776. * and the output jack. If this turns out to be the case for all such
  2777. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2778. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2779. */
  2780. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2781. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2782. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2783. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2784. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2785. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2786. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2787. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2788. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2789. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2790. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2791. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2792. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2793. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2794. { } /* end */
  2795. };
  2796. /* capture mixer elements */
  2797. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2798. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2799. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2800. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2801. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2802. {
  2803. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2804. /* The multiple "Capture Source" controls confuse alsamixer
  2805. * So call somewhat different..
  2806. * FIXME: the controls appear in the "playback" view!
  2807. */
  2808. /* .name = "Capture Source", */
  2809. .name = "Input Source",
  2810. .count = 2,
  2811. .info = alc_mux_enum_info,
  2812. .get = alc_mux_enum_get,
  2813. .put = alc_mux_enum_put,
  2814. },
  2815. { } /* end */
  2816. };
  2817. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2818. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2819. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2820. {
  2821. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2822. /* The multiple "Capture Source" controls confuse alsamixer
  2823. * So call somewhat different..
  2824. * FIXME: the controls appear in the "playback" view!
  2825. */
  2826. /* .name = "Capture Source", */
  2827. .name = "Input Source",
  2828. .count = 1,
  2829. .info = alc_mux_enum_info,
  2830. .get = alc_mux_enum_get,
  2831. .put = alc_mux_enum_put,
  2832. },
  2833. { } /* end */
  2834. };
  2835. /*
  2836. * initialization verbs
  2837. */
  2838. static struct hda_verb alc260_init_verbs[] = {
  2839. /* Line In pin widget for input */
  2840. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2841. /* CD pin widget for input */
  2842. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2843. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2844. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2845. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2846. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2847. /* LINE-2 is used for line-out in rear */
  2848. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2849. /* select line-out */
  2850. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2851. /* LINE-OUT pin */
  2852. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2853. /* enable HP */
  2854. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2855. /* enable Mono */
  2856. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2857. /* mute capture amp left and right */
  2858. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2859. /* set connection select to line in (default select for this ADC) */
  2860. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2861. /* mute capture amp left and right */
  2862. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2863. /* set connection select to line in (default select for this ADC) */
  2864. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2865. /* set vol=0 Line-Out mixer amp left and right */
  2866. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2867. /* unmute pin widget amp left and right (no gain on this amp) */
  2868. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2869. /* set vol=0 HP mixer amp left and right */
  2870. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2871. /* unmute pin widget amp left and right (no gain on this amp) */
  2872. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2873. /* set vol=0 Mono mixer amp left and right */
  2874. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2875. /* unmute pin widget amp left and right (no gain on this amp) */
  2876. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2877. /* unmute LINE-2 out pin */
  2878. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2879. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2880. /* mute CD */
  2881. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2882. /* mute Line In */
  2883. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2884. /* mute Mic */
  2885. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2886. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2887. /* mute Front out path */
  2888. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2889. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2890. /* mute Headphone out path */
  2891. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2892. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2893. /* mute Mono out path */
  2894. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2895. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2896. { }
  2897. };
  2898. #if 0 /* should be identical with alc260_init_verbs? */
  2899. static struct hda_verb alc260_hp_init_verbs[] = {
  2900. /* Headphone and output */
  2901. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2902. /* mono output */
  2903. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2904. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2905. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2906. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2907. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2908. /* Line In pin widget for input */
  2909. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2910. /* Line-2 pin widget for output */
  2911. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2912. /* CD pin widget for input */
  2913. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2914. /* unmute amp left and right */
  2915. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2916. /* set connection select to line in (default select for this ADC) */
  2917. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2918. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2920. /* mute pin widget amp left and right (no gain on this amp) */
  2921. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2922. /* unmute HP mixer amp left and right (volume = 0) */
  2923. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2924. /* mute pin widget amp left and right (no gain on this amp) */
  2925. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2926. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2927. /* unmute CD */
  2928. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2929. /* unmute Line In */
  2930. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2931. /* unmute Mic */
  2932. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2933. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2934. /* Unmute Front out path */
  2935. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2936. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2937. /* Unmute Headphone out path */
  2938. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2939. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2940. /* Unmute Mono out path */
  2941. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2942. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2943. { }
  2944. };
  2945. #endif
  2946. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2947. /* Line out and output */
  2948. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2949. /* mono output */
  2950. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2951. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2952. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2953. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2954. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2955. /* Line In pin widget for input */
  2956. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2957. /* Headphone pin widget for output */
  2958. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2959. /* CD pin widget for input */
  2960. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2961. /* unmute amp left and right */
  2962. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2963. /* set connection select to line in (default select for this ADC) */
  2964. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2965. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2966. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2967. /* mute pin widget amp left and right (no gain on this amp) */
  2968. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2969. /* unmute HP mixer amp left and right (volume = 0) */
  2970. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2971. /* mute pin widget amp left and right (no gain on this amp) */
  2972. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2973. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2974. /* unmute CD */
  2975. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2976. /* unmute Line In */
  2977. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2978. /* unmute Mic */
  2979. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2980. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2981. /* Unmute Front out path */
  2982. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2983. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2984. /* Unmute Headphone out path */
  2985. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2986. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2987. /* Unmute Mono out path */
  2988. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2989. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2990. { }
  2991. };
  2992. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2993. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  2994. * audio = 0x16, internal speaker = 0x10.
  2995. */
  2996. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2997. /* Disable all GPIOs */
  2998. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2999. /* Internal speaker is connected to headphone pin */
  3000. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3001. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3002. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3003. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3004. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3005. /* Ensure all other unused pins are disabled and muted. */
  3006. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3007. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3008. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3009. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3010. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3011. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3012. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3013. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3014. /* Disable digital (SPDIF) pins */
  3015. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3016. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3017. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3018. * when acting as an output.
  3019. */
  3020. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3021. /* Start with output sum widgets muted and their output gains at min */
  3022. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3023. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3024. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3025. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3026. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3027. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3028. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3029. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3030. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3031. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3032. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3033. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3034. * If the pin mode is changed by the user the pin mode control will
  3035. * take care of enabling the pin's input/output buffers as needed.
  3036. * Therefore there's no need to enable the input buffer at this
  3037. * stage.
  3038. */
  3039. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3040. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3041. * mixer ctrl)
  3042. */
  3043. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3044. /* Mute capture amp left and right */
  3045. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3046. /* Set ADC connection select to match default mixer setting - line
  3047. * in (on mic1 pin)
  3048. */
  3049. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3050. /* Do the same for the second ADC: mute capture input amp and
  3051. * set ADC connection to line in (on mic1 pin)
  3052. */
  3053. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3054. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3055. /* Mute all inputs to mixer widget (even unconnected ones) */
  3056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3064. { }
  3065. };
  3066. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3067. * similar laptops (adapted from Fujitsu init verbs).
  3068. */
  3069. static struct hda_verb alc260_acer_init_verbs[] = {
  3070. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3071. * the headphone jack. Turn this on and rely on the standard mute
  3072. * methods whenever the user wants to turn these outputs off.
  3073. */
  3074. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3075. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3076. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3077. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3078. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3079. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3080. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3081. /* Line In jack is connected to Line1 pin */
  3082. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3083. /* Ensure all other unused pins are disabled and muted. */
  3084. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3085. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3086. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3087. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3088. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3089. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3090. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3091. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3092. /* Disable digital (SPDIF) pins */
  3093. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3094. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3095. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3096. * bus when acting as outputs.
  3097. */
  3098. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3099. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3100. /* Start with output sum widgets muted and their output gains at min */
  3101. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3102. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3103. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3104. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3105. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3106. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3107. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3108. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3109. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3110. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3111. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3112. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3113. * inputs. If the pin mode is changed by the user the pin mode control
  3114. * will take care of enabling the pin's input/output buffers as needed.
  3115. * Therefore there's no need to enable the input buffer at this
  3116. * stage.
  3117. */
  3118. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3119. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3120. /* Mute capture amp left and right */
  3121. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3122. /* Set ADC connection select to match default mixer setting - mic
  3123. * (on mic1 pin)
  3124. */
  3125. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3126. /* Do similar with the second ADC: mute capture input amp and
  3127. * set ADC connection to mic to match ALSA's default state.
  3128. */
  3129. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3130. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3131. /* Mute all inputs to mixer widget (even unconnected ones) */
  3132. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3134. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3135. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3136. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3137. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3138. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3139. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3140. { }
  3141. };
  3142. /* Test configuration for debugging, modelled after the ALC880 test
  3143. * configuration.
  3144. */
  3145. #ifdef CONFIG_SND_DEBUG
  3146. static hda_nid_t alc260_test_dac_nids[1] = {
  3147. 0x02,
  3148. };
  3149. static hda_nid_t alc260_test_adc_nids[2] = {
  3150. 0x04, 0x05,
  3151. };
  3152. /* For testing the ALC260, each input MUX needs its own definition since
  3153. * the signal assignments are different. This assumes that the first ADC
  3154. * is NID 0x04.
  3155. */
  3156. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3157. {
  3158. .num_items = 7,
  3159. .items = {
  3160. { "MIC1 pin", 0x0 },
  3161. { "MIC2 pin", 0x1 },
  3162. { "LINE1 pin", 0x2 },
  3163. { "LINE2 pin", 0x3 },
  3164. { "CD pin", 0x4 },
  3165. { "LINE-OUT pin", 0x5 },
  3166. { "HP-OUT pin", 0x6 },
  3167. },
  3168. },
  3169. {
  3170. .num_items = 8,
  3171. .items = {
  3172. { "MIC1 pin", 0x0 },
  3173. { "MIC2 pin", 0x1 },
  3174. { "LINE1 pin", 0x2 },
  3175. { "LINE2 pin", 0x3 },
  3176. { "CD pin", 0x4 },
  3177. { "Mixer", 0x5 },
  3178. { "LINE-OUT pin", 0x6 },
  3179. { "HP-OUT pin", 0x7 },
  3180. },
  3181. },
  3182. };
  3183. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3184. /* Output driver widgets */
  3185. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3186. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3187. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3188. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3190. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3191. /* Modes for retasking pin widgets
  3192. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3193. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3194. * mention this restriction. At this stage it's not clear whether
  3195. * this behaviour is intentional or is a hardware bug in chip
  3196. * revisions available at least up until early 2006. Therefore for
  3197. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3198. * choices, but if it turns out that the lack of mic bias for these
  3199. * NIDs is intentional we could change their modes from
  3200. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3201. */
  3202. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3203. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3204. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3205. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3206. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3207. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3208. /* Loopback mixer controls */
  3209. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3210. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3211. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3212. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3213. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3214. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3215. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3216. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3217. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3218. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3219. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3220. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3222. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3224. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3225. /* Controls for GPIO pins, assuming they are configured as outputs */
  3226. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3227. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3228. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3229. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3230. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3231. * is ambigious as to which NID is which; testing on laptops which
  3232. * make this output available should provide clarification.
  3233. */
  3234. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3235. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3236. { } /* end */
  3237. };
  3238. static struct hda_verb alc260_test_init_verbs[] = {
  3239. /* Enable all GPIOs as outputs with an initial value of 0 */
  3240. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3241. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3242. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3243. /* Enable retasking pins as output, initially without power amp */
  3244. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3245. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3246. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3248. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3249. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3250. /* Disable digital (SPDIF) pins initially, but users can enable
  3251. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3252. * payload also sets the generation to 0, output to be in "consumer"
  3253. * PCM format, copyright asserted, no pre-emphasis and no validity
  3254. * control.
  3255. */
  3256. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3257. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3258. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3259. * OUT1 sum bus when acting as an output.
  3260. */
  3261. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3262. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3263. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3264. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3265. /* Start with output sum widgets muted and their output gains at min */
  3266. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3268. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3269. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3270. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3272. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3273. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3274. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3275. /* Unmute retasking pin widget output buffers since the default
  3276. * state appears to be output. As the pin mode is changed by the
  3277. * user the pin mode control will take care of enabling the pin's
  3278. * input/output buffers as needed.
  3279. */
  3280. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3281. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3282. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3284. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3285. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3286. /* Also unmute the mono-out pin widget */
  3287. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3288. /* Mute capture amp left and right */
  3289. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3290. /* Set ADC connection select to match default mixer setting (mic1
  3291. * pin)
  3292. */
  3293. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3294. /* Do the same for the second ADC: mute capture input amp and
  3295. * set ADC connection to mic1 pin
  3296. */
  3297. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3298. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3299. /* Mute all inputs to mixer widget (even unconnected ones) */
  3300. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3301. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3302. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3303. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3304. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3305. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3306. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3308. { }
  3309. };
  3310. #endif
  3311. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3312. .substreams = 1,
  3313. .channels_min = 2,
  3314. .channels_max = 2,
  3315. };
  3316. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3317. .substreams = 1,
  3318. .channels_min = 2,
  3319. .channels_max = 2,
  3320. };
  3321. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3322. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3323. /*
  3324. * for BIOS auto-configuration
  3325. */
  3326. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3327. const char *pfx)
  3328. {
  3329. hda_nid_t nid_vol;
  3330. unsigned long vol_val, sw_val;
  3331. char name[32];
  3332. int err;
  3333. if (nid >= 0x0f && nid < 0x11) {
  3334. nid_vol = nid - 0x7;
  3335. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3336. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3337. } else if (nid == 0x11) {
  3338. nid_vol = nid - 0x7;
  3339. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3340. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3341. } else if (nid >= 0x12 && nid <= 0x15) {
  3342. nid_vol = 0x08;
  3343. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3344. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3345. } else
  3346. return 0; /* N/A */
  3347. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3348. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3349. return err;
  3350. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3351. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3352. return err;
  3353. return 1;
  3354. }
  3355. /* add playback controls from the parsed DAC table */
  3356. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3357. const struct auto_pin_cfg *cfg)
  3358. {
  3359. hda_nid_t nid;
  3360. int err;
  3361. spec->multiout.num_dacs = 1;
  3362. spec->multiout.dac_nids = spec->private_dac_nids;
  3363. spec->multiout.dac_nids[0] = 0x02;
  3364. nid = cfg->line_out_pins[0];
  3365. if (nid) {
  3366. err = alc260_add_playback_controls(spec, nid, "Front");
  3367. if (err < 0)
  3368. return err;
  3369. }
  3370. nid = cfg->speaker_pins[0];
  3371. if (nid) {
  3372. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3373. if (err < 0)
  3374. return err;
  3375. }
  3376. nid = cfg->hp_pins[0];
  3377. if (nid) {
  3378. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3379. if (err < 0)
  3380. return err;
  3381. }
  3382. return 0;
  3383. }
  3384. /* create playback/capture controls for input pins */
  3385. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3386. const struct auto_pin_cfg *cfg)
  3387. {
  3388. struct hda_input_mux *imux = &spec->private_imux;
  3389. int i, err, idx;
  3390. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3391. if (cfg->input_pins[i] >= 0x12) {
  3392. idx = cfg->input_pins[i] - 0x12;
  3393. err = new_analog_input(spec, cfg->input_pins[i],
  3394. auto_pin_cfg_labels[i], idx, 0x07);
  3395. if (err < 0)
  3396. return err;
  3397. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3398. imux->items[imux->num_items].index = idx;
  3399. imux->num_items++;
  3400. }
  3401. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3402. idx = cfg->input_pins[i] - 0x09;
  3403. err = new_analog_input(spec, cfg->input_pins[i],
  3404. auto_pin_cfg_labels[i], idx, 0x07);
  3405. if (err < 0)
  3406. return err;
  3407. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3408. imux->items[imux->num_items].index = idx;
  3409. imux->num_items++;
  3410. }
  3411. }
  3412. return 0;
  3413. }
  3414. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3415. hda_nid_t nid, int pin_type,
  3416. int sel_idx)
  3417. {
  3418. /* set as output */
  3419. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3420. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3421. /* need the manual connection? */
  3422. if (nid >= 0x12) {
  3423. int idx = nid - 0x12;
  3424. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3425. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3426. }
  3427. }
  3428. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3429. {
  3430. struct alc_spec *spec = codec->spec;
  3431. hda_nid_t nid;
  3432. nid = spec->autocfg.line_out_pins[0];
  3433. if (nid)
  3434. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3435. nid = spec->autocfg.speaker_pins[0];
  3436. if (nid)
  3437. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3438. nid = spec->autocfg.hp_pins[0];
  3439. if (nid)
  3440. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3441. }
  3442. #define ALC260_PIN_CD_NID 0x16
  3443. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3444. {
  3445. struct alc_spec *spec = codec->spec;
  3446. int i;
  3447. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3448. hda_nid_t nid = spec->autocfg.input_pins[i];
  3449. if (nid >= 0x12) {
  3450. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3451. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3452. if (nid != ALC260_PIN_CD_NID)
  3453. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3454. AMP_OUT_MUTE);
  3455. }
  3456. }
  3457. }
  3458. /*
  3459. * generic initialization of ADC, input mixers and output mixers
  3460. */
  3461. static struct hda_verb alc260_volume_init_verbs[] = {
  3462. /*
  3463. * Unmute ADC0-1 and set the default input to mic-in
  3464. */
  3465. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3466. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3467. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3468. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3469. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3470. * mixer widget
  3471. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3472. * mic (mic 2)
  3473. */
  3474. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3475. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3476. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3480. /*
  3481. * Set up output mixers (0x08 - 0x0a)
  3482. */
  3483. /* set vol=0 to output mixers */
  3484. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3486. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3487. /* set up input amps for analog loopback */
  3488. /* Amp Indices: DAC = 0, mixer = 1 */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3491. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3493. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3494. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3495. { }
  3496. };
  3497. static int alc260_parse_auto_config(struct hda_codec *codec)
  3498. {
  3499. struct alc_spec *spec = codec->spec;
  3500. unsigned int wcap;
  3501. int err;
  3502. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3503. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3504. alc260_ignore)) < 0)
  3505. return err;
  3506. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3507. return err;
  3508. if (! spec->kctl_alloc)
  3509. return 0; /* can't find valid BIOS pin config */
  3510. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3511. return err;
  3512. spec->multiout.max_channels = 2;
  3513. if (spec->autocfg.dig_out_pin)
  3514. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3515. if (spec->kctl_alloc)
  3516. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3517. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3518. spec->num_mux_defs = 1;
  3519. spec->input_mux = &spec->private_imux;
  3520. /* check whether NID 0x04 is valid */
  3521. wcap = get_wcaps(codec, 0x04);
  3522. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3523. if (wcap != AC_WID_AUD_IN) {
  3524. spec->adc_nids = alc260_adc_nids_alt;
  3525. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3526. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3527. } else {
  3528. spec->adc_nids = alc260_adc_nids;
  3529. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3530. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3531. }
  3532. spec->num_mixers++;
  3533. return 1;
  3534. }
  3535. /* additional initialization for auto-configuration model */
  3536. static void alc260_auto_init(struct hda_codec *codec)
  3537. {
  3538. alc260_auto_init_multi_out(codec);
  3539. alc260_auto_init_analog_input(codec);
  3540. }
  3541. /*
  3542. * ALC260 configurations
  3543. */
  3544. static struct hda_board_config alc260_cfg_tbl[] = {
  3545. { .modelname = "basic", .config = ALC260_BASIC },
  3546. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3547. .config = ALC260_BASIC }, /* Sony VAIO */
  3548. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
  3549. .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
  3550. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
  3551. .config = ALC260_BASIC }, /* Sony VAIO */
  3552. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3553. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3554. { .modelname = "hp", .config = ALC260_HP },
  3555. { .modelname = "hp-3013", .config = ALC260_HP_3013 },
  3556. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
  3557. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3558. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
  3559. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3560. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3561. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3562. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3563. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3564. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3565. { .modelname = "acer", .config = ALC260_ACER },
  3566. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3567. #ifdef CONFIG_SND_DEBUG
  3568. { .modelname = "test", .config = ALC260_TEST },
  3569. #endif
  3570. { .modelname = "auto", .config = ALC260_AUTO },
  3571. {}
  3572. };
  3573. static struct alc_config_preset alc260_presets[] = {
  3574. [ALC260_BASIC] = {
  3575. .mixers = { alc260_base_output_mixer,
  3576. alc260_input_mixer,
  3577. alc260_pc_beep_mixer,
  3578. alc260_capture_mixer },
  3579. .init_verbs = { alc260_init_verbs },
  3580. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3581. .dac_nids = alc260_dac_nids,
  3582. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3583. .adc_nids = alc260_adc_nids,
  3584. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3585. .channel_mode = alc260_modes,
  3586. .input_mux = &alc260_capture_source,
  3587. },
  3588. [ALC260_HP] = {
  3589. .mixers = { alc260_base_output_mixer,
  3590. alc260_input_mixer,
  3591. alc260_capture_alt_mixer },
  3592. .init_verbs = { alc260_init_verbs },
  3593. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3594. .dac_nids = alc260_dac_nids,
  3595. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3596. .adc_nids = alc260_hp_adc_nids,
  3597. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3598. .channel_mode = alc260_modes,
  3599. .input_mux = &alc260_capture_source,
  3600. },
  3601. [ALC260_HP_3013] = {
  3602. .mixers = { alc260_hp_3013_mixer,
  3603. alc260_input_mixer,
  3604. alc260_capture_alt_mixer },
  3605. .init_verbs = { alc260_hp_3013_init_verbs },
  3606. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3607. .dac_nids = alc260_dac_nids,
  3608. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3609. .adc_nids = alc260_hp_adc_nids,
  3610. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3611. .channel_mode = alc260_modes,
  3612. .input_mux = &alc260_capture_source,
  3613. },
  3614. [ALC260_FUJITSU_S702X] = {
  3615. .mixers = { alc260_fujitsu_mixer,
  3616. alc260_capture_mixer },
  3617. .init_verbs = { alc260_fujitsu_init_verbs },
  3618. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3619. .dac_nids = alc260_dac_nids,
  3620. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3621. .adc_nids = alc260_dual_adc_nids,
  3622. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3623. .channel_mode = alc260_modes,
  3624. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3625. .input_mux = alc260_fujitsu_capture_sources,
  3626. },
  3627. [ALC260_ACER] = {
  3628. .mixers = { alc260_acer_mixer,
  3629. alc260_capture_mixer },
  3630. .init_verbs = { alc260_acer_init_verbs },
  3631. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3632. .dac_nids = alc260_dac_nids,
  3633. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3634. .adc_nids = alc260_dual_adc_nids,
  3635. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3636. .channel_mode = alc260_modes,
  3637. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3638. .input_mux = alc260_acer_capture_sources,
  3639. },
  3640. #ifdef CONFIG_SND_DEBUG
  3641. [ALC260_TEST] = {
  3642. .mixers = { alc260_test_mixer,
  3643. alc260_capture_mixer },
  3644. .init_verbs = { alc260_test_init_verbs },
  3645. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3646. .dac_nids = alc260_test_dac_nids,
  3647. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3648. .adc_nids = alc260_test_adc_nids,
  3649. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3650. .channel_mode = alc260_modes,
  3651. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3652. .input_mux = alc260_test_capture_sources,
  3653. },
  3654. #endif
  3655. };
  3656. static int patch_alc260(struct hda_codec *codec)
  3657. {
  3658. struct alc_spec *spec;
  3659. int err, board_config;
  3660. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3661. if (spec == NULL)
  3662. return -ENOMEM;
  3663. codec->spec = spec;
  3664. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3665. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3666. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3667. "trying auto-probe from BIOS...\n");
  3668. board_config = ALC260_AUTO;
  3669. }
  3670. if (board_config == ALC260_AUTO) {
  3671. /* automatic parse from the BIOS config */
  3672. err = alc260_parse_auto_config(codec);
  3673. if (err < 0) {
  3674. alc_free(codec);
  3675. return err;
  3676. } else if (! err) {
  3677. printk(KERN_INFO
  3678. "hda_codec: Cannot set up configuration "
  3679. "from BIOS. Using base mode...\n");
  3680. board_config = ALC260_BASIC;
  3681. }
  3682. }
  3683. if (board_config != ALC260_AUTO)
  3684. setup_preset(spec, &alc260_presets[board_config]);
  3685. spec->stream_name_analog = "ALC260 Analog";
  3686. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3687. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3688. spec->stream_name_digital = "ALC260 Digital";
  3689. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3690. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3691. codec->patch_ops = alc_patch_ops;
  3692. if (board_config == ALC260_AUTO)
  3693. spec->init_hook = alc260_auto_init;
  3694. return 0;
  3695. }
  3696. /*
  3697. * ALC882 support
  3698. *
  3699. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3700. * configuration. Each pin widget can choose any input DACs and a mixer.
  3701. * Each ADC is connected from a mixer of all inputs. This makes possible
  3702. * 6-channel independent captures.
  3703. *
  3704. * In addition, an independent DAC for the multi-playback (not used in this
  3705. * driver yet).
  3706. */
  3707. #define ALC882_DIGOUT_NID 0x06
  3708. #define ALC882_DIGIN_NID 0x0a
  3709. static struct hda_channel_mode alc882_ch_modes[1] = {
  3710. { 8, NULL }
  3711. };
  3712. static hda_nid_t alc882_dac_nids[4] = {
  3713. /* front, rear, clfe, rear_surr */
  3714. 0x02, 0x03, 0x04, 0x05
  3715. };
  3716. /* identical with ALC880 */
  3717. #define alc882_adc_nids alc880_adc_nids
  3718. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3719. /* input MUX */
  3720. /* FIXME: should be a matrix-type input source selection */
  3721. static struct hda_input_mux alc882_capture_source = {
  3722. .num_items = 4,
  3723. .items = {
  3724. { "Mic", 0x0 },
  3725. { "Front Mic", 0x1 },
  3726. { "Line", 0x2 },
  3727. { "CD", 0x4 },
  3728. },
  3729. };
  3730. #define alc882_mux_enum_info alc_mux_enum_info
  3731. #define alc882_mux_enum_get alc_mux_enum_get
  3732. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3733. {
  3734. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3735. struct alc_spec *spec = codec->spec;
  3736. const struct hda_input_mux *imux = spec->input_mux;
  3737. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3738. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3739. hda_nid_t nid = capture_mixers[adc_idx];
  3740. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3741. unsigned int i, idx;
  3742. idx = ucontrol->value.enumerated.item[0];
  3743. if (idx >= imux->num_items)
  3744. idx = imux->num_items - 1;
  3745. if (*cur_val == idx && ! codec->in_resume)
  3746. return 0;
  3747. for (i = 0; i < imux->num_items; i++) {
  3748. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3749. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3750. v | (imux->items[i].index << 8));
  3751. }
  3752. *cur_val = idx;
  3753. return 1;
  3754. }
  3755. /*
  3756. * 6ch mode
  3757. */
  3758. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3759. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3760. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3761. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3762. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3763. { } /* end */
  3764. };
  3765. /*
  3766. * 8ch mode
  3767. */
  3768. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3769. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3770. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3771. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3772. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3773. { } /* end */
  3774. };
  3775. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3776. { 6, alc882_sixstack_ch6_init },
  3777. { 8, alc882_sixstack_ch8_init },
  3778. };
  3779. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3780. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3781. */
  3782. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3783. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3784. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3786. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3787. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3788. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3789. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3790. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3791. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3792. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3793. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3794. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3795. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3796. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3797. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3798. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3799. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3800. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3801. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3802. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3803. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3804. { } /* end */
  3805. };
  3806. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3807. {
  3808. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3809. .name = "Channel Mode",
  3810. .info = alc_ch_mode_info,
  3811. .get = alc_ch_mode_get,
  3812. .put = alc_ch_mode_put,
  3813. },
  3814. { } /* end */
  3815. };
  3816. static struct hda_verb alc882_init_verbs[] = {
  3817. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3821. /* Rear mixer */
  3822. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3823. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3824. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3825. /* CLFE mixer */
  3826. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3827. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3828. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3829. /* Side mixer */
  3830. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3831. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3832. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3833. /* Front Pin: output 0 (0x0c) */
  3834. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3835. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3836. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3837. /* Rear Pin: output 1 (0x0d) */
  3838. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3839. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3840. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3841. /* CLFE Pin: output 2 (0x0e) */
  3842. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3843. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3845. /* Side Pin: output 3 (0x0f) */
  3846. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3847. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3849. /* Mic (rear) pin: input vref at 80% */
  3850. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3851. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3852. /* Front Mic pin: input vref at 80% */
  3853. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3854. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3855. /* Line In pin: input */
  3856. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3857. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3858. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3859. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3860. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3861. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* CD pin widget for input */
  3863. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3864. /* FIXME: use matrix-type input source selection */
  3865. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3866. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3867. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3868. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3869. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3870. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3871. /* Input mixer2 */
  3872. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3873. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3874. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3875. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3876. /* Input mixer3 */
  3877. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3878. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3879. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3880. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3881. /* ADC1: mute amp left and right */
  3882. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3883. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3884. /* ADC2: mute amp left and right */
  3885. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3886. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3887. /* ADC3: mute amp left and right */
  3888. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3889. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3890. { }
  3891. };
  3892. static struct hda_verb alc882_eapd_verbs[] = {
  3893. /* change to EAPD mode */
  3894. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  3895. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  3896. { }
  3897. };
  3898. /*
  3899. * generic initialization of ADC, input mixers and output mixers
  3900. */
  3901. static struct hda_verb alc882_auto_init_verbs[] = {
  3902. /*
  3903. * Unmute ADC0-2 and set the default input to mic-in
  3904. */
  3905. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3906. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3907. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3908. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3909. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3910. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3911. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3912. * mixer widget
  3913. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3914. * mic (mic 2)
  3915. */
  3916. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3920. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3921. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3922. /*
  3923. * Set up output mixers (0x0c - 0x0f)
  3924. */
  3925. /* set vol=0 to output mixers */
  3926. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3927. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3928. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3929. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3930. /* set up input amps for analog loopback */
  3931. /* Amp Indices: DAC = 0, mixer = 1 */
  3932. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3933. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3934. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3935. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3936. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3938. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3939. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3940. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3941. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3942. /* FIXME: use matrix-type input source selection */
  3943. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3944. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3945. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3946. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3947. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3949. /* Input mixer2 */
  3950. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3951. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3954. /* Input mixer3 */
  3955. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3956. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3959. { }
  3960. };
  3961. /* capture mixer elements */
  3962. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3963. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3964. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3965. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3966. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3967. {
  3968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3969. /* The multiple "Capture Source" controls confuse alsamixer
  3970. * So call somewhat different..
  3971. * FIXME: the controls appear in the "playback" view!
  3972. */
  3973. /* .name = "Capture Source", */
  3974. .name = "Input Source",
  3975. .count = 2,
  3976. .info = alc882_mux_enum_info,
  3977. .get = alc882_mux_enum_get,
  3978. .put = alc882_mux_enum_put,
  3979. },
  3980. { } /* end */
  3981. };
  3982. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3983. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3984. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3985. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3986. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3987. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3988. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3989. {
  3990. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3991. /* The multiple "Capture Source" controls confuse alsamixer
  3992. * So call somewhat different..
  3993. * FIXME: the controls appear in the "playback" view!
  3994. */
  3995. /* .name = "Capture Source", */
  3996. .name = "Input Source",
  3997. .count = 3,
  3998. .info = alc882_mux_enum_info,
  3999. .get = alc882_mux_enum_get,
  4000. .put = alc882_mux_enum_put,
  4001. },
  4002. { } /* end */
  4003. };
  4004. /* pcm configuration: identiacal with ALC880 */
  4005. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4006. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4007. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4008. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4009. /*
  4010. * configuration and preset
  4011. */
  4012. static struct hda_board_config alc882_cfg_tbl[] = {
  4013. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  4014. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  4015. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4016. .config = ALC882_6ST_DIG }, /* MSI */
  4017. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4018. .config = ALC882_6ST_DIG }, /* Foxconn */
  4019. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4020. .config = ALC882_6ST_DIG }, /* ECS to Intel*/
  4021. { .modelname = "arima", .config = ALC882_ARIMA },
  4022. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4023. .config = ALC882_ARIMA }, /* Arima W820Di1 */
  4024. { .modelname = "auto", .config = ALC882_AUTO },
  4025. {}
  4026. };
  4027. static struct alc_config_preset alc882_presets[] = {
  4028. [ALC882_3ST_DIG] = {
  4029. .mixers = { alc882_base_mixer },
  4030. .init_verbs = { alc882_init_verbs },
  4031. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4032. .dac_nids = alc882_dac_nids,
  4033. .dig_out_nid = ALC882_DIGOUT_NID,
  4034. .dig_in_nid = ALC882_DIGIN_NID,
  4035. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4036. .channel_mode = alc882_ch_modes,
  4037. .need_dac_fix = 1,
  4038. .input_mux = &alc882_capture_source,
  4039. },
  4040. [ALC882_6ST_DIG] = {
  4041. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4042. .init_verbs = { alc882_init_verbs },
  4043. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4044. .dac_nids = alc882_dac_nids,
  4045. .dig_out_nid = ALC882_DIGOUT_NID,
  4046. .dig_in_nid = ALC882_DIGIN_NID,
  4047. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4048. .channel_mode = alc882_sixstack_modes,
  4049. .input_mux = &alc882_capture_source,
  4050. },
  4051. [ALC882_ARIMA] = {
  4052. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4053. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4054. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4055. .dac_nids = alc882_dac_nids,
  4056. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4057. .channel_mode = alc882_sixstack_modes,
  4058. .input_mux = &alc882_capture_source,
  4059. },
  4060. };
  4061. /*
  4062. * BIOS auto configuration
  4063. */
  4064. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4065. hda_nid_t nid, int pin_type,
  4066. int dac_idx)
  4067. {
  4068. /* set as output */
  4069. struct alc_spec *spec = codec->spec;
  4070. int idx;
  4071. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4072. idx = 4;
  4073. else
  4074. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4075. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4076. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4077. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4078. }
  4079. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4080. {
  4081. struct alc_spec *spec = codec->spec;
  4082. int i;
  4083. for (i = 0; i <= HDA_SIDE; i++) {
  4084. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4085. if (nid)
  4086. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4087. }
  4088. }
  4089. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4090. {
  4091. struct alc_spec *spec = codec->spec;
  4092. hda_nid_t pin;
  4093. pin = spec->autocfg.hp_pins[0];
  4094. if (pin) /* connect to front */
  4095. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4096. }
  4097. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4098. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4099. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4100. {
  4101. struct alc_spec *spec = codec->spec;
  4102. int i;
  4103. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4104. hda_nid_t nid = spec->autocfg.input_pins[i];
  4105. if (alc882_is_input_pin(nid)) {
  4106. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4107. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4108. if (nid != ALC882_PIN_CD_NID)
  4109. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4110. AMP_OUT_MUTE);
  4111. }
  4112. }
  4113. }
  4114. /* almost identical with ALC880 parser... */
  4115. static int alc882_parse_auto_config(struct hda_codec *codec)
  4116. {
  4117. struct alc_spec *spec = codec->spec;
  4118. int err = alc880_parse_auto_config(codec);
  4119. if (err < 0)
  4120. return err;
  4121. else if (err > 0)
  4122. /* hack - override the init verbs */
  4123. spec->init_verbs[0] = alc882_auto_init_verbs;
  4124. return err;
  4125. }
  4126. /* additional initialization for auto-configuration model */
  4127. static void alc882_auto_init(struct hda_codec *codec)
  4128. {
  4129. alc882_auto_init_multi_out(codec);
  4130. alc882_auto_init_hp_out(codec);
  4131. alc882_auto_init_analog_input(codec);
  4132. }
  4133. static int patch_alc882(struct hda_codec *codec)
  4134. {
  4135. struct alc_spec *spec;
  4136. int err, board_config;
  4137. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4138. if (spec == NULL)
  4139. return -ENOMEM;
  4140. codec->spec = spec;
  4141. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  4142. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4143. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4144. "trying auto-probe from BIOS...\n");
  4145. board_config = ALC882_AUTO;
  4146. }
  4147. if (board_config == ALC882_AUTO) {
  4148. /* automatic parse from the BIOS config */
  4149. err = alc882_parse_auto_config(codec);
  4150. if (err < 0) {
  4151. alc_free(codec);
  4152. return err;
  4153. } else if (! err) {
  4154. printk(KERN_INFO
  4155. "hda_codec: Cannot set up configuration "
  4156. "from BIOS. Using base mode...\n");
  4157. board_config = ALC882_3ST_DIG;
  4158. }
  4159. }
  4160. if (board_config != ALC882_AUTO)
  4161. setup_preset(spec, &alc882_presets[board_config]);
  4162. spec->stream_name_analog = "ALC882 Analog";
  4163. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4164. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4165. spec->stream_name_digital = "ALC882 Digital";
  4166. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4167. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4168. if (! spec->adc_nids && spec->input_mux) {
  4169. /* check whether NID 0x07 is valid */
  4170. unsigned int wcap = get_wcaps(codec, 0x07);
  4171. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4172. if (wcap != AC_WID_AUD_IN) {
  4173. spec->adc_nids = alc882_adc_nids_alt;
  4174. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4175. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4176. spec->num_mixers++;
  4177. } else {
  4178. spec->adc_nids = alc882_adc_nids;
  4179. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4180. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4181. spec->num_mixers++;
  4182. }
  4183. }
  4184. codec->patch_ops = alc_patch_ops;
  4185. if (board_config == ALC882_AUTO)
  4186. spec->init_hook = alc882_auto_init;
  4187. return 0;
  4188. }
  4189. /*
  4190. * ALC883 support
  4191. *
  4192. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4193. * configuration. Each pin widget can choose any input DACs and a mixer.
  4194. * Each ADC is connected from a mixer of all inputs. This makes possible
  4195. * 6-channel independent captures.
  4196. *
  4197. * In addition, an independent DAC for the multi-playback (not used in this
  4198. * driver yet).
  4199. */
  4200. #define ALC883_DIGOUT_NID 0x06
  4201. #define ALC883_DIGIN_NID 0x0a
  4202. static hda_nid_t alc883_dac_nids[4] = {
  4203. /* front, rear, clfe, rear_surr */
  4204. 0x02, 0x04, 0x03, 0x05
  4205. };
  4206. static hda_nid_t alc883_adc_nids[2] = {
  4207. /* ADC1-2 */
  4208. 0x08, 0x09,
  4209. };
  4210. /* input MUX */
  4211. /* FIXME: should be a matrix-type input source selection */
  4212. static struct hda_input_mux alc883_capture_source = {
  4213. .num_items = 4,
  4214. .items = {
  4215. { "Mic", 0x0 },
  4216. { "Front Mic", 0x1 },
  4217. { "Line", 0x2 },
  4218. { "CD", 0x4 },
  4219. },
  4220. };
  4221. #define alc883_mux_enum_info alc_mux_enum_info
  4222. #define alc883_mux_enum_get alc_mux_enum_get
  4223. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4224. struct snd_ctl_elem_value *ucontrol)
  4225. {
  4226. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4227. struct alc_spec *spec = codec->spec;
  4228. const struct hda_input_mux *imux = spec->input_mux;
  4229. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4230. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4231. hda_nid_t nid = capture_mixers[adc_idx];
  4232. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4233. unsigned int i, idx;
  4234. idx = ucontrol->value.enumerated.item[0];
  4235. if (idx >= imux->num_items)
  4236. idx = imux->num_items - 1;
  4237. if (*cur_val == idx && ! codec->in_resume)
  4238. return 0;
  4239. for (i = 0; i < imux->num_items; i++) {
  4240. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4241. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4242. v | (imux->items[i].index << 8));
  4243. }
  4244. *cur_val = idx;
  4245. return 1;
  4246. }
  4247. /*
  4248. * 2ch mode
  4249. */
  4250. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4251. { 2, NULL }
  4252. };
  4253. /*
  4254. * 2ch mode
  4255. */
  4256. static struct hda_verb alc883_3ST_ch2_init[] = {
  4257. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4258. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4259. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4260. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4261. { } /* end */
  4262. };
  4263. /*
  4264. * 6ch mode
  4265. */
  4266. static struct hda_verb alc883_3ST_ch6_init[] = {
  4267. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4268. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4269. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4270. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4271. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4272. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4273. { } /* end */
  4274. };
  4275. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4276. { 2, alc883_3ST_ch2_init },
  4277. { 6, alc883_3ST_ch6_init },
  4278. };
  4279. /*
  4280. * 6ch mode
  4281. */
  4282. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4283. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4284. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4285. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4286. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4287. { } /* end */
  4288. };
  4289. /*
  4290. * 8ch mode
  4291. */
  4292. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4293. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4294. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4295. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4296. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4297. { } /* end */
  4298. };
  4299. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4300. { 6, alc883_sixstack_ch6_init },
  4301. { 8, alc883_sixstack_ch8_init },
  4302. };
  4303. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4304. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4305. */
  4306. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4307. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4308. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4309. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4310. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4311. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4312. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4313. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4314. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4315. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4316. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4317. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4318. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4319. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4320. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4321. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4322. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4323. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4324. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4325. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4326. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4327. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4328. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4329. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4330. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4331. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4332. {
  4333. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4334. /* .name = "Capture Source", */
  4335. .name = "Input Source",
  4336. .count = 2,
  4337. .info = alc883_mux_enum_info,
  4338. .get = alc883_mux_enum_get,
  4339. .put = alc883_mux_enum_put,
  4340. },
  4341. { } /* end */
  4342. };
  4343. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4344. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4345. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4346. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4347. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4348. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4349. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4350. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4351. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4352. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4353. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4354. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4355. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4356. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4357. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4358. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4359. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4360. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4361. {
  4362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4363. /* .name = "Capture Source", */
  4364. .name = "Input Source",
  4365. .count = 2,
  4366. .info = alc883_mux_enum_info,
  4367. .get = alc883_mux_enum_get,
  4368. .put = alc883_mux_enum_put,
  4369. },
  4370. { } /* end */
  4371. };
  4372. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4374. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4375. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4376. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4378. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4379. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4380. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4381. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4382. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4383. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4385. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4386. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4387. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4391. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4392. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4393. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4394. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4395. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4396. {
  4397. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4398. /* .name = "Capture Source", */
  4399. .name = "Input Source",
  4400. .count = 2,
  4401. .info = alc883_mux_enum_info,
  4402. .get = alc883_mux_enum_get,
  4403. .put = alc883_mux_enum_put,
  4404. },
  4405. { } /* end */
  4406. };
  4407. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4408. {
  4409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4410. .name = "Channel Mode",
  4411. .info = alc_ch_mode_info,
  4412. .get = alc_ch_mode_get,
  4413. .put = alc_ch_mode_put,
  4414. },
  4415. { } /* end */
  4416. };
  4417. static struct hda_verb alc883_init_verbs[] = {
  4418. /* ADC1: mute amp left and right */
  4419. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4420. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4421. /* ADC2: mute amp left and right */
  4422. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4423. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4424. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4425. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4426. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4427. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4428. /* Rear mixer */
  4429. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4430. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4431. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4432. /* CLFE mixer */
  4433. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4434. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4435. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4436. /* Side mixer */
  4437. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4438. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4439. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4440. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4441. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4442. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4443. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4444. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4445. /* Front Pin: output 0 (0x0c) */
  4446. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4447. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4448. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4449. /* Rear Pin: output 1 (0x0d) */
  4450. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4451. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4452. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4453. /* CLFE Pin: output 2 (0x0e) */
  4454. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4455. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4456. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4457. /* Side Pin: output 3 (0x0f) */
  4458. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4459. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4460. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4461. /* Mic (rear) pin: input vref at 80% */
  4462. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4463. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4464. /* Front Mic pin: input vref at 80% */
  4465. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4466. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4467. /* Line In pin: input */
  4468. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4469. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4470. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4471. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4472. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4473. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4474. /* CD pin widget for input */
  4475. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4476. /* FIXME: use matrix-type input source selection */
  4477. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4478. /* Input mixer2 */
  4479. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4480. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4481. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4482. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4483. /* Input mixer3 */
  4484. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4485. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4486. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4487. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4488. { }
  4489. };
  4490. /*
  4491. * generic initialization of ADC, input mixers and output mixers
  4492. */
  4493. static struct hda_verb alc883_auto_init_verbs[] = {
  4494. /*
  4495. * Unmute ADC0-2 and set the default input to mic-in
  4496. */
  4497. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4498. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4499. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4500. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4501. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4502. * mixer widget
  4503. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4504. * mic (mic 2)
  4505. */
  4506. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4507. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4508. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4509. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4510. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4511. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4512. /*
  4513. * Set up output mixers (0x0c - 0x0f)
  4514. */
  4515. /* set vol=0 to output mixers */
  4516. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4517. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4518. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4519. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4520. /* set up input amps for analog loopback */
  4521. /* Amp Indices: DAC = 0, mixer = 1 */
  4522. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4523. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4524. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4525. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4526. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4527. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4528. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4529. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4530. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4531. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4532. /* FIXME: use matrix-type input source selection */
  4533. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4534. /* Input mixer1 */
  4535. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4536. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4537. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4538. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4539. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4540. /* Input mixer2 */
  4541. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4542. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4543. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4544. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4545. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4546. { }
  4547. };
  4548. /* capture mixer elements */
  4549. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4550. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4552. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4553. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4554. {
  4555. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4556. /* The multiple "Capture Source" controls confuse alsamixer
  4557. * So call somewhat different..
  4558. * FIXME: the controls appear in the "playback" view!
  4559. */
  4560. /* .name = "Capture Source", */
  4561. .name = "Input Source",
  4562. .count = 2,
  4563. .info = alc882_mux_enum_info,
  4564. .get = alc882_mux_enum_get,
  4565. .put = alc882_mux_enum_put,
  4566. },
  4567. { } /* end */
  4568. };
  4569. /* pcm configuration: identiacal with ALC880 */
  4570. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4571. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4572. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4573. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4574. /*
  4575. * configuration and preset
  4576. */
  4577. static struct hda_board_config alc883_cfg_tbl[] = {
  4578. { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
  4579. { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
  4580. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4581. .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
  4582. { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
  4583. { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
  4584. .config = ALC883_3ST_6ch },
  4585. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
  4586. .config = ALC883_3ST_6ch }, /* D102GGC */
  4587. { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
  4588. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4589. .config = ALC883_6ST_DIG }, /* MSI */
  4590. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4591. .config = ALC883_6ST_DIG }, /* Foxconn */
  4592. { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
  4593. { .modelname = "acer", .config = ALC883_ACER },
  4594. { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
  4595. .config = ALC883_ACER },
  4596. { .modelname = "auto", .config = ALC883_AUTO },
  4597. {}
  4598. };
  4599. static struct alc_config_preset alc883_presets[] = {
  4600. [ALC883_3ST_2ch_DIG] = {
  4601. .mixers = { alc883_3ST_2ch_mixer },
  4602. .init_verbs = { alc883_init_verbs },
  4603. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4604. .dac_nids = alc883_dac_nids,
  4605. .dig_out_nid = ALC883_DIGOUT_NID,
  4606. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4607. .adc_nids = alc883_adc_nids,
  4608. .dig_in_nid = ALC883_DIGIN_NID,
  4609. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4610. .channel_mode = alc883_3ST_2ch_modes,
  4611. .input_mux = &alc883_capture_source,
  4612. },
  4613. [ALC883_3ST_6ch_DIG] = {
  4614. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4615. .init_verbs = { alc883_init_verbs },
  4616. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4617. .dac_nids = alc883_dac_nids,
  4618. .dig_out_nid = ALC883_DIGOUT_NID,
  4619. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4620. .adc_nids = alc883_adc_nids,
  4621. .dig_in_nid = ALC883_DIGIN_NID,
  4622. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4623. .channel_mode = alc883_3ST_6ch_modes,
  4624. .need_dac_fix = 1,
  4625. .input_mux = &alc883_capture_source,
  4626. },
  4627. [ALC883_3ST_6ch] = {
  4628. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4629. .init_verbs = { alc883_init_verbs },
  4630. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4631. .dac_nids = alc883_dac_nids,
  4632. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4633. .adc_nids = alc883_adc_nids,
  4634. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4635. .channel_mode = alc883_3ST_6ch_modes,
  4636. .need_dac_fix = 1,
  4637. .input_mux = &alc883_capture_source,
  4638. },
  4639. [ALC883_6ST_DIG] = {
  4640. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4641. .init_verbs = { alc883_init_verbs },
  4642. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4643. .dac_nids = alc883_dac_nids,
  4644. .dig_out_nid = ALC883_DIGOUT_NID,
  4645. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4646. .adc_nids = alc883_adc_nids,
  4647. .dig_in_nid = ALC883_DIGIN_NID,
  4648. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4649. .channel_mode = alc883_sixstack_modes,
  4650. .input_mux = &alc883_capture_source,
  4651. },
  4652. [ALC888_DEMO_BOARD] = {
  4653. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  4654. .init_verbs = { alc883_init_verbs },
  4655. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4656. .dac_nids = alc883_dac_nids,
  4657. .dig_out_nid = ALC883_DIGOUT_NID,
  4658. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4659. .adc_nids = alc883_adc_nids,
  4660. .dig_in_nid = ALC883_DIGIN_NID,
  4661. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  4662. .channel_mode = alc883_sixstack_modes,
  4663. .input_mux = &alc883_capture_source,
  4664. },
  4665. [ALC883_ACER] = {
  4666. .mixers = { alc883_base_mixer,
  4667. alc883_chmode_mixer },
  4668. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  4669. * and the headphone jack. Turn this on and rely on the
  4670. * standard mute methods whenever the user wants to turn
  4671. * these outputs off.
  4672. */
  4673. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  4674. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4675. .dac_nids = alc883_dac_nids,
  4676. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4677. .adc_nids = alc883_adc_nids,
  4678. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4679. .channel_mode = alc883_3ST_2ch_modes,
  4680. .input_mux = &alc883_capture_source,
  4681. },
  4682. };
  4683. /*
  4684. * BIOS auto configuration
  4685. */
  4686. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  4687. hda_nid_t nid, int pin_type,
  4688. int dac_idx)
  4689. {
  4690. /* set as output */
  4691. struct alc_spec *spec = codec->spec;
  4692. int idx;
  4693. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4694. idx = 4;
  4695. else
  4696. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4697. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4698. pin_type);
  4699. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4700. AMP_OUT_UNMUTE);
  4701. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4702. }
  4703. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  4704. {
  4705. struct alc_spec *spec = codec->spec;
  4706. int i;
  4707. for (i = 0; i <= HDA_SIDE; i++) {
  4708. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4709. if (nid)
  4710. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4711. }
  4712. }
  4713. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  4714. {
  4715. struct alc_spec *spec = codec->spec;
  4716. hda_nid_t pin;
  4717. pin = spec->autocfg.hp_pins[0];
  4718. if (pin) /* connect to front */
  4719. /* use dac 0 */
  4720. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4721. }
  4722. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  4723. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  4724. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  4725. {
  4726. struct alc_spec *spec = codec->spec;
  4727. int i;
  4728. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4729. hda_nid_t nid = spec->autocfg.input_pins[i];
  4730. if (alc883_is_input_pin(nid)) {
  4731. snd_hda_codec_write(codec, nid, 0,
  4732. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4733. (i <= AUTO_PIN_FRONT_MIC ?
  4734. PIN_VREF80 : PIN_IN));
  4735. if (nid != ALC883_PIN_CD_NID)
  4736. snd_hda_codec_write(codec, nid, 0,
  4737. AC_VERB_SET_AMP_GAIN_MUTE,
  4738. AMP_OUT_MUTE);
  4739. }
  4740. }
  4741. }
  4742. /* almost identical with ALC880 parser... */
  4743. static int alc883_parse_auto_config(struct hda_codec *codec)
  4744. {
  4745. struct alc_spec *spec = codec->spec;
  4746. int err = alc880_parse_auto_config(codec);
  4747. if (err < 0)
  4748. return err;
  4749. else if (err > 0)
  4750. /* hack - override the init verbs */
  4751. spec->init_verbs[0] = alc883_auto_init_verbs;
  4752. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  4753. spec->num_mixers++;
  4754. return err;
  4755. }
  4756. /* additional initialization for auto-configuration model */
  4757. static void alc883_auto_init(struct hda_codec *codec)
  4758. {
  4759. alc883_auto_init_multi_out(codec);
  4760. alc883_auto_init_hp_out(codec);
  4761. alc883_auto_init_analog_input(codec);
  4762. }
  4763. static int patch_alc883(struct hda_codec *codec)
  4764. {
  4765. struct alc_spec *spec;
  4766. int err, board_config;
  4767. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4768. if (spec == NULL)
  4769. return -ENOMEM;
  4770. codec->spec = spec;
  4771. board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
  4772. if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
  4773. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  4774. "trying auto-probe from BIOS...\n");
  4775. board_config = ALC883_AUTO;
  4776. }
  4777. if (board_config == ALC883_AUTO) {
  4778. /* automatic parse from the BIOS config */
  4779. err = alc883_parse_auto_config(codec);
  4780. if (err < 0) {
  4781. alc_free(codec);
  4782. return err;
  4783. } else if (! err) {
  4784. printk(KERN_INFO
  4785. "hda_codec: Cannot set up configuration "
  4786. "from BIOS. Using base mode...\n");
  4787. board_config = ALC883_3ST_2ch_DIG;
  4788. }
  4789. }
  4790. if (board_config != ALC883_AUTO)
  4791. setup_preset(spec, &alc883_presets[board_config]);
  4792. spec->stream_name_analog = "ALC883 Analog";
  4793. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  4794. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  4795. spec->stream_name_digital = "ALC883 Digital";
  4796. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  4797. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  4798. if (! spec->adc_nids && spec->input_mux) {
  4799. spec->adc_nids = alc883_adc_nids;
  4800. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  4801. }
  4802. codec->patch_ops = alc_patch_ops;
  4803. if (board_config == ALC883_AUTO)
  4804. spec->init_hook = alc883_auto_init;
  4805. return 0;
  4806. }
  4807. /*
  4808. * ALC262 support
  4809. */
  4810. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  4811. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  4812. #define alc262_dac_nids alc260_dac_nids
  4813. #define alc262_adc_nids alc882_adc_nids
  4814. #define alc262_adc_nids_alt alc882_adc_nids_alt
  4815. #define alc262_modes alc260_modes
  4816. #define alc262_capture_source alc882_capture_source
  4817. static struct snd_kcontrol_new alc262_base_mixer[] = {
  4818. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4819. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4820. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4821. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4822. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4823. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4824. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4825. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4826. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4827. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4828. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4829. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  4830. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  4831. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4832. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4833. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4834. { } /* end */
  4835. };
  4836. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  4837. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4838. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4839. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4840. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4841. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4842. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4843. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4844. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4845. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4846. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4847. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4848. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4849. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4850. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4851. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4852. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  4853. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  4854. { } /* end */
  4855. };
  4856. #define alc262_capture_mixer alc882_capture_mixer
  4857. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  4858. /*
  4859. * generic initialization of ADC, input mixers and output mixers
  4860. */
  4861. static struct hda_verb alc262_init_verbs[] = {
  4862. /*
  4863. * Unmute ADC0-2 and set the default input to mic-in
  4864. */
  4865. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4867. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4868. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4869. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4870. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4871. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4872. * mixer widget
  4873. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4874. * mic (mic 2)
  4875. */
  4876. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4881. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4882. /*
  4883. * Set up output mixers (0x0c - 0x0e)
  4884. */
  4885. /* set vol=0 to output mixers */
  4886. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4887. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4888. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4889. /* set up input amps for analog loopback */
  4890. /* Amp Indices: DAC = 0, mixer = 1 */
  4891. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4892. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4893. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4894. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4895. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4896. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4897. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4898. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  4899. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4900. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  4901. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4902. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4903. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4904. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4905. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4906. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4907. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4908. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4909. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4910. /* FIXME: use matrix-type input source selection */
  4911. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4912. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4913. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4914. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4915. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4916. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4917. /* Input mixer2 */
  4918. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4919. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4920. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4921. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4922. /* Input mixer3 */
  4923. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4924. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4925. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4926. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4927. { }
  4928. };
  4929. /*
  4930. * fujitsu model
  4931. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  4932. */
  4933. #define ALC_HP_EVENT 0x37
  4934. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4935. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4936. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4937. {}
  4938. };
  4939. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4940. .num_items = 2,
  4941. .items = {
  4942. { "Mic", 0x0 },
  4943. { "CD", 0x4 },
  4944. },
  4945. };
  4946. static struct hda_input_mux alc262_HP_capture_source = {
  4947. .num_items = 5,
  4948. .items = {
  4949. { "Mic", 0x0 },
  4950. { "Front Mic", 0x3 },
  4951. { "Line", 0x2 },
  4952. { "CD", 0x4 },
  4953. { "AUX IN", 0x6 },
  4954. },
  4955. };
  4956. /* mute/unmute internal speaker according to the hp jack and mute state */
  4957. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  4958. {
  4959. struct alc_spec *spec = codec->spec;
  4960. unsigned int mute;
  4961. if (force || ! spec->sense_updated) {
  4962. unsigned int present;
  4963. /* need to execute and sync at first */
  4964. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  4965. present = snd_hda_codec_read(codec, 0x14, 0,
  4966. AC_VERB_GET_PIN_SENSE, 0);
  4967. spec->jack_present = (present & 0x80000000) != 0;
  4968. spec->sense_updated = 1;
  4969. }
  4970. if (spec->jack_present) {
  4971. /* mute internal speaker */
  4972. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4973. 0x80, 0x80);
  4974. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4975. 0x80, 0x80);
  4976. } else {
  4977. /* unmute internal speaker if necessary */
  4978. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  4979. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4980. 0x80, mute & 0x80);
  4981. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  4982. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4983. 0x80, mute & 0x80);
  4984. }
  4985. }
  4986. /* unsolicited event for HP jack sensing */
  4987. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  4988. unsigned int res)
  4989. {
  4990. if ((res >> 26) != ALC_HP_EVENT)
  4991. return;
  4992. alc262_fujitsu_automute(codec, 1);
  4993. }
  4994. /* bind volumes of both NID 0x0c and 0x0d */
  4995. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  4996. struct snd_ctl_elem_value *ucontrol)
  4997. {
  4998. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4999. long *valp = ucontrol->value.integer.value;
  5000. int change;
  5001. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5002. 0x7f, valp[0] & 0x7f);
  5003. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5004. 0x7f, valp[1] & 0x7f);
  5005. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5006. 0x7f, valp[0] & 0x7f);
  5007. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5008. 0x7f, valp[1] & 0x7f);
  5009. return change;
  5010. }
  5011. /* bind hp and internal speaker mute (with plug check) */
  5012. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5013. struct snd_ctl_elem_value *ucontrol)
  5014. {
  5015. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5016. long *valp = ucontrol->value.integer.value;
  5017. int change;
  5018. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5019. 0x80, valp[0] ? 0 : 0x80);
  5020. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5021. 0x80, valp[1] ? 0 : 0x80);
  5022. if (change || codec->in_resume)
  5023. alc262_fujitsu_automute(codec, codec->in_resume);
  5024. return change;
  5025. }
  5026. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5027. {
  5028. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5029. .name = "Master Playback Volume",
  5030. .info = snd_hda_mixer_amp_volume_info,
  5031. .get = snd_hda_mixer_amp_volume_get,
  5032. .put = alc262_fujitsu_master_vol_put,
  5033. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5034. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5035. },
  5036. {
  5037. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5038. .name = "Master Playback Switch",
  5039. .info = snd_hda_mixer_amp_switch_info,
  5040. .get = snd_hda_mixer_amp_switch_get,
  5041. .put = alc262_fujitsu_master_sw_put,
  5042. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5043. },
  5044. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5045. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5046. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5047. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5048. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5049. { } /* end */
  5050. };
  5051. /* additional init verbs for Benq laptops */
  5052. static struct hda_verb alc262_EAPD_verbs[] = {
  5053. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5054. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5055. {}
  5056. };
  5057. /* add playback controls from the parsed DAC table */
  5058. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5059. {
  5060. hda_nid_t nid;
  5061. int err;
  5062. spec->multiout.num_dacs = 1; /* only use one dac */
  5063. spec->multiout.dac_nids = spec->private_dac_nids;
  5064. spec->multiout.dac_nids[0] = 2;
  5065. nid = cfg->line_out_pins[0];
  5066. if (nid) {
  5067. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5068. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5069. return err;
  5070. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5071. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5072. return err;
  5073. }
  5074. nid = cfg->speaker_pins[0];
  5075. if (nid) {
  5076. if (nid == 0x16) {
  5077. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5078. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5079. return err;
  5080. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5081. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5082. return err;
  5083. } else {
  5084. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5085. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5086. return err;
  5087. }
  5088. }
  5089. nid = cfg->hp_pins[0];
  5090. if (nid) {
  5091. /* spec->multiout.hp_nid = 2; */
  5092. if (nid == 0x16) {
  5093. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5094. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5095. return err;
  5096. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5097. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5098. return err;
  5099. } else {
  5100. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5101. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5102. return err;
  5103. }
  5104. }
  5105. return 0;
  5106. }
  5107. /* identical with ALC880 */
  5108. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5109. /*
  5110. * generic initialization of ADC, input mixers and output mixers
  5111. */
  5112. static struct hda_verb alc262_volume_init_verbs[] = {
  5113. /*
  5114. * Unmute ADC0-2 and set the default input to mic-in
  5115. */
  5116. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5117. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5118. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5119. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5120. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5121. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5122. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5123. * mixer widget
  5124. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5125. * mic (mic 2)
  5126. */
  5127. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5128. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5129. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5130. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5131. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5132. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5133. /*
  5134. * Set up output mixers (0x0c - 0x0f)
  5135. */
  5136. /* set vol=0 to output mixers */
  5137. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5138. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5139. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5140. /* set up input amps for analog loopback */
  5141. /* Amp Indices: DAC = 0, mixer = 1 */
  5142. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5143. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5144. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5145. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5146. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5147. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5148. /* FIXME: use matrix-type input source selection */
  5149. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5150. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5151. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5152. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5153. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5154. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5155. /* Input mixer2 */
  5156. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5157. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5158. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5159. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5160. /* Input mixer3 */
  5161. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5162. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5163. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5164. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5165. { }
  5166. };
  5167. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5168. /*
  5169. * Unmute ADC0-2 and set the default input to mic-in
  5170. */
  5171. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5172. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5173. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5174. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5175. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5176. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5177. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5178. * mixer widget
  5179. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5180. * mic (mic 2)
  5181. */
  5182. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5183. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5184. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5185. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5186. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5187. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5188. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5189. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5190. /*
  5191. * Set up output mixers (0x0c - 0x0e)
  5192. */
  5193. /* set vol=0 to output mixers */
  5194. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5195. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5197. /* set up input amps for analog loopback */
  5198. /* Amp Indices: DAC = 0, mixer = 1 */
  5199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5200. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5201. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5202. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5203. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5204. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5205. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5206. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5207. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5208. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5209. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5210. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5211. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5212. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5213. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5214. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5215. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5216. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5218. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5219. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5220. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5221. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5222. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5223. /* FIXME: use matrix-type input source selection */
  5224. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5225. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5226. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5227. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5228. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5229. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5230. /* Input mixer2 */
  5231. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5233. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5234. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5235. /* Input mixer3 */
  5236. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5237. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5238. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5239. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5240. { }
  5241. };
  5242. /* pcm configuration: identiacal with ALC880 */
  5243. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5244. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5245. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5246. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5247. /*
  5248. * BIOS auto configuration
  5249. */
  5250. static int alc262_parse_auto_config(struct hda_codec *codec)
  5251. {
  5252. struct alc_spec *spec = codec->spec;
  5253. int err;
  5254. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5255. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5256. alc262_ignore)) < 0)
  5257. return err;
  5258. if (! spec->autocfg.line_outs)
  5259. return 0; /* can't find valid BIOS pin config */
  5260. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5261. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5262. return err;
  5263. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5264. if (spec->autocfg.dig_out_pin)
  5265. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5266. if (spec->autocfg.dig_in_pin)
  5267. spec->dig_in_nid = ALC262_DIGIN_NID;
  5268. if (spec->kctl_alloc)
  5269. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5270. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5271. spec->num_mux_defs = 1;
  5272. spec->input_mux = &spec->private_imux;
  5273. return 1;
  5274. }
  5275. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5276. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5277. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5278. /* init callback for auto-configuration model -- overriding the default init */
  5279. static void alc262_auto_init(struct hda_codec *codec)
  5280. {
  5281. alc262_auto_init_multi_out(codec);
  5282. alc262_auto_init_hp_out(codec);
  5283. alc262_auto_init_analog_input(codec);
  5284. }
  5285. /*
  5286. * configuration and preset
  5287. */
  5288. static struct hda_board_config alc262_cfg_tbl[] = {
  5289. { .modelname = "basic", .config = ALC262_BASIC },
  5290. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  5291. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
  5292. .config = ALC262_FUJITSU },
  5293. { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
  5294. { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
  5295. .config = ALC262_HP_BPC }, /* xw4400 */
  5296. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
  5297. .config = ALC262_HP_BPC }, /* xw6400 */
  5298. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
  5299. .config = ALC262_HP_BPC }, /* xw8400 */
  5300. { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
  5301. .config = ALC262_HP_BPC }, /* xw9400 */
  5302. { .modelname = "benq", .config = ALC262_BENQ_ED8 },
  5303. { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
  5304. .config = ALC262_BENQ_ED8 },
  5305. { .modelname = "auto", .config = ALC262_AUTO },
  5306. {}
  5307. };
  5308. static struct alc_config_preset alc262_presets[] = {
  5309. [ALC262_BASIC] = {
  5310. .mixers = { alc262_base_mixer },
  5311. .init_verbs = { alc262_init_verbs },
  5312. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5313. .dac_nids = alc262_dac_nids,
  5314. .hp_nid = 0x03,
  5315. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5316. .channel_mode = alc262_modes,
  5317. .input_mux = &alc262_capture_source,
  5318. },
  5319. [ALC262_FUJITSU] = {
  5320. .mixers = { alc262_fujitsu_mixer },
  5321. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5322. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5323. .dac_nids = alc262_dac_nids,
  5324. .hp_nid = 0x03,
  5325. .dig_out_nid = ALC262_DIGOUT_NID,
  5326. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5327. .channel_mode = alc262_modes,
  5328. .input_mux = &alc262_fujitsu_capture_source,
  5329. .unsol_event = alc262_fujitsu_unsol_event,
  5330. },
  5331. [ALC262_HP_BPC] = {
  5332. .mixers = { alc262_HP_BPC_mixer },
  5333. .init_verbs = { alc262_HP_BPC_init_verbs },
  5334. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5335. .dac_nids = alc262_dac_nids,
  5336. .hp_nid = 0x03,
  5337. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5338. .channel_mode = alc262_modes,
  5339. .input_mux = &alc262_HP_capture_source,
  5340. },
  5341. [ALC262_BENQ_ED8] = {
  5342. .mixers = { alc262_base_mixer },
  5343. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5344. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5345. .dac_nids = alc262_dac_nids,
  5346. .hp_nid = 0x03,
  5347. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5348. .channel_mode = alc262_modes,
  5349. .input_mux = &alc262_capture_source,
  5350. },
  5351. };
  5352. static int patch_alc262(struct hda_codec *codec)
  5353. {
  5354. struct alc_spec *spec;
  5355. int board_config;
  5356. int err;
  5357. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  5358. if (spec == NULL)
  5359. return -ENOMEM;
  5360. codec->spec = spec;
  5361. #if 0
  5362. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5363. {
  5364. int tmp;
  5365. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5366. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5367. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5368. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5369. }
  5370. #endif
  5371. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  5372. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  5373. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5374. "trying auto-probe from BIOS...\n");
  5375. board_config = ALC262_AUTO;
  5376. }
  5377. if (board_config == ALC262_AUTO) {
  5378. /* automatic parse from the BIOS config */
  5379. err = alc262_parse_auto_config(codec);
  5380. if (err < 0) {
  5381. alc_free(codec);
  5382. return err;
  5383. } else if (! err) {
  5384. printk(KERN_INFO
  5385. "hda_codec: Cannot set up configuration "
  5386. "from BIOS. Using base mode...\n");
  5387. board_config = ALC262_BASIC;
  5388. }
  5389. }
  5390. if (board_config != ALC262_AUTO)
  5391. setup_preset(spec, &alc262_presets[board_config]);
  5392. spec->stream_name_analog = "ALC262 Analog";
  5393. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5394. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5395. spec->stream_name_digital = "ALC262 Digital";
  5396. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  5397. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  5398. if (! spec->adc_nids && spec->input_mux) {
  5399. /* check whether NID 0x07 is valid */
  5400. unsigned int wcap = get_wcaps(codec, 0x07);
  5401. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  5402. if (wcap != AC_WID_AUD_IN) {
  5403. spec->adc_nids = alc262_adc_nids_alt;
  5404. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  5405. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  5406. spec->num_mixers++;
  5407. } else {
  5408. spec->adc_nids = alc262_adc_nids;
  5409. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  5410. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  5411. spec->num_mixers++;
  5412. }
  5413. }
  5414. codec->patch_ops = alc_patch_ops;
  5415. if (board_config == ALC262_AUTO)
  5416. spec->init_hook = alc262_auto_init;
  5417. return 0;
  5418. }
  5419. /*
  5420. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  5421. */
  5422. /*
  5423. * set the path ways for 2 channel output
  5424. * need to set the codec line out and mic 1 pin widgets to inputs
  5425. */
  5426. static struct hda_verb alc861_threestack_ch2_init[] = {
  5427. /* set pin widget 1Ah (line in) for input */
  5428. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5429. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  5430. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5431. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  5432. #if 0
  5433. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5434. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  5435. #endif
  5436. { } /* end */
  5437. };
  5438. /*
  5439. * 6ch mode
  5440. * need to set the codec line out and mic 1 pin widgets to outputs
  5441. */
  5442. static struct hda_verb alc861_threestack_ch6_init[] = {
  5443. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  5444. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5445. /* set pin widget 18h (mic1) for output (CLFE)*/
  5446. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5447. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5448. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5449. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  5450. #if 0
  5451. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5452. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  5453. #endif
  5454. { } /* end */
  5455. };
  5456. static struct hda_channel_mode alc861_threestack_modes[2] = {
  5457. { 2, alc861_threestack_ch2_init },
  5458. { 6, alc861_threestack_ch6_init },
  5459. };
  5460. /* Set mic1 as input and unmute the mixer */
  5461. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  5462. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5463. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5464. { } /* end */
  5465. };
  5466. /* Set mic1 as output and mute mixer */
  5467. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  5468. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5469. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5470. { } /* end */
  5471. };
  5472. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  5473. { 2, alc861_uniwill_m31_ch2_init },
  5474. { 4, alc861_uniwill_m31_ch4_init },
  5475. };
  5476. /* patch-ALC861 */
  5477. static struct snd_kcontrol_new alc861_base_mixer[] = {
  5478. /* output mixer control */
  5479. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5480. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5481. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5482. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5483. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  5484. /*Input mixer control */
  5485. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5486. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5487. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5488. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5489. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5490. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5491. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5492. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5493. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5494. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5495. /* Capture mixer control */
  5496. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5497. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5498. {
  5499. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5500. .name = "Capture Source",
  5501. .count = 1,
  5502. .info = alc_mux_enum_info,
  5503. .get = alc_mux_enum_get,
  5504. .put = alc_mux_enum_put,
  5505. },
  5506. { } /* end */
  5507. };
  5508. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  5509. /* output mixer control */
  5510. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5511. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5512. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5513. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5514. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5515. /* Input mixer control */
  5516. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5517. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5518. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5519. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5520. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5521. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5522. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5523. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5524. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5525. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5526. /* Capture mixer control */
  5527. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5528. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5529. {
  5530. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5531. .name = "Capture Source",
  5532. .count = 1,
  5533. .info = alc_mux_enum_info,
  5534. .get = alc_mux_enum_get,
  5535. .put = alc_mux_enum_put,
  5536. },
  5537. {
  5538. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5539. .name = "Channel Mode",
  5540. .info = alc_ch_mode_info,
  5541. .get = alc_ch_mode_get,
  5542. .put = alc_ch_mode_put,
  5543. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  5544. },
  5545. { } /* end */
  5546. };
  5547. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  5548. /* output mixer control */
  5549. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  5550. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  5551. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  5552. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  5553. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  5554. /* Input mixer control */
  5555. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  5556. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  5557. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  5558. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  5559. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  5560. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  5561. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  5562. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  5563. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  5564. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  5565. /* Capture mixer control */
  5566. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5567. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5568. {
  5569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5570. .name = "Capture Source",
  5571. .count = 1,
  5572. .info = alc_mux_enum_info,
  5573. .get = alc_mux_enum_get,
  5574. .put = alc_mux_enum_put,
  5575. },
  5576. {
  5577. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5578. .name = "Channel Mode",
  5579. .info = alc_ch_mode_info,
  5580. .get = alc_ch_mode_get,
  5581. .put = alc_ch_mode_put,
  5582. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  5583. },
  5584. { } /* end */
  5585. };
  5586. /*
  5587. * generic initialization of ADC, input mixers and output mixers
  5588. */
  5589. static struct hda_verb alc861_base_init_verbs[] = {
  5590. /*
  5591. * Unmute ADC0 and set the default input to mic-in
  5592. */
  5593. /* port-A for surround (rear panel) */
  5594. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5595. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5596. /* port-B for mic-in (rear panel) with vref */
  5597. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5598. /* port-C for line-in (rear panel) */
  5599. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5600. /* port-D for Front */
  5601. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5602. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5603. /* port-E for HP out (front panel) */
  5604. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5605. /* route front PCM to HP */
  5606. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5607. /* port-F for mic-in (front panel) with vref */
  5608. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5609. /* port-G for CLFE (rear panel) */
  5610. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5611. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5612. /* port-H for side (rear panel) */
  5613. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5614. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5615. /* CD-in */
  5616. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5617. /* route front mic to ADC1*/
  5618. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5620. /* Unmute DAC0~3 & spdif out*/
  5621. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5622. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5623. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5624. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5625. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5626. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5627. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5628. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5629. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5630. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5631. /* Unmute Stereo Mixer 15 */
  5632. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5633. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5634. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5635. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5636. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5637. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5638. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5639. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5640. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5641. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5642. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5643. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5644. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5645. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5646. { }
  5647. };
  5648. static struct hda_verb alc861_threestack_init_verbs[] = {
  5649. /*
  5650. * Unmute ADC0 and set the default input to mic-in
  5651. */
  5652. /* port-A for surround (rear panel) */
  5653. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5654. /* port-B for mic-in (rear panel) with vref */
  5655. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5656. /* port-C for line-in (rear panel) */
  5657. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5658. /* port-D for Front */
  5659. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5660. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5661. /* port-E for HP out (front panel) */
  5662. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  5663. /* route front PCM to HP */
  5664. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5665. /* port-F for mic-in (front panel) with vref */
  5666. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5667. /* port-G for CLFE (rear panel) */
  5668. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5669. /* port-H for side (rear panel) */
  5670. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5671. /* CD-in */
  5672. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5673. /* route front mic to ADC1*/
  5674. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5675. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5676. /* Unmute DAC0~3 & spdif out*/
  5677. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5678. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5679. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5680. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5681. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5682. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5683. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5684. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5685. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5686. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5687. /* Unmute Stereo Mixer 15 */
  5688. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5690. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5691. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5692. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5693. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5694. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5695. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5696. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5698. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5699. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5700. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5701. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5702. { }
  5703. };
  5704. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  5705. /*
  5706. * Unmute ADC0 and set the default input to mic-in
  5707. */
  5708. /* port-A for surround (rear panel) */
  5709. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5710. /* port-B for mic-in (rear panel) with vref */
  5711. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5712. /* port-C for line-in (rear panel) */
  5713. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5714. /* port-D for Front */
  5715. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5716. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5717. /* port-E for HP out (front panel) */
  5718. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  5719. /* route front PCM to HP */
  5720. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5721. /* port-F for mic-in (front panel) with vref */
  5722. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5723. /* port-G for CLFE (rear panel) */
  5724. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5725. /* port-H for side (rear panel) */
  5726. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5727. /* CD-in */
  5728. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5729. /* route front mic to ADC1*/
  5730. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5731. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5732. /* Unmute DAC0~3 & spdif out*/
  5733. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5734. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5735. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5736. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5737. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5738. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5739. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5740. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5741. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5742. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5743. /* Unmute Stereo Mixer 15 */
  5744. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  5748. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5750. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5751. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5752. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5753. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5754. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5755. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5756. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  5757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5758. { }
  5759. };
  5760. /*
  5761. * generic initialization of ADC, input mixers and output mixers
  5762. */
  5763. static struct hda_verb alc861_auto_init_verbs[] = {
  5764. /*
  5765. * Unmute ADC0 and set the default input to mic-in
  5766. */
  5767. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5768. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5769. /* Unmute DAC0~3 & spdif out*/
  5770. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5771. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5772. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5773. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5774. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5775. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  5776. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5777. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5778. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5779. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5780. /* Unmute Stereo Mixer 15 */
  5781. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5782. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5783. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5784. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  5785. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5786. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5787. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5788. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5789. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5790. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5791. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5792. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5793. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5794. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5795. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5796. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5797. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5798. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5799. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5800. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5801. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  5802. { }
  5803. };
  5804. /* pcm configuration: identiacal with ALC880 */
  5805. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  5806. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  5807. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  5808. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  5809. #define ALC861_DIGOUT_NID 0x07
  5810. static struct hda_channel_mode alc861_8ch_modes[1] = {
  5811. { 8, NULL }
  5812. };
  5813. static hda_nid_t alc861_dac_nids[4] = {
  5814. /* front, surround, clfe, side */
  5815. 0x03, 0x06, 0x05, 0x04
  5816. };
  5817. static hda_nid_t alc660_dac_nids[3] = {
  5818. /* front, clfe, surround */
  5819. 0x03, 0x05, 0x06
  5820. };
  5821. static hda_nid_t alc861_adc_nids[1] = {
  5822. /* ADC0-2 */
  5823. 0x08,
  5824. };
  5825. static struct hda_input_mux alc861_capture_source = {
  5826. .num_items = 5,
  5827. .items = {
  5828. { "Mic", 0x0 },
  5829. { "Front Mic", 0x3 },
  5830. { "Line", 0x1 },
  5831. { "CD", 0x4 },
  5832. { "Mixer", 0x5 },
  5833. },
  5834. };
  5835. /* fill in the dac_nids table from the parsed pin configuration */
  5836. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5837. {
  5838. int i;
  5839. hda_nid_t nid;
  5840. spec->multiout.dac_nids = spec->private_dac_nids;
  5841. for (i = 0; i < cfg->line_outs; i++) {
  5842. nid = cfg->line_out_pins[i];
  5843. if (nid) {
  5844. if (i >= ARRAY_SIZE(alc861_dac_nids))
  5845. continue;
  5846. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  5847. }
  5848. }
  5849. spec->multiout.num_dacs = cfg->line_outs;
  5850. return 0;
  5851. }
  5852. /* add playback controls from the parsed DAC table */
  5853. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  5854. const struct auto_pin_cfg *cfg)
  5855. {
  5856. char name[32];
  5857. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  5858. hda_nid_t nid;
  5859. int i, idx, err;
  5860. for (i = 0; i < cfg->line_outs; i++) {
  5861. nid = spec->multiout.dac_nids[i];
  5862. if (! nid)
  5863. continue;
  5864. if (nid == 0x05) {
  5865. /* Center/LFE */
  5866. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  5867. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  5868. return err;
  5869. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  5870. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5871. return err;
  5872. } else {
  5873. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  5874. if (nid == alc861_dac_nids[idx])
  5875. break;
  5876. sprintf(name, "%s Playback Switch", chname[idx]);
  5877. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  5878. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5879. return err;
  5880. }
  5881. }
  5882. return 0;
  5883. }
  5884. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  5885. {
  5886. int err;
  5887. hda_nid_t nid;
  5888. if (! pin)
  5889. return 0;
  5890. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  5891. nid = 0x03;
  5892. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5893. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5894. return err;
  5895. spec->multiout.hp_nid = nid;
  5896. }
  5897. return 0;
  5898. }
  5899. /* create playback/capture controls for input pins */
  5900. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5901. {
  5902. struct hda_input_mux *imux = &spec->private_imux;
  5903. int i, err, idx, idx1;
  5904. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5905. switch(cfg->input_pins[i]) {
  5906. case 0x0c:
  5907. idx1 = 1;
  5908. idx = 2; // Line In
  5909. break;
  5910. case 0x0f:
  5911. idx1 = 2;
  5912. idx = 2; // Line In
  5913. break;
  5914. case 0x0d:
  5915. idx1 = 0;
  5916. idx = 1; // Mic In
  5917. break;
  5918. case 0x10:
  5919. idx1 = 3;
  5920. idx = 1; // Mic In
  5921. break;
  5922. case 0x11:
  5923. idx1 = 4;
  5924. idx = 0; // CD
  5925. break;
  5926. default:
  5927. continue;
  5928. }
  5929. err = new_analog_input(spec, cfg->input_pins[i],
  5930. auto_pin_cfg_labels[i], idx, 0x15);
  5931. if (err < 0)
  5932. return err;
  5933. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  5934. imux->items[imux->num_items].index = idx1;
  5935. imux->num_items++;
  5936. }
  5937. return 0;
  5938. }
  5939. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  5940. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5941. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5942. {
  5943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5944. /* The multiple "Capture Source" controls confuse alsamixer
  5945. * So call somewhat different..
  5946. *FIXME: the controls appear in the "playback" view!
  5947. */
  5948. /* .name = "Capture Source", */
  5949. .name = "Input Source",
  5950. .count = 1,
  5951. .info = alc_mux_enum_info,
  5952. .get = alc_mux_enum_get,
  5953. .put = alc_mux_enum_put,
  5954. },
  5955. { } /* end */
  5956. };
  5957. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  5958. int pin_type, int dac_idx)
  5959. {
  5960. /* set as output */
  5961. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  5962. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  5963. }
  5964. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  5965. {
  5966. struct alc_spec *spec = codec->spec;
  5967. int i;
  5968. for (i = 0; i < spec->autocfg.line_outs; i++) {
  5969. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5970. if (nid)
  5971. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  5972. }
  5973. }
  5974. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  5975. {
  5976. struct alc_spec *spec = codec->spec;
  5977. hda_nid_t pin;
  5978. pin = spec->autocfg.hp_pins[0];
  5979. if (pin) /* connect to front */
  5980. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  5981. }
  5982. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  5983. {
  5984. struct alc_spec *spec = codec->spec;
  5985. int i;
  5986. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5987. hda_nid_t nid = spec->autocfg.input_pins[i];
  5988. if ((nid>=0x0c) && (nid <=0x11)) {
  5989. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5990. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  5991. }
  5992. }
  5993. }
  5994. /* parse the BIOS configuration and set up the alc_spec */
  5995. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  5996. static int alc861_parse_auto_config(struct hda_codec *codec)
  5997. {
  5998. struct alc_spec *spec = codec->spec;
  5999. int err;
  6000. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6001. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6002. alc861_ignore)) < 0)
  6003. return err;
  6004. if (! spec->autocfg.line_outs)
  6005. return 0; /* can't find valid BIOS pin config */
  6006. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6007. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6008. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6009. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6010. return err;
  6011. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6012. if (spec->autocfg.dig_out_pin)
  6013. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6014. if (spec->kctl_alloc)
  6015. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6016. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6017. spec->num_mux_defs = 1;
  6018. spec->input_mux = &spec->private_imux;
  6019. spec->adc_nids = alc861_adc_nids;
  6020. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6021. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6022. spec->num_mixers++;
  6023. return 1;
  6024. }
  6025. /* additional initialization for auto-configuration model */
  6026. static void alc861_auto_init(struct hda_codec *codec)
  6027. {
  6028. alc861_auto_init_multi_out(codec);
  6029. alc861_auto_init_hp_out(codec);
  6030. alc861_auto_init_analog_input(codec);
  6031. }
  6032. /*
  6033. * configuration and preset
  6034. */
  6035. static struct hda_board_config alc861_cfg_tbl[] = {
  6036. { .modelname = "3stack", .config = ALC861_3ST },
  6037. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
  6038. .config = ALC861_3ST },
  6039. { .modelname = "3stack-660", .config = ALC660_3ST },
  6040. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
  6041. .config = ALC660_3ST },
  6042. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  6043. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  6044. { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
  6045. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
  6046. .config = ALC861_UNIWILL_M31 },
  6047. { .modelname = "auto", .config = ALC861_AUTO },
  6048. {}
  6049. };
  6050. static struct alc_config_preset alc861_presets[] = {
  6051. [ALC861_3ST] = {
  6052. .mixers = { alc861_3ST_mixer },
  6053. .init_verbs = { alc861_threestack_init_verbs },
  6054. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6055. .dac_nids = alc861_dac_nids,
  6056. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6057. .channel_mode = alc861_threestack_modes,
  6058. .need_dac_fix = 1,
  6059. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6060. .adc_nids = alc861_adc_nids,
  6061. .input_mux = &alc861_capture_source,
  6062. },
  6063. [ALC861_3ST_DIG] = {
  6064. .mixers = { alc861_base_mixer },
  6065. .init_verbs = { alc861_threestack_init_verbs },
  6066. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6067. .dac_nids = alc861_dac_nids,
  6068. .dig_out_nid = ALC861_DIGOUT_NID,
  6069. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6070. .channel_mode = alc861_threestack_modes,
  6071. .need_dac_fix = 1,
  6072. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6073. .adc_nids = alc861_adc_nids,
  6074. .input_mux = &alc861_capture_source,
  6075. },
  6076. [ALC861_6ST_DIG] = {
  6077. .mixers = { alc861_base_mixer },
  6078. .init_verbs = { alc861_base_init_verbs },
  6079. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6080. .dac_nids = alc861_dac_nids,
  6081. .dig_out_nid = ALC861_DIGOUT_NID,
  6082. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6083. .channel_mode = alc861_8ch_modes,
  6084. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6085. .adc_nids = alc861_adc_nids,
  6086. .input_mux = &alc861_capture_source,
  6087. },
  6088. [ALC660_3ST] = {
  6089. .mixers = { alc861_3ST_mixer },
  6090. .init_verbs = { alc861_threestack_init_verbs },
  6091. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6092. .dac_nids = alc660_dac_nids,
  6093. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6094. .channel_mode = alc861_threestack_modes,
  6095. .need_dac_fix = 1,
  6096. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6097. .adc_nids = alc861_adc_nids,
  6098. .input_mux = &alc861_capture_source,
  6099. },
  6100. [ALC861_UNIWILL_M31] = {
  6101. .mixers = { alc861_uniwill_m31_mixer },
  6102. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6103. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6104. .dac_nids = alc861_dac_nids,
  6105. .dig_out_nid = ALC861_DIGOUT_NID,
  6106. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6107. .channel_mode = alc861_uniwill_m31_modes,
  6108. .need_dac_fix = 1,
  6109. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6110. .adc_nids = alc861_adc_nids,
  6111. .input_mux = &alc861_capture_source,
  6112. },
  6113. };
  6114. static int patch_alc861(struct hda_codec *codec)
  6115. {
  6116. struct alc_spec *spec;
  6117. int board_config;
  6118. int err;
  6119. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  6120. if (spec == NULL)
  6121. return -ENOMEM;
  6122. codec->spec = spec;
  6123. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  6124. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  6125. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6126. "trying auto-probe from BIOS...\n");
  6127. board_config = ALC861_AUTO;
  6128. }
  6129. if (board_config == ALC861_AUTO) {
  6130. /* automatic parse from the BIOS config */
  6131. err = alc861_parse_auto_config(codec);
  6132. if (err < 0) {
  6133. alc_free(codec);
  6134. return err;
  6135. } else if (! err) {
  6136. printk(KERN_INFO
  6137. "hda_codec: Cannot set up configuration "
  6138. "from BIOS. Using base mode...\n");
  6139. board_config = ALC861_3ST_DIG;
  6140. }
  6141. }
  6142. if (board_config != ALC861_AUTO)
  6143. setup_preset(spec, &alc861_presets[board_config]);
  6144. spec->stream_name_analog = "ALC861 Analog";
  6145. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6146. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6147. spec->stream_name_digital = "ALC861 Digital";
  6148. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6149. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6150. codec->patch_ops = alc_patch_ops;
  6151. if (board_config == ALC861_AUTO)
  6152. spec->init_hook = alc861_auto_init;
  6153. return 0;
  6154. }
  6155. /*
  6156. * patch entries
  6157. */
  6158. struct hda_codec_preset snd_hda_preset_realtek[] = {
  6159. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  6160. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  6161. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  6162. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  6163. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  6164. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  6165. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  6166. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  6167. .patch = patch_alc861 },
  6168. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  6169. .patch = patch_alc861 },
  6170. {} /* terminator */
  6171. };