patch_realtek.c 263 KB

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