patch_realtek.c 266 KB

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