patch_realtek.c 232 KB

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