patch_realtek.c 232 KB

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