patch_realtek.c 271 KB

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