patch_realtek.c 293 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677
  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. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. #ifdef CONFIG_SND_DEBUG
  74. ALC260_TEST,
  75. #endif
  76. ALC260_AUTO,
  77. ALC260_MODEL_LAST /* last tag */
  78. };
  79. /* ALC262 models */
  80. enum {
  81. ALC262_BASIC,
  82. ALC262_HIPPO,
  83. ALC262_HIPPO_1,
  84. ALC262_FUJITSU,
  85. ALC262_HP_BPC,
  86. ALC262_HP_BPC_D7000_WL,
  87. ALC262_HP_BPC_D7000_WF,
  88. ALC262_BENQ_ED8,
  89. ALC262_AUTO,
  90. ALC262_MODEL_LAST /* last tag */
  91. };
  92. /* ALC861 models */
  93. enum {
  94. ALC861_3ST,
  95. ALC660_3ST,
  96. ALC861_3ST_DIG,
  97. ALC861_6ST_DIG,
  98. ALC861_UNIWILL_M31,
  99. ALC861_TOSHIBA,
  100. ALC861_ASUS,
  101. ALC861_ASUS_LAPTOP,
  102. ALC861_AUTO,
  103. ALC861_MODEL_LAST,
  104. };
  105. /* ALC861-VD models */
  106. enum {
  107. ALC660VD_3ST,
  108. ALC861VD_3ST,
  109. ALC861VD_3ST_DIG,
  110. ALC861VD_6ST_DIG,
  111. ALC861VD_AUTO,
  112. ALC861VD_MODEL_LAST,
  113. };
  114. /* ALC882 models */
  115. enum {
  116. ALC882_3ST_DIG,
  117. ALC882_6ST_DIG,
  118. ALC882_ARIMA,
  119. ALC882_AUTO,
  120. ALC885_MACPRO,
  121. ALC882_MODEL_LAST,
  122. };
  123. /* ALC883 models */
  124. enum {
  125. ALC883_3ST_2ch_DIG,
  126. ALC883_3ST_6ch_DIG,
  127. ALC883_3ST_6ch,
  128. ALC883_6ST_DIG,
  129. ALC883_TARGA_DIG,
  130. ALC883_TARGA_2ch_DIG,
  131. ALC888_DEMO_BOARD,
  132. ALC883_ACER,
  133. ALC883_MEDION,
  134. ALC883_LAPTOP_EAPD,
  135. ALC883_AUTO,
  136. ALC883_MODEL_LAST,
  137. };
  138. /* for GPIO Poll */
  139. #define GPIO_MASK 0x03
  140. struct alc_spec {
  141. /* codec parameterization */
  142. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  143. unsigned int num_mixers;
  144. const struct hda_verb *init_verbs[5]; /* initialization verbs
  145. * don't forget NULL
  146. * termination!
  147. */
  148. unsigned int num_init_verbs;
  149. char *stream_name_analog; /* analog PCM stream */
  150. struct hda_pcm_stream *stream_analog_playback;
  151. struct hda_pcm_stream *stream_analog_capture;
  152. char *stream_name_digital; /* digital PCM stream */
  153. struct hda_pcm_stream *stream_digital_playback;
  154. struct hda_pcm_stream *stream_digital_capture;
  155. /* playback */
  156. struct hda_multi_out multiout; /* playback set-up
  157. * max_channels, dacs must be set
  158. * dig_out_nid and hp_nid are optional
  159. */
  160. /* capture */
  161. unsigned int num_adc_nids;
  162. hda_nid_t *adc_nids;
  163. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  164. /* capture source */
  165. unsigned int num_mux_defs;
  166. const struct hda_input_mux *input_mux;
  167. unsigned int cur_mux[3];
  168. /* channel model */
  169. const struct hda_channel_mode *channel_mode;
  170. int num_channel_mode;
  171. int need_dac_fix;
  172. /* PCM information */
  173. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  174. /* dynamic controls, init_verbs and input_mux */
  175. struct auto_pin_cfg autocfg;
  176. unsigned int num_kctl_alloc, num_kctl_used;
  177. struct snd_kcontrol_new *kctl_alloc;
  178. struct hda_input_mux private_imux;
  179. hda_nid_t private_dac_nids[5];
  180. /* hooks */
  181. void (*init_hook)(struct hda_codec *codec);
  182. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  183. /* for pin sensing */
  184. unsigned int sense_updated: 1;
  185. unsigned int jack_present: 1;
  186. };
  187. /*
  188. * configuration template - to be copied to the spec instance
  189. */
  190. struct alc_config_preset {
  191. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  192. * with spec
  193. */
  194. const struct hda_verb *init_verbs[5];
  195. unsigned int num_dacs;
  196. hda_nid_t *dac_nids;
  197. hda_nid_t dig_out_nid; /* optional */
  198. hda_nid_t hp_nid; /* optional */
  199. unsigned int num_adc_nids;
  200. hda_nid_t *adc_nids;
  201. hda_nid_t dig_in_nid;
  202. unsigned int num_channel_mode;
  203. const struct hda_channel_mode *channel_mode;
  204. int need_dac_fix;
  205. unsigned int num_mux_defs;
  206. const struct hda_input_mux *input_mux;
  207. void (*unsol_event)(struct hda_codec *, unsigned int);
  208. void (*init_hook)(struct hda_codec *);
  209. };
  210. /*
  211. * input MUX handling
  212. */
  213. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  214. struct snd_ctl_elem_info *uinfo)
  215. {
  216. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  217. struct alc_spec *spec = codec->spec;
  218. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  219. if (mux_idx >= spec->num_mux_defs)
  220. mux_idx = 0;
  221. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  222. }
  223. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  224. struct snd_ctl_elem_value *ucontrol)
  225. {
  226. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  227. struct alc_spec *spec = codec->spec;
  228. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  229. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  230. return 0;
  231. }
  232. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  233. struct snd_ctl_elem_value *ucontrol)
  234. {
  235. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  236. struct alc_spec *spec = codec->spec;
  237. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  238. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  239. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  240. spec->adc_nids[adc_idx],
  241. &spec->cur_mux[adc_idx]);
  242. }
  243. /*
  244. * channel mode setting
  245. */
  246. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  247. struct snd_ctl_elem_info *uinfo)
  248. {
  249. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  250. struct alc_spec *spec = codec->spec;
  251. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  252. spec->num_channel_mode);
  253. }
  254. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_value *ucontrol)
  256. {
  257. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  258. struct alc_spec *spec = codec->spec;
  259. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  260. spec->num_channel_mode,
  261. spec->multiout.max_channels);
  262. }
  263. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  264. struct snd_ctl_elem_value *ucontrol)
  265. {
  266. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  267. struct alc_spec *spec = codec->spec;
  268. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  269. spec->num_channel_mode,
  270. &spec->multiout.max_channels);
  271. if (err >= 0 && spec->need_dac_fix)
  272. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  273. return err;
  274. }
  275. /*
  276. * Control the mode of pin widget settings via the mixer. "pc" is used
  277. * instead of "%" to avoid consequences of accidently treating the % as
  278. * being part of a format specifier. Maximum allowed length of a value is
  279. * 63 characters plus NULL terminator.
  280. *
  281. * Note: some retasking pin complexes seem to ignore requests for input
  282. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  283. * are requested. Therefore order this list so that this behaviour will not
  284. * cause problems when mixer clients move through the enum sequentially.
  285. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  286. * March 2006.
  287. */
  288. static char *alc_pin_mode_names[] = {
  289. "Mic 50pc bias", "Mic 80pc bias",
  290. "Line in", "Line out", "Headphone out",
  291. };
  292. static unsigned char alc_pin_mode_values[] = {
  293. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  294. };
  295. /* The control can present all 5 options, or it can limit the options based
  296. * in the pin being assumed to be exclusively an input or an output pin. In
  297. * addition, "input" pins may or may not process the mic bias option
  298. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  299. * accept requests for bias as of chip versions up to March 2006) and/or
  300. * wiring in the computer.
  301. */
  302. #define ALC_PIN_DIR_IN 0x00
  303. #define ALC_PIN_DIR_OUT 0x01
  304. #define ALC_PIN_DIR_INOUT 0x02
  305. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  306. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  307. /* Info about the pin modes supported by the different pin direction modes.
  308. * For each direction the minimum and maximum values are given.
  309. */
  310. static signed char alc_pin_mode_dir_info[5][2] = {
  311. { 0, 2 }, /* ALC_PIN_DIR_IN */
  312. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  313. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  314. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  315. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  316. };
  317. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  318. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  319. #define alc_pin_mode_n_items(_dir) \
  320. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  321. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  322. struct snd_ctl_elem_info *uinfo)
  323. {
  324. unsigned int item_num = uinfo->value.enumerated.item;
  325. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  326. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  327. uinfo->count = 1;
  328. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  329. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  330. item_num = alc_pin_mode_min(dir);
  331. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  332. return 0;
  333. }
  334. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  335. struct snd_ctl_elem_value *ucontrol)
  336. {
  337. unsigned int i;
  338. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  339. hda_nid_t nid = kcontrol->private_value & 0xffff;
  340. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  341. long *valp = ucontrol->value.integer.value;
  342. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  343. AC_VERB_GET_PIN_WIDGET_CONTROL,
  344. 0x00);
  345. /* Find enumerated value for current pinctl setting */
  346. i = alc_pin_mode_min(dir);
  347. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  348. i++;
  349. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  350. return 0;
  351. }
  352. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  353. struct snd_ctl_elem_value *ucontrol)
  354. {
  355. signed int change;
  356. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  357. hda_nid_t nid = kcontrol->private_value & 0xffff;
  358. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  359. long val = *ucontrol->value.integer.value;
  360. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  361. AC_VERB_GET_PIN_WIDGET_CONTROL,
  362. 0x00);
  363. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  364. val = alc_pin_mode_min(dir);
  365. change = pinctl != alc_pin_mode_values[val];
  366. if (change) {
  367. /* Set pin mode to that requested */
  368. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  369. alc_pin_mode_values[val]);
  370. /* Also enable the retasking pin's input/output as required
  371. * for the requested pin mode. Enum values of 2 or less are
  372. * input modes.
  373. *
  374. * Dynamically switching the input/output buffers probably
  375. * reduces noise slightly (particularly on input) so we'll
  376. * do it. However, having both input and output buffers
  377. * enabled simultaneously doesn't seem to be problematic if
  378. * this turns out to be necessary in the future.
  379. */
  380. if (val <= 2) {
  381. snd_hda_codec_write(codec, nid, 0,
  382. AC_VERB_SET_AMP_GAIN_MUTE,
  383. AMP_OUT_MUTE);
  384. snd_hda_codec_write(codec, nid, 0,
  385. AC_VERB_SET_AMP_GAIN_MUTE,
  386. AMP_IN_UNMUTE(0));
  387. } else {
  388. snd_hda_codec_write(codec, nid, 0,
  389. AC_VERB_SET_AMP_GAIN_MUTE,
  390. AMP_IN_MUTE(0));
  391. snd_hda_codec_write(codec, nid, 0,
  392. AC_VERB_SET_AMP_GAIN_MUTE,
  393. AMP_OUT_UNMUTE);
  394. }
  395. }
  396. return change;
  397. }
  398. #define ALC_PIN_MODE(xname, nid, dir) \
  399. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  400. .info = alc_pin_mode_info, \
  401. .get = alc_pin_mode_get, \
  402. .put = alc_pin_mode_put, \
  403. .private_value = nid | (dir<<16) }
  404. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  405. * together using a mask with more than one bit set. This control is
  406. * currently used only by the ALC260 test model. At this stage they are not
  407. * needed for any "production" models.
  408. */
  409. #ifdef CONFIG_SND_DEBUG
  410. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  411. struct snd_ctl_elem_info *uinfo)
  412. {
  413. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  414. uinfo->count = 1;
  415. uinfo->value.integer.min = 0;
  416. uinfo->value.integer.max = 1;
  417. return 0;
  418. }
  419. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  420. struct snd_ctl_elem_value *ucontrol)
  421. {
  422. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  423. hda_nid_t nid = kcontrol->private_value & 0xffff;
  424. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  425. long *valp = ucontrol->value.integer.value;
  426. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  427. AC_VERB_GET_GPIO_DATA, 0x00);
  428. *valp = (val & mask) != 0;
  429. return 0;
  430. }
  431. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_value *ucontrol)
  433. {
  434. signed int change;
  435. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  436. hda_nid_t nid = kcontrol->private_value & 0xffff;
  437. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  438. long val = *ucontrol->value.integer.value;
  439. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  440. AC_VERB_GET_GPIO_DATA,
  441. 0x00);
  442. /* Set/unset the masked GPIO bit(s) as needed */
  443. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  444. if (val == 0)
  445. gpio_data &= ~mask;
  446. else
  447. gpio_data |= mask;
  448. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  449. return change;
  450. }
  451. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  452. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  453. .info = alc_gpio_data_info, \
  454. .get = alc_gpio_data_get, \
  455. .put = alc_gpio_data_put, \
  456. .private_value = nid | (mask<<16) }
  457. #endif /* CONFIG_SND_DEBUG */
  458. /* A switch control to allow the enabling of the digital IO pins on the
  459. * ALC260. This is incredibly simplistic; the intention of this control is
  460. * to provide something in the test model allowing digital outputs to be
  461. * identified if present. If models are found which can utilise these
  462. * outputs a more complete mixer control can be devised for those models if
  463. * necessary.
  464. */
  465. #ifdef CONFIG_SND_DEBUG
  466. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_info *uinfo)
  468. {
  469. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  470. uinfo->count = 1;
  471. uinfo->value.integer.min = 0;
  472. uinfo->value.integer.max = 1;
  473. return 0;
  474. }
  475. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  476. struct snd_ctl_elem_value *ucontrol)
  477. {
  478. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  479. hda_nid_t nid = kcontrol->private_value & 0xffff;
  480. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  481. long *valp = ucontrol->value.integer.value;
  482. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  483. AC_VERB_GET_DIGI_CONVERT, 0x00);
  484. *valp = (val & mask) != 0;
  485. return 0;
  486. }
  487. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  488. struct snd_ctl_elem_value *ucontrol)
  489. {
  490. signed int change;
  491. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  492. hda_nid_t nid = kcontrol->private_value & 0xffff;
  493. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  494. long val = *ucontrol->value.integer.value;
  495. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  496. AC_VERB_GET_DIGI_CONVERT,
  497. 0x00);
  498. /* Set/unset the masked control bit(s) as needed */
  499. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  500. if (val==0)
  501. ctrl_data &= ~mask;
  502. else
  503. ctrl_data |= mask;
  504. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  505. ctrl_data);
  506. return change;
  507. }
  508. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  509. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  510. .info = alc_spdif_ctrl_info, \
  511. .get = alc_spdif_ctrl_get, \
  512. .put = alc_spdif_ctrl_put, \
  513. .private_value = nid | (mask<<16) }
  514. #endif /* CONFIG_SND_DEBUG */
  515. /*
  516. * set up from the preset table
  517. */
  518. static void setup_preset(struct alc_spec *spec,
  519. const struct alc_config_preset *preset)
  520. {
  521. int i;
  522. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  523. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  524. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  525. i++)
  526. spec->init_verbs[spec->num_init_verbs++] =
  527. preset->init_verbs[i];
  528. spec->channel_mode = preset->channel_mode;
  529. spec->num_channel_mode = preset->num_channel_mode;
  530. spec->need_dac_fix = preset->need_dac_fix;
  531. spec->multiout.max_channels = spec->channel_mode[0].channels;
  532. spec->multiout.num_dacs = preset->num_dacs;
  533. spec->multiout.dac_nids = preset->dac_nids;
  534. spec->multiout.dig_out_nid = preset->dig_out_nid;
  535. spec->multiout.hp_nid = preset->hp_nid;
  536. spec->num_mux_defs = preset->num_mux_defs;
  537. if (! spec->num_mux_defs)
  538. spec->num_mux_defs = 1;
  539. spec->input_mux = preset->input_mux;
  540. spec->num_adc_nids = preset->num_adc_nids;
  541. spec->adc_nids = preset->adc_nids;
  542. spec->dig_in_nid = preset->dig_in_nid;
  543. spec->unsol_event = preset->unsol_event;
  544. spec->init_hook = preset->init_hook;
  545. }
  546. /*
  547. * ALC880 3-stack model
  548. *
  549. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  550. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  551. * F-Mic = 0x1b, HP = 0x19
  552. */
  553. static hda_nid_t alc880_dac_nids[4] = {
  554. /* front, rear, clfe, rear_surr */
  555. 0x02, 0x05, 0x04, 0x03
  556. };
  557. static hda_nid_t alc880_adc_nids[3] = {
  558. /* ADC0-2 */
  559. 0x07, 0x08, 0x09,
  560. };
  561. /* The datasheet says the node 0x07 is connected from inputs,
  562. * but it shows zero connection in the real implementation on some devices.
  563. * Note: this is a 915GAV bug, fixed on 915GLV
  564. */
  565. static hda_nid_t alc880_adc_nids_alt[2] = {
  566. /* ADC1-2 */
  567. 0x08, 0x09,
  568. };
  569. #define ALC880_DIGOUT_NID 0x06
  570. #define ALC880_DIGIN_NID 0x0a
  571. static struct hda_input_mux alc880_capture_source = {
  572. .num_items = 4,
  573. .items = {
  574. { "Mic", 0x0 },
  575. { "Front Mic", 0x3 },
  576. { "Line", 0x2 },
  577. { "CD", 0x4 },
  578. },
  579. };
  580. /* channel source setting (2/6 channel selection for 3-stack) */
  581. /* 2ch mode */
  582. static struct hda_verb alc880_threestack_ch2_init[] = {
  583. /* set line-in to input, mute it */
  584. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  585. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  586. /* set mic-in to input vref 80%, mute it */
  587. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  588. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  589. { } /* end */
  590. };
  591. /* 6ch mode */
  592. static struct hda_verb alc880_threestack_ch6_init[] = {
  593. /* set line-in to output, unmute it */
  594. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  595. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  596. /* set mic-in to output, unmute it */
  597. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  598. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  599. { } /* end */
  600. };
  601. static struct hda_channel_mode alc880_threestack_modes[2] = {
  602. { 2, alc880_threestack_ch2_init },
  603. { 6, alc880_threestack_ch6_init },
  604. };
  605. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  606. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  607. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  608. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  609. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  610. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  611. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  612. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  613. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  614. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  615. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  616. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  617. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  619. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  620. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  621. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  622. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  623. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  624. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  625. {
  626. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  627. .name = "Channel Mode",
  628. .info = alc_ch_mode_info,
  629. .get = alc_ch_mode_get,
  630. .put = alc_ch_mode_put,
  631. },
  632. { } /* end */
  633. };
  634. /* capture mixer elements */
  635. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  636. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  637. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  638. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  639. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  640. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  641. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  642. {
  643. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  644. /* The multiple "Capture Source" controls confuse alsamixer
  645. * So call somewhat different..
  646. * FIXME: the controls appear in the "playback" view!
  647. */
  648. /* .name = "Capture Source", */
  649. .name = "Input Source",
  650. .count = 3,
  651. .info = alc_mux_enum_info,
  652. .get = alc_mux_enum_get,
  653. .put = alc_mux_enum_put,
  654. },
  655. { } /* end */
  656. };
  657. /* capture mixer elements (in case NID 0x07 not available) */
  658. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  659. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  660. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  661. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  662. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  663. {
  664. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  665. /* The multiple "Capture Source" controls confuse alsamixer
  666. * So call somewhat different..
  667. * FIXME: the controls appear in the "playback" view!
  668. */
  669. /* .name = "Capture Source", */
  670. .name = "Input Source",
  671. .count = 2,
  672. .info = alc_mux_enum_info,
  673. .get = alc_mux_enum_get,
  674. .put = alc_mux_enum_put,
  675. },
  676. { } /* end */
  677. };
  678. /*
  679. * ALC880 5-stack model
  680. *
  681. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  682. * Side = 0x02 (0xd)
  683. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  684. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  685. */
  686. /* additional mixers to alc880_three_stack_mixer */
  687. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  688. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  689. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  690. { } /* end */
  691. };
  692. /* channel source setting (6/8 channel selection for 5-stack) */
  693. /* 6ch mode */
  694. static struct hda_verb alc880_fivestack_ch6_init[] = {
  695. /* set line-in to input, mute it */
  696. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  697. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  698. { } /* end */
  699. };
  700. /* 8ch mode */
  701. static struct hda_verb alc880_fivestack_ch8_init[] = {
  702. /* set line-in to output, unmute it */
  703. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. { } /* end */
  706. };
  707. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  708. { 6, alc880_fivestack_ch6_init },
  709. { 8, alc880_fivestack_ch8_init },
  710. };
  711. /*
  712. * ALC880 6-stack model
  713. *
  714. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  715. * Side = 0x05 (0x0f)
  716. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  717. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  718. */
  719. static hda_nid_t alc880_6st_dac_nids[4] = {
  720. /* front, rear, clfe, rear_surr */
  721. 0x02, 0x03, 0x04, 0x05
  722. };
  723. static struct hda_input_mux alc880_6stack_capture_source = {
  724. .num_items = 4,
  725. .items = {
  726. { "Mic", 0x0 },
  727. { "Front Mic", 0x1 },
  728. { "Line", 0x2 },
  729. { "CD", 0x4 },
  730. },
  731. };
  732. /* fixed 8-channels */
  733. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  734. { 8, NULL },
  735. };
  736. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  737. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  738. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  740. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  741. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  742. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  744. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  745. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  747. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  748. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  750. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  752. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  754. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  755. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  756. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  757. {
  758. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  759. .name = "Channel Mode",
  760. .info = alc_ch_mode_info,
  761. .get = alc_ch_mode_get,
  762. .put = alc_ch_mode_put,
  763. },
  764. { } /* end */
  765. };
  766. /*
  767. * ALC880 W810 model
  768. *
  769. * W810 has rear IO for:
  770. * Front (DAC 02)
  771. * Surround (DAC 03)
  772. * Center/LFE (DAC 04)
  773. * Digital out (06)
  774. *
  775. * The system also has a pair of internal speakers, and a headphone jack.
  776. * These are both connected to Line2 on the codec, hence to DAC 02.
  777. *
  778. * There is a variable resistor to control the speaker or headphone
  779. * volume. This is a hardware-only device without a software API.
  780. *
  781. * Plugging headphones in will disable the internal speakers. This is
  782. * implemented in hardware, not via the driver using jack sense. In
  783. * a similar fashion, plugging into the rear socket marked "front" will
  784. * disable both the speakers and headphones.
  785. *
  786. * For input, there's a microphone jack, and an "audio in" jack.
  787. * These may not do anything useful with this driver yet, because I
  788. * haven't setup any initialization verbs for these yet...
  789. */
  790. static hda_nid_t alc880_w810_dac_nids[3] = {
  791. /* front, rear/surround, clfe */
  792. 0x02, 0x03, 0x04
  793. };
  794. /* fixed 6 channels */
  795. static struct hda_channel_mode alc880_w810_modes[1] = {
  796. { 6, NULL }
  797. };
  798. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  799. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  800. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  801. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  802. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  803. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  804. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  805. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  806. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  807. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  808. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  809. { } /* end */
  810. };
  811. /*
  812. * Z710V model
  813. *
  814. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  815. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  816. * Line = 0x1a
  817. */
  818. static hda_nid_t alc880_z71v_dac_nids[1] = {
  819. 0x02
  820. };
  821. #define ALC880_Z71V_HP_DAC 0x03
  822. /* fixed 2 channels */
  823. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  824. { 2, NULL }
  825. };
  826. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  827. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  828. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  829. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  830. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  831. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  832. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  833. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  834. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  835. { } /* end */
  836. };
  837. /* FIXME! */
  838. /*
  839. * ALC880 F1734 model
  840. *
  841. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  842. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  843. */
  844. static hda_nid_t alc880_f1734_dac_nids[1] = {
  845. 0x03
  846. };
  847. #define ALC880_F1734_HP_DAC 0x02
  848. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  849. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  850. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  856. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  857. { } /* end */
  858. };
  859. /* FIXME! */
  860. /*
  861. * ALC880 ASUS model
  862. *
  863. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  864. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  865. * Mic = 0x18, Line = 0x1a
  866. */
  867. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  868. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  869. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  870. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  871. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  878. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  879. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  881. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  882. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  883. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  884. {
  885. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  886. .name = "Channel Mode",
  887. .info = alc_ch_mode_info,
  888. .get = alc_ch_mode_get,
  889. .put = alc_ch_mode_put,
  890. },
  891. { } /* end */
  892. };
  893. /* FIXME! */
  894. /*
  895. * ALC880 ASUS W1V model
  896. *
  897. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  898. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  899. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  900. */
  901. /* additional mixers to alc880_asus_mixer */
  902. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  903. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  904. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  905. { } /* end */
  906. };
  907. /* additional mixers to alc880_asus_mixer */
  908. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  909. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  910. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  911. { } /* end */
  912. };
  913. /* TCL S700 */
  914. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  915. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  916. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  917. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  918. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  919. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  920. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  921. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  922. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  923. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  924. {
  925. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  926. /* The multiple "Capture Source" controls confuse alsamixer
  927. * So call somewhat different..
  928. * FIXME: the controls appear in the "playback" view!
  929. */
  930. /* .name = "Capture Source", */
  931. .name = "Input Source",
  932. .count = 1,
  933. .info = alc_mux_enum_info,
  934. .get = alc_mux_enum_get,
  935. .put = alc_mux_enum_put,
  936. },
  937. { } /* end */
  938. };
  939. /* Uniwill */
  940. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  941. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  942. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  943. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  944. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  945. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  946. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  947. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  948. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  949. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  950. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  951. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  952. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  953. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  954. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  955. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  956. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  957. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  958. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  959. {
  960. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  961. .name = "Channel Mode",
  962. .info = alc_ch_mode_info,
  963. .get = alc_ch_mode_get,
  964. .put = alc_ch_mode_put,
  965. },
  966. { } /* end */
  967. };
  968. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  969. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  970. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  971. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  972. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  973. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  974. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  975. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  976. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  977. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  978. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  979. { } /* end */
  980. };
  981. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  982. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  983. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  987. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  988. { } /* end */
  989. };
  990. /*
  991. * build control elements
  992. */
  993. static int alc_build_controls(struct hda_codec *codec)
  994. {
  995. struct alc_spec *spec = codec->spec;
  996. int err;
  997. int i;
  998. for (i = 0; i < spec->num_mixers; i++) {
  999. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1000. if (err < 0)
  1001. return err;
  1002. }
  1003. if (spec->multiout.dig_out_nid) {
  1004. err = snd_hda_create_spdif_out_ctls(codec,
  1005. spec->multiout.dig_out_nid);
  1006. if (err < 0)
  1007. return err;
  1008. }
  1009. if (spec->dig_in_nid) {
  1010. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1011. if (err < 0)
  1012. return err;
  1013. }
  1014. return 0;
  1015. }
  1016. /*
  1017. * initialize the codec volumes, etc
  1018. */
  1019. /*
  1020. * generic initialization of ADC, input mixers and output mixers
  1021. */
  1022. static struct hda_verb alc880_volume_init_verbs[] = {
  1023. /*
  1024. * Unmute ADC0-2 and set the default input to mic-in
  1025. */
  1026. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1028. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1029. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1030. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1031. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1032. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1033. * mixer widget
  1034. * Note: PASD motherboards uses the Line In 2 as the input for front
  1035. * panel mic (mic 2)
  1036. */
  1037. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1038. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1039. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1040. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1041. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1042. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1043. /*
  1044. * Set up output mixers (0x0c - 0x0f)
  1045. */
  1046. /* set vol=0 to output mixers */
  1047. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1048. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1049. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1050. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1051. /* set up input amps for analog loopback */
  1052. /* Amp Indices: DAC = 0, mixer = 1 */
  1053. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1055. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1056. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1057. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1058. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1059. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1060. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1061. { }
  1062. };
  1063. /*
  1064. * 3-stack pin configuration:
  1065. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1066. */
  1067. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1068. /*
  1069. * preset connection lists of input pins
  1070. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1071. */
  1072. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1073. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1074. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1075. /*
  1076. * Set pin mode and muting
  1077. */
  1078. /* set front pin widgets 0x14 for output */
  1079. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1080. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1081. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1082. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1083. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1084. /* Mic2 (as headphone out) for HP output */
  1085. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1086. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1087. /* Line In pin widget for input */
  1088. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1089. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1090. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1091. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1092. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1093. /* CD pin widget for input */
  1094. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1095. { }
  1096. };
  1097. /*
  1098. * 5-stack pin configuration:
  1099. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1100. * line-in/side = 0x1a, f-mic = 0x1b
  1101. */
  1102. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1103. /*
  1104. * preset connection lists of input pins
  1105. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1106. */
  1107. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1108. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1109. /*
  1110. * Set pin mode and muting
  1111. */
  1112. /* set pin widgets 0x14-0x17 for output */
  1113. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1114. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1115. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1116. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1117. /* unmute pins for output (no gain on this amp) */
  1118. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1119. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1120. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1121. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1122. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1123. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1124. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1125. /* Mic2 (as headphone out) for HP output */
  1126. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1127. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1128. /* Line In pin widget for input */
  1129. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1130. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1131. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1132. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1133. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1134. /* CD pin widget for input */
  1135. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1136. { }
  1137. };
  1138. /*
  1139. * W810 pin configuration:
  1140. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1141. */
  1142. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1143. /* hphone/speaker input selector: front DAC */
  1144. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1145. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1146. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1147. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1148. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1149. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1150. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1151. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1152. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1153. { }
  1154. };
  1155. /*
  1156. * Z71V pin configuration:
  1157. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1158. */
  1159. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1160. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1161. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1162. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1163. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1164. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1165. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1167. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1168. { }
  1169. };
  1170. /*
  1171. * 6-stack pin configuration:
  1172. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1173. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1174. */
  1175. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1176. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1178. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1179. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1180. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1181. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1182. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1183. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1184. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1185. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1186. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1187. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1188. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1190. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1191. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1192. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. { }
  1195. };
  1196. /*
  1197. * Uniwill pin configuration:
  1198. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1199. * line = 0x1a
  1200. */
  1201. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1202. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1203. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1204. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1205. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1206. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1207. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1208. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1209. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1210. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1211. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1212. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1213. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1215. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1216. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1217. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1218. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1219. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1220. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1223. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1224. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1225. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1227. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1228. { }
  1229. };
  1230. /*
  1231. * Uniwill P53
  1232. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1233. */
  1234. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1235. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1236. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1237. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1238. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1239. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1240. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1241. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1245. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1247. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1248. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1249. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1250. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1251. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1252. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1253. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1254. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1255. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1256. { }
  1257. };
  1258. static struct hda_verb alc880_beep_init_verbs[] = {
  1259. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1260. { }
  1261. };
  1262. /* toggle speaker-output according to the hp-jack state */
  1263. static void alc880_uniwill_automute(struct hda_codec *codec)
  1264. {
  1265. unsigned int present;
  1266. present = snd_hda_codec_read(codec, 0x14, 0,
  1267. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1268. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1269. 0x80, present ? 0x80 : 0);
  1270. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1271. 0x80, present ? 0x80 : 0);
  1272. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1273. 0x80, present ? 0x80 : 0);
  1274. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1275. 0x80, present ? 0x80 : 0);
  1276. present = snd_hda_codec_read(codec, 0x18, 0,
  1277. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1278. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1279. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  1280. }
  1281. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1282. unsigned int res)
  1283. {
  1284. /* Looks like the unsol event is incompatible with the standard
  1285. * definition. 4bit tag is placed at 28 bit!
  1286. */
  1287. if ((res >> 28) == ALC880_HP_EVENT ||
  1288. (res >> 28) == ALC880_MIC_EVENT)
  1289. alc880_uniwill_automute(codec);
  1290. }
  1291. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1292. {
  1293. unsigned int present;
  1294. present = snd_hda_codec_read(codec, 0x14, 0,
  1295. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1296. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1297. 0x80, present ? 0x80 : 0);
  1298. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1299. 0x80, present ? 0x80 : 0);
  1300. }
  1301. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1302. {
  1303. unsigned int present;
  1304. present = snd_hda_codec_read(codec, 0x21, 0,
  1305. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1306. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1307. 0x7f, present);
  1308. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1309. 0x7f, present);
  1310. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1311. 0x7f, present);
  1312. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1313. 0x7f, present);
  1314. }
  1315. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1316. unsigned int res)
  1317. {
  1318. /* Looks like the unsol event is incompatible with the standard
  1319. * definition. 4bit tag is placed at 28 bit!
  1320. */
  1321. if ((res >> 28) == ALC880_HP_EVENT)
  1322. alc880_uniwill_p53_hp_automute(codec);
  1323. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1324. alc880_uniwill_p53_dcvol_automute(codec);
  1325. }
  1326. /* FIXME! */
  1327. /*
  1328. * F1734 pin configuration:
  1329. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1330. */
  1331. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1332. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1333. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1334. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1335. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1336. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1337. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1338. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1339. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1341. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1342. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1343. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1344. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1345. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1349. { }
  1350. };
  1351. /* FIXME! */
  1352. /*
  1353. * ASUS pin configuration:
  1354. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1355. */
  1356. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1357. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1358. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1359. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1360. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1361. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1362. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1363. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1364. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1365. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1366. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1367. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1368. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1369. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1370. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1371. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1372. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1375. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1376. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1378. { }
  1379. };
  1380. /* Enable GPIO mask and set output */
  1381. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1382. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1383. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1384. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1385. { }
  1386. };
  1387. /* Enable GPIO mask and set output */
  1388. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1389. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1390. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1391. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1392. { }
  1393. };
  1394. /* Clevo m520g init */
  1395. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1396. /* headphone output */
  1397. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1398. /* line-out */
  1399. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1400. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. /* Line-in */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1404. /* CD */
  1405. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1406. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1407. /* Mic1 (rear panel) */
  1408. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1409. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1410. /* Mic2 (front panel) */
  1411. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1412. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1413. /* headphone */
  1414. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1415. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1416. /* change to EAPD mode */
  1417. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1418. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1419. { }
  1420. };
  1421. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1422. /* change to EAPD mode */
  1423. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1424. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1425. /* Headphone output */
  1426. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1427. /* Front output*/
  1428. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1429. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1430. /* Line In pin widget for input */
  1431. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1432. /* CD pin widget for input */
  1433. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1434. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1435. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1436. /* change to EAPD mode */
  1437. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1438. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1439. { }
  1440. };
  1441. /*
  1442. * LG m1 express dual
  1443. *
  1444. * Pin assignment:
  1445. * Rear Line-In/Out (blue): 0x14
  1446. * Build-in Mic-In: 0x15
  1447. * Speaker-out: 0x17
  1448. * HP-Out (green): 0x1b
  1449. * Mic-In/Out (red): 0x19
  1450. * SPDIF-Out: 0x1e
  1451. */
  1452. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1453. static hda_nid_t alc880_lg_dac_nids[3] = {
  1454. 0x05, 0x02, 0x03
  1455. };
  1456. /* seems analog CD is not working */
  1457. static struct hda_input_mux alc880_lg_capture_source = {
  1458. .num_items = 3,
  1459. .items = {
  1460. { "Mic", 0x1 },
  1461. { "Line", 0x5 },
  1462. { "Internal Mic", 0x6 },
  1463. },
  1464. };
  1465. /* 2,4,6 channel modes */
  1466. static struct hda_verb alc880_lg_ch2_init[] = {
  1467. /* set line-in and mic-in to input */
  1468. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1469. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1470. { }
  1471. };
  1472. static struct hda_verb alc880_lg_ch4_init[] = {
  1473. /* set line-in to out and mic-in to input */
  1474. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1475. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1476. { }
  1477. };
  1478. static struct hda_verb alc880_lg_ch6_init[] = {
  1479. /* set line-in and mic-in to output */
  1480. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1481. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1482. { }
  1483. };
  1484. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1485. { 2, alc880_lg_ch2_init },
  1486. { 4, alc880_lg_ch4_init },
  1487. { 6, alc880_lg_ch6_init },
  1488. };
  1489. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1490. /* FIXME: it's not really "master" but front channels */
  1491. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1492. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1493. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1494. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1495. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1496. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1497. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1498. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1499. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1500. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1501. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1502. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1503. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1504. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1505. {
  1506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1507. .name = "Channel Mode",
  1508. .info = alc_ch_mode_info,
  1509. .get = alc_ch_mode_get,
  1510. .put = alc_ch_mode_put,
  1511. },
  1512. { } /* end */
  1513. };
  1514. static struct hda_verb alc880_lg_init_verbs[] = {
  1515. /* set capture source to mic-in */
  1516. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1517. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1519. /* mute all amp mixer inputs */
  1520. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1521. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1522. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1523. /* line-in to input */
  1524. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1526. /* built-in mic */
  1527. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1528. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1529. /* speaker-out */
  1530. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1531. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1532. /* mic-in to input */
  1533. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1534. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1535. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. /* HP-out */
  1537. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1538. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1539. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* jack sense */
  1541. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1542. { }
  1543. };
  1544. /* toggle speaker-output according to the hp-jack state */
  1545. static void alc880_lg_automute(struct hda_codec *codec)
  1546. {
  1547. unsigned int present;
  1548. present = snd_hda_codec_read(codec, 0x1b, 0,
  1549. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1550. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1551. 0x80, present ? 0x80 : 0);
  1552. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1553. 0x80, present ? 0x80 : 0);
  1554. }
  1555. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1556. {
  1557. /* Looks like the unsol event is incompatible with the standard
  1558. * definition. 4bit tag is placed at 28 bit!
  1559. */
  1560. if ((res >> 28) == 0x01)
  1561. alc880_lg_automute(codec);
  1562. }
  1563. /*
  1564. * LG LW20
  1565. *
  1566. * Pin assignment:
  1567. * Speaker-out: 0x14
  1568. * Mic-In: 0x18
  1569. * Built-in Mic-In: 0x19 (?)
  1570. * HP-Out: 0x1b
  1571. * SPDIF-Out: 0x1e
  1572. */
  1573. /* seems analog CD is not working */
  1574. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1575. .num_items = 2,
  1576. .items = {
  1577. { "Mic", 0x0 },
  1578. { "Internal Mic", 0x1 },
  1579. },
  1580. };
  1581. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1582. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1583. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1584. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1585. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1586. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1587. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1588. { } /* end */
  1589. };
  1590. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1591. /* set capture source to mic-in */
  1592. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1593. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1594. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1595. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1596. /* speaker-out */
  1597. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1598. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1599. /* HP-out */
  1600. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1602. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1603. /* mic-in to input */
  1604. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1605. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1606. /* built-in mic */
  1607. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1608. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1609. /* jack sense */
  1610. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1611. { }
  1612. };
  1613. /* toggle speaker-output according to the hp-jack state */
  1614. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1615. {
  1616. unsigned int present;
  1617. present = snd_hda_codec_read(codec, 0x1b, 0,
  1618. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1619. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1620. 0x80, present ? 0x80 : 0);
  1621. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1622. 0x80, present ? 0x80 : 0);
  1623. }
  1624. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1625. {
  1626. /* Looks like the unsol event is incompatible with the standard
  1627. * definition. 4bit tag is placed at 28 bit!
  1628. */
  1629. if ((res >> 28) == 0x01)
  1630. alc880_lg_lw_automute(codec);
  1631. }
  1632. /*
  1633. * Common callbacks
  1634. */
  1635. static int alc_init(struct hda_codec *codec)
  1636. {
  1637. struct alc_spec *spec = codec->spec;
  1638. unsigned int i;
  1639. for (i = 0; i < spec->num_init_verbs; i++)
  1640. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1641. if (spec->init_hook)
  1642. spec->init_hook(codec);
  1643. return 0;
  1644. }
  1645. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1646. {
  1647. struct alc_spec *spec = codec->spec;
  1648. if (spec->unsol_event)
  1649. spec->unsol_event(codec, res);
  1650. }
  1651. #ifdef CONFIG_PM
  1652. /*
  1653. * resume
  1654. */
  1655. static int alc_resume(struct hda_codec *codec)
  1656. {
  1657. struct alc_spec *spec = codec->spec;
  1658. int i;
  1659. alc_init(codec);
  1660. for (i = 0; i < spec->num_mixers; i++)
  1661. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1662. if (spec->multiout.dig_out_nid)
  1663. snd_hda_resume_spdif_out(codec);
  1664. if (spec->dig_in_nid)
  1665. snd_hda_resume_spdif_in(codec);
  1666. return 0;
  1667. }
  1668. #endif
  1669. /*
  1670. * Analog playback callbacks
  1671. */
  1672. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1673. struct hda_codec *codec,
  1674. struct snd_pcm_substream *substream)
  1675. {
  1676. struct alc_spec *spec = codec->spec;
  1677. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1678. }
  1679. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1680. struct hda_codec *codec,
  1681. unsigned int stream_tag,
  1682. unsigned int format,
  1683. struct snd_pcm_substream *substream)
  1684. {
  1685. struct alc_spec *spec = codec->spec;
  1686. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1687. stream_tag, format, substream);
  1688. }
  1689. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1690. struct hda_codec *codec,
  1691. struct snd_pcm_substream *substream)
  1692. {
  1693. struct alc_spec *spec = codec->spec;
  1694. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1695. }
  1696. /*
  1697. * Digital out
  1698. */
  1699. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1700. struct hda_codec *codec,
  1701. struct snd_pcm_substream *substream)
  1702. {
  1703. struct alc_spec *spec = codec->spec;
  1704. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1705. }
  1706. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1707. struct hda_codec *codec,
  1708. struct snd_pcm_substream *substream)
  1709. {
  1710. struct alc_spec *spec = codec->spec;
  1711. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1712. }
  1713. /*
  1714. * Analog capture
  1715. */
  1716. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1717. struct hda_codec *codec,
  1718. unsigned int stream_tag,
  1719. unsigned int format,
  1720. struct snd_pcm_substream *substream)
  1721. {
  1722. struct alc_spec *spec = codec->spec;
  1723. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1724. stream_tag, 0, format);
  1725. return 0;
  1726. }
  1727. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1728. struct hda_codec *codec,
  1729. struct snd_pcm_substream *substream)
  1730. {
  1731. struct alc_spec *spec = codec->spec;
  1732. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1733. 0, 0, 0);
  1734. return 0;
  1735. }
  1736. /*
  1737. */
  1738. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1739. .substreams = 1,
  1740. .channels_min = 2,
  1741. .channels_max = 8,
  1742. /* NID is set in alc_build_pcms */
  1743. .ops = {
  1744. .open = alc880_playback_pcm_open,
  1745. .prepare = alc880_playback_pcm_prepare,
  1746. .cleanup = alc880_playback_pcm_cleanup
  1747. },
  1748. };
  1749. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1750. .substreams = 2,
  1751. .channels_min = 2,
  1752. .channels_max = 2,
  1753. /* NID is set in alc_build_pcms */
  1754. .ops = {
  1755. .prepare = alc880_capture_pcm_prepare,
  1756. .cleanup = alc880_capture_pcm_cleanup
  1757. },
  1758. };
  1759. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1760. .substreams = 1,
  1761. .channels_min = 2,
  1762. .channels_max = 2,
  1763. /* NID is set in alc_build_pcms */
  1764. .ops = {
  1765. .open = alc880_dig_playback_pcm_open,
  1766. .close = alc880_dig_playback_pcm_close
  1767. },
  1768. };
  1769. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1770. .substreams = 1,
  1771. .channels_min = 2,
  1772. .channels_max = 2,
  1773. /* NID is set in alc_build_pcms */
  1774. };
  1775. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1776. static struct hda_pcm_stream alc_pcm_null_playback = {
  1777. .substreams = 0,
  1778. .channels_min = 0,
  1779. .channels_max = 0,
  1780. };
  1781. static int alc_build_pcms(struct hda_codec *codec)
  1782. {
  1783. struct alc_spec *spec = codec->spec;
  1784. struct hda_pcm *info = spec->pcm_rec;
  1785. int i;
  1786. codec->num_pcms = 1;
  1787. codec->pcm_info = info;
  1788. info->name = spec->stream_name_analog;
  1789. if (spec->stream_analog_playback) {
  1790. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1791. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1792. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1793. }
  1794. if (spec->stream_analog_capture) {
  1795. snd_assert(spec->adc_nids, return -EINVAL);
  1796. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1797. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1798. }
  1799. if (spec->channel_mode) {
  1800. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1801. for (i = 0; i < spec->num_channel_mode; i++) {
  1802. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1803. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1804. }
  1805. }
  1806. }
  1807. /* SPDIF for stream index #1 */
  1808. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1809. codec->num_pcms = 2;
  1810. info = spec->pcm_rec + 1;
  1811. info->name = spec->stream_name_digital;
  1812. if (spec->multiout.dig_out_nid &&
  1813. spec->stream_digital_playback) {
  1814. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1815. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1816. }
  1817. if (spec->dig_in_nid &&
  1818. spec->stream_digital_capture) {
  1819. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1820. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1821. }
  1822. }
  1823. /* If the use of more than one ADC is requested for the current
  1824. * model, configure a second analog capture-only PCM.
  1825. */
  1826. /* Additional Analaog capture for index #2 */
  1827. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1828. spec->adc_nids) {
  1829. codec->num_pcms = 3;
  1830. info = spec->pcm_rec + 2;
  1831. info->name = spec->stream_name_analog;
  1832. /* No playback stream for second PCM */
  1833. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1834. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1835. if (spec->stream_analog_capture) {
  1836. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1837. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1838. }
  1839. }
  1840. return 0;
  1841. }
  1842. static void alc_free(struct hda_codec *codec)
  1843. {
  1844. struct alc_spec *spec = codec->spec;
  1845. unsigned int i;
  1846. if (! spec)
  1847. return;
  1848. if (spec->kctl_alloc) {
  1849. for (i = 0; i < spec->num_kctl_used; i++)
  1850. kfree(spec->kctl_alloc[i].name);
  1851. kfree(spec->kctl_alloc);
  1852. }
  1853. kfree(spec);
  1854. }
  1855. /*
  1856. */
  1857. static struct hda_codec_ops alc_patch_ops = {
  1858. .build_controls = alc_build_controls,
  1859. .build_pcms = alc_build_pcms,
  1860. .init = alc_init,
  1861. .free = alc_free,
  1862. .unsol_event = alc_unsol_event,
  1863. #ifdef CONFIG_PM
  1864. .resume = alc_resume,
  1865. #endif
  1866. };
  1867. /*
  1868. * Test configuration for debugging
  1869. *
  1870. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1871. * enum controls.
  1872. */
  1873. #ifdef CONFIG_SND_DEBUG
  1874. static hda_nid_t alc880_test_dac_nids[4] = {
  1875. 0x02, 0x03, 0x04, 0x05
  1876. };
  1877. static struct hda_input_mux alc880_test_capture_source = {
  1878. .num_items = 7,
  1879. .items = {
  1880. { "In-1", 0x0 },
  1881. { "In-2", 0x1 },
  1882. { "In-3", 0x2 },
  1883. { "In-4", 0x3 },
  1884. { "CD", 0x4 },
  1885. { "Front", 0x5 },
  1886. { "Surround", 0x6 },
  1887. },
  1888. };
  1889. static struct hda_channel_mode alc880_test_modes[4] = {
  1890. { 2, NULL },
  1891. { 4, NULL },
  1892. { 6, NULL },
  1893. { 8, NULL },
  1894. };
  1895. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1896. struct snd_ctl_elem_info *uinfo)
  1897. {
  1898. static char *texts[] = {
  1899. "N/A", "Line Out", "HP Out",
  1900. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1901. };
  1902. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1903. uinfo->count = 1;
  1904. uinfo->value.enumerated.items = 8;
  1905. if (uinfo->value.enumerated.item >= 8)
  1906. uinfo->value.enumerated.item = 7;
  1907. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1908. return 0;
  1909. }
  1910. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1911. struct snd_ctl_elem_value *ucontrol)
  1912. {
  1913. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1914. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1915. unsigned int pin_ctl, item = 0;
  1916. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1917. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1918. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1919. if (pin_ctl & AC_PINCTL_HP_EN)
  1920. item = 2;
  1921. else
  1922. item = 1;
  1923. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1924. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1925. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1926. case AC_PINCTL_VREF_50: item = 4; break;
  1927. case AC_PINCTL_VREF_GRD: item = 5; break;
  1928. case AC_PINCTL_VREF_80: item = 6; break;
  1929. case AC_PINCTL_VREF_100: item = 7; break;
  1930. }
  1931. }
  1932. ucontrol->value.enumerated.item[0] = item;
  1933. return 0;
  1934. }
  1935. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1936. struct snd_ctl_elem_value *ucontrol)
  1937. {
  1938. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1939. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1940. static unsigned int ctls[] = {
  1941. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1942. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1943. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1944. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1945. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1946. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1947. };
  1948. unsigned int old_ctl, new_ctl;
  1949. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1950. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1951. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1952. if (old_ctl != new_ctl) {
  1953. snd_hda_codec_write(codec, nid, 0,
  1954. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1955. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1956. (ucontrol->value.enumerated.item[0] >= 3 ?
  1957. 0xb080 : 0xb000));
  1958. return 1;
  1959. }
  1960. return 0;
  1961. }
  1962. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1963. struct snd_ctl_elem_info *uinfo)
  1964. {
  1965. static char *texts[] = {
  1966. "Front", "Surround", "CLFE", "Side"
  1967. };
  1968. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1969. uinfo->count = 1;
  1970. uinfo->value.enumerated.items = 4;
  1971. if (uinfo->value.enumerated.item >= 4)
  1972. uinfo->value.enumerated.item = 3;
  1973. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1974. return 0;
  1975. }
  1976. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1977. struct snd_ctl_elem_value *ucontrol)
  1978. {
  1979. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1980. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1981. unsigned int sel;
  1982. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1983. ucontrol->value.enumerated.item[0] = sel & 3;
  1984. return 0;
  1985. }
  1986. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1987. struct snd_ctl_elem_value *ucontrol)
  1988. {
  1989. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1990. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1991. unsigned int sel;
  1992. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1993. if (ucontrol->value.enumerated.item[0] != sel) {
  1994. sel = ucontrol->value.enumerated.item[0] & 3;
  1995. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1996. return 1;
  1997. }
  1998. return 0;
  1999. }
  2000. #define PIN_CTL_TEST(xname,nid) { \
  2001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2002. .name = xname, \
  2003. .info = alc_test_pin_ctl_info, \
  2004. .get = alc_test_pin_ctl_get, \
  2005. .put = alc_test_pin_ctl_put, \
  2006. .private_value = nid \
  2007. }
  2008. #define PIN_SRC_TEST(xname,nid) { \
  2009. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2010. .name = xname, \
  2011. .info = alc_test_pin_src_info, \
  2012. .get = alc_test_pin_src_get, \
  2013. .put = alc_test_pin_src_put, \
  2014. .private_value = nid \
  2015. }
  2016. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2017. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2018. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2019. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2020. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2021. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2022. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2023. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2024. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2025. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2026. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2027. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2028. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2029. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2030. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2031. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2032. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2033. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2034. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2035. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2036. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2037. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2038. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2039. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2040. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2041. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2042. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2043. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2044. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2045. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2046. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2047. {
  2048. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2049. .name = "Channel Mode",
  2050. .info = alc_ch_mode_info,
  2051. .get = alc_ch_mode_get,
  2052. .put = alc_ch_mode_put,
  2053. },
  2054. { } /* end */
  2055. };
  2056. static struct hda_verb alc880_test_init_verbs[] = {
  2057. /* Unmute inputs of 0x0c - 0x0f */
  2058. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2059. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2060. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2061. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2062. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2063. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2064. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2065. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2066. /* Vol output for 0x0c-0x0f */
  2067. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2068. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2069. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2070. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2071. /* Set output pins 0x14-0x17 */
  2072. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2073. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2074. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2075. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2076. /* Unmute output pins 0x14-0x17 */
  2077. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2078. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2079. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2080. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2081. /* Set input pins 0x18-0x1c */
  2082. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2083. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2084. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2085. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2086. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2087. /* Mute input pins 0x18-0x1b */
  2088. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2089. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2090. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2091. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2092. /* ADC set up */
  2093. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2094. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2095. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2096. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2097. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2098. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2099. /* Analog input/passthru */
  2100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2103. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2104. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2105. { }
  2106. };
  2107. #endif
  2108. /*
  2109. */
  2110. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2111. [ALC880_3ST] = "3stack",
  2112. [ALC880_TCL_S700] = "tcl",
  2113. [ALC880_3ST_DIG] = "3stack-digout",
  2114. [ALC880_CLEVO] = "clevo",
  2115. [ALC880_5ST] = "5stack",
  2116. [ALC880_5ST_DIG] = "5stack-digout",
  2117. [ALC880_W810] = "w810",
  2118. [ALC880_Z71V] = "z71v",
  2119. [ALC880_6ST] = "6stack",
  2120. [ALC880_6ST_DIG] = "6stack-digout",
  2121. [ALC880_ASUS] = "asus",
  2122. [ALC880_ASUS_W1V] = "asus-w1v",
  2123. [ALC880_ASUS_DIG] = "asus-dig",
  2124. [ALC880_ASUS_DIG2] = "asus-dig2",
  2125. [ALC880_UNIWILL_DIG] = "uniwill",
  2126. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2127. [ALC880_FUJITSU] = "fujitsu",
  2128. [ALC880_F1734] = "F1734",
  2129. [ALC880_LG] = "lg",
  2130. [ALC880_LG_LW] = "lg-lw",
  2131. #ifdef CONFIG_SND_DEBUG
  2132. [ALC880_TEST] = "test",
  2133. #endif
  2134. [ALC880_AUTO] = "auto",
  2135. };
  2136. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2137. /* Broken BIOS configuration */
  2138. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2139. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2140. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2141. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2142. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2143. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2144. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2145. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2146. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2147. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2148. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2149. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2150. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2151. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2152. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2153. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2154. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2155. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2156. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2157. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2158. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2159. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2160. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2161. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2162. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2163. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2164. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2165. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2166. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2167. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2168. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2169. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2170. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2171. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2172. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2173. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2174. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2175. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2176. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2177. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2178. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2179. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2180. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2181. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2182. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2183. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2184. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2185. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2186. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2187. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2188. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2189. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2190. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2191. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2192. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2193. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2194. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2195. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2196. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2197. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2198. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2199. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2200. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2201. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2202. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2203. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2204. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2205. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2206. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2207. {}
  2208. };
  2209. /*
  2210. * ALC880 codec presets
  2211. */
  2212. static struct alc_config_preset alc880_presets[] = {
  2213. [ALC880_3ST] = {
  2214. .mixers = { alc880_three_stack_mixer },
  2215. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2216. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2217. .dac_nids = alc880_dac_nids,
  2218. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2219. .channel_mode = alc880_threestack_modes,
  2220. .need_dac_fix = 1,
  2221. .input_mux = &alc880_capture_source,
  2222. },
  2223. [ALC880_3ST_DIG] = {
  2224. .mixers = { alc880_three_stack_mixer },
  2225. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2226. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2227. .dac_nids = alc880_dac_nids,
  2228. .dig_out_nid = ALC880_DIGOUT_NID,
  2229. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2230. .channel_mode = alc880_threestack_modes,
  2231. .need_dac_fix = 1,
  2232. .input_mux = &alc880_capture_source,
  2233. },
  2234. [ALC880_TCL_S700] = {
  2235. .mixers = { alc880_tcl_s700_mixer },
  2236. .init_verbs = { alc880_volume_init_verbs,
  2237. alc880_pin_tcl_S700_init_verbs,
  2238. alc880_gpio2_init_verbs },
  2239. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2240. .dac_nids = alc880_dac_nids,
  2241. .hp_nid = 0x03,
  2242. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2243. .channel_mode = alc880_2_jack_modes,
  2244. .input_mux = &alc880_capture_source,
  2245. },
  2246. [ALC880_5ST] = {
  2247. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2248. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2249. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2250. .dac_nids = alc880_dac_nids,
  2251. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2252. .channel_mode = alc880_fivestack_modes,
  2253. .input_mux = &alc880_capture_source,
  2254. },
  2255. [ALC880_5ST_DIG] = {
  2256. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2257. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2258. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2259. .dac_nids = alc880_dac_nids,
  2260. .dig_out_nid = ALC880_DIGOUT_NID,
  2261. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2262. .channel_mode = alc880_fivestack_modes,
  2263. .input_mux = &alc880_capture_source,
  2264. },
  2265. [ALC880_6ST] = {
  2266. .mixers = { alc880_six_stack_mixer },
  2267. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2268. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2269. .dac_nids = alc880_6st_dac_nids,
  2270. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2271. .channel_mode = alc880_sixstack_modes,
  2272. .input_mux = &alc880_6stack_capture_source,
  2273. },
  2274. [ALC880_6ST_DIG] = {
  2275. .mixers = { alc880_six_stack_mixer },
  2276. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2277. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2278. .dac_nids = alc880_6st_dac_nids,
  2279. .dig_out_nid = ALC880_DIGOUT_NID,
  2280. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2281. .channel_mode = alc880_sixstack_modes,
  2282. .input_mux = &alc880_6stack_capture_source,
  2283. },
  2284. [ALC880_W810] = {
  2285. .mixers = { alc880_w810_base_mixer },
  2286. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2287. alc880_gpio2_init_verbs },
  2288. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2289. .dac_nids = alc880_w810_dac_nids,
  2290. .dig_out_nid = ALC880_DIGOUT_NID,
  2291. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2292. .channel_mode = alc880_w810_modes,
  2293. .input_mux = &alc880_capture_source,
  2294. },
  2295. [ALC880_Z71V] = {
  2296. .mixers = { alc880_z71v_mixer },
  2297. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2298. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2299. .dac_nids = alc880_z71v_dac_nids,
  2300. .dig_out_nid = ALC880_DIGOUT_NID,
  2301. .hp_nid = 0x03,
  2302. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2303. .channel_mode = alc880_2_jack_modes,
  2304. .input_mux = &alc880_capture_source,
  2305. },
  2306. [ALC880_F1734] = {
  2307. .mixers = { alc880_f1734_mixer },
  2308. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2309. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2310. .dac_nids = alc880_f1734_dac_nids,
  2311. .hp_nid = 0x02,
  2312. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2313. .channel_mode = alc880_2_jack_modes,
  2314. .input_mux = &alc880_capture_source,
  2315. },
  2316. [ALC880_ASUS] = {
  2317. .mixers = { alc880_asus_mixer },
  2318. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2319. alc880_gpio1_init_verbs },
  2320. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2321. .dac_nids = alc880_asus_dac_nids,
  2322. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2323. .channel_mode = alc880_asus_modes,
  2324. .need_dac_fix = 1,
  2325. .input_mux = &alc880_capture_source,
  2326. },
  2327. [ALC880_ASUS_DIG] = {
  2328. .mixers = { alc880_asus_mixer },
  2329. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2330. alc880_gpio1_init_verbs },
  2331. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2332. .dac_nids = alc880_asus_dac_nids,
  2333. .dig_out_nid = ALC880_DIGOUT_NID,
  2334. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2335. .channel_mode = alc880_asus_modes,
  2336. .need_dac_fix = 1,
  2337. .input_mux = &alc880_capture_source,
  2338. },
  2339. [ALC880_ASUS_DIG2] = {
  2340. .mixers = { alc880_asus_mixer },
  2341. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2342. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2343. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2344. .dac_nids = alc880_asus_dac_nids,
  2345. .dig_out_nid = ALC880_DIGOUT_NID,
  2346. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2347. .channel_mode = alc880_asus_modes,
  2348. .need_dac_fix = 1,
  2349. .input_mux = &alc880_capture_source,
  2350. },
  2351. [ALC880_ASUS_W1V] = {
  2352. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2353. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2354. alc880_gpio1_init_verbs },
  2355. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2356. .dac_nids = alc880_asus_dac_nids,
  2357. .dig_out_nid = ALC880_DIGOUT_NID,
  2358. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2359. .channel_mode = alc880_asus_modes,
  2360. .need_dac_fix = 1,
  2361. .input_mux = &alc880_capture_source,
  2362. },
  2363. [ALC880_UNIWILL_DIG] = {
  2364. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2365. .init_verbs = { alc880_volume_init_verbs,
  2366. alc880_pin_asus_init_verbs },
  2367. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2368. .dac_nids = alc880_asus_dac_nids,
  2369. .dig_out_nid = ALC880_DIGOUT_NID,
  2370. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2371. .channel_mode = alc880_asus_modes,
  2372. .need_dac_fix = 1,
  2373. .input_mux = &alc880_capture_source,
  2374. },
  2375. [ALC880_UNIWILL] = {
  2376. .mixers = { alc880_uniwill_mixer },
  2377. .init_verbs = { alc880_volume_init_verbs,
  2378. alc880_uniwill_init_verbs },
  2379. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2380. .dac_nids = alc880_asus_dac_nids,
  2381. .dig_out_nid = ALC880_DIGOUT_NID,
  2382. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2383. .channel_mode = alc880_threestack_modes,
  2384. .need_dac_fix = 1,
  2385. .input_mux = &alc880_capture_source,
  2386. .unsol_event = alc880_uniwill_unsol_event,
  2387. .init_hook = alc880_uniwill_automute,
  2388. },
  2389. [ALC880_UNIWILL_P53] = {
  2390. .mixers = { alc880_uniwill_p53_mixer },
  2391. .init_verbs = { alc880_volume_init_verbs,
  2392. alc880_uniwill_p53_init_verbs },
  2393. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2394. .dac_nids = alc880_asus_dac_nids,
  2395. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2396. .channel_mode = alc880_threestack_modes,
  2397. .input_mux = &alc880_capture_source,
  2398. .unsol_event = alc880_uniwill_p53_unsol_event,
  2399. .init_hook = alc880_uniwill_p53_hp_automute,
  2400. },
  2401. [ALC880_FUJITSU] = {
  2402. .mixers = { alc880_fujitsu_mixer,
  2403. alc880_pcbeep_mixer, },
  2404. .init_verbs = { alc880_volume_init_verbs,
  2405. alc880_uniwill_p53_init_verbs,
  2406. alc880_beep_init_verbs },
  2407. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2408. .dac_nids = alc880_dac_nids,
  2409. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2410. .channel_mode = alc880_2_jack_modes,
  2411. .input_mux = &alc880_capture_source,
  2412. .unsol_event = alc880_uniwill_p53_unsol_event,
  2413. .init_hook = alc880_uniwill_p53_hp_automute,
  2414. },
  2415. [ALC880_CLEVO] = {
  2416. .mixers = { alc880_three_stack_mixer },
  2417. .init_verbs = { alc880_volume_init_verbs,
  2418. alc880_pin_clevo_init_verbs },
  2419. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2420. .dac_nids = alc880_dac_nids,
  2421. .hp_nid = 0x03,
  2422. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2423. .channel_mode = alc880_threestack_modes,
  2424. .need_dac_fix = 1,
  2425. .input_mux = &alc880_capture_source,
  2426. },
  2427. [ALC880_LG] = {
  2428. .mixers = { alc880_lg_mixer },
  2429. .init_verbs = { alc880_volume_init_verbs,
  2430. alc880_lg_init_verbs },
  2431. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2432. .dac_nids = alc880_lg_dac_nids,
  2433. .dig_out_nid = ALC880_DIGOUT_NID,
  2434. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2435. .channel_mode = alc880_lg_ch_modes,
  2436. .need_dac_fix = 1,
  2437. .input_mux = &alc880_lg_capture_source,
  2438. .unsol_event = alc880_lg_unsol_event,
  2439. .init_hook = alc880_lg_automute,
  2440. },
  2441. [ALC880_LG_LW] = {
  2442. .mixers = { alc880_lg_lw_mixer },
  2443. .init_verbs = { alc880_volume_init_verbs,
  2444. alc880_lg_lw_init_verbs },
  2445. .num_dacs = 1,
  2446. .dac_nids = alc880_dac_nids,
  2447. .dig_out_nid = ALC880_DIGOUT_NID,
  2448. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2449. .channel_mode = alc880_2_jack_modes,
  2450. .input_mux = &alc880_lg_lw_capture_source,
  2451. .unsol_event = alc880_lg_lw_unsol_event,
  2452. .init_hook = alc880_lg_lw_automute,
  2453. },
  2454. #ifdef CONFIG_SND_DEBUG
  2455. [ALC880_TEST] = {
  2456. .mixers = { alc880_test_mixer },
  2457. .init_verbs = { alc880_test_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2459. .dac_nids = alc880_test_dac_nids,
  2460. .dig_out_nid = ALC880_DIGOUT_NID,
  2461. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2462. .channel_mode = alc880_test_modes,
  2463. .input_mux = &alc880_test_capture_source,
  2464. },
  2465. #endif
  2466. };
  2467. /*
  2468. * Automatic parse of I/O pins from the BIOS configuration
  2469. */
  2470. #define NUM_CONTROL_ALLOC 32
  2471. #define NUM_VERB_ALLOC 32
  2472. enum {
  2473. ALC_CTL_WIDGET_VOL,
  2474. ALC_CTL_WIDGET_MUTE,
  2475. ALC_CTL_BIND_MUTE,
  2476. };
  2477. static struct snd_kcontrol_new alc880_control_templates[] = {
  2478. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2479. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2480. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2481. };
  2482. /* add dynamic controls */
  2483. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2484. {
  2485. struct snd_kcontrol_new *knew;
  2486. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2487. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2488. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2489. if (! knew)
  2490. return -ENOMEM;
  2491. if (spec->kctl_alloc) {
  2492. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2493. kfree(spec->kctl_alloc);
  2494. }
  2495. spec->kctl_alloc = knew;
  2496. spec->num_kctl_alloc = num;
  2497. }
  2498. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2499. *knew = alc880_control_templates[type];
  2500. knew->name = kstrdup(name, GFP_KERNEL);
  2501. if (! knew->name)
  2502. return -ENOMEM;
  2503. knew->private_value = val;
  2504. spec->num_kctl_used++;
  2505. return 0;
  2506. }
  2507. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2508. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2509. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2510. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2511. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2512. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2513. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2514. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2515. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2516. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2517. #define ALC880_PIN_CD_NID 0x1c
  2518. /* fill in the dac_nids table from the parsed pin configuration */
  2519. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2520. {
  2521. hda_nid_t nid;
  2522. int assigned[4];
  2523. int i, j;
  2524. memset(assigned, 0, sizeof(assigned));
  2525. spec->multiout.dac_nids = spec->private_dac_nids;
  2526. /* check the pins hardwired to audio widget */
  2527. for (i = 0; i < cfg->line_outs; i++) {
  2528. nid = cfg->line_out_pins[i];
  2529. if (alc880_is_fixed_pin(nid)) {
  2530. int idx = alc880_fixed_pin_idx(nid);
  2531. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2532. assigned[idx] = 1;
  2533. }
  2534. }
  2535. /* left pins can be connect to any audio widget */
  2536. for (i = 0; i < cfg->line_outs; i++) {
  2537. nid = cfg->line_out_pins[i];
  2538. if (alc880_is_fixed_pin(nid))
  2539. continue;
  2540. /* search for an empty channel */
  2541. for (j = 0; j < cfg->line_outs; j++) {
  2542. if (! assigned[j]) {
  2543. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2544. assigned[j] = 1;
  2545. break;
  2546. }
  2547. }
  2548. }
  2549. spec->multiout.num_dacs = cfg->line_outs;
  2550. return 0;
  2551. }
  2552. /* add playback controls from the parsed DAC table */
  2553. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2554. const struct auto_pin_cfg *cfg)
  2555. {
  2556. char name[32];
  2557. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2558. hda_nid_t nid;
  2559. int i, err;
  2560. for (i = 0; i < cfg->line_outs; i++) {
  2561. if (! spec->multiout.dac_nids[i])
  2562. continue;
  2563. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2564. if (i == 2) {
  2565. /* Center/LFE */
  2566. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2567. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2568. return err;
  2569. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2570. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2571. return err;
  2572. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2573. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2574. return err;
  2575. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2576. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2577. return err;
  2578. } else {
  2579. sprintf(name, "%s Playback Volume", chname[i]);
  2580. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2581. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2582. return err;
  2583. sprintf(name, "%s Playback Switch", chname[i]);
  2584. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2585. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2586. return err;
  2587. }
  2588. }
  2589. return 0;
  2590. }
  2591. /* add playback controls for speaker and HP outputs */
  2592. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2593. const char *pfx)
  2594. {
  2595. hda_nid_t nid;
  2596. int err;
  2597. char name[32];
  2598. if (! pin)
  2599. return 0;
  2600. if (alc880_is_fixed_pin(pin)) {
  2601. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2602. /* specify the DAC as the extra output */
  2603. if (! spec->multiout.hp_nid)
  2604. spec->multiout.hp_nid = nid;
  2605. else
  2606. spec->multiout.extra_out_nid[0] = nid;
  2607. /* control HP volume/switch on the output mixer amp */
  2608. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2609. sprintf(name, "%s Playback Volume", pfx);
  2610. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2611. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2612. return err;
  2613. sprintf(name, "%s Playback Switch", pfx);
  2614. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2615. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2616. return err;
  2617. } else if (alc880_is_multi_pin(pin)) {
  2618. /* set manual connection */
  2619. /* we have only a switch on HP-out PIN */
  2620. sprintf(name, "%s Playback Switch", pfx);
  2621. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2622. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2623. return err;
  2624. }
  2625. return 0;
  2626. }
  2627. /* create input playback/capture controls for the given pin */
  2628. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2629. int idx, hda_nid_t mix_nid)
  2630. {
  2631. char name[32];
  2632. int err;
  2633. sprintf(name, "%s Playback Volume", ctlname);
  2634. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2635. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2636. return err;
  2637. sprintf(name, "%s Playback Switch", ctlname);
  2638. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2639. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2640. return err;
  2641. return 0;
  2642. }
  2643. /* create playback/capture controls for input pins */
  2644. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2645. const struct auto_pin_cfg *cfg)
  2646. {
  2647. struct hda_input_mux *imux = &spec->private_imux;
  2648. int i, err, idx;
  2649. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2650. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2651. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2652. err = new_analog_input(spec, cfg->input_pins[i],
  2653. auto_pin_cfg_labels[i],
  2654. idx, 0x0b);
  2655. if (err < 0)
  2656. return err;
  2657. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2658. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2659. imux->num_items++;
  2660. }
  2661. }
  2662. return 0;
  2663. }
  2664. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2665. hda_nid_t nid, int pin_type,
  2666. int dac_idx)
  2667. {
  2668. /* set as output */
  2669. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2670. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2671. /* need the manual connection? */
  2672. if (alc880_is_multi_pin(nid)) {
  2673. struct alc_spec *spec = codec->spec;
  2674. int idx = alc880_multi_pin_idx(nid);
  2675. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2676. AC_VERB_SET_CONNECT_SEL,
  2677. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2678. }
  2679. }
  2680. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2681. {
  2682. struct alc_spec *spec = codec->spec;
  2683. int i;
  2684. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2685. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2686. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2687. }
  2688. }
  2689. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2690. {
  2691. struct alc_spec *spec = codec->spec;
  2692. hda_nid_t pin;
  2693. pin = spec->autocfg.speaker_pins[0];
  2694. if (pin) /* connect to front */
  2695. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2696. pin = spec->autocfg.hp_pins[0];
  2697. if (pin) /* connect to front */
  2698. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2699. }
  2700. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2701. {
  2702. struct alc_spec *spec = codec->spec;
  2703. int i;
  2704. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2705. hda_nid_t nid = spec->autocfg.input_pins[i];
  2706. if (alc880_is_input_pin(nid)) {
  2707. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2708. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2709. if (nid != ALC880_PIN_CD_NID)
  2710. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2711. AMP_OUT_MUTE);
  2712. }
  2713. }
  2714. }
  2715. /* parse the BIOS configuration and set up the alc_spec */
  2716. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2717. static int alc880_parse_auto_config(struct hda_codec *codec)
  2718. {
  2719. struct alc_spec *spec = codec->spec;
  2720. int err;
  2721. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2722. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2723. alc880_ignore)) < 0)
  2724. return err;
  2725. if (! spec->autocfg.line_outs)
  2726. return 0; /* can't find valid BIOS pin config */
  2727. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2728. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2729. (err = alc880_auto_create_extra_out(spec,
  2730. spec->autocfg.speaker_pins[0],
  2731. "Speaker")) < 0 ||
  2732. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2733. "Headphone")) < 0 ||
  2734. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2735. return err;
  2736. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2737. if (spec->autocfg.dig_out_pin)
  2738. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2739. if (spec->autocfg.dig_in_pin)
  2740. spec->dig_in_nid = ALC880_DIGIN_NID;
  2741. if (spec->kctl_alloc)
  2742. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2743. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2744. spec->num_mux_defs = 1;
  2745. spec->input_mux = &spec->private_imux;
  2746. return 1;
  2747. }
  2748. /* additional initialization for auto-configuration model */
  2749. static void alc880_auto_init(struct hda_codec *codec)
  2750. {
  2751. alc880_auto_init_multi_out(codec);
  2752. alc880_auto_init_extra_out(codec);
  2753. alc880_auto_init_analog_input(codec);
  2754. }
  2755. /*
  2756. * OK, here we have finally the patch for ALC880
  2757. */
  2758. static int patch_alc880(struct hda_codec *codec)
  2759. {
  2760. struct alc_spec *spec;
  2761. int board_config;
  2762. int err;
  2763. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2764. if (spec == NULL)
  2765. return -ENOMEM;
  2766. codec->spec = spec;
  2767. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2768. alc880_models,
  2769. alc880_cfg_tbl);
  2770. if (board_config < 0) {
  2771. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2772. "trying auto-probe from BIOS...\n");
  2773. board_config = ALC880_AUTO;
  2774. }
  2775. if (board_config == ALC880_AUTO) {
  2776. /* automatic parse from the BIOS config */
  2777. err = alc880_parse_auto_config(codec);
  2778. if (err < 0) {
  2779. alc_free(codec);
  2780. return err;
  2781. } else if (! err) {
  2782. printk(KERN_INFO
  2783. "hda_codec: Cannot set up configuration "
  2784. "from BIOS. Using 3-stack mode...\n");
  2785. board_config = ALC880_3ST;
  2786. }
  2787. }
  2788. if (board_config != ALC880_AUTO)
  2789. setup_preset(spec, &alc880_presets[board_config]);
  2790. spec->stream_name_analog = "ALC880 Analog";
  2791. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2792. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2793. spec->stream_name_digital = "ALC880 Digital";
  2794. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2795. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2796. if (! spec->adc_nids && spec->input_mux) {
  2797. /* check whether NID 0x07 is valid */
  2798. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2799. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2800. if (wcap != AC_WID_AUD_IN) {
  2801. spec->adc_nids = alc880_adc_nids_alt;
  2802. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2803. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2804. spec->num_mixers++;
  2805. } else {
  2806. spec->adc_nids = alc880_adc_nids;
  2807. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2808. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2809. spec->num_mixers++;
  2810. }
  2811. }
  2812. codec->patch_ops = alc_patch_ops;
  2813. if (board_config == ALC880_AUTO)
  2814. spec->init_hook = alc880_auto_init;
  2815. return 0;
  2816. }
  2817. /*
  2818. * ALC260 support
  2819. */
  2820. static hda_nid_t alc260_dac_nids[1] = {
  2821. /* front */
  2822. 0x02,
  2823. };
  2824. static hda_nid_t alc260_adc_nids[1] = {
  2825. /* ADC0 */
  2826. 0x04,
  2827. };
  2828. static hda_nid_t alc260_adc_nids_alt[1] = {
  2829. /* ADC1 */
  2830. 0x05,
  2831. };
  2832. static hda_nid_t alc260_hp_adc_nids[2] = {
  2833. /* ADC1, 0 */
  2834. 0x05, 0x04
  2835. };
  2836. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2837. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2838. */
  2839. static hda_nid_t alc260_dual_adc_nids[2] = {
  2840. /* ADC0, ADC1 */
  2841. 0x04, 0x05
  2842. };
  2843. #define ALC260_DIGOUT_NID 0x03
  2844. #define ALC260_DIGIN_NID 0x06
  2845. static struct hda_input_mux alc260_capture_source = {
  2846. .num_items = 4,
  2847. .items = {
  2848. { "Mic", 0x0 },
  2849. { "Front Mic", 0x1 },
  2850. { "Line", 0x2 },
  2851. { "CD", 0x4 },
  2852. },
  2853. };
  2854. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2855. * headphone jack and the internal CD lines since these are the only pins at
  2856. * which audio can appear. For flexibility, also allow the option of
  2857. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2858. * connection to the mixer output).
  2859. */
  2860. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2861. {
  2862. .num_items = 3,
  2863. .items = {
  2864. { "Mic/Line", 0x0 },
  2865. { "CD", 0x4 },
  2866. { "Headphone", 0x2 },
  2867. },
  2868. },
  2869. {
  2870. .num_items = 4,
  2871. .items = {
  2872. { "Mic/Line", 0x0 },
  2873. { "CD", 0x4 },
  2874. { "Headphone", 0x2 },
  2875. { "Mixer", 0x5 },
  2876. },
  2877. },
  2878. };
  2879. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2880. * the Fujitsu S702x, but jacks are marked differently.
  2881. */
  2882. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2883. {
  2884. .num_items = 4,
  2885. .items = {
  2886. { "Mic", 0x0 },
  2887. { "Line", 0x2 },
  2888. { "CD", 0x4 },
  2889. { "Headphone", 0x5 },
  2890. },
  2891. },
  2892. {
  2893. .num_items = 5,
  2894. .items = {
  2895. { "Mic", 0x0 },
  2896. { "Line", 0x2 },
  2897. { "CD", 0x4 },
  2898. { "Headphone", 0x6 },
  2899. { "Mixer", 0x5 },
  2900. },
  2901. },
  2902. };
  2903. /*
  2904. * This is just place-holder, so there's something for alc_build_pcms to look
  2905. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2906. * element which allows changing the channel mode, so the verb list is
  2907. * never used.
  2908. */
  2909. static struct hda_channel_mode alc260_modes[1] = {
  2910. { 2, NULL },
  2911. };
  2912. /* Mixer combinations
  2913. *
  2914. * basic: base_output + input + pc_beep + capture
  2915. * HP: base_output + input + capture_alt
  2916. * HP_3013: hp_3013 + input + capture
  2917. * fujitsu: fujitsu + capture
  2918. * acer: acer + capture
  2919. */
  2920. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2921. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2922. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2923. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2924. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2925. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2926. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2927. { } /* end */
  2928. };
  2929. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2930. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2931. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2932. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2933. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2934. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2935. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2936. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2937. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2938. { } /* end */
  2939. };
  2940. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2941. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2942. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2943. { } /* end */
  2944. };
  2945. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2946. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2947. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2948. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2949. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2950. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2951. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2952. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2953. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2954. { } /* end */
  2955. };
  2956. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2957. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2958. */
  2959. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2960. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2961. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2962. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2963. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2964. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2965. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2966. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2967. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2968. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2969. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2970. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2971. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2972. { } /* end */
  2973. };
  2974. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2975. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2976. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2977. * datasheet doesn't mention this restriction. At this stage it's not clear
  2978. * whether this behaviour is intentional or is a hardware bug in chip
  2979. * revisions available in early 2006. Therefore for now allow the
  2980. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2981. * that the lack of mic bias for this NID is intentional we could change the
  2982. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2983. *
  2984. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2985. * don't appear to make the mic bias available from the "line" jack, even
  2986. * though the NID used for this jack (0x14) can supply it. The theory is
  2987. * that perhaps Acer have included blocking capacitors between the ALC260
  2988. * and the output jack. If this turns out to be the case for all such
  2989. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2990. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2991. *
  2992. * The C20x Tablet series have a mono internal speaker which is controlled
  2993. * via the chip's Mono sum widget and pin complex, so include the necessary
  2994. * controls for such models. On models without a "mono speaker" the control
  2995. * won't do anything.
  2996. */
  2997. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2998. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2999. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3000. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3001. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3002. HDA_OUTPUT),
  3003. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3004. HDA_INPUT),
  3005. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3006. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3007. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3008. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3009. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3010. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3011. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3012. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3013. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3014. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3015. { } /* end */
  3016. };
  3017. /* capture mixer elements */
  3018. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3019. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3020. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3021. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3022. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3023. {
  3024. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3025. /* The multiple "Capture Source" controls confuse alsamixer
  3026. * So call somewhat different..
  3027. * FIXME: the controls appear in the "playback" view!
  3028. */
  3029. /* .name = "Capture Source", */
  3030. .name = "Input Source",
  3031. .count = 2,
  3032. .info = alc_mux_enum_info,
  3033. .get = alc_mux_enum_get,
  3034. .put = alc_mux_enum_put,
  3035. },
  3036. { } /* end */
  3037. };
  3038. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3039. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3040. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3041. {
  3042. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3043. /* The multiple "Capture Source" controls confuse alsamixer
  3044. * So call somewhat different..
  3045. * FIXME: the controls appear in the "playback" view!
  3046. */
  3047. /* .name = "Capture Source", */
  3048. .name = "Input Source",
  3049. .count = 1,
  3050. .info = alc_mux_enum_info,
  3051. .get = alc_mux_enum_get,
  3052. .put = alc_mux_enum_put,
  3053. },
  3054. { } /* end */
  3055. };
  3056. /*
  3057. * initialization verbs
  3058. */
  3059. static struct hda_verb alc260_init_verbs[] = {
  3060. /* Line In pin widget for input */
  3061. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3062. /* CD pin widget for input */
  3063. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3064. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3065. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3066. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3067. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3068. /* LINE-2 is used for line-out in rear */
  3069. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3070. /* select line-out */
  3071. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3072. /* LINE-OUT pin */
  3073. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3074. /* enable HP */
  3075. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3076. /* enable Mono */
  3077. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3078. /* mute capture amp left and right */
  3079. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3080. /* set connection select to line in (default select for this ADC) */
  3081. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3082. /* mute capture amp left and right */
  3083. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3084. /* set connection select to line in (default select for this ADC) */
  3085. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3086. /* set vol=0 Line-Out mixer amp left and right */
  3087. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3088. /* unmute pin widget amp left and right (no gain on this amp) */
  3089. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3090. /* set vol=0 HP mixer amp left and right */
  3091. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3092. /* unmute pin widget amp left and right (no gain on this amp) */
  3093. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3094. /* set vol=0 Mono mixer amp left and right */
  3095. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3096. /* unmute pin widget amp left and right (no gain on this amp) */
  3097. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3098. /* unmute LINE-2 out pin */
  3099. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3100. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3101. /* mute CD */
  3102. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3103. /* mute Line In */
  3104. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3105. /* mute Mic */
  3106. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3107. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3108. /* mute Front out path */
  3109. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3110. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3111. /* mute Headphone out path */
  3112. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3113. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3114. /* mute Mono out path */
  3115. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3116. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3117. { }
  3118. };
  3119. #if 0 /* should be identical with alc260_init_verbs? */
  3120. static struct hda_verb alc260_hp_init_verbs[] = {
  3121. /* Headphone and output */
  3122. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3123. /* mono output */
  3124. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3125. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3126. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3127. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3128. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3129. /* Line In pin widget for input */
  3130. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3131. /* Line-2 pin widget for output */
  3132. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3133. /* CD pin widget for input */
  3134. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3135. /* unmute amp left and right */
  3136. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3137. /* set connection select to line in (default select for this ADC) */
  3138. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3139. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3140. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3141. /* mute pin widget amp left and right (no gain on this amp) */
  3142. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3143. /* unmute HP mixer amp left and right (volume = 0) */
  3144. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3145. /* mute pin widget amp left and right (no gain on this amp) */
  3146. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3147. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3148. /* unmute CD */
  3149. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3150. /* unmute Line In */
  3151. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3152. /* unmute Mic */
  3153. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3154. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3155. /* Unmute Front out path */
  3156. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3157. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3158. /* Unmute Headphone out path */
  3159. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3160. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3161. /* Unmute Mono out path */
  3162. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3163. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3164. { }
  3165. };
  3166. #endif
  3167. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3168. /* Line out and output */
  3169. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3170. /* mono output */
  3171. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3172. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3173. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3174. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3175. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3176. /* Line In pin widget for input */
  3177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3178. /* Headphone pin widget for output */
  3179. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3180. /* CD pin widget for input */
  3181. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3182. /* unmute amp left and right */
  3183. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3184. /* set connection select to line in (default select for this ADC) */
  3185. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3186. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3187. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3188. /* mute pin widget amp left and right (no gain on this amp) */
  3189. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3190. /* unmute HP mixer amp left and right (volume = 0) */
  3191. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3192. /* mute pin widget amp left and right (no gain on this amp) */
  3193. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3194. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3195. /* unmute CD */
  3196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3197. /* unmute Line In */
  3198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3199. /* unmute Mic */
  3200. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3201. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3202. /* Unmute Front out path */
  3203. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3204. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3205. /* Unmute Headphone out path */
  3206. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3207. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3208. /* Unmute Mono out path */
  3209. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3210. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3211. { }
  3212. };
  3213. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3214. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3215. * audio = 0x16, internal speaker = 0x10.
  3216. */
  3217. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3218. /* Disable all GPIOs */
  3219. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3220. /* Internal speaker is connected to headphone pin */
  3221. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3222. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3223. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3224. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3225. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3226. /* Ensure all other unused pins are disabled and muted. */
  3227. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3228. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3229. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3230. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3231. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3232. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3233. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3234. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3235. /* Disable digital (SPDIF) pins */
  3236. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3237. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3238. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3239. * when acting as an output.
  3240. */
  3241. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3242. /* Start with output sum widgets muted and their output gains at min */
  3243. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3244. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3245. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3246. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3247. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3248. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3249. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3250. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3251. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3252. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3253. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3254. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3255. * If the pin mode is changed by the user the pin mode control will
  3256. * take care of enabling the pin's input/output buffers as needed.
  3257. * Therefore there's no need to enable the input buffer at this
  3258. * stage.
  3259. */
  3260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3261. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3262. * mixer ctrl)
  3263. */
  3264. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3265. /* Mute capture amp left and right */
  3266. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. /* Set ADC connection select to match default mixer setting - line
  3268. * in (on mic1 pin)
  3269. */
  3270. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3271. /* Do the same for the second ADC: mute capture input amp and
  3272. * set ADC connection to line in (on mic1 pin)
  3273. */
  3274. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3275. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3276. /* Mute all inputs to mixer widget (even unconnected ones) */
  3277. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3278. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3279. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3280. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3281. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3282. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3283. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3284. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3285. { }
  3286. };
  3287. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3288. * similar laptops (adapted from Fujitsu init verbs).
  3289. */
  3290. static struct hda_verb alc260_acer_init_verbs[] = {
  3291. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3292. * the headphone jack. Turn this on and rely on the standard mute
  3293. * methods whenever the user wants to turn these outputs off.
  3294. */
  3295. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3296. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3297. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3298. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3299. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3300. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3301. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3302. /* Line In jack is connected to Line1 pin */
  3303. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3304. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3305. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3306. /* Ensure all other unused pins are disabled and muted. */
  3307. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3308. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3309. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3310. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3313. /* Disable digital (SPDIF) pins */
  3314. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3315. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3316. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3317. * bus when acting as outputs.
  3318. */
  3319. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3320. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3321. /* Start with output sum widgets muted and their output gains at min */
  3322. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3323. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3324. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3325. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3326. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3327. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3328. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3329. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3330. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3331. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3332. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3333. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3334. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3335. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3336. * inputs. If the pin mode is changed by the user the pin mode control
  3337. * will take care of enabling the pin's input/output buffers as needed.
  3338. * Therefore there's no need to enable the input buffer at this
  3339. * stage.
  3340. */
  3341. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3343. /* Mute capture amp left and right */
  3344. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3345. /* Set ADC connection select to match default mixer setting - mic
  3346. * (on mic1 pin)
  3347. */
  3348. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3349. /* Do similar with the second ADC: mute capture input amp and
  3350. * set ADC connection to mic to match ALSA's default state.
  3351. */
  3352. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3353. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3354. /* Mute all inputs to mixer widget (even unconnected ones) */
  3355. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3356. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3357. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3358. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3359. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3360. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3361. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3362. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3363. { }
  3364. };
  3365. /* Test configuration for debugging, modelled after the ALC880 test
  3366. * configuration.
  3367. */
  3368. #ifdef CONFIG_SND_DEBUG
  3369. static hda_nid_t alc260_test_dac_nids[1] = {
  3370. 0x02,
  3371. };
  3372. static hda_nid_t alc260_test_adc_nids[2] = {
  3373. 0x04, 0x05,
  3374. };
  3375. /* For testing the ALC260, each input MUX needs its own definition since
  3376. * the signal assignments are different. This assumes that the first ADC
  3377. * is NID 0x04.
  3378. */
  3379. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3380. {
  3381. .num_items = 7,
  3382. .items = {
  3383. { "MIC1 pin", 0x0 },
  3384. { "MIC2 pin", 0x1 },
  3385. { "LINE1 pin", 0x2 },
  3386. { "LINE2 pin", 0x3 },
  3387. { "CD pin", 0x4 },
  3388. { "LINE-OUT pin", 0x5 },
  3389. { "HP-OUT pin", 0x6 },
  3390. },
  3391. },
  3392. {
  3393. .num_items = 8,
  3394. .items = {
  3395. { "MIC1 pin", 0x0 },
  3396. { "MIC2 pin", 0x1 },
  3397. { "LINE1 pin", 0x2 },
  3398. { "LINE2 pin", 0x3 },
  3399. { "CD pin", 0x4 },
  3400. { "Mixer", 0x5 },
  3401. { "LINE-OUT pin", 0x6 },
  3402. { "HP-OUT pin", 0x7 },
  3403. },
  3404. },
  3405. };
  3406. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3407. /* Output driver widgets */
  3408. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3409. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3410. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3411. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3412. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3413. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3414. /* Modes for retasking pin widgets
  3415. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3416. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3417. * mention this restriction. At this stage it's not clear whether
  3418. * this behaviour is intentional or is a hardware bug in chip
  3419. * revisions available at least up until early 2006. Therefore for
  3420. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3421. * choices, but if it turns out that the lack of mic bias for these
  3422. * NIDs is intentional we could change their modes from
  3423. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3424. */
  3425. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3426. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3427. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3428. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3429. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3430. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3431. /* Loopback mixer controls */
  3432. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3433. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3434. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3435. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3436. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3437. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3438. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3439. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3440. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3441. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3442. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3443. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3444. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3445. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3446. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3447. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3448. /* Controls for GPIO pins, assuming they are configured as outputs */
  3449. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3450. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3451. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3452. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3453. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3454. * is ambigious as to which NID is which; testing on laptops which
  3455. * make this output available should provide clarification.
  3456. */
  3457. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3458. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3459. { } /* end */
  3460. };
  3461. static struct hda_verb alc260_test_init_verbs[] = {
  3462. /* Enable all GPIOs as outputs with an initial value of 0 */
  3463. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3464. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3465. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3466. /* Enable retasking pins as output, initially without power amp */
  3467. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3468. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3469. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3470. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3471. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3472. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3473. /* Disable digital (SPDIF) pins initially, but users can enable
  3474. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3475. * payload also sets the generation to 0, output to be in "consumer"
  3476. * PCM format, copyright asserted, no pre-emphasis and no validity
  3477. * control.
  3478. */
  3479. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3480. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3481. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3482. * OUT1 sum bus when acting as an output.
  3483. */
  3484. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3485. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3486. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3487. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3488. /* Start with output sum widgets muted and their output gains at min */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3495. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3498. /* Unmute retasking pin widget output buffers since the default
  3499. * state appears to be output. As the pin mode is changed by the
  3500. * user the pin mode control will take care of enabling the pin's
  3501. * input/output buffers as needed.
  3502. */
  3503. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3504. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3507. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3508. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3509. /* Also unmute the mono-out pin widget */
  3510. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3511. /* Mute capture amp left and right */
  3512. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. /* Set ADC connection select to match default mixer setting (mic1
  3514. * pin)
  3515. */
  3516. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3517. /* Do the same for the second ADC: mute capture input amp and
  3518. * set ADC connection to mic1 pin
  3519. */
  3520. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3522. /* Mute all inputs to mixer widget (even unconnected ones) */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3531. { }
  3532. };
  3533. #endif
  3534. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3535. .substreams = 1,
  3536. .channels_min = 2,
  3537. .channels_max = 2,
  3538. };
  3539. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3540. .substreams = 1,
  3541. .channels_min = 2,
  3542. .channels_max = 2,
  3543. };
  3544. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3545. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3546. /*
  3547. * for BIOS auto-configuration
  3548. */
  3549. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3550. const char *pfx)
  3551. {
  3552. hda_nid_t nid_vol;
  3553. unsigned long vol_val, sw_val;
  3554. char name[32];
  3555. int err;
  3556. if (nid >= 0x0f && nid < 0x11) {
  3557. nid_vol = nid - 0x7;
  3558. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3559. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3560. } else if (nid == 0x11) {
  3561. nid_vol = nid - 0x7;
  3562. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3563. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3564. } else if (nid >= 0x12 && nid <= 0x15) {
  3565. nid_vol = 0x08;
  3566. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3567. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3568. } else
  3569. return 0; /* N/A */
  3570. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3571. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3572. return err;
  3573. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3574. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3575. return err;
  3576. return 1;
  3577. }
  3578. /* add playback controls from the parsed DAC table */
  3579. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3580. const struct auto_pin_cfg *cfg)
  3581. {
  3582. hda_nid_t nid;
  3583. int err;
  3584. spec->multiout.num_dacs = 1;
  3585. spec->multiout.dac_nids = spec->private_dac_nids;
  3586. spec->multiout.dac_nids[0] = 0x02;
  3587. nid = cfg->line_out_pins[0];
  3588. if (nid) {
  3589. err = alc260_add_playback_controls(spec, nid, "Front");
  3590. if (err < 0)
  3591. return err;
  3592. }
  3593. nid = cfg->speaker_pins[0];
  3594. if (nid) {
  3595. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3596. if (err < 0)
  3597. return err;
  3598. }
  3599. nid = cfg->hp_pins[0];
  3600. if (nid) {
  3601. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3602. if (err < 0)
  3603. return err;
  3604. }
  3605. return 0;
  3606. }
  3607. /* create playback/capture controls for input pins */
  3608. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3609. const struct auto_pin_cfg *cfg)
  3610. {
  3611. struct hda_input_mux *imux = &spec->private_imux;
  3612. int i, err, idx;
  3613. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3614. if (cfg->input_pins[i] >= 0x12) {
  3615. idx = cfg->input_pins[i] - 0x12;
  3616. err = new_analog_input(spec, cfg->input_pins[i],
  3617. auto_pin_cfg_labels[i], idx, 0x07);
  3618. if (err < 0)
  3619. return err;
  3620. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3621. imux->items[imux->num_items].index = idx;
  3622. imux->num_items++;
  3623. }
  3624. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3625. idx = cfg->input_pins[i] - 0x09;
  3626. err = new_analog_input(spec, cfg->input_pins[i],
  3627. auto_pin_cfg_labels[i], idx, 0x07);
  3628. if (err < 0)
  3629. return err;
  3630. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3631. imux->items[imux->num_items].index = idx;
  3632. imux->num_items++;
  3633. }
  3634. }
  3635. return 0;
  3636. }
  3637. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3638. hda_nid_t nid, int pin_type,
  3639. int sel_idx)
  3640. {
  3641. /* set as output */
  3642. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3643. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3644. /* need the manual connection? */
  3645. if (nid >= 0x12) {
  3646. int idx = nid - 0x12;
  3647. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3648. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3649. }
  3650. }
  3651. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3652. {
  3653. struct alc_spec *spec = codec->spec;
  3654. hda_nid_t nid;
  3655. nid = spec->autocfg.line_out_pins[0];
  3656. if (nid)
  3657. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3658. nid = spec->autocfg.speaker_pins[0];
  3659. if (nid)
  3660. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3661. nid = spec->autocfg.hp_pins[0];
  3662. if (nid)
  3663. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3664. }
  3665. #define ALC260_PIN_CD_NID 0x16
  3666. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3667. {
  3668. struct alc_spec *spec = codec->spec;
  3669. int i;
  3670. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3671. hda_nid_t nid = spec->autocfg.input_pins[i];
  3672. if (nid >= 0x12) {
  3673. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3674. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3675. if (nid != ALC260_PIN_CD_NID)
  3676. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3677. AMP_OUT_MUTE);
  3678. }
  3679. }
  3680. }
  3681. /*
  3682. * generic initialization of ADC, input mixers and output mixers
  3683. */
  3684. static struct hda_verb alc260_volume_init_verbs[] = {
  3685. /*
  3686. * Unmute ADC0-1 and set the default input to mic-in
  3687. */
  3688. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3689. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3690. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3691. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3692. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3693. * mixer widget
  3694. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3695. * mic (mic 2)
  3696. */
  3697. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3698. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3699. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3700. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3701. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3702. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3703. /*
  3704. * Set up output mixers (0x08 - 0x0a)
  3705. */
  3706. /* set vol=0 to output mixers */
  3707. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3708. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3709. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3710. /* set up input amps for analog loopback */
  3711. /* Amp Indices: DAC = 0, mixer = 1 */
  3712. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3713. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3714. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3715. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3716. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3717. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3718. { }
  3719. };
  3720. static int alc260_parse_auto_config(struct hda_codec *codec)
  3721. {
  3722. struct alc_spec *spec = codec->spec;
  3723. unsigned int wcap;
  3724. int err;
  3725. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3726. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3727. alc260_ignore)) < 0)
  3728. return err;
  3729. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3730. return err;
  3731. if (! spec->kctl_alloc)
  3732. return 0; /* can't find valid BIOS pin config */
  3733. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3734. return err;
  3735. spec->multiout.max_channels = 2;
  3736. if (spec->autocfg.dig_out_pin)
  3737. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3738. if (spec->kctl_alloc)
  3739. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3740. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3741. spec->num_mux_defs = 1;
  3742. spec->input_mux = &spec->private_imux;
  3743. /* check whether NID 0x04 is valid */
  3744. wcap = get_wcaps(codec, 0x04);
  3745. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3746. if (wcap != AC_WID_AUD_IN) {
  3747. spec->adc_nids = alc260_adc_nids_alt;
  3748. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3749. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3750. } else {
  3751. spec->adc_nids = alc260_adc_nids;
  3752. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3753. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3754. }
  3755. spec->num_mixers++;
  3756. return 1;
  3757. }
  3758. /* additional initialization for auto-configuration model */
  3759. static void alc260_auto_init(struct hda_codec *codec)
  3760. {
  3761. alc260_auto_init_multi_out(codec);
  3762. alc260_auto_init_analog_input(codec);
  3763. }
  3764. /*
  3765. * ALC260 configurations
  3766. */
  3767. static const char *alc260_models[ALC260_MODEL_LAST] = {
  3768. [ALC260_BASIC] = "basic",
  3769. [ALC260_HP] = "hp",
  3770. [ALC260_HP_3013] = "hp-3013",
  3771. [ALC260_FUJITSU_S702X] = "fujitsu",
  3772. [ALC260_ACER] = "acer",
  3773. #ifdef CONFIG_SND_DEBUG
  3774. [ALC260_TEST] = "test",
  3775. #endif
  3776. [ALC260_AUTO] = "auto",
  3777. };
  3778. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  3779. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  3780. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  3781. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  3782. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  3783. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  3784. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  3785. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  3786. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  3787. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  3788. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  3789. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  3790. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  3791. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  3792. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  3793. {}
  3794. };
  3795. static struct alc_config_preset alc260_presets[] = {
  3796. [ALC260_BASIC] = {
  3797. .mixers = { alc260_base_output_mixer,
  3798. alc260_input_mixer,
  3799. alc260_pc_beep_mixer,
  3800. alc260_capture_mixer },
  3801. .init_verbs = { alc260_init_verbs },
  3802. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3803. .dac_nids = alc260_dac_nids,
  3804. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3805. .adc_nids = alc260_adc_nids,
  3806. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3807. .channel_mode = alc260_modes,
  3808. .input_mux = &alc260_capture_source,
  3809. },
  3810. [ALC260_HP] = {
  3811. .mixers = { alc260_base_output_mixer,
  3812. alc260_input_mixer,
  3813. alc260_capture_alt_mixer },
  3814. .init_verbs = { alc260_init_verbs },
  3815. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3816. .dac_nids = alc260_dac_nids,
  3817. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3818. .adc_nids = alc260_hp_adc_nids,
  3819. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3820. .channel_mode = alc260_modes,
  3821. .input_mux = &alc260_capture_source,
  3822. },
  3823. [ALC260_HP_3013] = {
  3824. .mixers = { alc260_hp_3013_mixer,
  3825. alc260_input_mixer,
  3826. alc260_capture_alt_mixer },
  3827. .init_verbs = { alc260_hp_3013_init_verbs },
  3828. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3829. .dac_nids = alc260_dac_nids,
  3830. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3831. .adc_nids = alc260_hp_adc_nids,
  3832. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3833. .channel_mode = alc260_modes,
  3834. .input_mux = &alc260_capture_source,
  3835. },
  3836. [ALC260_FUJITSU_S702X] = {
  3837. .mixers = { alc260_fujitsu_mixer,
  3838. alc260_capture_mixer },
  3839. .init_verbs = { alc260_fujitsu_init_verbs },
  3840. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3841. .dac_nids = alc260_dac_nids,
  3842. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3843. .adc_nids = alc260_dual_adc_nids,
  3844. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3845. .channel_mode = alc260_modes,
  3846. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3847. .input_mux = alc260_fujitsu_capture_sources,
  3848. },
  3849. [ALC260_ACER] = {
  3850. .mixers = { alc260_acer_mixer,
  3851. alc260_capture_mixer },
  3852. .init_verbs = { alc260_acer_init_verbs },
  3853. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3854. .dac_nids = alc260_dac_nids,
  3855. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3856. .adc_nids = alc260_dual_adc_nids,
  3857. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3858. .channel_mode = alc260_modes,
  3859. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3860. .input_mux = alc260_acer_capture_sources,
  3861. },
  3862. #ifdef CONFIG_SND_DEBUG
  3863. [ALC260_TEST] = {
  3864. .mixers = { alc260_test_mixer,
  3865. alc260_capture_mixer },
  3866. .init_verbs = { alc260_test_init_verbs },
  3867. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3868. .dac_nids = alc260_test_dac_nids,
  3869. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3870. .adc_nids = alc260_test_adc_nids,
  3871. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3872. .channel_mode = alc260_modes,
  3873. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3874. .input_mux = alc260_test_capture_sources,
  3875. },
  3876. #endif
  3877. };
  3878. static int patch_alc260(struct hda_codec *codec)
  3879. {
  3880. struct alc_spec *spec;
  3881. int err, board_config;
  3882. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3883. if (spec == NULL)
  3884. return -ENOMEM;
  3885. codec->spec = spec;
  3886. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  3887. alc260_models,
  3888. alc260_cfg_tbl);
  3889. if (board_config < 0) {
  3890. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3891. "trying auto-probe from BIOS...\n");
  3892. board_config = ALC260_AUTO;
  3893. }
  3894. if (board_config == ALC260_AUTO) {
  3895. /* automatic parse from the BIOS config */
  3896. err = alc260_parse_auto_config(codec);
  3897. if (err < 0) {
  3898. alc_free(codec);
  3899. return err;
  3900. } else if (! err) {
  3901. printk(KERN_INFO
  3902. "hda_codec: Cannot set up configuration "
  3903. "from BIOS. Using base mode...\n");
  3904. board_config = ALC260_BASIC;
  3905. }
  3906. }
  3907. if (board_config != ALC260_AUTO)
  3908. setup_preset(spec, &alc260_presets[board_config]);
  3909. spec->stream_name_analog = "ALC260 Analog";
  3910. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3911. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3912. spec->stream_name_digital = "ALC260 Digital";
  3913. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3914. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3915. codec->patch_ops = alc_patch_ops;
  3916. if (board_config == ALC260_AUTO)
  3917. spec->init_hook = alc260_auto_init;
  3918. return 0;
  3919. }
  3920. /*
  3921. * ALC882 support
  3922. *
  3923. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3924. * configuration. Each pin widget can choose any input DACs and a mixer.
  3925. * Each ADC is connected from a mixer of all inputs. This makes possible
  3926. * 6-channel independent captures.
  3927. *
  3928. * In addition, an independent DAC for the multi-playback (not used in this
  3929. * driver yet).
  3930. */
  3931. #define ALC882_DIGOUT_NID 0x06
  3932. #define ALC882_DIGIN_NID 0x0a
  3933. static struct hda_channel_mode alc882_ch_modes[1] = {
  3934. { 8, NULL }
  3935. };
  3936. static hda_nid_t alc882_dac_nids[4] = {
  3937. /* front, rear, clfe, rear_surr */
  3938. 0x02, 0x03, 0x04, 0x05
  3939. };
  3940. /* identical with ALC880 */
  3941. #define alc882_adc_nids alc880_adc_nids
  3942. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3943. /* input MUX */
  3944. /* FIXME: should be a matrix-type input source selection */
  3945. static struct hda_input_mux alc882_capture_source = {
  3946. .num_items = 4,
  3947. .items = {
  3948. { "Mic", 0x0 },
  3949. { "Front Mic", 0x1 },
  3950. { "Line", 0x2 },
  3951. { "CD", 0x4 },
  3952. },
  3953. };
  3954. #define alc882_mux_enum_info alc_mux_enum_info
  3955. #define alc882_mux_enum_get alc_mux_enum_get
  3956. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3957. {
  3958. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3959. struct alc_spec *spec = codec->spec;
  3960. const struct hda_input_mux *imux = spec->input_mux;
  3961. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3962. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3963. hda_nid_t nid = capture_mixers[adc_idx];
  3964. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3965. unsigned int i, idx;
  3966. idx = ucontrol->value.enumerated.item[0];
  3967. if (idx >= imux->num_items)
  3968. idx = imux->num_items - 1;
  3969. if (*cur_val == idx && ! codec->in_resume)
  3970. return 0;
  3971. for (i = 0; i < imux->num_items; i++) {
  3972. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3973. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3974. v | (imux->items[i].index << 8));
  3975. }
  3976. *cur_val = idx;
  3977. return 1;
  3978. }
  3979. /*
  3980. * 6ch mode
  3981. */
  3982. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3983. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3984. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3985. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3986. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3987. { } /* end */
  3988. };
  3989. /*
  3990. * 8ch mode
  3991. */
  3992. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3993. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3994. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3995. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3996. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3997. { } /* end */
  3998. };
  3999. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4000. { 6, alc882_sixstack_ch6_init },
  4001. { 8, alc882_sixstack_ch8_init },
  4002. };
  4003. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4004. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4005. */
  4006. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4007. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4008. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4009. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4010. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4011. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4012. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4013. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4014. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4015. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4016. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4017. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4018. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4019. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4020. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4021. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4022. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4023. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4024. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4025. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4026. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4027. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4028. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4029. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4030. { } /* end */
  4031. };
  4032. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4033. {
  4034. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4035. .name = "Channel Mode",
  4036. .info = alc_ch_mode_info,
  4037. .get = alc_ch_mode_get,
  4038. .put = alc_ch_mode_put,
  4039. },
  4040. { } /* end */
  4041. };
  4042. static struct hda_verb alc882_init_verbs[] = {
  4043. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4044. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4045. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4046. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4047. /* Rear mixer */
  4048. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4049. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4050. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4051. /* CLFE mixer */
  4052. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4053. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4054. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4055. /* Side mixer */
  4056. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4057. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4058. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4059. /* Front Pin: output 0 (0x0c) */
  4060. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4061. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4062. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4063. /* Rear Pin: output 1 (0x0d) */
  4064. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4065. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4066. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4067. /* CLFE Pin: output 2 (0x0e) */
  4068. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4069. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4070. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4071. /* Side Pin: output 3 (0x0f) */
  4072. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4073. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4074. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4075. /* Mic (rear) pin: input vref at 80% */
  4076. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4077. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4078. /* Front Mic pin: input vref at 80% */
  4079. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4080. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4081. /* Line In pin: input */
  4082. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4083. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4084. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4085. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4086. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4087. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4088. /* CD pin widget for input */
  4089. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4090. /* FIXME: use matrix-type input source selection */
  4091. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4092. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4093. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4094. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4095. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4096. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4097. /* Input mixer2 */
  4098. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4099. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4100. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4101. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4102. /* Input mixer3 */
  4103. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4104. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4105. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4106. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4107. /* ADC1: mute amp left and right */
  4108. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4109. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4110. /* ADC2: mute amp left and right */
  4111. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4112. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4113. /* ADC3: mute amp left and right */
  4114. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4115. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4116. { }
  4117. };
  4118. static struct hda_verb alc882_eapd_verbs[] = {
  4119. /* change to EAPD mode */
  4120. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4121. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4122. { }
  4123. };
  4124. /* Mac Pro test */
  4125. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4126. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4127. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4128. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4129. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4130. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4131. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4132. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4133. { } /* end */
  4134. };
  4135. static struct hda_verb alc882_macpro_init_verbs[] = {
  4136. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4137. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4138. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4139. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4140. /* Front Pin: output 0 (0x0c) */
  4141. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4142. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4143. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4144. /* Front Mic pin: input vref at 80% */
  4145. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4146. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4147. /* Speaker: output */
  4148. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4149. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4150. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4151. /* Headphone output (output 0 - 0x0c) */
  4152. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4153. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4154. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4155. /* FIXME: use matrix-type input source selection */
  4156. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4157. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4159. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4160. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4161. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4162. /* Input mixer2 */
  4163. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4164. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4165. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4166. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4167. /* Input mixer3 */
  4168. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4169. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4170. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4171. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4172. /* ADC1: mute amp left and right */
  4173. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4174. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4175. /* ADC2: mute amp left and right */
  4176. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4177. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4178. /* ADC3: mute amp left and right */
  4179. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4180. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4181. { }
  4182. };
  4183. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4184. {
  4185. unsigned int gpiostate, gpiomask, gpiodir;
  4186. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4187. AC_VERB_GET_GPIO_DATA, 0);
  4188. if (!muted)
  4189. gpiostate |= (1 << pin);
  4190. else
  4191. gpiostate &= ~(1 << pin);
  4192. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4193. AC_VERB_GET_GPIO_MASK, 0);
  4194. gpiomask |= (1 << pin);
  4195. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4196. AC_VERB_GET_GPIO_DIRECTION, 0);
  4197. gpiodir |= (1 << pin);
  4198. snd_hda_codec_write(codec, codec->afg, 0,
  4199. AC_VERB_SET_GPIO_MASK, gpiomask);
  4200. snd_hda_codec_write(codec, codec->afg, 0,
  4201. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4202. msleep(1);
  4203. snd_hda_codec_write(codec, codec->afg, 0,
  4204. AC_VERB_SET_GPIO_DATA, gpiostate);
  4205. }
  4206. /*
  4207. * generic initialization of ADC, input mixers and output mixers
  4208. */
  4209. static struct hda_verb alc882_auto_init_verbs[] = {
  4210. /*
  4211. * Unmute ADC0-2 and set the default input to mic-in
  4212. */
  4213. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4214. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4215. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4216. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4217. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4218. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4219. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4220. * mixer widget
  4221. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4222. * mic (mic 2)
  4223. */
  4224. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4225. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4226. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4227. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4230. /*
  4231. * Set up output mixers (0x0c - 0x0f)
  4232. */
  4233. /* set vol=0 to output mixers */
  4234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4237. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4238. /* set up input amps for analog loopback */
  4239. /* Amp Indices: DAC = 0, mixer = 1 */
  4240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4247. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4248. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4249. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4250. /* FIXME: use matrix-type input source selection */
  4251. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4252. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4253. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4254. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4255. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4256. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4257. /* Input mixer2 */
  4258. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4259. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4260. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4261. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4262. /* Input mixer3 */
  4263. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4264. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4265. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4266. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4267. { }
  4268. };
  4269. /* capture mixer elements */
  4270. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4271. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4272. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4273. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4274. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4275. {
  4276. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4277. /* The multiple "Capture Source" controls confuse alsamixer
  4278. * So call somewhat different..
  4279. * FIXME: the controls appear in the "playback" view!
  4280. */
  4281. /* .name = "Capture Source", */
  4282. .name = "Input Source",
  4283. .count = 2,
  4284. .info = alc882_mux_enum_info,
  4285. .get = alc882_mux_enum_get,
  4286. .put = alc882_mux_enum_put,
  4287. },
  4288. { } /* end */
  4289. };
  4290. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4291. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4292. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4293. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4294. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4295. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4296. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4297. {
  4298. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4299. /* The multiple "Capture Source" controls confuse alsamixer
  4300. * So call somewhat different..
  4301. * FIXME: the controls appear in the "playback" view!
  4302. */
  4303. /* .name = "Capture Source", */
  4304. .name = "Input Source",
  4305. .count = 3,
  4306. .info = alc882_mux_enum_info,
  4307. .get = alc882_mux_enum_get,
  4308. .put = alc882_mux_enum_put,
  4309. },
  4310. { } /* end */
  4311. };
  4312. /* pcm configuration: identiacal with ALC880 */
  4313. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4314. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4315. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4316. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4317. /*
  4318. * configuration and preset
  4319. */
  4320. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4321. [ALC882_3ST_DIG] = "3stack-dig",
  4322. [ALC882_6ST_DIG] = "6stack-dig",
  4323. [ALC882_ARIMA] = "arima",
  4324. [ALC885_MACPRO] = "macpro",
  4325. [ALC882_AUTO] = "auto",
  4326. };
  4327. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4328. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4329. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4330. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4331. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4332. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4333. {}
  4334. };
  4335. static struct alc_config_preset alc882_presets[] = {
  4336. [ALC882_3ST_DIG] = {
  4337. .mixers = { alc882_base_mixer },
  4338. .init_verbs = { alc882_init_verbs },
  4339. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4340. .dac_nids = alc882_dac_nids,
  4341. .dig_out_nid = ALC882_DIGOUT_NID,
  4342. .dig_in_nid = ALC882_DIGIN_NID,
  4343. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4344. .channel_mode = alc882_ch_modes,
  4345. .need_dac_fix = 1,
  4346. .input_mux = &alc882_capture_source,
  4347. },
  4348. [ALC882_6ST_DIG] = {
  4349. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4350. .init_verbs = { alc882_init_verbs },
  4351. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4352. .dac_nids = alc882_dac_nids,
  4353. .dig_out_nid = ALC882_DIGOUT_NID,
  4354. .dig_in_nid = ALC882_DIGIN_NID,
  4355. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4356. .channel_mode = alc882_sixstack_modes,
  4357. .input_mux = &alc882_capture_source,
  4358. },
  4359. [ALC882_ARIMA] = {
  4360. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4361. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4362. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4363. .dac_nids = alc882_dac_nids,
  4364. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4365. .channel_mode = alc882_sixstack_modes,
  4366. .input_mux = &alc882_capture_source,
  4367. },
  4368. [ALC885_MACPRO] = {
  4369. .mixers = { alc882_macpro_mixer },
  4370. .init_verbs = { alc882_macpro_init_verbs },
  4371. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4372. .dac_nids = alc882_dac_nids,
  4373. .dig_out_nid = ALC882_DIGOUT_NID,
  4374. .dig_in_nid = ALC882_DIGIN_NID,
  4375. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4376. .channel_mode = alc882_ch_modes,
  4377. .input_mux = &alc882_capture_source,
  4378. },
  4379. };
  4380. /*
  4381. * BIOS auto configuration
  4382. */
  4383. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4384. hda_nid_t nid, int pin_type,
  4385. int dac_idx)
  4386. {
  4387. /* set as output */
  4388. struct alc_spec *spec = codec->spec;
  4389. int idx;
  4390. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4391. idx = 4;
  4392. else
  4393. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4394. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4395. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4396. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4397. }
  4398. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4399. {
  4400. struct alc_spec *spec = codec->spec;
  4401. int i;
  4402. for (i = 0; i <= HDA_SIDE; i++) {
  4403. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4404. if (nid)
  4405. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4406. }
  4407. }
  4408. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4409. {
  4410. struct alc_spec *spec = codec->spec;
  4411. hda_nid_t pin;
  4412. pin = spec->autocfg.hp_pins[0];
  4413. if (pin) /* connect to front */
  4414. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4415. }
  4416. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4417. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4418. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4419. {
  4420. struct alc_spec *spec = codec->spec;
  4421. int i;
  4422. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4423. hda_nid_t nid = spec->autocfg.input_pins[i];
  4424. if (alc882_is_input_pin(nid)) {
  4425. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4426. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4427. if (nid != ALC882_PIN_CD_NID)
  4428. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4429. AMP_OUT_MUTE);
  4430. }
  4431. }
  4432. }
  4433. /* almost identical with ALC880 parser... */
  4434. static int alc882_parse_auto_config(struct hda_codec *codec)
  4435. {
  4436. struct alc_spec *spec = codec->spec;
  4437. int err = alc880_parse_auto_config(codec);
  4438. if (err < 0)
  4439. return err;
  4440. else if (err > 0)
  4441. /* hack - override the init verbs */
  4442. spec->init_verbs[0] = alc882_auto_init_verbs;
  4443. return err;
  4444. }
  4445. /* additional initialization for auto-configuration model */
  4446. static void alc882_auto_init(struct hda_codec *codec)
  4447. {
  4448. alc882_auto_init_multi_out(codec);
  4449. alc882_auto_init_hp_out(codec);
  4450. alc882_auto_init_analog_input(codec);
  4451. }
  4452. static int patch_alc882(struct hda_codec *codec)
  4453. {
  4454. struct alc_spec *spec;
  4455. int err, board_config;
  4456. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4457. if (spec == NULL)
  4458. return -ENOMEM;
  4459. codec->spec = spec;
  4460. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4461. alc882_models,
  4462. alc882_cfg_tbl);
  4463. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4464. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4465. "trying auto-probe from BIOS...\n");
  4466. board_config = ALC882_AUTO;
  4467. }
  4468. if (board_config == ALC882_AUTO) {
  4469. /* automatic parse from the BIOS config */
  4470. err = alc882_parse_auto_config(codec);
  4471. if (err < 0) {
  4472. alc_free(codec);
  4473. return err;
  4474. } else if (! err) {
  4475. printk(KERN_INFO
  4476. "hda_codec: Cannot set up configuration "
  4477. "from BIOS. Using base mode...\n");
  4478. board_config = ALC882_3ST_DIG;
  4479. }
  4480. }
  4481. if (board_config != ALC882_AUTO)
  4482. setup_preset(spec, &alc882_presets[board_config]);
  4483. if (board_config == ALC885_MACPRO) {
  4484. alc882_gpio_mute(codec, 0, 0);
  4485. alc882_gpio_mute(codec, 1, 0);
  4486. }
  4487. spec->stream_name_analog = "ALC882 Analog";
  4488. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4489. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4490. spec->stream_name_digital = "ALC882 Digital";
  4491. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4492. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4493. if (! spec->adc_nids && spec->input_mux) {
  4494. /* check whether NID 0x07 is valid */
  4495. unsigned int wcap = get_wcaps(codec, 0x07);
  4496. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4497. if (wcap != AC_WID_AUD_IN) {
  4498. spec->adc_nids = alc882_adc_nids_alt;
  4499. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4500. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4501. spec->num_mixers++;
  4502. } else {
  4503. spec->adc_nids = alc882_adc_nids;
  4504. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4505. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4506. spec->num_mixers++;
  4507. }
  4508. }
  4509. codec->patch_ops = alc_patch_ops;
  4510. if (board_config == ALC882_AUTO)
  4511. spec->init_hook = alc882_auto_init;
  4512. return 0;
  4513. }
  4514. /*
  4515. * ALC883 support
  4516. *
  4517. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4518. * configuration. Each pin widget can choose any input DACs and a mixer.
  4519. * Each ADC is connected from a mixer of all inputs. This makes possible
  4520. * 6-channel independent captures.
  4521. *
  4522. * In addition, an independent DAC for the multi-playback (not used in this
  4523. * driver yet).
  4524. */
  4525. #define ALC883_DIGOUT_NID 0x06
  4526. #define ALC883_DIGIN_NID 0x0a
  4527. static hda_nid_t alc883_dac_nids[4] = {
  4528. /* front, rear, clfe, rear_surr */
  4529. 0x02, 0x04, 0x03, 0x05
  4530. };
  4531. static hda_nid_t alc883_adc_nids[2] = {
  4532. /* ADC1-2 */
  4533. 0x08, 0x09,
  4534. };
  4535. /* input MUX */
  4536. /* FIXME: should be a matrix-type input source selection */
  4537. static struct hda_input_mux alc883_capture_source = {
  4538. .num_items = 4,
  4539. .items = {
  4540. { "Mic", 0x0 },
  4541. { "Front Mic", 0x1 },
  4542. { "Line", 0x2 },
  4543. { "CD", 0x4 },
  4544. },
  4545. };
  4546. #define alc883_mux_enum_info alc_mux_enum_info
  4547. #define alc883_mux_enum_get alc_mux_enum_get
  4548. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4549. struct snd_ctl_elem_value *ucontrol)
  4550. {
  4551. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4552. struct alc_spec *spec = codec->spec;
  4553. const struct hda_input_mux *imux = spec->input_mux;
  4554. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4555. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4556. hda_nid_t nid = capture_mixers[adc_idx];
  4557. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4558. unsigned int i, idx;
  4559. idx = ucontrol->value.enumerated.item[0];
  4560. if (idx >= imux->num_items)
  4561. idx = imux->num_items - 1;
  4562. if (*cur_val == idx && ! codec->in_resume)
  4563. return 0;
  4564. for (i = 0; i < imux->num_items; i++) {
  4565. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4566. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4567. v | (imux->items[i].index << 8));
  4568. }
  4569. *cur_val = idx;
  4570. return 1;
  4571. }
  4572. /*
  4573. * 2ch mode
  4574. */
  4575. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4576. { 2, NULL }
  4577. };
  4578. /*
  4579. * 2ch mode
  4580. */
  4581. static struct hda_verb alc883_3ST_ch2_init[] = {
  4582. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4583. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4584. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4585. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4586. { } /* end */
  4587. };
  4588. /*
  4589. * 6ch mode
  4590. */
  4591. static struct hda_verb alc883_3ST_ch6_init[] = {
  4592. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4593. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4594. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4595. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4596. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4597. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4598. { } /* end */
  4599. };
  4600. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4601. { 2, alc883_3ST_ch2_init },
  4602. { 6, alc883_3ST_ch6_init },
  4603. };
  4604. /*
  4605. * 6ch mode
  4606. */
  4607. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4608. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4609. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4610. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4611. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4612. { } /* end */
  4613. };
  4614. /*
  4615. * 8ch mode
  4616. */
  4617. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4618. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4619. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4620. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4621. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4622. { } /* end */
  4623. };
  4624. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4625. { 6, alc883_sixstack_ch6_init },
  4626. { 8, alc883_sixstack_ch8_init },
  4627. };
  4628. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4629. /* eanable EAPD on medion laptop */
  4630. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4631. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4632. { }
  4633. };
  4634. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4635. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4636. */
  4637. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4638. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4639. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4640. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4641. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4642. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4643. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4644. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4645. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4646. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4647. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4648. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4649. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4650. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4651. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4652. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4653. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4654. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4655. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4656. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4657. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4658. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4659. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4660. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4661. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4662. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4663. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4664. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4665. {
  4666. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4667. /* .name = "Capture Source", */
  4668. .name = "Input Source",
  4669. .count = 2,
  4670. .info = alc883_mux_enum_info,
  4671. .get = alc883_mux_enum_get,
  4672. .put = alc883_mux_enum_put,
  4673. },
  4674. { } /* end */
  4675. };
  4676. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4677. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4678. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4679. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4680. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4681. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4682. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4683. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4684. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4685. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4686. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4687. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4688. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4689. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4690. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4691. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4692. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4693. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4694. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4695. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4696. {
  4697. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4698. /* .name = "Capture Source", */
  4699. .name = "Input Source",
  4700. .count = 2,
  4701. .info = alc883_mux_enum_info,
  4702. .get = alc883_mux_enum_get,
  4703. .put = alc883_mux_enum_put,
  4704. },
  4705. { } /* end */
  4706. };
  4707. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4708. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4709. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4710. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4711. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4712. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4713. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4714. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4715. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4716. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4717. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4718. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4719. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4720. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4721. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4722. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4723. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4724. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4725. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4727. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4728. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4729. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4730. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4731. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4732. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4733. {
  4734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4735. /* .name = "Capture Source", */
  4736. .name = "Input Source",
  4737. .count = 2,
  4738. .info = alc883_mux_enum_info,
  4739. .get = alc883_mux_enum_get,
  4740. .put = alc883_mux_enum_put,
  4741. },
  4742. { } /* end */
  4743. };
  4744. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  4745. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4746. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4747. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4748. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4749. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4750. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4751. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4752. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4753. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4754. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4755. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4756. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4757. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4758. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4759. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4760. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4761. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4762. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4763. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4764. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4765. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4766. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4767. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4768. {
  4769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4770. /* .name = "Capture Source", */
  4771. .name = "Input Source",
  4772. .count = 1,
  4773. .info = alc883_mux_enum_info,
  4774. .get = alc883_mux_enum_get,
  4775. .put = alc883_mux_enum_put,
  4776. },
  4777. { } /* end */
  4778. };
  4779. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  4780. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4781. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4782. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4783. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4784. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4785. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4786. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4787. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4788. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  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_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4795. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4796. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4797. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4798. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4799. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4800. {
  4801. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4802. /* .name = "Capture Source", */
  4803. .name = "Input Source",
  4804. .count = 2,
  4805. .info = alc883_mux_enum_info,
  4806. .get = alc883_mux_enum_get,
  4807. .put = alc883_mux_enum_put,
  4808. },
  4809. { } /* end */
  4810. };
  4811. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  4812. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4813. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4814. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4815. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4816. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4817. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4818. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4819. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4820. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4821. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4822. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4823. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4824. {
  4825. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4826. /* .name = "Capture Source", */
  4827. .name = "Input Source",
  4828. .count = 2,
  4829. .info = alc883_mux_enum_info,
  4830. .get = alc883_mux_enum_get,
  4831. .put = alc883_mux_enum_put,
  4832. },
  4833. { } /* end */
  4834. };
  4835. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4836. {
  4837. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4838. .name = "Channel Mode",
  4839. .info = alc_ch_mode_info,
  4840. .get = alc_ch_mode_get,
  4841. .put = alc_ch_mode_put,
  4842. },
  4843. { } /* end */
  4844. };
  4845. static struct hda_verb alc883_init_verbs[] = {
  4846. /* ADC1: mute amp left and right */
  4847. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4848. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4849. /* ADC2: mute amp left and right */
  4850. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4851. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4852. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4853. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4854. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4855. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4856. /* Rear mixer */
  4857. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4858. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4859. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4860. /* CLFE mixer */
  4861. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4862. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4863. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4864. /* Side mixer */
  4865. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4866. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4867. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4868. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4869. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4870. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4871. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4872. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4873. /* Front Pin: output 0 (0x0c) */
  4874. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4875. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4876. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4877. /* Rear Pin: output 1 (0x0d) */
  4878. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4879. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4880. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4881. /* CLFE Pin: output 2 (0x0e) */
  4882. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4883. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4884. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4885. /* Side Pin: output 3 (0x0f) */
  4886. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4887. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4888. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4889. /* Mic (rear) pin: input vref at 80% */
  4890. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4891. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4892. /* Front Mic pin: input vref at 80% */
  4893. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4894. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4895. /* Line In pin: input */
  4896. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4897. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4898. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4899. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4900. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4901. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4902. /* CD pin widget for input */
  4903. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4904. /* FIXME: use matrix-type input source selection */
  4905. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4906. /* Input mixer2 */
  4907. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4908. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4909. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4910. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4911. /* Input mixer3 */
  4912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4913. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4914. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4915. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4916. { }
  4917. };
  4918. static struct hda_verb alc883_tagra_verbs[] = {
  4919. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4920. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4921. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4922. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4923. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4924. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4925. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4926. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4927. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4928. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4929. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4930. { } /* end */
  4931. };
  4932. /* toggle speaker-output according to the hp-jack state */
  4933. static void alc883_tagra_automute(struct hda_codec *codec)
  4934. {
  4935. unsigned int present;
  4936. present = snd_hda_codec_read(codec, 0x14, 0,
  4937. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4938. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4939. 0x80, present ? 0x80 : 0);
  4940. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4941. 0x80, present ? 0x80 : 0);
  4942. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4943. }
  4944. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  4945. {
  4946. if ((res >> 26) == ALC880_HP_EVENT)
  4947. alc883_tagra_automute(codec);
  4948. }
  4949. /*
  4950. * generic initialization of ADC, input mixers and output mixers
  4951. */
  4952. static struct hda_verb alc883_auto_init_verbs[] = {
  4953. /*
  4954. * Unmute ADC0-2 and set the default input to mic-in
  4955. */
  4956. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4957. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4958. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4959. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4960. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4961. * mixer widget
  4962. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4963. * mic (mic 2)
  4964. */
  4965. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4966. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4967. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4968. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4969. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4970. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4971. /*
  4972. * Set up output mixers (0x0c - 0x0f)
  4973. */
  4974. /* set vol=0 to output mixers */
  4975. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4976. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4977. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4978. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4979. /* set up input amps for analog loopback */
  4980. /* Amp Indices: DAC = 0, mixer = 1 */
  4981. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4982. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4983. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4984. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4985. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4986. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4987. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4988. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4989. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4990. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4991. /* FIXME: use matrix-type input source selection */
  4992. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4993. /* Input mixer1 */
  4994. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4995. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4996. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4997. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4998. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4999. /* Input mixer2 */
  5000. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5001. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5002. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5003. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5004. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5005. { }
  5006. };
  5007. /* capture mixer elements */
  5008. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5009. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5010. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5011. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5012. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5013. {
  5014. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5015. /* The multiple "Capture Source" controls confuse alsamixer
  5016. * So call somewhat different..
  5017. * FIXME: the controls appear in the "playback" view!
  5018. */
  5019. /* .name = "Capture Source", */
  5020. .name = "Input Source",
  5021. .count = 2,
  5022. .info = alc882_mux_enum_info,
  5023. .get = alc882_mux_enum_get,
  5024. .put = alc882_mux_enum_put,
  5025. },
  5026. { } /* end */
  5027. };
  5028. /* pcm configuration: identiacal with ALC880 */
  5029. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5030. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5031. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5032. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5033. /*
  5034. * configuration and preset
  5035. */
  5036. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5037. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5038. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5039. [ALC883_3ST_6ch] = "3stack-6ch",
  5040. [ALC883_6ST_DIG] = "6stack-dig",
  5041. [ALC883_TARGA_DIG] = "targa-dig",
  5042. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5043. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  5044. [ALC883_ACER] = "acer",
  5045. [ALC883_MEDION] = "medion",
  5046. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5047. [ALC883_AUTO] = "auto",
  5048. };
  5049. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5050. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5051. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5052. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5053. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5054. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5055. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5056. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5057. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5058. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5059. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5060. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5061. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5062. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5063. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5064. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5065. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5066. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5067. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5068. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5069. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5070. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5071. {}
  5072. };
  5073. static struct alc_config_preset alc883_presets[] = {
  5074. [ALC883_3ST_2ch_DIG] = {
  5075. .mixers = { alc883_3ST_2ch_mixer },
  5076. .init_verbs = { alc883_init_verbs },
  5077. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5078. .dac_nids = alc883_dac_nids,
  5079. .dig_out_nid = ALC883_DIGOUT_NID,
  5080. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5081. .adc_nids = alc883_adc_nids,
  5082. .dig_in_nid = ALC883_DIGIN_NID,
  5083. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5084. .channel_mode = alc883_3ST_2ch_modes,
  5085. .input_mux = &alc883_capture_source,
  5086. },
  5087. [ALC883_3ST_6ch_DIG] = {
  5088. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5089. .init_verbs = { alc883_init_verbs },
  5090. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5091. .dac_nids = alc883_dac_nids,
  5092. .dig_out_nid = ALC883_DIGOUT_NID,
  5093. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5094. .adc_nids = alc883_adc_nids,
  5095. .dig_in_nid = ALC883_DIGIN_NID,
  5096. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5097. .channel_mode = alc883_3ST_6ch_modes,
  5098. .need_dac_fix = 1,
  5099. .input_mux = &alc883_capture_source,
  5100. },
  5101. [ALC883_3ST_6ch] = {
  5102. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5103. .init_verbs = { alc883_init_verbs },
  5104. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5105. .dac_nids = alc883_dac_nids,
  5106. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5107. .adc_nids = alc883_adc_nids,
  5108. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5109. .channel_mode = alc883_3ST_6ch_modes,
  5110. .need_dac_fix = 1,
  5111. .input_mux = &alc883_capture_source,
  5112. },
  5113. [ALC883_6ST_DIG] = {
  5114. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5115. .init_verbs = { alc883_init_verbs },
  5116. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5117. .dac_nids = alc883_dac_nids,
  5118. .dig_out_nid = ALC883_DIGOUT_NID,
  5119. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5120. .adc_nids = alc883_adc_nids,
  5121. .dig_in_nid = ALC883_DIGIN_NID,
  5122. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5123. .channel_mode = alc883_sixstack_modes,
  5124. .input_mux = &alc883_capture_source,
  5125. },
  5126. [ALC883_TARGA_DIG] = {
  5127. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5128. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5129. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5130. .dac_nids = alc883_dac_nids,
  5131. .dig_out_nid = ALC883_DIGOUT_NID,
  5132. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5133. .adc_nids = alc883_adc_nids,
  5134. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5135. .channel_mode = alc883_3ST_6ch_modes,
  5136. .need_dac_fix = 1,
  5137. .input_mux = &alc883_capture_source,
  5138. .unsol_event = alc883_tagra_unsol_event,
  5139. .init_hook = alc883_tagra_automute,
  5140. },
  5141. [ALC883_TARGA_2ch_DIG] = {
  5142. .mixers = { alc883_tagra_2ch_mixer},
  5143. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5144. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5145. .dac_nids = alc883_dac_nids,
  5146. .dig_out_nid = ALC883_DIGOUT_NID,
  5147. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5148. .adc_nids = alc883_adc_nids,
  5149. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5150. .channel_mode = alc883_3ST_2ch_modes,
  5151. .input_mux = &alc883_capture_source,
  5152. .unsol_event = alc883_tagra_unsol_event,
  5153. .init_hook = alc883_tagra_automute,
  5154. },
  5155. [ALC888_DEMO_BOARD] = {
  5156. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5157. .init_verbs = { alc883_init_verbs },
  5158. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5159. .dac_nids = alc883_dac_nids,
  5160. .dig_out_nid = ALC883_DIGOUT_NID,
  5161. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5162. .adc_nids = alc883_adc_nids,
  5163. .dig_in_nid = ALC883_DIGIN_NID,
  5164. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5165. .channel_mode = alc883_sixstack_modes,
  5166. .input_mux = &alc883_capture_source,
  5167. },
  5168. [ALC883_ACER] = {
  5169. .mixers = { alc883_base_mixer,
  5170. alc883_chmode_mixer },
  5171. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5172. * and the headphone jack. Turn this on and rely on the
  5173. * standard mute methods whenever the user wants to turn
  5174. * these outputs off.
  5175. */
  5176. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5177. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5178. .dac_nids = alc883_dac_nids,
  5179. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5180. .adc_nids = alc883_adc_nids,
  5181. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5182. .channel_mode = alc883_3ST_2ch_modes,
  5183. .input_mux = &alc883_capture_source,
  5184. },
  5185. [ALC883_MEDION] = {
  5186. .mixers = { alc883_fivestack_mixer,
  5187. alc883_chmode_mixer },
  5188. .init_verbs = { alc883_init_verbs,
  5189. alc883_medion_eapd_verbs },
  5190. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5191. .dac_nids = alc883_dac_nids,
  5192. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5193. .adc_nids = alc883_adc_nids,
  5194. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5195. .channel_mode = alc883_sixstack_modes,
  5196. .input_mux = &alc883_capture_source,
  5197. },
  5198. [ALC883_LAPTOP_EAPD] = {
  5199. .mixers = { alc883_base_mixer,
  5200. alc883_chmode_mixer },
  5201. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5202. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5203. .dac_nids = alc883_dac_nids,
  5204. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5205. .adc_nids = alc883_adc_nids,
  5206. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5207. .channel_mode = alc883_3ST_2ch_modes,
  5208. .input_mux = &alc883_capture_source,
  5209. },
  5210. };
  5211. /*
  5212. * BIOS auto configuration
  5213. */
  5214. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5215. hda_nid_t nid, int pin_type,
  5216. int dac_idx)
  5217. {
  5218. /* set as output */
  5219. struct alc_spec *spec = codec->spec;
  5220. int idx;
  5221. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5222. idx = 4;
  5223. else
  5224. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5225. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5226. pin_type);
  5227. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5228. AMP_OUT_UNMUTE);
  5229. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5230. }
  5231. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5232. {
  5233. struct alc_spec *spec = codec->spec;
  5234. int i;
  5235. for (i = 0; i <= HDA_SIDE; i++) {
  5236. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5237. if (nid)
  5238. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  5239. }
  5240. }
  5241. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5242. {
  5243. struct alc_spec *spec = codec->spec;
  5244. hda_nid_t pin;
  5245. pin = spec->autocfg.hp_pins[0];
  5246. if (pin) /* connect to front */
  5247. /* use dac 0 */
  5248. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5249. }
  5250. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5251. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5252. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5253. {
  5254. struct alc_spec *spec = codec->spec;
  5255. int i;
  5256. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5257. hda_nid_t nid = spec->autocfg.input_pins[i];
  5258. if (alc883_is_input_pin(nid)) {
  5259. snd_hda_codec_write(codec, nid, 0,
  5260. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5261. (i <= AUTO_PIN_FRONT_MIC ?
  5262. PIN_VREF80 : PIN_IN));
  5263. if (nid != ALC883_PIN_CD_NID)
  5264. snd_hda_codec_write(codec, nid, 0,
  5265. AC_VERB_SET_AMP_GAIN_MUTE,
  5266. AMP_OUT_MUTE);
  5267. }
  5268. }
  5269. }
  5270. /* almost identical with ALC880 parser... */
  5271. static int alc883_parse_auto_config(struct hda_codec *codec)
  5272. {
  5273. struct alc_spec *spec = codec->spec;
  5274. int err = alc880_parse_auto_config(codec);
  5275. if (err < 0)
  5276. return err;
  5277. else if (err > 0)
  5278. /* hack - override the init verbs */
  5279. spec->init_verbs[0] = alc883_auto_init_verbs;
  5280. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5281. spec->num_mixers++;
  5282. return err;
  5283. }
  5284. /* additional initialization for auto-configuration model */
  5285. static void alc883_auto_init(struct hda_codec *codec)
  5286. {
  5287. alc883_auto_init_multi_out(codec);
  5288. alc883_auto_init_hp_out(codec);
  5289. alc883_auto_init_analog_input(codec);
  5290. }
  5291. static int patch_alc883(struct hda_codec *codec)
  5292. {
  5293. struct alc_spec *spec;
  5294. int err, board_config;
  5295. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5296. if (spec == NULL)
  5297. return -ENOMEM;
  5298. codec->spec = spec;
  5299. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5300. alc883_models,
  5301. alc883_cfg_tbl);
  5302. if (board_config < 0) {
  5303. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5304. "trying auto-probe from BIOS...\n");
  5305. board_config = ALC883_AUTO;
  5306. }
  5307. if (board_config == ALC883_AUTO) {
  5308. /* automatic parse from the BIOS config */
  5309. err = alc883_parse_auto_config(codec);
  5310. if (err < 0) {
  5311. alc_free(codec);
  5312. return err;
  5313. } else if (! err) {
  5314. printk(KERN_INFO
  5315. "hda_codec: Cannot set up configuration "
  5316. "from BIOS. Using base mode...\n");
  5317. board_config = ALC883_3ST_2ch_DIG;
  5318. }
  5319. }
  5320. if (board_config != ALC883_AUTO)
  5321. setup_preset(spec, &alc883_presets[board_config]);
  5322. spec->stream_name_analog = "ALC883 Analog";
  5323. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5324. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5325. spec->stream_name_digital = "ALC883 Digital";
  5326. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5327. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5328. if (! spec->adc_nids && spec->input_mux) {
  5329. spec->adc_nids = alc883_adc_nids;
  5330. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5331. }
  5332. codec->patch_ops = alc_patch_ops;
  5333. if (board_config == ALC883_AUTO)
  5334. spec->init_hook = alc883_auto_init;
  5335. return 0;
  5336. }
  5337. /*
  5338. * ALC262 support
  5339. */
  5340. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5341. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5342. #define alc262_dac_nids alc260_dac_nids
  5343. #define alc262_adc_nids alc882_adc_nids
  5344. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5345. #define alc262_modes alc260_modes
  5346. #define alc262_capture_source alc882_capture_source
  5347. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5348. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5349. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5350. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5351. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5352. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5353. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5355. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5356. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5357. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5358. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5359. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5360. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5361. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5362. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5363. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5364. { } /* end */
  5365. };
  5366. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5367. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5368. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5369. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5370. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5371. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5372. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5373. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5374. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5376. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5377. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5378. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5379. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5380. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5381. { } /* end */
  5382. };
  5383. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5384. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5385. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5386. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5387. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5388. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5389. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5390. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5391. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5392. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5393. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5394. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5395. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5396. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5397. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5398. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5399. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5400. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5401. { } /* end */
  5402. };
  5403. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  5404. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5405. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5406. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5407. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5408. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5409. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5410. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5411. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5412. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5413. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5414. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5415. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5416. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5417. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5418. { } /* end */
  5419. };
  5420. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  5421. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5422. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5423. { } /* end */
  5424. };
  5425. #define alc262_capture_mixer alc882_capture_mixer
  5426. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5427. /*
  5428. * generic initialization of ADC, input mixers and output mixers
  5429. */
  5430. static struct hda_verb alc262_init_verbs[] = {
  5431. /*
  5432. * Unmute ADC0-2 and set the default input to mic-in
  5433. */
  5434. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5435. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5436. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5437. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5438. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5439. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5440. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5441. * mixer widget
  5442. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5443. * mic (mic 2)
  5444. */
  5445. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5446. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5447. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5448. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5449. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5450. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5451. /*
  5452. * Set up output mixers (0x0c - 0x0e)
  5453. */
  5454. /* set vol=0 to output mixers */
  5455. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5456. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5457. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5458. /* set up input amps for analog loopback */
  5459. /* Amp Indices: DAC = 0, mixer = 1 */
  5460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5461. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5462. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5464. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5465. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5466. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5468. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5469. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5470. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5471. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5472. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5473. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5474. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5475. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5476. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5477. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5478. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5479. /* FIXME: use matrix-type input source selection */
  5480. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5481. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5482. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5483. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5484. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5485. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5486. /* Input mixer2 */
  5487. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5488. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5489. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5490. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5491. /* Input mixer3 */
  5492. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5493. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5494. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5495. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5496. { }
  5497. };
  5498. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5499. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5500. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5501. {}
  5502. };
  5503. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5504. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5505. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5506. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5507. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5508. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5509. {}
  5510. };
  5511. /* mute/unmute internal speaker according to the hp jack and mute state */
  5512. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5513. {
  5514. struct alc_spec *spec = codec->spec;
  5515. unsigned int mute;
  5516. if (force || ! spec->sense_updated) {
  5517. unsigned int present;
  5518. /* need to execute and sync at first */
  5519. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5520. present = snd_hda_codec_read(codec, 0x15, 0,
  5521. AC_VERB_GET_PIN_SENSE, 0);
  5522. spec->jack_present = (present & 0x80000000) != 0;
  5523. spec->sense_updated = 1;
  5524. }
  5525. if (spec->jack_present) {
  5526. /* mute internal speaker */
  5527. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5528. 0x80, 0x80);
  5529. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5530. 0x80, 0x80);
  5531. } else {
  5532. /* unmute internal speaker if necessary */
  5533. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5534. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5535. 0x80, mute & 0x80);
  5536. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5537. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5538. 0x80, mute & 0x80);
  5539. }
  5540. }
  5541. /* unsolicited event for HP jack sensing */
  5542. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5543. unsigned int res)
  5544. {
  5545. if ((res >> 26) != ALC880_HP_EVENT)
  5546. return;
  5547. alc262_hippo_automute(codec, 1);
  5548. }
  5549. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5550. {
  5551. struct alc_spec *spec = codec->spec;
  5552. unsigned int mute;
  5553. if (force || ! spec->sense_updated) {
  5554. unsigned int present;
  5555. /* need to execute and sync at first */
  5556. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5557. present = snd_hda_codec_read(codec, 0x1b, 0,
  5558. AC_VERB_GET_PIN_SENSE, 0);
  5559. spec->jack_present = (present & 0x80000000) != 0;
  5560. spec->sense_updated = 1;
  5561. }
  5562. if (spec->jack_present) {
  5563. /* mute internal speaker */
  5564. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5565. 0x80, 0x80);
  5566. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5567. 0x80, 0x80);
  5568. } else {
  5569. /* unmute internal speaker if necessary */
  5570. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5571. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5572. 0x80, mute & 0x80);
  5573. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5574. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5575. 0x80, mute & 0x80);
  5576. }
  5577. }
  5578. /* unsolicited event for HP jack sensing */
  5579. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5580. unsigned int res)
  5581. {
  5582. if ((res >> 26) != ALC880_HP_EVENT)
  5583. return;
  5584. alc262_hippo1_automute(codec, 1);
  5585. }
  5586. /*
  5587. * fujitsu model
  5588. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5589. */
  5590. #define ALC_HP_EVENT 0x37
  5591. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5592. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5593. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5594. {}
  5595. };
  5596. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5597. .num_items = 2,
  5598. .items = {
  5599. { "Mic", 0x0 },
  5600. { "CD", 0x4 },
  5601. },
  5602. };
  5603. static struct hda_input_mux alc262_HP_capture_source = {
  5604. .num_items = 5,
  5605. .items = {
  5606. { "Mic", 0x0 },
  5607. { "Front Mic", 0x3 },
  5608. { "Line", 0x2 },
  5609. { "CD", 0x4 },
  5610. { "AUX IN", 0x6 },
  5611. },
  5612. };
  5613. /* mute/unmute internal speaker according to the hp jack and mute state */
  5614. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5615. {
  5616. struct alc_spec *spec = codec->spec;
  5617. unsigned int mute;
  5618. if (force || ! spec->sense_updated) {
  5619. unsigned int present;
  5620. /* need to execute and sync at first */
  5621. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5622. present = snd_hda_codec_read(codec, 0x14, 0,
  5623. AC_VERB_GET_PIN_SENSE, 0);
  5624. spec->jack_present = (present & 0x80000000) != 0;
  5625. spec->sense_updated = 1;
  5626. }
  5627. if (spec->jack_present) {
  5628. /* mute internal speaker */
  5629. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5630. 0x80, 0x80);
  5631. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5632. 0x80, 0x80);
  5633. } else {
  5634. /* unmute internal speaker if necessary */
  5635. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5636. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5637. 0x80, mute & 0x80);
  5638. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5639. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5640. 0x80, mute & 0x80);
  5641. }
  5642. }
  5643. /* unsolicited event for HP jack sensing */
  5644. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5645. unsigned int res)
  5646. {
  5647. if ((res >> 26) != ALC_HP_EVENT)
  5648. return;
  5649. alc262_fujitsu_automute(codec, 1);
  5650. }
  5651. /* bind volumes of both NID 0x0c and 0x0d */
  5652. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5653. struct snd_ctl_elem_value *ucontrol)
  5654. {
  5655. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5656. long *valp = ucontrol->value.integer.value;
  5657. int change;
  5658. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5659. 0x7f, valp[0] & 0x7f);
  5660. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5661. 0x7f, valp[1] & 0x7f);
  5662. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5663. 0x7f, valp[0] & 0x7f);
  5664. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5665. 0x7f, valp[1] & 0x7f);
  5666. return change;
  5667. }
  5668. /* bind hp and internal speaker mute (with plug check) */
  5669. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5670. struct snd_ctl_elem_value *ucontrol)
  5671. {
  5672. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5673. long *valp = ucontrol->value.integer.value;
  5674. int change;
  5675. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5676. 0x80, valp[0] ? 0 : 0x80);
  5677. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5678. 0x80, valp[1] ? 0 : 0x80);
  5679. if (change || codec->in_resume)
  5680. alc262_fujitsu_automute(codec, codec->in_resume);
  5681. return change;
  5682. }
  5683. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5684. {
  5685. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5686. .name = "Master Playback Volume",
  5687. .info = snd_hda_mixer_amp_volume_info,
  5688. .get = snd_hda_mixer_amp_volume_get,
  5689. .put = alc262_fujitsu_master_vol_put,
  5690. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5691. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5692. },
  5693. {
  5694. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5695. .name = "Master Playback Switch",
  5696. .info = snd_hda_mixer_amp_switch_info,
  5697. .get = snd_hda_mixer_amp_switch_get,
  5698. .put = alc262_fujitsu_master_sw_put,
  5699. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5700. },
  5701. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5702. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5703. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5706. { } /* end */
  5707. };
  5708. /* additional init verbs for Benq laptops */
  5709. static struct hda_verb alc262_EAPD_verbs[] = {
  5710. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5711. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5712. {}
  5713. };
  5714. /* add playback controls from the parsed DAC table */
  5715. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5716. {
  5717. hda_nid_t nid;
  5718. int err;
  5719. spec->multiout.num_dacs = 1; /* only use one dac */
  5720. spec->multiout.dac_nids = spec->private_dac_nids;
  5721. spec->multiout.dac_nids[0] = 2;
  5722. nid = cfg->line_out_pins[0];
  5723. if (nid) {
  5724. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5725. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5726. return err;
  5727. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5728. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5729. return err;
  5730. }
  5731. nid = cfg->speaker_pins[0];
  5732. if (nid) {
  5733. if (nid == 0x16) {
  5734. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5735. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5736. return err;
  5737. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5738. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5739. return err;
  5740. } else {
  5741. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5742. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5743. return err;
  5744. }
  5745. }
  5746. nid = cfg->hp_pins[0];
  5747. if (nid) {
  5748. /* spec->multiout.hp_nid = 2; */
  5749. if (nid == 0x16) {
  5750. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5751. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5752. return err;
  5753. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5754. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5755. return err;
  5756. } else {
  5757. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5758. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5759. return err;
  5760. }
  5761. }
  5762. return 0;
  5763. }
  5764. /* identical with ALC880 */
  5765. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5766. /*
  5767. * generic initialization of ADC, input mixers and output mixers
  5768. */
  5769. static struct hda_verb alc262_volume_init_verbs[] = {
  5770. /*
  5771. * Unmute ADC0-2 and set the default input to mic-in
  5772. */
  5773. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5774. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5775. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5776. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5777. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5778. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5779. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5780. * mixer widget
  5781. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5782. * mic (mic 2)
  5783. */
  5784. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5785. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5786. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5787. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5788. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5789. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5790. /*
  5791. * Set up output mixers (0x0c - 0x0f)
  5792. */
  5793. /* set vol=0 to output mixers */
  5794. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5795. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5796. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5797. /* set up input amps for analog loopback */
  5798. /* Amp Indices: DAC = 0, mixer = 1 */
  5799. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5800. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5801. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5802. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5803. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5804. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5805. /* FIXME: use matrix-type input source selection */
  5806. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5807. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5808. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5809. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5810. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5811. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5812. /* Input mixer2 */
  5813. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5814. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5815. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5816. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5817. /* Input mixer3 */
  5818. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5819. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5820. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5821. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5822. { }
  5823. };
  5824. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5825. /*
  5826. * Unmute ADC0-2 and set the default input to mic-in
  5827. */
  5828. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5829. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5830. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5832. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5834. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5835. * mixer widget
  5836. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5837. * mic (mic 2)
  5838. */
  5839. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5840. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5841. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5842. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5843. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5844. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5845. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5846. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5847. /*
  5848. * Set up output mixers (0x0c - 0x0e)
  5849. */
  5850. /* set vol=0 to output mixers */
  5851. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5852. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5853. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5854. /* set up input amps for analog loopback */
  5855. /* Amp Indices: DAC = 0, mixer = 1 */
  5856. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5857. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5858. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5859. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5860. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5861. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5862. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5863. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5864. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5865. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5866. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5867. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5868. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5869. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5870. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5871. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5872. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5873. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5874. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5875. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5876. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5877. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5878. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5879. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5880. /* FIXME: use matrix-type input source selection */
  5881. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5882. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5883. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5884. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5885. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5886. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5887. /* Input mixer2 */
  5888. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5889. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5890. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5891. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5892. /* Input mixer3 */
  5893. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5894. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5895. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5896. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5897. { }
  5898. };
  5899. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  5900. /*
  5901. * Unmute ADC0-2 and set the default input to mic-in
  5902. */
  5903. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5904. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5905. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5906. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5907. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5908. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5909. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5910. * mixer widget
  5911. * Note: PASD motherboards uses the Line In 2 as the input for front
  5912. * panel mic (mic 2)
  5913. */
  5914. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5916. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5920. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5921. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5922. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  5923. /*
  5924. * Set up output mixers (0x0c - 0x0e)
  5925. */
  5926. /* set vol=0 to output mixers */
  5927. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5928. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5929. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5930. /* set up input amps for analog loopback */
  5931. /* Amp Indices: DAC = 0, mixer = 1 */
  5932. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5933. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5934. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5935. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5936. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5938. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  5939. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  5940. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  5941. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  5942. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  5943. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  5944. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  5945. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5946. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5947. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5948. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5949. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  5950. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5951. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5952. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5953. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5954. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5955. /* FIXME: use matrix-type input source selection */
  5956. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5957. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5958. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  5959. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  5960. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  5961. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  5962. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  5963. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5964. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  5965. /* Input mixer2 */
  5966. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5967. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  5968. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5969. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5970. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5971. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5972. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  5973. /* Input mixer3 */
  5974. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5975. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  5976. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5977. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5979. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  5980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  5981. { }
  5982. };
  5983. /* pcm configuration: identiacal with ALC880 */
  5984. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5985. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5986. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5987. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5988. /*
  5989. * BIOS auto configuration
  5990. */
  5991. static int alc262_parse_auto_config(struct hda_codec *codec)
  5992. {
  5993. struct alc_spec *spec = codec->spec;
  5994. int err;
  5995. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5996. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5997. alc262_ignore)) < 0)
  5998. return err;
  5999. if (! spec->autocfg.line_outs)
  6000. return 0; /* can't find valid BIOS pin config */
  6001. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6002. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6003. return err;
  6004. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6005. if (spec->autocfg.dig_out_pin)
  6006. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6007. if (spec->autocfg.dig_in_pin)
  6008. spec->dig_in_nid = ALC262_DIGIN_NID;
  6009. if (spec->kctl_alloc)
  6010. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6011. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6012. spec->num_mux_defs = 1;
  6013. spec->input_mux = &spec->private_imux;
  6014. return 1;
  6015. }
  6016. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6017. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6018. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6019. /* init callback for auto-configuration model -- overriding the default init */
  6020. static void alc262_auto_init(struct hda_codec *codec)
  6021. {
  6022. alc262_auto_init_multi_out(codec);
  6023. alc262_auto_init_hp_out(codec);
  6024. alc262_auto_init_analog_input(codec);
  6025. }
  6026. /*
  6027. * configuration and preset
  6028. */
  6029. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6030. [ALC262_BASIC] = "basic",
  6031. [ALC262_HIPPO] = "hippo",
  6032. [ALC262_HIPPO_1] = "hippo_1",
  6033. [ALC262_FUJITSU] = "fujitsu",
  6034. [ALC262_HP_BPC] = "hp-bpc",
  6035. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6036. [ALC262_BENQ_ED8] = "benq",
  6037. [ALC262_AUTO] = "auto",
  6038. };
  6039. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6040. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6041. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6042. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6043. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6044. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6045. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6046. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6047. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6048. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6049. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6050. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6051. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6052. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6053. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6054. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6055. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6056. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6057. {}
  6058. };
  6059. static struct alc_config_preset alc262_presets[] = {
  6060. [ALC262_BASIC] = {
  6061. .mixers = { alc262_base_mixer },
  6062. .init_verbs = { alc262_init_verbs },
  6063. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6064. .dac_nids = alc262_dac_nids,
  6065. .hp_nid = 0x03,
  6066. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6067. .channel_mode = alc262_modes,
  6068. .input_mux = &alc262_capture_source,
  6069. },
  6070. [ALC262_HIPPO] = {
  6071. .mixers = { alc262_base_mixer },
  6072. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6073. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6074. .dac_nids = alc262_dac_nids,
  6075. .hp_nid = 0x03,
  6076. .dig_out_nid = ALC262_DIGOUT_NID,
  6077. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6078. .channel_mode = alc262_modes,
  6079. .input_mux = &alc262_capture_source,
  6080. .unsol_event = alc262_hippo_unsol_event,
  6081. },
  6082. [ALC262_HIPPO_1] = {
  6083. .mixers = { alc262_hippo1_mixer },
  6084. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6085. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6086. .dac_nids = alc262_dac_nids,
  6087. .hp_nid = 0x02,
  6088. .dig_out_nid = ALC262_DIGOUT_NID,
  6089. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6090. .channel_mode = alc262_modes,
  6091. .input_mux = &alc262_capture_source,
  6092. .unsol_event = alc262_hippo1_unsol_event,
  6093. },
  6094. [ALC262_FUJITSU] = {
  6095. .mixers = { alc262_fujitsu_mixer },
  6096. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6097. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6098. .dac_nids = alc262_dac_nids,
  6099. .hp_nid = 0x03,
  6100. .dig_out_nid = ALC262_DIGOUT_NID,
  6101. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6102. .channel_mode = alc262_modes,
  6103. .input_mux = &alc262_fujitsu_capture_source,
  6104. .unsol_event = alc262_fujitsu_unsol_event,
  6105. },
  6106. [ALC262_HP_BPC] = {
  6107. .mixers = { alc262_HP_BPC_mixer },
  6108. .init_verbs = { alc262_HP_BPC_init_verbs },
  6109. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6110. .dac_nids = alc262_dac_nids,
  6111. .hp_nid = 0x03,
  6112. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6113. .channel_mode = alc262_modes,
  6114. .input_mux = &alc262_HP_capture_source,
  6115. },
  6116. [ALC262_HP_BPC_D7000_WF] = {
  6117. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6118. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6119. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6120. .dac_nids = alc262_dac_nids,
  6121. .hp_nid = 0x03,
  6122. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6123. .channel_mode = alc262_modes,
  6124. .input_mux = &alc262_HP_capture_source,
  6125. },
  6126. [ALC262_HP_BPC_D7000_WL] = {
  6127. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6128. alc262_HP_BPC_WildWest_option_mixer },
  6129. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6130. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6131. .dac_nids = alc262_dac_nids,
  6132. .hp_nid = 0x03,
  6133. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6134. .channel_mode = alc262_modes,
  6135. .input_mux = &alc262_HP_capture_source,
  6136. },
  6137. [ALC262_BENQ_ED8] = {
  6138. .mixers = { alc262_base_mixer },
  6139. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6140. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6141. .dac_nids = alc262_dac_nids,
  6142. .hp_nid = 0x03,
  6143. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6144. .channel_mode = alc262_modes,
  6145. .input_mux = &alc262_capture_source,
  6146. },
  6147. };
  6148. static int patch_alc262(struct hda_codec *codec)
  6149. {
  6150. struct alc_spec *spec;
  6151. int board_config;
  6152. int err;
  6153. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6154. if (spec == NULL)
  6155. return -ENOMEM;
  6156. codec->spec = spec;
  6157. #if 0
  6158. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  6159. {
  6160. int tmp;
  6161. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6162. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  6163. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6164. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  6165. }
  6166. #endif
  6167. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  6168. alc262_models,
  6169. alc262_cfg_tbl);
  6170. if (board_config < 0) {
  6171. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  6172. "trying auto-probe from BIOS...\n");
  6173. board_config = ALC262_AUTO;
  6174. }
  6175. if (board_config == ALC262_AUTO) {
  6176. /* automatic parse from the BIOS config */
  6177. err = alc262_parse_auto_config(codec);
  6178. if (err < 0) {
  6179. alc_free(codec);
  6180. return err;
  6181. } else if (! err) {
  6182. printk(KERN_INFO
  6183. "hda_codec: Cannot set up configuration "
  6184. "from BIOS. Using base mode...\n");
  6185. board_config = ALC262_BASIC;
  6186. }
  6187. }
  6188. if (board_config != ALC262_AUTO)
  6189. setup_preset(spec, &alc262_presets[board_config]);
  6190. spec->stream_name_analog = "ALC262 Analog";
  6191. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  6192. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  6193. spec->stream_name_digital = "ALC262 Digital";
  6194. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6195. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6196. if (! spec->adc_nids && spec->input_mux) {
  6197. /* check whether NID 0x07 is valid */
  6198. unsigned int wcap = get_wcaps(codec, 0x07);
  6199. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  6200. if (wcap != AC_WID_AUD_IN) {
  6201. spec->adc_nids = alc262_adc_nids_alt;
  6202. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6203. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  6204. spec->num_mixers++;
  6205. } else {
  6206. spec->adc_nids = alc262_adc_nids;
  6207. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6208. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6209. spec->num_mixers++;
  6210. }
  6211. }
  6212. codec->patch_ops = alc_patch_ops;
  6213. if (board_config == ALC262_AUTO)
  6214. spec->init_hook = alc262_auto_init;
  6215. return 0;
  6216. }
  6217. /*
  6218. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6219. */
  6220. /*
  6221. * set the path ways for 2 channel output
  6222. * need to set the codec line out and mic 1 pin widgets to inputs
  6223. */
  6224. static struct hda_verb alc861_threestack_ch2_init[] = {
  6225. /* set pin widget 1Ah (line in) for input */
  6226. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6227. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6228. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6229. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6230. #if 0
  6231. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6232. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6233. #endif
  6234. { } /* end */
  6235. };
  6236. /*
  6237. * 6ch mode
  6238. * need to set the codec line out and mic 1 pin widgets to outputs
  6239. */
  6240. static struct hda_verb alc861_threestack_ch6_init[] = {
  6241. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6242. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6243. /* set pin widget 18h (mic1) for output (CLFE)*/
  6244. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6245. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6246. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6247. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6248. #if 0
  6249. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6250. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6251. #endif
  6252. { } /* end */
  6253. };
  6254. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6255. { 2, alc861_threestack_ch2_init },
  6256. { 6, alc861_threestack_ch6_init },
  6257. };
  6258. /* Set mic1 as input and unmute the mixer */
  6259. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6260. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6261. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6262. { } /* end */
  6263. };
  6264. /* Set mic1 as output and mute mixer */
  6265. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6266. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6267. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6268. { } /* end */
  6269. };
  6270. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6271. { 2, alc861_uniwill_m31_ch2_init },
  6272. { 4, alc861_uniwill_m31_ch4_init },
  6273. };
  6274. /* Set mic1 and line-in as input and unmute the mixer */
  6275. static struct hda_verb alc861_asus_ch2_init[] = {
  6276. /* set pin widget 1Ah (line in) for input */
  6277. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6278. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6279. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6280. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6281. #if 0
  6282. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6283. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6284. #endif
  6285. { } /* end */
  6286. };
  6287. /* Set mic1 nad line-in as output and mute mixer */
  6288. static struct hda_verb alc861_asus_ch6_init[] = {
  6289. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6290. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6291. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6292. /* set pin widget 18h (mic1) for output (CLFE)*/
  6293. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6294. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6295. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6296. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6297. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6298. #if 0
  6299. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6300. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6301. #endif
  6302. { } /* end */
  6303. };
  6304. static struct hda_channel_mode alc861_asus_modes[2] = {
  6305. { 2, alc861_asus_ch2_init },
  6306. { 6, alc861_asus_ch6_init },
  6307. };
  6308. /* patch-ALC861 */
  6309. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6310. /* output mixer control */
  6311. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6312. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6313. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6314. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6315. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6316. /*Input mixer control */
  6317. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6318. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6319. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6320. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6321. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6322. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6323. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6324. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6325. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6326. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6327. /* Capture mixer control */
  6328. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6329. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6330. {
  6331. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6332. .name = "Capture Source",
  6333. .count = 1,
  6334. .info = alc_mux_enum_info,
  6335. .get = alc_mux_enum_get,
  6336. .put = alc_mux_enum_put,
  6337. },
  6338. { } /* end */
  6339. };
  6340. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6341. /* output mixer control */
  6342. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6343. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6344. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6345. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6346. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6347. /* Input mixer control */
  6348. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6349. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6350. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6351. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6352. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6353. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6355. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6356. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6357. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6358. /* Capture mixer control */
  6359. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6360. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6361. {
  6362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6363. .name = "Capture Source",
  6364. .count = 1,
  6365. .info = alc_mux_enum_info,
  6366. .get = alc_mux_enum_get,
  6367. .put = alc_mux_enum_put,
  6368. },
  6369. {
  6370. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6371. .name = "Channel Mode",
  6372. .info = alc_ch_mode_info,
  6373. .get = alc_ch_mode_get,
  6374. .put = alc_ch_mode_put,
  6375. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6376. },
  6377. { } /* end */
  6378. };
  6379. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6380. /* output mixer control */
  6381. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6382. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6383. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6384. /*Capture mixer control */
  6385. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6386. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6387. {
  6388. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6389. .name = "Capture Source",
  6390. .count = 1,
  6391. .info = alc_mux_enum_info,
  6392. .get = alc_mux_enum_get,
  6393. .put = alc_mux_enum_put,
  6394. },
  6395. { } /* end */
  6396. };
  6397. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6398. /* output mixer control */
  6399. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6400. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6401. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6402. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6403. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6404. /* Input mixer control */
  6405. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6406. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6407. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6408. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6409. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6410. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6411. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6412. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6413. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6414. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6415. /* Capture mixer control */
  6416. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6417. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6418. {
  6419. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6420. .name = "Capture Source",
  6421. .count = 1,
  6422. .info = alc_mux_enum_info,
  6423. .get = alc_mux_enum_get,
  6424. .put = alc_mux_enum_put,
  6425. },
  6426. {
  6427. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6428. .name = "Channel Mode",
  6429. .info = alc_ch_mode_info,
  6430. .get = alc_ch_mode_get,
  6431. .put = alc_ch_mode_put,
  6432. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6433. },
  6434. { } /* end */
  6435. };
  6436. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6437. /* output mixer control */
  6438. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6439. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6440. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6441. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6442. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6443. /* Input mixer control */
  6444. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6445. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6446. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6447. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6448. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6449. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6450. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6451. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6452. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
  6454. /* Capture mixer control */
  6455. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6456. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6457. {
  6458. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6459. .name = "Capture Source",
  6460. .count = 1,
  6461. .info = alc_mux_enum_info,
  6462. .get = alc_mux_enum_get,
  6463. .put = alc_mux_enum_put,
  6464. },
  6465. {
  6466. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6467. .name = "Channel Mode",
  6468. .info = alc_ch_mode_info,
  6469. .get = alc_ch_mode_get,
  6470. .put = alc_ch_mode_put,
  6471. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6472. },
  6473. { }
  6474. };
  6475. /* additional mixer */
  6476. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6477. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6478. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6479. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6480. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6481. { }
  6482. };
  6483. /*
  6484. * generic initialization of ADC, input mixers and output mixers
  6485. */
  6486. static struct hda_verb alc861_base_init_verbs[] = {
  6487. /*
  6488. * Unmute ADC0 and set the default input to mic-in
  6489. */
  6490. /* port-A for surround (rear panel) */
  6491. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6492. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6493. /* port-B for mic-in (rear panel) with vref */
  6494. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6495. /* port-C for line-in (rear panel) */
  6496. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6497. /* port-D for Front */
  6498. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6499. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6500. /* port-E for HP out (front panel) */
  6501. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6502. /* route front PCM to HP */
  6503. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6504. /* port-F for mic-in (front panel) with vref */
  6505. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6506. /* port-G for CLFE (rear panel) */
  6507. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6508. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6509. /* port-H for side (rear panel) */
  6510. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6511. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6512. /* CD-in */
  6513. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6514. /* route front mic to ADC1*/
  6515. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6516. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6517. /* Unmute DAC0~3 & spdif out*/
  6518. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6519. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6520. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6521. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6522. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6523. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6524. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6525. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6526. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6527. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6528. /* Unmute Stereo Mixer 15 */
  6529. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6531. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6532. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6533. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6534. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6535. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6536. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6537. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6538. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6539. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6540. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6541. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6542. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6543. { }
  6544. };
  6545. static struct hda_verb alc861_threestack_init_verbs[] = {
  6546. /*
  6547. * Unmute ADC0 and set the default input to mic-in
  6548. */
  6549. /* port-A for surround (rear panel) */
  6550. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6551. /* port-B for mic-in (rear panel) with vref */
  6552. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6553. /* port-C for line-in (rear panel) */
  6554. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6555. /* port-D for Front */
  6556. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6557. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6558. /* port-E for HP out (front panel) */
  6559. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6560. /* route front PCM to HP */
  6561. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6562. /* port-F for mic-in (front panel) with vref */
  6563. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6564. /* port-G for CLFE (rear panel) */
  6565. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6566. /* port-H for side (rear panel) */
  6567. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6568. /* CD-in */
  6569. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6570. /* route front mic to ADC1*/
  6571. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6572. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6573. /* Unmute DAC0~3 & spdif out*/
  6574. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6575. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6576. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6577. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6579. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6580. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6581. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6582. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6583. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6584. /* Unmute Stereo Mixer 15 */
  6585. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6586. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6587. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6588. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6589. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6590. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6591. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6592. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6593. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6594. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6595. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6596. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6597. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6598. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6599. { }
  6600. };
  6601. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  6602. /*
  6603. * Unmute ADC0 and set the default input to mic-in
  6604. */
  6605. /* port-A for surround (rear panel) */
  6606. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6607. /* port-B for mic-in (rear panel) with vref */
  6608. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6609. /* port-C for line-in (rear panel) */
  6610. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6611. /* port-D for Front */
  6612. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6613. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6614. /* port-E for HP out (front panel) */
  6615. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  6616. /* route front PCM to HP */
  6617. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6618. /* port-F for mic-in (front panel) with vref */
  6619. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6620. /* port-G for CLFE (rear panel) */
  6621. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6622. /* port-H for side (rear panel) */
  6623. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6624. /* CD-in */
  6625. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6626. /* route front mic to ADC1*/
  6627. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6628. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6629. /* Unmute DAC0~3 & spdif out*/
  6630. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6631. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6632. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6633. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6635. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6636. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6637. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6638. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6639. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6640. /* Unmute Stereo Mixer 15 */
  6641. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6642. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6643. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6644. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6645. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6646. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6647. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6648. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6649. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6650. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6651. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6652. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6653. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6654. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6655. { }
  6656. };
  6657. static struct hda_verb alc861_asus_init_verbs[] = {
  6658. /*
  6659. * Unmute ADC0 and set the default input to mic-in
  6660. */
  6661. /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
  6662. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  6663. /* route front PCM to HP */
  6664. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6665. /* port-B for mic-in (rear panel) with vref */
  6666. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6667. /* port-C for line-in (rear panel) */
  6668. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6669. /* port-D for Front */
  6670. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6671. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6672. /* port-E for HP out (front panel) */
  6673. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
  6674. /* route front PCM to HP */
  6675. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6676. /* port-F for mic-in (front panel) with vref */
  6677. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6678. /* port-G for CLFE (rear panel) */
  6679. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6680. /* port-H for side (rear panel) */
  6681. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6682. /* CD-in */
  6683. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6684. /* route front mic to ADC1*/
  6685. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6686. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6687. /* Unmute DAC0~3 & spdif out*/
  6688. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6689. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6690. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6691. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6692. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6693. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6694. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6695. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6696. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6697. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6698. /* Unmute Stereo Mixer 15 */
  6699. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6700. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6701. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6702. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
  6703. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6704. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6705. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6706. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6707. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6708. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6709. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6710. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6711. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
  6712. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6713. { }
  6714. };
  6715. /* additional init verbs for ASUS laptops */
  6716. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  6717. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  6718. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  6719. { }
  6720. };
  6721. /*
  6722. * generic initialization of ADC, input mixers and output mixers
  6723. */
  6724. static struct hda_verb alc861_auto_init_verbs[] = {
  6725. /*
  6726. * Unmute ADC0 and set the default input to mic-in
  6727. */
  6728. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6729. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6730. /* Unmute DAC0~3 & spdif out*/
  6731. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6732. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6733. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6734. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6735. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6736. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6737. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6738. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6739. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6740. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6741. /* Unmute Stereo Mixer 15 */
  6742. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6743. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6744. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  6746. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6747. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6748. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6749. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6750. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6751. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6752. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6753. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6754. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6755. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6756. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6758. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6759. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6760. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6761. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6762. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  6763. { }
  6764. };
  6765. static struct hda_verb alc861_toshiba_init_verbs[] = {
  6766. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6767. { }
  6768. };
  6769. /* toggle speaker-output according to the hp-jack state */
  6770. static void alc861_toshiba_automute(struct hda_codec *codec)
  6771. {
  6772. unsigned int present;
  6773. present = snd_hda_codec_read(codec, 0x0f, 0,
  6774. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6775. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  6776. 0x80, present ? 0x80 : 0);
  6777. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  6778. 0x80, present ? 0x80 : 0);
  6779. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  6780. 0x80, present ? 0 : 0x80);
  6781. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  6782. 0x80, present ? 0 : 0x80);
  6783. }
  6784. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  6785. unsigned int res)
  6786. {
  6787. /* Looks like the unsol event is incompatible with the standard
  6788. * definition. 6bit tag is placed at 26 bit!
  6789. */
  6790. if ((res >> 26) == ALC880_HP_EVENT)
  6791. alc861_toshiba_automute(codec);
  6792. }
  6793. /* pcm configuration: identiacal with ALC880 */
  6794. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  6795. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  6796. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  6797. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  6798. #define ALC861_DIGOUT_NID 0x07
  6799. static struct hda_channel_mode alc861_8ch_modes[1] = {
  6800. { 8, NULL }
  6801. };
  6802. static hda_nid_t alc861_dac_nids[4] = {
  6803. /* front, surround, clfe, side */
  6804. 0x03, 0x06, 0x05, 0x04
  6805. };
  6806. static hda_nid_t alc660_dac_nids[3] = {
  6807. /* front, clfe, surround */
  6808. 0x03, 0x05, 0x06
  6809. };
  6810. static hda_nid_t alc861_adc_nids[1] = {
  6811. /* ADC0-2 */
  6812. 0x08,
  6813. };
  6814. static struct hda_input_mux alc861_capture_source = {
  6815. .num_items = 5,
  6816. .items = {
  6817. { "Mic", 0x0 },
  6818. { "Front Mic", 0x3 },
  6819. { "Line", 0x1 },
  6820. { "CD", 0x4 },
  6821. { "Mixer", 0x5 },
  6822. },
  6823. };
  6824. /* fill in the dac_nids table from the parsed pin configuration */
  6825. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6826. {
  6827. int i;
  6828. hda_nid_t nid;
  6829. spec->multiout.dac_nids = spec->private_dac_nids;
  6830. for (i = 0; i < cfg->line_outs; i++) {
  6831. nid = cfg->line_out_pins[i];
  6832. if (nid) {
  6833. if (i >= ARRAY_SIZE(alc861_dac_nids))
  6834. continue;
  6835. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  6836. }
  6837. }
  6838. spec->multiout.num_dacs = cfg->line_outs;
  6839. return 0;
  6840. }
  6841. /* add playback controls from the parsed DAC table */
  6842. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  6843. const struct auto_pin_cfg *cfg)
  6844. {
  6845. char name[32];
  6846. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  6847. hda_nid_t nid;
  6848. int i, idx, err;
  6849. for (i = 0; i < cfg->line_outs; i++) {
  6850. nid = spec->multiout.dac_nids[i];
  6851. if (! nid)
  6852. continue;
  6853. if (nid == 0x05) {
  6854. /* Center/LFE */
  6855. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  6856. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  6857. return err;
  6858. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  6859. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  6860. return err;
  6861. } else {
  6862. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  6863. if (nid == alc861_dac_nids[idx])
  6864. break;
  6865. sprintf(name, "%s Playback Switch", chname[idx]);
  6866. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  6867. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6868. return err;
  6869. }
  6870. }
  6871. return 0;
  6872. }
  6873. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  6874. {
  6875. int err;
  6876. hda_nid_t nid;
  6877. if (! pin)
  6878. return 0;
  6879. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  6880. nid = 0x03;
  6881. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  6882. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6883. return err;
  6884. spec->multiout.hp_nid = nid;
  6885. }
  6886. return 0;
  6887. }
  6888. /* create playback/capture controls for input pins */
  6889. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6890. {
  6891. struct hda_input_mux *imux = &spec->private_imux;
  6892. int i, err, idx, idx1;
  6893. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6894. switch(cfg->input_pins[i]) {
  6895. case 0x0c:
  6896. idx1 = 1;
  6897. idx = 2; // Line In
  6898. break;
  6899. case 0x0f:
  6900. idx1 = 2;
  6901. idx = 2; // Line In
  6902. break;
  6903. case 0x0d:
  6904. idx1 = 0;
  6905. idx = 1; // Mic In
  6906. break;
  6907. case 0x10:
  6908. idx1 = 3;
  6909. idx = 1; // Mic In
  6910. break;
  6911. case 0x11:
  6912. idx1 = 4;
  6913. idx = 0; // CD
  6914. break;
  6915. default:
  6916. continue;
  6917. }
  6918. err = new_analog_input(spec, cfg->input_pins[i],
  6919. auto_pin_cfg_labels[i], idx, 0x15);
  6920. if (err < 0)
  6921. return err;
  6922. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  6923. imux->items[imux->num_items].index = idx1;
  6924. imux->num_items++;
  6925. }
  6926. return 0;
  6927. }
  6928. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  6929. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6930. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6931. {
  6932. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6933. /* The multiple "Capture Source" controls confuse alsamixer
  6934. * So call somewhat different..
  6935. *FIXME: the controls appear in the "playback" view!
  6936. */
  6937. /* .name = "Capture Source", */
  6938. .name = "Input Source",
  6939. .count = 1,
  6940. .info = alc_mux_enum_info,
  6941. .get = alc_mux_enum_get,
  6942. .put = alc_mux_enum_put,
  6943. },
  6944. { } /* end */
  6945. };
  6946. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6947. int pin_type, int dac_idx)
  6948. {
  6949. /* set as output */
  6950. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6951. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6952. }
  6953. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6954. {
  6955. struct alc_spec *spec = codec->spec;
  6956. int i;
  6957. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6958. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6959. if (nid)
  6960. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6961. }
  6962. }
  6963. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6964. {
  6965. struct alc_spec *spec = codec->spec;
  6966. hda_nid_t pin;
  6967. pin = spec->autocfg.hp_pins[0];
  6968. if (pin) /* connect to front */
  6969. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6970. }
  6971. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6972. {
  6973. struct alc_spec *spec = codec->spec;
  6974. int i;
  6975. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6976. hda_nid_t nid = spec->autocfg.input_pins[i];
  6977. if ((nid>=0x0c) && (nid <=0x11)) {
  6978. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6979. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6980. }
  6981. }
  6982. }
  6983. /* parse the BIOS configuration and set up the alc_spec */
  6984. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6985. static int alc861_parse_auto_config(struct hda_codec *codec)
  6986. {
  6987. struct alc_spec *spec = codec->spec;
  6988. int err;
  6989. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6990. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6991. alc861_ignore)) < 0)
  6992. return err;
  6993. if (! spec->autocfg.line_outs)
  6994. return 0; /* can't find valid BIOS pin config */
  6995. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6996. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6997. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6998. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6999. return err;
  7000. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7001. if (spec->autocfg.dig_out_pin)
  7002. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7003. if (spec->kctl_alloc)
  7004. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7005. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7006. spec->num_mux_defs = 1;
  7007. spec->input_mux = &spec->private_imux;
  7008. spec->adc_nids = alc861_adc_nids;
  7009. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7010. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7011. spec->num_mixers++;
  7012. return 1;
  7013. }
  7014. /* additional initialization for auto-configuration model */
  7015. static void alc861_auto_init(struct hda_codec *codec)
  7016. {
  7017. alc861_auto_init_multi_out(codec);
  7018. alc861_auto_init_hp_out(codec);
  7019. alc861_auto_init_analog_input(codec);
  7020. }
  7021. /*
  7022. * configuration and preset
  7023. */
  7024. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7025. [ALC861_3ST] = "3stack",
  7026. [ALC660_3ST] = "3stack-660",
  7027. [ALC861_3ST_DIG] = "3stack-dig",
  7028. [ALC861_6ST_DIG] = "6stack-dig",
  7029. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7030. [ALC861_TOSHIBA] = "toshiba",
  7031. [ALC861_ASUS] = "asus",
  7032. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7033. [ALC861_AUTO] = "auto",
  7034. };
  7035. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7036. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7037. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7038. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7039. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7040. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  7041. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7042. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7043. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7044. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7045. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7046. {}
  7047. };
  7048. static struct alc_config_preset alc861_presets[] = {
  7049. [ALC861_3ST] = {
  7050. .mixers = { alc861_3ST_mixer },
  7051. .init_verbs = { alc861_threestack_init_verbs },
  7052. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7053. .dac_nids = alc861_dac_nids,
  7054. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7055. .channel_mode = alc861_threestack_modes,
  7056. .need_dac_fix = 1,
  7057. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7058. .adc_nids = alc861_adc_nids,
  7059. .input_mux = &alc861_capture_source,
  7060. },
  7061. [ALC861_3ST_DIG] = {
  7062. .mixers = { alc861_base_mixer },
  7063. .init_verbs = { alc861_threestack_init_verbs },
  7064. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7065. .dac_nids = alc861_dac_nids,
  7066. .dig_out_nid = ALC861_DIGOUT_NID,
  7067. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7068. .channel_mode = alc861_threestack_modes,
  7069. .need_dac_fix = 1,
  7070. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7071. .adc_nids = alc861_adc_nids,
  7072. .input_mux = &alc861_capture_source,
  7073. },
  7074. [ALC861_6ST_DIG] = {
  7075. .mixers = { alc861_base_mixer },
  7076. .init_verbs = { alc861_base_init_verbs },
  7077. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7078. .dac_nids = alc861_dac_nids,
  7079. .dig_out_nid = ALC861_DIGOUT_NID,
  7080. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7081. .channel_mode = alc861_8ch_modes,
  7082. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7083. .adc_nids = alc861_adc_nids,
  7084. .input_mux = &alc861_capture_source,
  7085. },
  7086. [ALC660_3ST] = {
  7087. .mixers = { alc861_3ST_mixer },
  7088. .init_verbs = { alc861_threestack_init_verbs },
  7089. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7090. .dac_nids = alc660_dac_nids,
  7091. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7092. .channel_mode = alc861_threestack_modes,
  7093. .need_dac_fix = 1,
  7094. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7095. .adc_nids = alc861_adc_nids,
  7096. .input_mux = &alc861_capture_source,
  7097. },
  7098. [ALC861_UNIWILL_M31] = {
  7099. .mixers = { alc861_uniwill_m31_mixer },
  7100. .init_verbs = { alc861_uniwill_m31_init_verbs },
  7101. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7102. .dac_nids = alc861_dac_nids,
  7103. .dig_out_nid = ALC861_DIGOUT_NID,
  7104. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7105. .channel_mode = alc861_uniwill_m31_modes,
  7106. .need_dac_fix = 1,
  7107. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7108. .adc_nids = alc861_adc_nids,
  7109. .input_mux = &alc861_capture_source,
  7110. },
  7111. [ALC861_TOSHIBA] = {
  7112. .mixers = { alc861_toshiba_mixer },
  7113. .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
  7114. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7115. .dac_nids = alc861_dac_nids,
  7116. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7117. .channel_mode = alc883_3ST_2ch_modes,
  7118. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7119. .adc_nids = alc861_adc_nids,
  7120. .input_mux = &alc861_capture_source,
  7121. .unsol_event = alc861_toshiba_unsol_event,
  7122. .init_hook = alc861_toshiba_automute,
  7123. },
  7124. [ALC861_ASUS] = {
  7125. .mixers = { alc861_asus_mixer },
  7126. .init_verbs = { alc861_asus_init_verbs },
  7127. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7128. .dac_nids = alc861_dac_nids,
  7129. .dig_out_nid = ALC861_DIGOUT_NID,
  7130. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  7131. .channel_mode = alc861_asus_modes,
  7132. .need_dac_fix = 1,
  7133. .hp_nid = 0x06,
  7134. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7135. .adc_nids = alc861_adc_nids,
  7136. .input_mux = &alc861_capture_source,
  7137. },
  7138. [ALC861_ASUS_LAPTOP] = {
  7139. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  7140. .init_verbs = { alc861_asus_init_verbs,
  7141. alc861_asus_laptop_init_verbs },
  7142. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7143. .dac_nids = alc861_dac_nids,
  7144. .dig_out_nid = ALC861_DIGOUT_NID,
  7145. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7146. .channel_mode = alc883_3ST_2ch_modes,
  7147. .need_dac_fix = 1,
  7148. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7149. .adc_nids = alc861_adc_nids,
  7150. .input_mux = &alc861_capture_source,
  7151. },
  7152. };
  7153. static int patch_alc861(struct hda_codec *codec)
  7154. {
  7155. struct alc_spec *spec;
  7156. int board_config;
  7157. int err;
  7158. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7159. if (spec == NULL)
  7160. return -ENOMEM;
  7161. codec->spec = spec;
  7162. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  7163. alc861_models,
  7164. alc861_cfg_tbl);
  7165. if (board_config < 0) {
  7166. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  7167. "trying auto-probe from BIOS...\n");
  7168. board_config = ALC861_AUTO;
  7169. }
  7170. if (board_config == ALC861_AUTO) {
  7171. /* automatic parse from the BIOS config */
  7172. err = alc861_parse_auto_config(codec);
  7173. if (err < 0) {
  7174. alc_free(codec);
  7175. return err;
  7176. } else if (! err) {
  7177. printk(KERN_INFO
  7178. "hda_codec: Cannot set up configuration "
  7179. "from BIOS. Using base mode...\n");
  7180. board_config = ALC861_3ST_DIG;
  7181. }
  7182. }
  7183. if (board_config != ALC861_AUTO)
  7184. setup_preset(spec, &alc861_presets[board_config]);
  7185. spec->stream_name_analog = "ALC861 Analog";
  7186. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  7187. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  7188. spec->stream_name_digital = "ALC861 Digital";
  7189. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  7190. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  7191. codec->patch_ops = alc_patch_ops;
  7192. if (board_config == ALC861_AUTO)
  7193. spec->init_hook = alc861_auto_init;
  7194. return 0;
  7195. }
  7196. /*
  7197. * ALC861-VD support
  7198. *
  7199. * Based on ALC882
  7200. *
  7201. * In addition, an independent DAC
  7202. */
  7203. #define ALC861VD_DIGOUT_NID 0x06
  7204. static hda_nid_t alc861vd_dac_nids[4] = {
  7205. /* front, surr, clfe, side surr */
  7206. 0x02, 0x03, 0x04, 0x05
  7207. };
  7208. /* dac_nids for ALC660vd are in a different order - according to
  7209. * Realtek's driver.
  7210. * This should probably tesult in a different mixer for 6stack models
  7211. * of ALC660vd codecs, but for now there is only 3stack mixer
  7212. * - and it is the same as in 861vd.
  7213. * adc_nids in ALC660vd are (is) the same as in 861vd
  7214. */
  7215. static hda_nid_t alc660vd_dac_nids[3] = {
  7216. /* front, rear, clfe, rear_surr */
  7217. 0x02, 0x04, 0x03
  7218. };
  7219. static hda_nid_t alc861vd_adc_nids[1] = {
  7220. /* ADC0 */
  7221. 0x09,
  7222. };
  7223. /* input MUX */
  7224. /* FIXME: should be a matrix-type input source selection */
  7225. static struct hda_input_mux alc861vd_capture_source = {
  7226. .num_items = 4,
  7227. .items = {
  7228. { "Mic", 0x0 },
  7229. { "Front Mic", 0x1 },
  7230. { "Line", 0x2 },
  7231. { "CD", 0x4 },
  7232. },
  7233. };
  7234. #define alc861vd_mux_enum_info alc_mux_enum_info
  7235. #define alc861vd_mux_enum_get alc_mux_enum_get
  7236. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  7237. struct snd_ctl_elem_value *ucontrol)
  7238. {
  7239. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7240. struct alc_spec *spec = codec->spec;
  7241. const struct hda_input_mux *imux = spec->input_mux;
  7242. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7243. static hda_nid_t capture_mixers[1] = { 0x22 };
  7244. hda_nid_t nid = capture_mixers[adc_idx];
  7245. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7246. unsigned int i, idx;
  7247. idx = ucontrol->value.enumerated.item[0];
  7248. if (idx >= imux->num_items)
  7249. idx = imux->num_items - 1;
  7250. if (*cur_val == idx && ! codec->in_resume)
  7251. return 0;
  7252. for (i = 0; i < imux->num_items; i++) {
  7253. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7254. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7255. v | (imux->items[i].index << 8));
  7256. }
  7257. *cur_val = idx;
  7258. return 1;
  7259. }
  7260. /*
  7261. * 2ch mode
  7262. */
  7263. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  7264. { 2, NULL }
  7265. };
  7266. /*
  7267. * 6ch mode
  7268. */
  7269. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  7270. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7271. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7272. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7273. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7274. { } /* end */
  7275. };
  7276. /*
  7277. * 8ch mode
  7278. */
  7279. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  7280. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7281. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7282. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7283. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7284. { } /* end */
  7285. };
  7286. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  7287. { 6, alc861vd_6stack_ch6_init },
  7288. { 8, alc861vd_6stack_ch8_init },
  7289. };
  7290. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  7291. {
  7292. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7293. .name = "Channel Mode",
  7294. .info = alc_ch_mode_info,
  7295. .get = alc_ch_mode_get,
  7296. .put = alc_ch_mode_put,
  7297. },
  7298. { } /* end */
  7299. };
  7300. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  7301. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  7302. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  7303. {
  7304. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7305. /* The multiple "Capture Source" controls confuse alsamixer
  7306. * So call somewhat different..
  7307. *FIXME: the controls appear in the "playback" view!
  7308. */
  7309. /* .name = "Capture Source", */
  7310. .name = "Input Source",
  7311. .count = 1,
  7312. .info = alc861vd_mux_enum_info,
  7313. .get = alc861vd_mux_enum_get,
  7314. .put = alc861vd_mux_enum_put,
  7315. },
  7316. { } /* end */
  7317. };
  7318. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  7319. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  7320. */
  7321. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  7322. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7323. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7324. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  7325. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  7326. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  7327. HDA_OUTPUT),
  7328. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  7329. HDA_OUTPUT),
  7330. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  7331. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  7332. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  7333. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  7334. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7335. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7336. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7337. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7338. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7339. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7340. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7341. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7342. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7343. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7344. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7345. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7346. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7347. { } /* end */
  7348. };
  7349. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  7350. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7351. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7352. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7353. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7355. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7356. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7357. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7358. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7359. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7360. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7361. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7362. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7363. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7364. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7365. { } /* end */
  7366. };
  7367. /*
  7368. * generic initialization of ADC, input mixers and output mixers
  7369. */
  7370. static struct hda_verb alc861vd_volume_init_verbs[] = {
  7371. /*
  7372. * Unmute ADC0 and set the default input to mic-in
  7373. */
  7374. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7375. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7376. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  7377. * the analog-loopback mixer widget
  7378. */
  7379. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7380. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7381. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7382. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7383. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7384. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7385. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  7386. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7387. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7388. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7389. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
  7390. /*
  7391. * Set up output mixers (0x02 - 0x05)
  7392. */
  7393. /* set vol=0 to output mixers */
  7394. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7395. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7396. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7397. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7398. /* set up input amps for analog loopback */
  7399. /* Amp Indices: DAC = 0, mixer = 1 */
  7400. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7401. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7402. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7403. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7404. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7405. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7406. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7407. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7408. { }
  7409. };
  7410. /*
  7411. * 3-stack pin configuration:
  7412. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  7413. */
  7414. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  7415. /*
  7416. * Set pin mode and muting
  7417. */
  7418. /* set front pin widgets 0x14 for output */
  7419. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7420. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7421. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7422. /* Mic (rear) pin: input vref at 80% */
  7423. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7424. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7425. /* Front Mic pin: input vref at 80% */
  7426. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7427. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7428. /* Line In pin: input */
  7429. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7430. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7431. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7432. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7433. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7434. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7435. /* CD pin widget for input */
  7436. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7437. { }
  7438. };
  7439. /*
  7440. * 6-stack pin configuration:
  7441. */
  7442. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  7443. /*
  7444. * Set pin mode and muting
  7445. */
  7446. /* set front pin widgets 0x14 for output */
  7447. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7448. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7449. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7450. /* Rear Pin: output 1 (0x0d) */
  7451. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7452. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7453. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7454. /* CLFE Pin: output 2 (0x0e) */
  7455. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7456. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7457. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  7458. /* Side Pin: output 3 (0x0f) */
  7459. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7460. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7461. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  7462. /* Mic (rear) pin: input vref at 80% */
  7463. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7464. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7465. /* Front Mic pin: input vref at 80% */
  7466. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7467. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7468. /* Line In pin: input */
  7469. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7470. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7471. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7472. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7473. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7474. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7475. /* CD pin widget for input */
  7476. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7477. { }
  7478. };
  7479. /* pcm configuration: identiacal with ALC880 */
  7480. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  7481. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  7482. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  7483. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  7484. /*
  7485. * configuration and preset
  7486. */
  7487. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  7488. [ALC660VD_3ST] = "3stack-660",
  7489. [ALC861VD_3ST] = "3stack",
  7490. [ALC861VD_3ST_DIG] = "3stack-digout",
  7491. [ALC861VD_6ST_DIG] = "6stack-digout",
  7492. [ALC861VD_AUTO] = "auto",
  7493. };
  7494. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  7495. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  7496. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  7497. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  7498. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
  7499. {}
  7500. };
  7501. static struct alc_config_preset alc861vd_presets[] = {
  7502. [ALC660VD_3ST] = {
  7503. .mixers = { alc861vd_3st_mixer },
  7504. .init_verbs = { alc861vd_volume_init_verbs,
  7505. alc861vd_3stack_init_verbs },
  7506. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  7507. .dac_nids = alc660vd_dac_nids,
  7508. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  7509. .adc_nids = alc861vd_adc_nids,
  7510. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7511. .channel_mode = alc861vd_3stack_2ch_modes,
  7512. .input_mux = &alc861vd_capture_source,
  7513. },
  7514. [ALC861VD_3ST] = {
  7515. .mixers = { alc861vd_3st_mixer },
  7516. .init_verbs = { alc861vd_volume_init_verbs,
  7517. alc861vd_3stack_init_verbs },
  7518. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7519. .dac_nids = alc861vd_dac_nids,
  7520. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7521. .channel_mode = alc861vd_3stack_2ch_modes,
  7522. .input_mux = &alc861vd_capture_source,
  7523. },
  7524. [ALC861VD_3ST_DIG] = {
  7525. .mixers = { alc861vd_3st_mixer },
  7526. .init_verbs = { alc861vd_volume_init_verbs,
  7527. alc861vd_3stack_init_verbs },
  7528. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7529. .dac_nids = alc861vd_dac_nids,
  7530. .dig_out_nid = ALC861VD_DIGOUT_NID,
  7531. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7532. .channel_mode = alc861vd_3stack_2ch_modes,
  7533. .input_mux = &alc861vd_capture_source,
  7534. },
  7535. [ALC861VD_6ST_DIG] = {
  7536. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  7537. .init_verbs = { alc861vd_volume_init_verbs,
  7538. alc861vd_6stack_init_verbs },
  7539. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  7540. .dac_nids = alc861vd_dac_nids,
  7541. .dig_out_nid = ALC861VD_DIGOUT_NID,
  7542. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  7543. .channel_mode = alc861vd_6stack_modes,
  7544. .input_mux = &alc861vd_capture_source,
  7545. },
  7546. };
  7547. /*
  7548. * BIOS auto configuration
  7549. */
  7550. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  7551. hda_nid_t nid, int pin_type, int dac_idx)
  7552. {
  7553. /* set as output */
  7554. snd_hda_codec_write(codec, nid, 0,
  7555. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  7556. snd_hda_codec_write(codec, nid, 0,
  7557. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  7558. }
  7559. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  7560. {
  7561. struct alc_spec *spec = codec->spec;
  7562. int i;
  7563. for (i = 0; i <= HDA_SIDE; i++) {
  7564. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7565. if (nid)
  7566. alc861vd_auto_set_output_and_unmute(codec, nid,
  7567. PIN_OUT, i);
  7568. }
  7569. }
  7570. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  7571. {
  7572. struct alc_spec *spec = codec->spec;
  7573. hda_nid_t pin;
  7574. pin = spec->autocfg.hp_pins[0];
  7575. if (pin) /* connect to front and use dac 0 */
  7576. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  7577. }
  7578. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  7579. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  7580. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  7581. {
  7582. struct alc_spec *spec = codec->spec;
  7583. int i;
  7584. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7585. hda_nid_t nid = spec->autocfg.input_pins[i];
  7586. if (alc861vd_is_input_pin(nid)) {
  7587. snd_hda_codec_write(codec, nid, 0,
  7588. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7589. i <= AUTO_PIN_FRONT_MIC ?
  7590. PIN_VREF80 : PIN_IN);
  7591. if (nid != ALC861VD_PIN_CD_NID)
  7592. snd_hda_codec_write(codec, nid, 0,
  7593. AC_VERB_SET_AMP_GAIN_MUTE,
  7594. AMP_OUT_MUTE);
  7595. }
  7596. }
  7597. }
  7598. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  7599. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  7600. /* add playback controls from the parsed DAC table */
  7601. /* Based on ALC880 version. But ALC861VD has separate,
  7602. * different NIDs for mute/unmute switch and volume control */
  7603. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  7604. const struct auto_pin_cfg *cfg)
  7605. {
  7606. char name[32];
  7607. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  7608. hda_nid_t nid_v, nid_s;
  7609. int i, err;
  7610. for (i = 0; i < cfg->line_outs; i++) {
  7611. if (! spec->multiout.dac_nids[i])
  7612. continue;
  7613. nid_v = alc861vd_idx_to_mixer_vol(
  7614. alc880_dac_to_idx(
  7615. spec->multiout.dac_nids[i]));
  7616. nid_s = alc861vd_idx_to_mixer_switch(
  7617. alc880_dac_to_idx(
  7618. spec->multiout.dac_nids[i]));
  7619. if (i == 2) {
  7620. /* Center/LFE */
  7621. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7622. "Center Playback Volume",
  7623. HDA_COMPOSE_AMP_VAL(nid_v, 1,
  7624. 0, HDA_OUTPUT))) < 0)
  7625. return err;
  7626. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7627. "LFE Playback Volume",
  7628. HDA_COMPOSE_AMP_VAL(nid_v, 2,
  7629. 0, HDA_OUTPUT))) < 0)
  7630. return err;
  7631. if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
  7632. "Center Playback Switch",
  7633. HDA_COMPOSE_AMP_VAL(nid_s, 1,
  7634. 2, HDA_INPUT))) < 0)
  7635. return err;
  7636. if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
  7637. "LFE Playback Switch",
  7638. HDA_COMPOSE_AMP_VAL(nid_s, 2,
  7639. 2, HDA_INPUT))) < 0)
  7640. return err;
  7641. } else {
  7642. sprintf(name, "%s Playback Volume", chname[i]);
  7643. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7644. HDA_COMPOSE_AMP_VAL(nid_v, 3,
  7645. 0, HDA_OUTPUT))) < 0)
  7646. return err;
  7647. sprintf(name, "%s Playback Switch", chname[i]);
  7648. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7649. HDA_COMPOSE_AMP_VAL(nid_v, 3,
  7650. 2, HDA_INPUT))) < 0)
  7651. return err;
  7652. }
  7653. }
  7654. return 0;
  7655. }
  7656. /* add playback controls for speaker and HP outputs */
  7657. /* Based on ALC880 version. But ALC861VD has separate,
  7658. * different NIDs for mute/unmute switch and volume control */
  7659. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  7660. hda_nid_t pin, const char *pfx)
  7661. {
  7662. hda_nid_t nid_v, nid_s;
  7663. int err;
  7664. char name[32];
  7665. if (! pin)
  7666. return 0;
  7667. if (alc880_is_fixed_pin(pin)) {
  7668. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  7669. /* specify the DAC as the extra output */
  7670. if (! spec->multiout.hp_nid)
  7671. spec->multiout.hp_nid = nid_v;
  7672. else
  7673. spec->multiout.extra_out_nid[0] = nid_v;
  7674. /* control HP volume/switch on the output mixer amp */
  7675. nid_v = alc861vd_idx_to_mixer_vol(
  7676. alc880_fixed_pin_idx(pin));
  7677. nid_s = alc861vd_idx_to_mixer_switch(
  7678. alc880_fixed_pin_idx(pin));
  7679. sprintf(name, "%s Playback Volume", pfx);
  7680. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7681. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  7682. HDA_OUTPUT))) < 0)
  7683. return err;
  7684. sprintf(name, "%s Playback Switch", pfx);
  7685. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7686. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  7687. HDA_INPUT))) < 0)
  7688. return err;
  7689. } else if (alc880_is_multi_pin(pin)) {
  7690. /* set manual connection */
  7691. /* we have only a switch on HP-out PIN */
  7692. sprintf(name, "%s Playback Switch", pfx);
  7693. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7694. HDA_COMPOSE_AMP_VAL(pin, 3, 0,
  7695. HDA_OUTPUT))) < 0)
  7696. return err;
  7697. }
  7698. return 0;
  7699. }
  7700. /* parse the BIOS configuration and set up the alc_spec
  7701. * return 1 if successful, 0 if the proper config is not found,
  7702. * or a negative error code
  7703. * Based on ALC880 version - had to change it to override
  7704. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  7705. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  7706. {
  7707. struct alc_spec *spec = codec->spec;
  7708. int err;
  7709. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  7710. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7711. alc861vd_ignore)) < 0)
  7712. return err;
  7713. if (! spec->autocfg.line_outs)
  7714. return 0; /* can't find valid BIOS pin config */
  7715. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  7716. (err = alc861vd_auto_create_multi_out_ctls(spec,
  7717. &spec->autocfg)) < 0 ||
  7718. (err = alc861vd_auto_create_extra_out(spec,
  7719. spec->autocfg.speaker_pins[0], "Speaker")) < 0 ||
  7720. (err = alc861vd_auto_create_extra_out(spec,
  7721. spec->autocfg.hp_pins[0], "Headphone")) < 0 ||
  7722. (err = alc880_auto_create_analog_input_ctls(spec,
  7723. &spec->autocfg)) < 0)
  7724. return err;
  7725. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7726. if (spec->autocfg.dig_out_pin)
  7727. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  7728. if (spec->kctl_alloc)
  7729. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7730. spec->init_verbs[spec->num_init_verbs++]
  7731. = alc861vd_volume_init_verbs;
  7732. spec->num_mux_defs = 1;
  7733. spec->input_mux = &spec->private_imux;
  7734. return 1;
  7735. }
  7736. /* additional initialization for auto-configuration model */
  7737. static void alc861vd_auto_init(struct hda_codec *codec)
  7738. {
  7739. alc861vd_auto_init_multi_out(codec);
  7740. alc861vd_auto_init_hp_out(codec);
  7741. alc861vd_auto_init_analog_input(codec);
  7742. }
  7743. static int patch_alc861vd(struct hda_codec *codec)
  7744. {
  7745. struct alc_spec *spec;
  7746. int err, board_config;
  7747. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7748. if (spec == NULL)
  7749. return -ENOMEM;
  7750. codec->spec = spec;
  7751. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  7752. alc861vd_models,
  7753. alc861vd_cfg_tbl);
  7754. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  7755. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  7756. "ALC861VD, trying auto-probe from BIOS...\n");
  7757. board_config = ALC861VD_AUTO;
  7758. }
  7759. if (board_config == ALC861VD_AUTO) {
  7760. /* automatic parse from the BIOS config */
  7761. err = alc861vd_parse_auto_config(codec);
  7762. if (err < 0) {
  7763. alc_free(codec);
  7764. return err;
  7765. } else if (! err) {
  7766. printk(KERN_INFO
  7767. "hda_codec: Cannot set up configuration "
  7768. "from BIOS. Using base mode...\n");
  7769. board_config = ALC861VD_3ST;
  7770. }
  7771. }
  7772. if (board_config != ALC861VD_AUTO)
  7773. setup_preset(spec, &alc861vd_presets[board_config]);
  7774. spec->stream_name_analog = "ALC861VD Analog";
  7775. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  7776. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  7777. spec->stream_name_digital = "ALC861VD Digital";
  7778. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  7779. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  7780. spec->adc_nids = alc861vd_adc_nids;
  7781. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  7782. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  7783. spec->num_mixers++;
  7784. codec->patch_ops = alc_patch_ops;
  7785. if (board_config == ALC861VD_AUTO)
  7786. spec->init_hook = alc861vd_auto_init;
  7787. return 0;
  7788. }
  7789. /*
  7790. * patch entries
  7791. */
  7792. struct hda_codec_preset snd_hda_preset_realtek[] = {
  7793. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  7794. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  7795. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  7796. .patch = patch_alc861 },
  7797. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  7798. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  7799. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  7800. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  7801. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  7802. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  7803. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  7804. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  7805. {} /* terminator */
  7806. };