patch_realtek.c 226 KB

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