patch_realtek.c 382 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC882_AUTO,
  147. ALC882_MODEL_LAST,
  148. };
  149. /* ALC883 models */
  150. enum {
  151. ALC883_3ST_2ch_DIG,
  152. ALC883_3ST_6ch_DIG,
  153. ALC883_3ST_6ch,
  154. ALC883_6ST_DIG,
  155. ALC883_TARGA_DIG,
  156. ALC883_TARGA_2ch_DIG,
  157. ALC883_ACER,
  158. ALC883_MEDION,
  159. ALC883_MEDION_MD2,
  160. ALC883_LAPTOP_EAPD,
  161. ALC883_LENOVO_101E_2ch,
  162. ALC883_LENOVO_NB0763,
  163. ALC888_LENOVO_MS7195_DIG,
  164. ALC888_HP_NETTLE,
  165. ALC888_HP_LUCKNOW,
  166. ALC883_AUTO,
  167. ALC883_MODEL_LAST,
  168. };
  169. /* for GPIO Poll */
  170. #define GPIO_MASK 0x03
  171. struct alc_spec {
  172. /* codec parameterization */
  173. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  174. unsigned int num_mixers;
  175. const struct hda_verb *init_verbs[5]; /* initialization verbs
  176. * don't forget NULL
  177. * termination!
  178. */
  179. unsigned int num_init_verbs;
  180. char *stream_name_analog; /* analog PCM stream */
  181. struct hda_pcm_stream *stream_analog_playback;
  182. struct hda_pcm_stream *stream_analog_capture;
  183. char *stream_name_digital; /* digital PCM stream */
  184. struct hda_pcm_stream *stream_digital_playback;
  185. struct hda_pcm_stream *stream_digital_capture;
  186. /* playback */
  187. struct hda_multi_out multiout; /* playback set-up
  188. * max_channels, dacs must be set
  189. * dig_out_nid and hp_nid are optional
  190. */
  191. /* capture */
  192. unsigned int num_adc_nids;
  193. hda_nid_t *adc_nids;
  194. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  195. /* capture source */
  196. unsigned int num_mux_defs;
  197. const struct hda_input_mux *input_mux;
  198. unsigned int cur_mux[3];
  199. /* channel model */
  200. const struct hda_channel_mode *channel_mode;
  201. int num_channel_mode;
  202. int need_dac_fix;
  203. /* PCM information */
  204. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  205. /* dynamic controls, init_verbs and input_mux */
  206. struct auto_pin_cfg autocfg;
  207. unsigned int num_kctl_alloc, num_kctl_used;
  208. struct snd_kcontrol_new *kctl_alloc;
  209. struct hda_input_mux private_imux;
  210. hda_nid_t private_dac_nids[5];
  211. /* hooks */
  212. void (*init_hook)(struct hda_codec *codec);
  213. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  214. /* for pin sensing */
  215. unsigned int sense_updated: 1;
  216. unsigned int jack_present: 1;
  217. };
  218. /*
  219. * configuration template - to be copied to the spec instance
  220. */
  221. struct alc_config_preset {
  222. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  223. * with spec
  224. */
  225. const struct hda_verb *init_verbs[5];
  226. unsigned int num_dacs;
  227. hda_nid_t *dac_nids;
  228. hda_nid_t dig_out_nid; /* optional */
  229. hda_nid_t hp_nid; /* optional */
  230. unsigned int num_adc_nids;
  231. hda_nid_t *adc_nids;
  232. hda_nid_t dig_in_nid;
  233. unsigned int num_channel_mode;
  234. const struct hda_channel_mode *channel_mode;
  235. int need_dac_fix;
  236. unsigned int num_mux_defs;
  237. const struct hda_input_mux *input_mux;
  238. void (*unsol_event)(struct hda_codec *, unsigned int);
  239. void (*init_hook)(struct hda_codec *);
  240. };
  241. /*
  242. * input MUX handling
  243. */
  244. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  245. struct snd_ctl_elem_info *uinfo)
  246. {
  247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  248. struct alc_spec *spec = codec->spec;
  249. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  250. if (mux_idx >= spec->num_mux_defs)
  251. mux_idx = 0;
  252. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  253. }
  254. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_value *ucontrol)
  256. {
  257. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  258. struct alc_spec *spec = codec->spec;
  259. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  260. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  261. return 0;
  262. }
  263. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  264. struct snd_ctl_elem_value *ucontrol)
  265. {
  266. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  267. struct alc_spec *spec = codec->spec;
  268. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  269. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  270. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  271. spec->adc_nids[adc_idx],
  272. &spec->cur_mux[adc_idx]);
  273. }
  274. /*
  275. * channel mode setting
  276. */
  277. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_info *uinfo)
  279. {
  280. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  281. struct alc_spec *spec = codec->spec;
  282. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  283. spec->num_channel_mode);
  284. }
  285. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  286. struct snd_ctl_elem_value *ucontrol)
  287. {
  288. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  289. struct alc_spec *spec = codec->spec;
  290. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  291. spec->num_channel_mode,
  292. spec->multiout.max_channels);
  293. }
  294. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  295. struct snd_ctl_elem_value *ucontrol)
  296. {
  297. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  298. struct alc_spec *spec = codec->spec;
  299. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  300. spec->num_channel_mode,
  301. &spec->multiout.max_channels);
  302. if (err >= 0 && spec->need_dac_fix)
  303. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  304. return err;
  305. }
  306. /*
  307. * Control the mode of pin widget settings via the mixer. "pc" is used
  308. * instead of "%" to avoid consequences of accidently treating the % as
  309. * being part of a format specifier. Maximum allowed length of a value is
  310. * 63 characters plus NULL terminator.
  311. *
  312. * Note: some retasking pin complexes seem to ignore requests for input
  313. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  314. * are requested. Therefore order this list so that this behaviour will not
  315. * cause problems when mixer clients move through the enum sequentially.
  316. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  317. * March 2006.
  318. */
  319. static char *alc_pin_mode_names[] = {
  320. "Mic 50pc bias", "Mic 80pc bias",
  321. "Line in", "Line out", "Headphone out",
  322. };
  323. static unsigned char alc_pin_mode_values[] = {
  324. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  325. };
  326. /* The control can present all 5 options, or it can limit the options based
  327. * in the pin being assumed to be exclusively an input or an output pin. In
  328. * addition, "input" pins may or may not process the mic bias option
  329. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  330. * accept requests for bias as of chip versions up to March 2006) and/or
  331. * wiring in the computer.
  332. */
  333. #define ALC_PIN_DIR_IN 0x00
  334. #define ALC_PIN_DIR_OUT 0x01
  335. #define ALC_PIN_DIR_INOUT 0x02
  336. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  337. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  338. /* Info about the pin modes supported by the different pin direction modes.
  339. * For each direction the minimum and maximum values are given.
  340. */
  341. static signed char alc_pin_mode_dir_info[5][2] = {
  342. { 0, 2 }, /* ALC_PIN_DIR_IN */
  343. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  344. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  345. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  346. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  347. };
  348. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  349. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  350. #define alc_pin_mode_n_items(_dir) \
  351. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  352. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  353. struct snd_ctl_elem_info *uinfo)
  354. {
  355. unsigned int item_num = uinfo->value.enumerated.item;
  356. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  357. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  358. uinfo->count = 1;
  359. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  360. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  361. item_num = alc_pin_mode_min(dir);
  362. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  363. return 0;
  364. }
  365. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_value *ucontrol)
  367. {
  368. unsigned int i;
  369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  370. hda_nid_t nid = kcontrol->private_value & 0xffff;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. long *valp = ucontrol->value.integer.value;
  373. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  374. AC_VERB_GET_PIN_WIDGET_CONTROL,
  375. 0x00);
  376. /* Find enumerated value for current pinctl setting */
  377. i = alc_pin_mode_min(dir);
  378. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  379. i++;
  380. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  381. return 0;
  382. }
  383. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  384. struct snd_ctl_elem_value *ucontrol)
  385. {
  386. signed int change;
  387. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  388. hda_nid_t nid = kcontrol->private_value & 0xffff;
  389. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  390. long val = *ucontrol->value.integer.value;
  391. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  392. AC_VERB_GET_PIN_WIDGET_CONTROL,
  393. 0x00);
  394. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  395. val = alc_pin_mode_min(dir);
  396. change = pinctl != alc_pin_mode_values[val];
  397. if (change) {
  398. /* Set pin mode to that requested */
  399. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  400. alc_pin_mode_values[val]);
  401. /* Also enable the retasking pin's input/output as required
  402. * for the requested pin mode. Enum values of 2 or less are
  403. * input modes.
  404. *
  405. * Dynamically switching the input/output buffers probably
  406. * reduces noise slightly (particularly on input) so we'll
  407. * do it. However, having both input and output buffers
  408. * enabled simultaneously doesn't seem to be problematic if
  409. * this turns out to be necessary in the future.
  410. */
  411. if (val <= 2) {
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_OUT_MUTE);
  415. snd_hda_codec_write(codec, nid, 0,
  416. AC_VERB_SET_AMP_GAIN_MUTE,
  417. AMP_IN_UNMUTE(0));
  418. } else {
  419. snd_hda_codec_write(codec, nid, 0,
  420. AC_VERB_SET_AMP_GAIN_MUTE,
  421. AMP_IN_MUTE(0));
  422. snd_hda_codec_write(codec, nid, 0,
  423. AC_VERB_SET_AMP_GAIN_MUTE,
  424. AMP_OUT_UNMUTE);
  425. }
  426. }
  427. return change;
  428. }
  429. #define ALC_PIN_MODE(xname, nid, dir) \
  430. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  431. .info = alc_pin_mode_info, \
  432. .get = alc_pin_mode_get, \
  433. .put = alc_pin_mode_put, \
  434. .private_value = nid | (dir<<16) }
  435. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  436. * together using a mask with more than one bit set. This control is
  437. * currently used only by the ALC260 test model. At this stage they are not
  438. * needed for any "production" models.
  439. */
  440. #ifdef CONFIG_SND_DEBUG
  441. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  442. struct snd_ctl_elem_info *uinfo)
  443. {
  444. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  445. uinfo->count = 1;
  446. uinfo->value.integer.min = 0;
  447. uinfo->value.integer.max = 1;
  448. return 0;
  449. }
  450. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  451. struct snd_ctl_elem_value *ucontrol)
  452. {
  453. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  454. hda_nid_t nid = kcontrol->private_value & 0xffff;
  455. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  456. long *valp = ucontrol->value.integer.value;
  457. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  458. AC_VERB_GET_GPIO_DATA, 0x00);
  459. *valp = (val & mask) != 0;
  460. return 0;
  461. }
  462. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  463. struct snd_ctl_elem_value *ucontrol)
  464. {
  465. signed int change;
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long val = *ucontrol->value.integer.value;
  470. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_GPIO_DATA,
  472. 0x00);
  473. /* Set/unset the masked GPIO bit(s) as needed */
  474. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  475. if (val == 0)
  476. gpio_data &= ~mask;
  477. else
  478. gpio_data |= mask;
  479. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  480. return change;
  481. }
  482. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  483. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  484. .info = alc_gpio_data_info, \
  485. .get = alc_gpio_data_get, \
  486. .put = alc_gpio_data_put, \
  487. .private_value = nid | (mask<<16) }
  488. #endif /* CONFIG_SND_DEBUG */
  489. /* A switch control to allow the enabling of the digital IO pins on the
  490. * ALC260. This is incredibly simplistic; the intention of this control is
  491. * to provide something in the test model allowing digital outputs to be
  492. * identified if present. If models are found which can utilise these
  493. * outputs a more complete mixer control can be devised for those models if
  494. * necessary.
  495. */
  496. #ifdef CONFIG_SND_DEBUG
  497. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  498. struct snd_ctl_elem_info *uinfo)
  499. {
  500. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  501. uinfo->count = 1;
  502. uinfo->value.integer.min = 0;
  503. uinfo->value.integer.max = 1;
  504. return 0;
  505. }
  506. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  507. struct snd_ctl_elem_value *ucontrol)
  508. {
  509. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  510. hda_nid_t nid = kcontrol->private_value & 0xffff;
  511. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  512. long *valp = ucontrol->value.integer.value;
  513. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  514. AC_VERB_GET_DIGI_CONVERT, 0x00);
  515. *valp = (val & mask) != 0;
  516. return 0;
  517. }
  518. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  519. struct snd_ctl_elem_value *ucontrol)
  520. {
  521. signed int change;
  522. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  523. hda_nid_t nid = kcontrol->private_value & 0xffff;
  524. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  525. long val = *ucontrol->value.integer.value;
  526. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  527. AC_VERB_GET_DIGI_CONVERT,
  528. 0x00);
  529. /* Set/unset the masked control bit(s) as needed */
  530. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  531. if (val==0)
  532. ctrl_data &= ~mask;
  533. else
  534. ctrl_data |= mask;
  535. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  536. ctrl_data);
  537. return change;
  538. }
  539. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  540. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  541. .info = alc_spdif_ctrl_info, \
  542. .get = alc_spdif_ctrl_get, \
  543. .put = alc_spdif_ctrl_put, \
  544. .private_value = nid | (mask<<16) }
  545. #endif /* CONFIG_SND_DEBUG */
  546. /*
  547. * set up from the preset table
  548. */
  549. static void setup_preset(struct alc_spec *spec,
  550. const struct alc_config_preset *preset)
  551. {
  552. int i;
  553. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  554. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  555. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  556. i++)
  557. spec->init_verbs[spec->num_init_verbs++] =
  558. preset->init_verbs[i];
  559. spec->channel_mode = preset->channel_mode;
  560. spec->num_channel_mode = preset->num_channel_mode;
  561. spec->need_dac_fix = preset->need_dac_fix;
  562. spec->multiout.max_channels = spec->channel_mode[0].channels;
  563. spec->multiout.num_dacs = preset->num_dacs;
  564. spec->multiout.dac_nids = preset->dac_nids;
  565. spec->multiout.dig_out_nid = preset->dig_out_nid;
  566. spec->multiout.hp_nid = preset->hp_nid;
  567. spec->num_mux_defs = preset->num_mux_defs;
  568. if (!spec->num_mux_defs)
  569. spec->num_mux_defs = 1;
  570. spec->input_mux = preset->input_mux;
  571. spec->num_adc_nids = preset->num_adc_nids;
  572. spec->adc_nids = preset->adc_nids;
  573. spec->dig_in_nid = preset->dig_in_nid;
  574. spec->unsol_event = preset->unsol_event;
  575. spec->init_hook = preset->init_hook;
  576. }
  577. /* Enable GPIO mask and set output */
  578. static struct hda_verb alc_gpio1_init_verbs[] = {
  579. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  582. { }
  583. };
  584. static struct hda_verb alc_gpio2_init_verbs[] = {
  585. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  588. { }
  589. };
  590. static struct hda_verb alc_gpio3_init_verbs[] = {
  591. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  594. { }
  595. };
  596. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  597. * 31 ~ 16 : Manufacture ID
  598. * 15 ~ 8 : SKU ID
  599. * 7 ~ 0 : Assembly ID
  600. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  601. */
  602. static void alc_subsystem_id(struct hda_codec *codec,
  603. unsigned int porta, unsigned int porte,
  604. unsigned int portd)
  605. {
  606. unsigned int ass, tmp;
  607. ass = codec->subsystem_id;
  608. if (!(ass & 1))
  609. return;
  610. /* Override */
  611. tmp = (ass & 0x38) >> 3; /* external Amp control */
  612. switch (tmp) {
  613. case 1:
  614. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  615. break;
  616. case 3:
  617. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  618. break;
  619. case 7:
  620. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  621. break;
  622. case 5:
  623. switch (codec->vendor_id) {
  624. case 0x10ec0862:
  625. case 0x10ec0660:
  626. case 0x10ec0662:
  627. case 0x10ec0267:
  628. case 0x10ec0268:
  629. snd_hda_codec_write(codec, 0x14, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. snd_hda_codec_write(codec, 0x15, 0,
  632. AC_VERB_SET_EAPD_BTLENABLE, 2);
  633. return;
  634. }
  635. case 6:
  636. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  637. hda_nid_t port = 0;
  638. tmp = (ass & 0x1800) >> 11;
  639. switch (tmp) {
  640. case 0: port = porta; break;
  641. case 1: port = porte; break;
  642. case 2: port = portd; break;
  643. }
  644. if (port)
  645. snd_hda_codec_write(codec, port, 0,
  646. AC_VERB_SET_EAPD_BTLENABLE,
  647. 2);
  648. }
  649. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  650. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  651. (tmp == 5 ? 0x3040 : 0x3050));
  652. break;
  653. }
  654. }
  655. /*
  656. * Fix-up pin default configurations
  657. */
  658. struct alc_pincfg {
  659. hda_nid_t nid;
  660. u32 val;
  661. };
  662. static void alc_fix_pincfg(struct hda_codec *codec,
  663. const struct snd_pci_quirk *quirk,
  664. const struct alc_pincfg **pinfix)
  665. {
  666. const struct alc_pincfg *cfg;
  667. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  668. if (!quirk)
  669. return;
  670. cfg = pinfix[quirk->value];
  671. for (; cfg->nid; cfg++) {
  672. int i;
  673. u32 val = cfg->val;
  674. for (i = 0; i < 4; i++) {
  675. snd_hda_codec_write(codec, cfg->nid, 0,
  676. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  677. val & 0xff);
  678. val >>= 8;
  679. }
  680. }
  681. }
  682. /*
  683. * ALC880 3-stack model
  684. *
  685. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  686. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  687. * F-Mic = 0x1b, HP = 0x19
  688. */
  689. static hda_nid_t alc880_dac_nids[4] = {
  690. /* front, rear, clfe, rear_surr */
  691. 0x02, 0x05, 0x04, 0x03
  692. };
  693. static hda_nid_t alc880_adc_nids[3] = {
  694. /* ADC0-2 */
  695. 0x07, 0x08, 0x09,
  696. };
  697. /* The datasheet says the node 0x07 is connected from inputs,
  698. * but it shows zero connection in the real implementation on some devices.
  699. * Note: this is a 915GAV bug, fixed on 915GLV
  700. */
  701. static hda_nid_t alc880_adc_nids_alt[2] = {
  702. /* ADC1-2 */
  703. 0x08, 0x09,
  704. };
  705. #define ALC880_DIGOUT_NID 0x06
  706. #define ALC880_DIGIN_NID 0x0a
  707. static struct hda_input_mux alc880_capture_source = {
  708. .num_items = 4,
  709. .items = {
  710. { "Mic", 0x0 },
  711. { "Front Mic", 0x3 },
  712. { "Line", 0x2 },
  713. { "CD", 0x4 },
  714. },
  715. };
  716. /* channel source setting (2/6 channel selection for 3-stack) */
  717. /* 2ch mode */
  718. static struct hda_verb alc880_threestack_ch2_init[] = {
  719. /* set line-in to input, mute it */
  720. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  721. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  722. /* set mic-in to input vref 80%, mute it */
  723. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  724. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  725. { } /* end */
  726. };
  727. /* 6ch mode */
  728. static struct hda_verb alc880_threestack_ch6_init[] = {
  729. /* set line-in to output, unmute it */
  730. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  731. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  732. /* set mic-in to output, unmute it */
  733. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  734. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  735. { } /* end */
  736. };
  737. static struct hda_channel_mode alc880_threestack_modes[2] = {
  738. { 2, alc880_threestack_ch2_init },
  739. { 6, alc880_threestack_ch6_init },
  740. };
  741. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  742. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  745. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  746. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  747. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  748. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  749. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  750. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  751. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  753. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  755. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  758. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  759. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  760. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  761. {
  762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  763. .name = "Channel Mode",
  764. .info = alc_ch_mode_info,
  765. .get = alc_ch_mode_get,
  766. .put = alc_ch_mode_put,
  767. },
  768. { } /* end */
  769. };
  770. /* capture mixer elements */
  771. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  772. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  776. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  777. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  778. {
  779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  780. /* The multiple "Capture Source" controls confuse alsamixer
  781. * So call somewhat different..
  782. * FIXME: the controls appear in the "playback" view!
  783. */
  784. /* .name = "Capture Source", */
  785. .name = "Input Source",
  786. .count = 3,
  787. .info = alc_mux_enum_info,
  788. .get = alc_mux_enum_get,
  789. .put = alc_mux_enum_put,
  790. },
  791. { } /* end */
  792. };
  793. /* capture mixer elements (in case NID 0x07 not available) */
  794. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  795. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  797. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  798. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  799. {
  800. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  801. /* The multiple "Capture Source" controls confuse alsamixer
  802. * So call somewhat different..
  803. * FIXME: the controls appear in the "playback" view!
  804. */
  805. /* .name = "Capture Source", */
  806. .name = "Input Source",
  807. .count = 2,
  808. .info = alc_mux_enum_info,
  809. .get = alc_mux_enum_get,
  810. .put = alc_mux_enum_put,
  811. },
  812. { } /* end */
  813. };
  814. /*
  815. * ALC880 5-stack model
  816. *
  817. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  818. * Side = 0x02 (0xd)
  819. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  820. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  821. */
  822. /* additional mixers to alc880_three_stack_mixer */
  823. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  824. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  825. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  826. { } /* end */
  827. };
  828. /* channel source setting (6/8 channel selection for 5-stack) */
  829. /* 6ch mode */
  830. static struct hda_verb alc880_fivestack_ch6_init[] = {
  831. /* set line-in to input, mute it */
  832. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  833. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  834. { } /* end */
  835. };
  836. /* 8ch mode */
  837. static struct hda_verb alc880_fivestack_ch8_init[] = {
  838. /* set line-in to output, unmute it */
  839. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  840. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  841. { } /* end */
  842. };
  843. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  844. { 6, alc880_fivestack_ch6_init },
  845. { 8, alc880_fivestack_ch8_init },
  846. };
  847. /*
  848. * ALC880 6-stack model
  849. *
  850. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  851. * Side = 0x05 (0x0f)
  852. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  853. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  854. */
  855. static hda_nid_t alc880_6st_dac_nids[4] = {
  856. /* front, rear, clfe, rear_surr */
  857. 0x02, 0x03, 0x04, 0x05
  858. };
  859. static struct hda_input_mux alc880_6stack_capture_source = {
  860. .num_items = 4,
  861. .items = {
  862. { "Mic", 0x0 },
  863. { "Front Mic", 0x1 },
  864. { "Line", 0x2 },
  865. { "CD", 0x4 },
  866. },
  867. };
  868. /* fixed 8-channels */
  869. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  870. { 8, NULL },
  871. };
  872. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  873. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  877. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  878. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  879. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  880. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  882. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  883. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  884. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  886. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  888. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  890. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  891. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  892. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  893. {
  894. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  895. .name = "Channel Mode",
  896. .info = alc_ch_mode_info,
  897. .get = alc_ch_mode_get,
  898. .put = alc_ch_mode_put,
  899. },
  900. { } /* end */
  901. };
  902. /*
  903. * ALC880 W810 model
  904. *
  905. * W810 has rear IO for:
  906. * Front (DAC 02)
  907. * Surround (DAC 03)
  908. * Center/LFE (DAC 04)
  909. * Digital out (06)
  910. *
  911. * The system also has a pair of internal speakers, and a headphone jack.
  912. * These are both connected to Line2 on the codec, hence to DAC 02.
  913. *
  914. * There is a variable resistor to control the speaker or headphone
  915. * volume. This is a hardware-only device without a software API.
  916. *
  917. * Plugging headphones in will disable the internal speakers. This is
  918. * implemented in hardware, not via the driver using jack sense. In
  919. * a similar fashion, plugging into the rear socket marked "front" will
  920. * disable both the speakers and headphones.
  921. *
  922. * For input, there's a microphone jack, and an "audio in" jack.
  923. * These may not do anything useful with this driver yet, because I
  924. * haven't setup any initialization verbs for these yet...
  925. */
  926. static hda_nid_t alc880_w810_dac_nids[3] = {
  927. /* front, rear/surround, clfe */
  928. 0x02, 0x03, 0x04
  929. };
  930. /* fixed 6 channels */
  931. static struct hda_channel_mode alc880_w810_modes[1] = {
  932. { 6, NULL }
  933. };
  934. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  935. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  936. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  939. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  940. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  941. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  942. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  943. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  944. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  945. { } /* end */
  946. };
  947. /*
  948. * Z710V model
  949. *
  950. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  951. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  952. * Line = 0x1a
  953. */
  954. static hda_nid_t alc880_z71v_dac_nids[1] = {
  955. 0x02
  956. };
  957. #define ALC880_Z71V_HP_DAC 0x03
  958. /* fixed 2 channels */
  959. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  960. { 2, NULL }
  961. };
  962. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  963. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  966. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  967. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  968. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  969. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  970. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  971. { } /* end */
  972. };
  973. /* FIXME! */
  974. /*
  975. * ALC880 F1734 model
  976. *
  977. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  978. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  979. */
  980. static hda_nid_t alc880_f1734_dac_nids[1] = {
  981. 0x03
  982. };
  983. #define ALC880_F1734_HP_DAC 0x02
  984. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  985. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  988. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  989. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  990. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  991. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  992. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  993. { } /* end */
  994. };
  995. /* FIXME! */
  996. /*
  997. * ALC880 ASUS model
  998. *
  999. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1000. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1001. * Mic = 0x18, Line = 0x1a
  1002. */
  1003. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1004. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1005. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1006. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1011. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1013. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1015. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1019. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1020. {
  1021. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1022. .name = "Channel Mode",
  1023. .info = alc_ch_mode_info,
  1024. .get = alc_ch_mode_get,
  1025. .put = alc_ch_mode_put,
  1026. },
  1027. { } /* end */
  1028. };
  1029. /* FIXME! */
  1030. /*
  1031. * ALC880 ASUS W1V model
  1032. *
  1033. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1034. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1035. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1036. */
  1037. /* additional mixers to alc880_asus_mixer */
  1038. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1039. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1040. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1041. { } /* end */
  1042. };
  1043. /* additional mixers to alc880_asus_mixer */
  1044. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1045. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1046. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1047. { } /* end */
  1048. };
  1049. /* TCL S700 */
  1050. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1051. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1054. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1055. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1059. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1060. {
  1061. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1062. /* The multiple "Capture Source" controls confuse alsamixer
  1063. * So call somewhat different..
  1064. * FIXME: the controls appear in the "playback" view!
  1065. */
  1066. /* .name = "Capture Source", */
  1067. .name = "Input Source",
  1068. .count = 1,
  1069. .info = alc_mux_enum_info,
  1070. .get = alc_mux_enum_get,
  1071. .put = alc_mux_enum_put,
  1072. },
  1073. { } /* end */
  1074. };
  1075. /* Uniwill */
  1076. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1077. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1080. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1081. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1082. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1083. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1084. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1086. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1092. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1093. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1094. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1095. {
  1096. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1097. .name = "Channel Mode",
  1098. .info = alc_ch_mode_info,
  1099. .get = alc_ch_mode_get,
  1100. .put = alc_ch_mode_put,
  1101. },
  1102. { } /* end */
  1103. };
  1104. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1105. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1108. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1110. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1113. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1114. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1115. { } /* end */
  1116. };
  1117. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1118. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1121. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1122. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1123. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1124. { } /* end */
  1125. };
  1126. /*
  1127. * build control elements
  1128. */
  1129. static int alc_build_controls(struct hda_codec *codec)
  1130. {
  1131. struct alc_spec *spec = codec->spec;
  1132. int err;
  1133. int i;
  1134. for (i = 0; i < spec->num_mixers; i++) {
  1135. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1136. if (err < 0)
  1137. return err;
  1138. }
  1139. if (spec->multiout.dig_out_nid) {
  1140. err = snd_hda_create_spdif_out_ctls(codec,
  1141. spec->multiout.dig_out_nid);
  1142. if (err < 0)
  1143. return err;
  1144. }
  1145. if (spec->dig_in_nid) {
  1146. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1147. if (err < 0)
  1148. return err;
  1149. }
  1150. return 0;
  1151. }
  1152. /*
  1153. * initialize the codec volumes, etc
  1154. */
  1155. /*
  1156. * generic initialization of ADC, input mixers and output mixers
  1157. */
  1158. static struct hda_verb alc880_volume_init_verbs[] = {
  1159. /*
  1160. * Unmute ADC0-2 and set the default input to mic-in
  1161. */
  1162. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1167. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1168. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1169. * mixer widget
  1170. * Note: PASD motherboards uses the Line In 2 as the input for front
  1171. * panel mic (mic 2)
  1172. */
  1173. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1179. /*
  1180. * Set up output mixers (0x0c - 0x0f)
  1181. */
  1182. /* set vol=0 to output mixers */
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. /* set up input amps for analog loopback */
  1188. /* Amp Indices: DAC = 0, mixer = 1 */
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. { }
  1198. };
  1199. /*
  1200. * 3-stack pin configuration:
  1201. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1202. */
  1203. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1204. /*
  1205. * preset connection lists of input pins
  1206. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1207. */
  1208. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1209. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1210. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1211. /*
  1212. * Set pin mode and muting
  1213. */
  1214. /* set front pin widgets 0x14 for output */
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1218. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1220. /* Mic2 (as headphone out) for HP output */
  1221. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1223. /* Line In pin widget for input */
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1227. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. /* CD pin widget for input */
  1230. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1231. { }
  1232. };
  1233. /*
  1234. * 5-stack pin configuration:
  1235. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1236. * line-in/side = 0x1a, f-mic = 0x1b
  1237. */
  1238. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1239. /*
  1240. * preset connection lists of input pins
  1241. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1242. */
  1243. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1244. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1245. /*
  1246. * Set pin mode and muting
  1247. */
  1248. /* set pin widgets 0x14-0x17 for output */
  1249. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. /* unmute pins for output (no gain on this amp) */
  1254. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. /* Mic2 (as headphone out) for HP output */
  1262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1264. /* Line In pin widget for input */
  1265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1267. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1270. /* CD pin widget for input */
  1271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. { }
  1273. };
  1274. /*
  1275. * W810 pin configuration:
  1276. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1277. */
  1278. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1279. /* hphone/speaker input selector: front DAC */
  1280. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1281. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. { }
  1290. };
  1291. /*
  1292. * Z71V pin configuration:
  1293. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1294. */
  1295. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1296. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1299. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. { }
  1305. };
  1306. /*
  1307. * 6-stack pin configuration:
  1308. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1309. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1310. */
  1311. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1312. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1326. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1330. { }
  1331. };
  1332. /*
  1333. * Uniwill pin configuration:
  1334. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1335. * line = 0x1a
  1336. */
  1337. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1338. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1339. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1346. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1360. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1361. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1363. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1364. { }
  1365. };
  1366. /*
  1367. * Uniwill P53
  1368. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1369. */
  1370. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1371. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1391. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1392. { }
  1393. };
  1394. static struct hda_verb alc880_beep_init_verbs[] = {
  1395. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1396. { }
  1397. };
  1398. /* toggle speaker-output according to the hp-jack state */
  1399. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1400. {
  1401. unsigned int present;
  1402. unsigned char bits;
  1403. present = snd_hda_codec_read(codec, 0x14, 0,
  1404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1405. bits = present ? 0x80 : 0;
  1406. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1407. 0x80, bits);
  1408. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1409. 0x80, bits);
  1410. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1411. 0x80, bits);
  1412. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1413. 0x80, bits);
  1414. }
  1415. /* auto-toggle front mic */
  1416. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1417. {
  1418. unsigned int present;
  1419. unsigned char bits;
  1420. present = snd_hda_codec_read(codec, 0x18, 0,
  1421. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1422. bits = present ? 0x80 : 0;
  1423. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1424. 0x80, bits);
  1425. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1426. 0x80, bits);
  1427. }
  1428. static void alc880_uniwill_automute(struct hda_codec *codec)
  1429. {
  1430. alc880_uniwill_hp_automute(codec);
  1431. alc880_uniwill_mic_automute(codec);
  1432. }
  1433. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1434. unsigned int res)
  1435. {
  1436. /* Looks like the unsol event is incompatible with the standard
  1437. * definition. 4bit tag is placed at 28 bit!
  1438. */
  1439. switch (res >> 28) {
  1440. case ALC880_HP_EVENT:
  1441. alc880_uniwill_hp_automute(codec);
  1442. break;
  1443. case ALC880_MIC_EVENT:
  1444. alc880_uniwill_mic_automute(codec);
  1445. break;
  1446. }
  1447. }
  1448. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1449. {
  1450. unsigned int present;
  1451. unsigned char bits;
  1452. present = snd_hda_codec_read(codec, 0x14, 0,
  1453. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1454. bits = present ? 0x80 : 0;
  1455. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1456. 0x80, bits);
  1457. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1458. 0x80, bits);
  1459. }
  1460. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1461. {
  1462. unsigned int present;
  1463. present = snd_hda_codec_read(codec, 0x21, 0,
  1464. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1465. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1466. 0x7f, present);
  1467. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1468. 0x7f, present);
  1469. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1470. 0x7f, present);
  1471. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1472. 0x7f, present);
  1473. }
  1474. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1475. unsigned int res)
  1476. {
  1477. /* Looks like the unsol event is incompatible with the standard
  1478. * definition. 4bit tag is placed at 28 bit!
  1479. */
  1480. if ((res >> 28) == ALC880_HP_EVENT)
  1481. alc880_uniwill_p53_hp_automute(codec);
  1482. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1483. alc880_uniwill_p53_dcvol_automute(codec);
  1484. }
  1485. /* FIXME! */
  1486. /*
  1487. * F1734 pin configuration:
  1488. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1489. */
  1490. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1491. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1492. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1493. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1494. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1498. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1499. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1500. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1501. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1502. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1503. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1504. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1505. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1506. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1508. { }
  1509. };
  1510. /* FIXME! */
  1511. /*
  1512. * ASUS pin configuration:
  1513. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1514. */
  1515. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1516. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1517. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1518. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1519. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1523. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1526. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1527. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1529. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1530. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1531. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1532. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1533. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1534. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1535. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1537. { }
  1538. };
  1539. /* Enable GPIO mask and set output */
  1540. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1541. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1542. /* Clevo m520g init */
  1543. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1544. /* headphone output */
  1545. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1546. /* line-out */
  1547. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1548. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* Line-in */
  1550. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1551. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1552. /* CD */
  1553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1554. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1555. /* Mic1 (rear panel) */
  1556. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1557. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1558. /* Mic2 (front panel) */
  1559. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1560. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1561. /* headphone */
  1562. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1563. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1564. /* change to EAPD mode */
  1565. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1566. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1567. { }
  1568. };
  1569. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1570. /* change to EAPD mode */
  1571. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1572. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1573. /* Headphone output */
  1574. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1575. /* Front output*/
  1576. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1577. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1578. /* Line In pin widget for input */
  1579. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1580. /* CD pin widget for input */
  1581. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1582. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1583. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1584. /* change to EAPD mode */
  1585. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1586. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1587. { }
  1588. };
  1589. /*
  1590. * LG m1 express dual
  1591. *
  1592. * Pin assignment:
  1593. * Rear Line-In/Out (blue): 0x14
  1594. * Build-in Mic-In: 0x15
  1595. * Speaker-out: 0x17
  1596. * HP-Out (green): 0x1b
  1597. * Mic-In/Out (red): 0x19
  1598. * SPDIF-Out: 0x1e
  1599. */
  1600. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1601. static hda_nid_t alc880_lg_dac_nids[3] = {
  1602. 0x05, 0x02, 0x03
  1603. };
  1604. /* seems analog CD is not working */
  1605. static struct hda_input_mux alc880_lg_capture_source = {
  1606. .num_items = 3,
  1607. .items = {
  1608. { "Mic", 0x1 },
  1609. { "Line", 0x5 },
  1610. { "Internal Mic", 0x6 },
  1611. },
  1612. };
  1613. /* 2,4,6 channel modes */
  1614. static struct hda_verb alc880_lg_ch2_init[] = {
  1615. /* set line-in and mic-in to input */
  1616. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1617. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1618. { }
  1619. };
  1620. static struct hda_verb alc880_lg_ch4_init[] = {
  1621. /* set line-in to out and mic-in to input */
  1622. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1623. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1624. { }
  1625. };
  1626. static struct hda_verb alc880_lg_ch6_init[] = {
  1627. /* set line-in and mic-in to output */
  1628. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1629. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1630. { }
  1631. };
  1632. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1633. { 2, alc880_lg_ch2_init },
  1634. { 4, alc880_lg_ch4_init },
  1635. { 6, alc880_lg_ch6_init },
  1636. };
  1637. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1638. /* FIXME: it's not really "master" but front channels */
  1639. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1640. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1641. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1642. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1643. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1644. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1645. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1646. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1647. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1648. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1649. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1650. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1651. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1652. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1653. {
  1654. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1655. .name = "Channel Mode",
  1656. .info = alc_ch_mode_info,
  1657. .get = alc_ch_mode_get,
  1658. .put = alc_ch_mode_put,
  1659. },
  1660. { } /* end */
  1661. };
  1662. static struct hda_verb alc880_lg_init_verbs[] = {
  1663. /* set capture source to mic-in */
  1664. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1665. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1666. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1667. /* mute all amp mixer inputs */
  1668. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1669. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1670. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1671. /* line-in to input */
  1672. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1673. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* built-in mic */
  1675. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1676. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1677. /* speaker-out */
  1678. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1679. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1680. /* mic-in to input */
  1681. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1682. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1683. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1684. /* HP-out */
  1685. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1686. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1687. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1688. /* jack sense */
  1689. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1690. { }
  1691. };
  1692. /* toggle speaker-output according to the hp-jack state */
  1693. static void alc880_lg_automute(struct hda_codec *codec)
  1694. {
  1695. unsigned int present;
  1696. unsigned char bits;
  1697. present = snd_hda_codec_read(codec, 0x1b, 0,
  1698. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1699. bits = present ? 0x80 : 0;
  1700. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1701. 0x80, bits);
  1702. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1703. 0x80, bits);
  1704. }
  1705. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1706. {
  1707. /* Looks like the unsol event is incompatible with the standard
  1708. * definition. 4bit tag is placed at 28 bit!
  1709. */
  1710. if ((res >> 28) == 0x01)
  1711. alc880_lg_automute(codec);
  1712. }
  1713. /*
  1714. * LG LW20
  1715. *
  1716. * Pin assignment:
  1717. * Speaker-out: 0x14
  1718. * Mic-In: 0x18
  1719. * Built-in Mic-In: 0x19
  1720. * Line-In: 0x1b
  1721. * HP-Out: 0x1a
  1722. * SPDIF-Out: 0x1e
  1723. */
  1724. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1725. .num_items = 3,
  1726. .items = {
  1727. { "Mic", 0x0 },
  1728. { "Internal Mic", 0x1 },
  1729. { "Line In", 0x2 },
  1730. },
  1731. };
  1732. #define alc880_lg_lw_modes alc880_threestack_modes
  1733. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1734. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1735. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1736. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1737. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1738. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1739. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1740. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1741. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1742. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1743. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1744. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1745. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1746. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1747. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1748. {
  1749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1750. .name = "Channel Mode",
  1751. .info = alc_ch_mode_info,
  1752. .get = alc_ch_mode_get,
  1753. .put = alc_ch_mode_put,
  1754. },
  1755. { } /* end */
  1756. };
  1757. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1758. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1759. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1760. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1761. /* set capture source to mic-in */
  1762. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1763. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1764. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1765. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1766. /* speaker-out */
  1767. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1768. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1769. /* HP-out */
  1770. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1771. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1772. /* mic-in to input */
  1773. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1774. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1775. /* built-in mic */
  1776. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1777. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1778. /* jack sense */
  1779. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1780. { }
  1781. };
  1782. /* toggle speaker-output according to the hp-jack state */
  1783. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1784. {
  1785. unsigned int present;
  1786. unsigned char bits;
  1787. present = snd_hda_codec_read(codec, 0x1b, 0,
  1788. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1789. bits = present ? 0x80 : 0;
  1790. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1791. 0x80, bits);
  1792. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1793. 0x80, bits);
  1794. }
  1795. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1796. {
  1797. /* Looks like the unsol event is incompatible with the standard
  1798. * definition. 4bit tag is placed at 28 bit!
  1799. */
  1800. if ((res >> 28) == 0x01)
  1801. alc880_lg_lw_automute(codec);
  1802. }
  1803. /*
  1804. * Common callbacks
  1805. */
  1806. static int alc_init(struct hda_codec *codec)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. unsigned int i;
  1810. for (i = 0; i < spec->num_init_verbs; i++)
  1811. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1812. if (spec->init_hook)
  1813. spec->init_hook(codec);
  1814. return 0;
  1815. }
  1816. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. if (spec->unsol_event)
  1820. spec->unsol_event(codec, res);
  1821. }
  1822. #ifdef CONFIG_PM
  1823. /*
  1824. * resume
  1825. */
  1826. static int alc_resume(struct hda_codec *codec)
  1827. {
  1828. struct alc_spec *spec = codec->spec;
  1829. int i;
  1830. alc_init(codec);
  1831. for (i = 0; i < spec->num_mixers; i++)
  1832. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1833. if (spec->multiout.dig_out_nid)
  1834. snd_hda_resume_spdif_out(codec);
  1835. if (spec->dig_in_nid)
  1836. snd_hda_resume_spdif_in(codec);
  1837. return 0;
  1838. }
  1839. #endif
  1840. /*
  1841. * Analog playback callbacks
  1842. */
  1843. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1844. struct hda_codec *codec,
  1845. struct snd_pcm_substream *substream)
  1846. {
  1847. struct alc_spec *spec = codec->spec;
  1848. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1849. }
  1850. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1851. struct hda_codec *codec,
  1852. unsigned int stream_tag,
  1853. unsigned int format,
  1854. struct snd_pcm_substream *substream)
  1855. {
  1856. struct alc_spec *spec = codec->spec;
  1857. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1858. stream_tag, format, substream);
  1859. }
  1860. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1861. struct hda_codec *codec,
  1862. struct snd_pcm_substream *substream)
  1863. {
  1864. struct alc_spec *spec = codec->spec;
  1865. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1866. }
  1867. /*
  1868. * Digital out
  1869. */
  1870. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1871. struct hda_codec *codec,
  1872. struct snd_pcm_substream *substream)
  1873. {
  1874. struct alc_spec *spec = codec->spec;
  1875. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1876. }
  1877. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1878. struct hda_codec *codec,
  1879. unsigned int stream_tag,
  1880. unsigned int format,
  1881. struct snd_pcm_substream *substream)
  1882. {
  1883. struct alc_spec *spec = codec->spec;
  1884. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1885. stream_tag, format, substream);
  1886. }
  1887. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1888. struct hda_codec *codec,
  1889. struct snd_pcm_substream *substream)
  1890. {
  1891. struct alc_spec *spec = codec->spec;
  1892. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1893. }
  1894. /*
  1895. * Analog capture
  1896. */
  1897. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1898. struct hda_codec *codec,
  1899. unsigned int stream_tag,
  1900. unsigned int format,
  1901. struct snd_pcm_substream *substream)
  1902. {
  1903. struct alc_spec *spec = codec->spec;
  1904. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1905. stream_tag, 0, format);
  1906. return 0;
  1907. }
  1908. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1909. struct hda_codec *codec,
  1910. struct snd_pcm_substream *substream)
  1911. {
  1912. struct alc_spec *spec = codec->spec;
  1913. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1914. 0, 0, 0);
  1915. return 0;
  1916. }
  1917. /*
  1918. */
  1919. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1920. .substreams = 1,
  1921. .channels_min = 2,
  1922. .channels_max = 8,
  1923. /* NID is set in alc_build_pcms */
  1924. .ops = {
  1925. .open = alc880_playback_pcm_open,
  1926. .prepare = alc880_playback_pcm_prepare,
  1927. .cleanup = alc880_playback_pcm_cleanup
  1928. },
  1929. };
  1930. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1931. .substreams = 2,
  1932. .channels_min = 2,
  1933. .channels_max = 2,
  1934. /* NID is set in alc_build_pcms */
  1935. .ops = {
  1936. .prepare = alc880_capture_pcm_prepare,
  1937. .cleanup = alc880_capture_pcm_cleanup
  1938. },
  1939. };
  1940. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1941. .substreams = 1,
  1942. .channels_min = 2,
  1943. .channels_max = 2,
  1944. /* NID is set in alc_build_pcms */
  1945. .ops = {
  1946. .open = alc880_dig_playback_pcm_open,
  1947. .close = alc880_dig_playback_pcm_close,
  1948. .prepare = alc880_dig_playback_pcm_prepare
  1949. },
  1950. };
  1951. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1952. .substreams = 1,
  1953. .channels_min = 2,
  1954. .channels_max = 2,
  1955. /* NID is set in alc_build_pcms */
  1956. };
  1957. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1958. static struct hda_pcm_stream alc_pcm_null_playback = {
  1959. .substreams = 0,
  1960. .channels_min = 0,
  1961. .channels_max = 0,
  1962. };
  1963. static int alc_build_pcms(struct hda_codec *codec)
  1964. {
  1965. struct alc_spec *spec = codec->spec;
  1966. struct hda_pcm *info = spec->pcm_rec;
  1967. int i;
  1968. codec->num_pcms = 1;
  1969. codec->pcm_info = info;
  1970. info->name = spec->stream_name_analog;
  1971. if (spec->stream_analog_playback) {
  1972. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1974. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1975. }
  1976. if (spec->stream_analog_capture) {
  1977. snd_assert(spec->adc_nids, return -EINVAL);
  1978. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1979. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1980. }
  1981. if (spec->channel_mode) {
  1982. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1983. for (i = 0; i < spec->num_channel_mode; i++) {
  1984. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1986. }
  1987. }
  1988. }
  1989. /* SPDIF for stream index #1 */
  1990. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1991. codec->num_pcms = 2;
  1992. info = spec->pcm_rec + 1;
  1993. info->name = spec->stream_name_digital;
  1994. if (spec->multiout.dig_out_nid &&
  1995. spec->stream_digital_playback) {
  1996. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1997. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1998. }
  1999. if (spec->dig_in_nid &&
  2000. spec->stream_digital_capture) {
  2001. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2002. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2003. }
  2004. }
  2005. /* If the use of more than one ADC is requested for the current
  2006. * model, configure a second analog capture-only PCM.
  2007. */
  2008. /* Additional Analaog capture for index #2 */
  2009. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2010. spec->adc_nids) {
  2011. codec->num_pcms = 3;
  2012. info = spec->pcm_rec + 2;
  2013. info->name = spec->stream_name_analog;
  2014. /* No playback stream for second PCM */
  2015. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2016. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2017. if (spec->stream_analog_capture) {
  2018. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2019. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2020. }
  2021. }
  2022. return 0;
  2023. }
  2024. static void alc_free(struct hda_codec *codec)
  2025. {
  2026. struct alc_spec *spec = codec->spec;
  2027. unsigned int i;
  2028. if (!spec)
  2029. return;
  2030. if (spec->kctl_alloc) {
  2031. for (i = 0; i < spec->num_kctl_used; i++)
  2032. kfree(spec->kctl_alloc[i].name);
  2033. kfree(spec->kctl_alloc);
  2034. }
  2035. kfree(spec);
  2036. }
  2037. /*
  2038. */
  2039. static struct hda_codec_ops alc_patch_ops = {
  2040. .build_controls = alc_build_controls,
  2041. .build_pcms = alc_build_pcms,
  2042. .init = alc_init,
  2043. .free = alc_free,
  2044. .unsol_event = alc_unsol_event,
  2045. #ifdef CONFIG_PM
  2046. .resume = alc_resume,
  2047. #endif
  2048. };
  2049. /*
  2050. * Test configuration for debugging
  2051. *
  2052. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2053. * enum controls.
  2054. */
  2055. #ifdef CONFIG_SND_DEBUG
  2056. static hda_nid_t alc880_test_dac_nids[4] = {
  2057. 0x02, 0x03, 0x04, 0x05
  2058. };
  2059. static struct hda_input_mux alc880_test_capture_source = {
  2060. .num_items = 7,
  2061. .items = {
  2062. { "In-1", 0x0 },
  2063. { "In-2", 0x1 },
  2064. { "In-3", 0x2 },
  2065. { "In-4", 0x3 },
  2066. { "CD", 0x4 },
  2067. { "Front", 0x5 },
  2068. { "Surround", 0x6 },
  2069. },
  2070. };
  2071. static struct hda_channel_mode alc880_test_modes[4] = {
  2072. { 2, NULL },
  2073. { 4, NULL },
  2074. { 6, NULL },
  2075. { 8, NULL },
  2076. };
  2077. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2078. struct snd_ctl_elem_info *uinfo)
  2079. {
  2080. static char *texts[] = {
  2081. "N/A", "Line Out", "HP Out",
  2082. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2083. };
  2084. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2085. uinfo->count = 1;
  2086. uinfo->value.enumerated.items = 8;
  2087. if (uinfo->value.enumerated.item >= 8)
  2088. uinfo->value.enumerated.item = 7;
  2089. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2090. return 0;
  2091. }
  2092. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2093. struct snd_ctl_elem_value *ucontrol)
  2094. {
  2095. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2096. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2097. unsigned int pin_ctl, item = 0;
  2098. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2099. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2100. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2101. if (pin_ctl & AC_PINCTL_HP_EN)
  2102. item = 2;
  2103. else
  2104. item = 1;
  2105. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2106. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2107. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2108. case AC_PINCTL_VREF_50: item = 4; break;
  2109. case AC_PINCTL_VREF_GRD: item = 5; break;
  2110. case AC_PINCTL_VREF_80: item = 6; break;
  2111. case AC_PINCTL_VREF_100: item = 7; break;
  2112. }
  2113. }
  2114. ucontrol->value.enumerated.item[0] = item;
  2115. return 0;
  2116. }
  2117. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2118. struct snd_ctl_elem_value *ucontrol)
  2119. {
  2120. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2121. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2122. static unsigned int ctls[] = {
  2123. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2124. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2125. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2126. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2127. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2128. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2129. };
  2130. unsigned int old_ctl, new_ctl;
  2131. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2132. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2133. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2134. if (old_ctl != new_ctl) {
  2135. snd_hda_codec_write(codec, nid, 0,
  2136. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2137. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2138. (ucontrol->value.enumerated.item[0] >= 3 ?
  2139. 0xb080 : 0xb000));
  2140. return 1;
  2141. }
  2142. return 0;
  2143. }
  2144. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2145. struct snd_ctl_elem_info *uinfo)
  2146. {
  2147. static char *texts[] = {
  2148. "Front", "Surround", "CLFE", "Side"
  2149. };
  2150. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2151. uinfo->count = 1;
  2152. uinfo->value.enumerated.items = 4;
  2153. if (uinfo->value.enumerated.item >= 4)
  2154. uinfo->value.enumerated.item = 3;
  2155. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2156. return 0;
  2157. }
  2158. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2162. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2163. unsigned int sel;
  2164. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2165. ucontrol->value.enumerated.item[0] = sel & 3;
  2166. return 0;
  2167. }
  2168. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2169. struct snd_ctl_elem_value *ucontrol)
  2170. {
  2171. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2172. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2173. unsigned int sel;
  2174. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2175. if (ucontrol->value.enumerated.item[0] != sel) {
  2176. sel = ucontrol->value.enumerated.item[0] & 3;
  2177. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2178. return 1;
  2179. }
  2180. return 0;
  2181. }
  2182. #define PIN_CTL_TEST(xname,nid) { \
  2183. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2184. .name = xname, \
  2185. .info = alc_test_pin_ctl_info, \
  2186. .get = alc_test_pin_ctl_get, \
  2187. .put = alc_test_pin_ctl_put, \
  2188. .private_value = nid \
  2189. }
  2190. #define PIN_SRC_TEST(xname,nid) { \
  2191. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2192. .name = xname, \
  2193. .info = alc_test_pin_src_info, \
  2194. .get = alc_test_pin_src_get, \
  2195. .put = alc_test_pin_src_put, \
  2196. .private_value = nid \
  2197. }
  2198. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2199. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2200. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2201. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2202. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2203. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2204. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2205. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2206. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2207. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2208. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2209. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2210. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2211. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2212. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2213. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2214. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2215. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2216. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2217. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2218. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2219. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2220. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2221. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2222. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2223. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2224. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2225. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2226. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2227. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2228. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2229. {
  2230. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2231. .name = "Channel Mode",
  2232. .info = alc_ch_mode_info,
  2233. .get = alc_ch_mode_get,
  2234. .put = alc_ch_mode_put,
  2235. },
  2236. { } /* end */
  2237. };
  2238. static struct hda_verb alc880_test_init_verbs[] = {
  2239. /* Unmute inputs of 0x0c - 0x0f */
  2240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2247. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2248. /* Vol output for 0x0c-0x0f */
  2249. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2250. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2251. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2253. /* Set output pins 0x14-0x17 */
  2254. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2255. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2257. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2258. /* Unmute output pins 0x14-0x17 */
  2259. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2260. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2262. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2263. /* Set input pins 0x18-0x1c */
  2264. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2265. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2266. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2267. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2268. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2269. /* Mute input pins 0x18-0x1b */
  2270. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2271. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2272. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2273. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2274. /* ADC set up */
  2275. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2276. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2277. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2278. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2279. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2280. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2281. /* Analog input/passthru */
  2282. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2283. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2284. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2286. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2287. { }
  2288. };
  2289. #endif
  2290. /*
  2291. */
  2292. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2293. [ALC880_3ST] = "3stack",
  2294. [ALC880_TCL_S700] = "tcl",
  2295. [ALC880_3ST_DIG] = "3stack-digout",
  2296. [ALC880_CLEVO] = "clevo",
  2297. [ALC880_5ST] = "5stack",
  2298. [ALC880_5ST_DIG] = "5stack-digout",
  2299. [ALC880_W810] = "w810",
  2300. [ALC880_Z71V] = "z71v",
  2301. [ALC880_6ST] = "6stack",
  2302. [ALC880_6ST_DIG] = "6stack-digout",
  2303. [ALC880_ASUS] = "asus",
  2304. [ALC880_ASUS_W1V] = "asus-w1v",
  2305. [ALC880_ASUS_DIG] = "asus-dig",
  2306. [ALC880_ASUS_DIG2] = "asus-dig2",
  2307. [ALC880_UNIWILL_DIG] = "uniwill",
  2308. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2309. [ALC880_FUJITSU] = "fujitsu",
  2310. [ALC880_F1734] = "F1734",
  2311. [ALC880_LG] = "lg",
  2312. [ALC880_LG_LW] = "lg-lw",
  2313. #ifdef CONFIG_SND_DEBUG
  2314. [ALC880_TEST] = "test",
  2315. #endif
  2316. [ALC880_AUTO] = "auto",
  2317. };
  2318. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2319. /* Broken BIOS configuration */
  2320. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2323. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2324. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2325. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2326. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2327. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2328. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2329. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2331. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2332. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2333. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2334. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2339. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2340. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2341. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2342. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2343. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2344. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2345. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2346. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2347. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2348. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2349. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2350. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2351. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2352. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2353. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2354. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2355. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2356. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2357. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2358. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2359. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2360. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2361. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2362. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2363. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2364. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2365. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2366. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2367. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2368. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2369. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2370. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2371. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2372. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2373. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2374. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2375. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2376. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2377. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2378. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2382. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2383. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2384. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2385. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2386. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2387. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2388. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2389. {}
  2390. };
  2391. /*
  2392. * ALC880 codec presets
  2393. */
  2394. static struct alc_config_preset alc880_presets[] = {
  2395. [ALC880_3ST] = {
  2396. .mixers = { alc880_three_stack_mixer },
  2397. .init_verbs = { alc880_volume_init_verbs,
  2398. alc880_pin_3stack_init_verbs },
  2399. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2400. .dac_nids = alc880_dac_nids,
  2401. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2402. .channel_mode = alc880_threestack_modes,
  2403. .need_dac_fix = 1,
  2404. .input_mux = &alc880_capture_source,
  2405. },
  2406. [ALC880_3ST_DIG] = {
  2407. .mixers = { alc880_three_stack_mixer },
  2408. .init_verbs = { alc880_volume_init_verbs,
  2409. alc880_pin_3stack_init_verbs },
  2410. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2411. .dac_nids = alc880_dac_nids,
  2412. .dig_out_nid = ALC880_DIGOUT_NID,
  2413. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2414. .channel_mode = alc880_threestack_modes,
  2415. .need_dac_fix = 1,
  2416. .input_mux = &alc880_capture_source,
  2417. },
  2418. [ALC880_TCL_S700] = {
  2419. .mixers = { alc880_tcl_s700_mixer },
  2420. .init_verbs = { alc880_volume_init_verbs,
  2421. alc880_pin_tcl_S700_init_verbs,
  2422. alc880_gpio2_init_verbs },
  2423. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2424. .dac_nids = alc880_dac_nids,
  2425. .hp_nid = 0x03,
  2426. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2427. .channel_mode = alc880_2_jack_modes,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_5ST] = {
  2431. .mixers = { alc880_three_stack_mixer,
  2432. alc880_five_stack_mixer},
  2433. .init_verbs = { alc880_volume_init_verbs,
  2434. alc880_pin_5stack_init_verbs },
  2435. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2436. .dac_nids = alc880_dac_nids,
  2437. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2438. .channel_mode = alc880_fivestack_modes,
  2439. .input_mux = &alc880_capture_source,
  2440. },
  2441. [ALC880_5ST_DIG] = {
  2442. .mixers = { alc880_three_stack_mixer,
  2443. alc880_five_stack_mixer },
  2444. .init_verbs = { alc880_volume_init_verbs,
  2445. alc880_pin_5stack_init_verbs },
  2446. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2447. .dac_nids = alc880_dac_nids,
  2448. .dig_out_nid = ALC880_DIGOUT_NID,
  2449. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2450. .channel_mode = alc880_fivestack_modes,
  2451. .input_mux = &alc880_capture_source,
  2452. },
  2453. [ALC880_6ST] = {
  2454. .mixers = { alc880_six_stack_mixer },
  2455. .init_verbs = { alc880_volume_init_verbs,
  2456. alc880_pin_6stack_init_verbs },
  2457. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2458. .dac_nids = alc880_6st_dac_nids,
  2459. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2460. .channel_mode = alc880_sixstack_modes,
  2461. .input_mux = &alc880_6stack_capture_source,
  2462. },
  2463. [ALC880_6ST_DIG] = {
  2464. .mixers = { alc880_six_stack_mixer },
  2465. .init_verbs = { alc880_volume_init_verbs,
  2466. alc880_pin_6stack_init_verbs },
  2467. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2468. .dac_nids = alc880_6st_dac_nids,
  2469. .dig_out_nid = ALC880_DIGOUT_NID,
  2470. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2471. .channel_mode = alc880_sixstack_modes,
  2472. .input_mux = &alc880_6stack_capture_source,
  2473. },
  2474. [ALC880_W810] = {
  2475. .mixers = { alc880_w810_base_mixer },
  2476. .init_verbs = { alc880_volume_init_verbs,
  2477. alc880_pin_w810_init_verbs,
  2478. alc880_gpio2_init_verbs },
  2479. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2480. .dac_nids = alc880_w810_dac_nids,
  2481. .dig_out_nid = ALC880_DIGOUT_NID,
  2482. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2483. .channel_mode = alc880_w810_modes,
  2484. .input_mux = &alc880_capture_source,
  2485. },
  2486. [ALC880_Z71V] = {
  2487. .mixers = { alc880_z71v_mixer },
  2488. .init_verbs = { alc880_volume_init_verbs,
  2489. alc880_pin_z71v_init_verbs },
  2490. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2491. .dac_nids = alc880_z71v_dac_nids,
  2492. .dig_out_nid = ALC880_DIGOUT_NID,
  2493. .hp_nid = 0x03,
  2494. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2495. .channel_mode = alc880_2_jack_modes,
  2496. .input_mux = &alc880_capture_source,
  2497. },
  2498. [ALC880_F1734] = {
  2499. .mixers = { alc880_f1734_mixer },
  2500. .init_verbs = { alc880_volume_init_verbs,
  2501. alc880_pin_f1734_init_verbs },
  2502. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2503. .dac_nids = alc880_f1734_dac_nids,
  2504. .hp_nid = 0x02,
  2505. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2506. .channel_mode = alc880_2_jack_modes,
  2507. .input_mux = &alc880_capture_source,
  2508. },
  2509. [ALC880_ASUS] = {
  2510. .mixers = { alc880_asus_mixer },
  2511. .init_verbs = { alc880_volume_init_verbs,
  2512. alc880_pin_asus_init_verbs,
  2513. alc880_gpio1_init_verbs },
  2514. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2515. .dac_nids = alc880_asus_dac_nids,
  2516. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2517. .channel_mode = alc880_asus_modes,
  2518. .need_dac_fix = 1,
  2519. .input_mux = &alc880_capture_source,
  2520. },
  2521. [ALC880_ASUS_DIG] = {
  2522. .mixers = { alc880_asus_mixer },
  2523. .init_verbs = { alc880_volume_init_verbs,
  2524. alc880_pin_asus_init_verbs,
  2525. alc880_gpio1_init_verbs },
  2526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2527. .dac_nids = alc880_asus_dac_nids,
  2528. .dig_out_nid = ALC880_DIGOUT_NID,
  2529. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2530. .channel_mode = alc880_asus_modes,
  2531. .need_dac_fix = 1,
  2532. .input_mux = &alc880_capture_source,
  2533. },
  2534. [ALC880_ASUS_DIG2] = {
  2535. .mixers = { alc880_asus_mixer },
  2536. .init_verbs = { alc880_volume_init_verbs,
  2537. alc880_pin_asus_init_verbs,
  2538. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2539. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2540. .dac_nids = alc880_asus_dac_nids,
  2541. .dig_out_nid = ALC880_DIGOUT_NID,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2543. .channel_mode = alc880_asus_modes,
  2544. .need_dac_fix = 1,
  2545. .input_mux = &alc880_capture_source,
  2546. },
  2547. [ALC880_ASUS_W1V] = {
  2548. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2549. .init_verbs = { alc880_volume_init_verbs,
  2550. alc880_pin_asus_init_verbs,
  2551. alc880_gpio1_init_verbs },
  2552. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2553. .dac_nids = alc880_asus_dac_nids,
  2554. .dig_out_nid = ALC880_DIGOUT_NID,
  2555. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2556. .channel_mode = alc880_asus_modes,
  2557. .need_dac_fix = 1,
  2558. .input_mux = &alc880_capture_source,
  2559. },
  2560. [ALC880_UNIWILL_DIG] = {
  2561. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2562. .init_verbs = { alc880_volume_init_verbs,
  2563. alc880_pin_asus_init_verbs },
  2564. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2565. .dac_nids = alc880_asus_dac_nids,
  2566. .dig_out_nid = ALC880_DIGOUT_NID,
  2567. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2568. .channel_mode = alc880_asus_modes,
  2569. .need_dac_fix = 1,
  2570. .input_mux = &alc880_capture_source,
  2571. },
  2572. [ALC880_UNIWILL] = {
  2573. .mixers = { alc880_uniwill_mixer },
  2574. .init_verbs = { alc880_volume_init_verbs,
  2575. alc880_uniwill_init_verbs },
  2576. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2577. .dac_nids = alc880_asus_dac_nids,
  2578. .dig_out_nid = ALC880_DIGOUT_NID,
  2579. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2580. .channel_mode = alc880_threestack_modes,
  2581. .need_dac_fix = 1,
  2582. .input_mux = &alc880_capture_source,
  2583. .unsol_event = alc880_uniwill_unsol_event,
  2584. .init_hook = alc880_uniwill_automute,
  2585. },
  2586. [ALC880_UNIWILL_P53] = {
  2587. .mixers = { alc880_uniwill_p53_mixer },
  2588. .init_verbs = { alc880_volume_init_verbs,
  2589. alc880_uniwill_p53_init_verbs },
  2590. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2591. .dac_nids = alc880_asus_dac_nids,
  2592. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2593. .channel_mode = alc880_threestack_modes,
  2594. .input_mux = &alc880_capture_source,
  2595. .unsol_event = alc880_uniwill_p53_unsol_event,
  2596. .init_hook = alc880_uniwill_p53_hp_automute,
  2597. },
  2598. [ALC880_FUJITSU] = {
  2599. .mixers = { alc880_fujitsu_mixer,
  2600. alc880_pcbeep_mixer, },
  2601. .init_verbs = { alc880_volume_init_verbs,
  2602. alc880_uniwill_p53_init_verbs,
  2603. alc880_beep_init_verbs },
  2604. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2605. .dac_nids = alc880_dac_nids,
  2606. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2607. .channel_mode = alc880_2_jack_modes,
  2608. .input_mux = &alc880_capture_source,
  2609. .unsol_event = alc880_uniwill_p53_unsol_event,
  2610. .init_hook = alc880_uniwill_p53_hp_automute,
  2611. },
  2612. [ALC880_CLEVO] = {
  2613. .mixers = { alc880_three_stack_mixer },
  2614. .init_verbs = { alc880_volume_init_verbs,
  2615. alc880_pin_clevo_init_verbs },
  2616. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2617. .dac_nids = alc880_dac_nids,
  2618. .hp_nid = 0x03,
  2619. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2620. .channel_mode = alc880_threestack_modes,
  2621. .need_dac_fix = 1,
  2622. .input_mux = &alc880_capture_source,
  2623. },
  2624. [ALC880_LG] = {
  2625. .mixers = { alc880_lg_mixer },
  2626. .init_verbs = { alc880_volume_init_verbs,
  2627. alc880_lg_init_verbs },
  2628. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2629. .dac_nids = alc880_lg_dac_nids,
  2630. .dig_out_nid = ALC880_DIGOUT_NID,
  2631. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2632. .channel_mode = alc880_lg_ch_modes,
  2633. .need_dac_fix = 1,
  2634. .input_mux = &alc880_lg_capture_source,
  2635. .unsol_event = alc880_lg_unsol_event,
  2636. .init_hook = alc880_lg_automute,
  2637. },
  2638. [ALC880_LG_LW] = {
  2639. .mixers = { alc880_lg_lw_mixer },
  2640. .init_verbs = { alc880_volume_init_verbs,
  2641. alc880_lg_lw_init_verbs },
  2642. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2643. .dac_nids = alc880_dac_nids,
  2644. .dig_out_nid = ALC880_DIGOUT_NID,
  2645. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2646. .channel_mode = alc880_lg_lw_modes,
  2647. .input_mux = &alc880_lg_lw_capture_source,
  2648. .unsol_event = alc880_lg_lw_unsol_event,
  2649. .init_hook = alc880_lg_lw_automute,
  2650. },
  2651. #ifdef CONFIG_SND_DEBUG
  2652. [ALC880_TEST] = {
  2653. .mixers = { alc880_test_mixer },
  2654. .init_verbs = { alc880_test_init_verbs },
  2655. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2656. .dac_nids = alc880_test_dac_nids,
  2657. .dig_out_nid = ALC880_DIGOUT_NID,
  2658. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2659. .channel_mode = alc880_test_modes,
  2660. .input_mux = &alc880_test_capture_source,
  2661. },
  2662. #endif
  2663. };
  2664. /*
  2665. * Automatic parse of I/O pins from the BIOS configuration
  2666. */
  2667. #define NUM_CONTROL_ALLOC 32
  2668. #define NUM_VERB_ALLOC 32
  2669. enum {
  2670. ALC_CTL_WIDGET_VOL,
  2671. ALC_CTL_WIDGET_MUTE,
  2672. ALC_CTL_BIND_MUTE,
  2673. };
  2674. static struct snd_kcontrol_new alc880_control_templates[] = {
  2675. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2676. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2677. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2678. };
  2679. /* add dynamic controls */
  2680. static int add_control(struct alc_spec *spec, int type, const char *name,
  2681. unsigned long val)
  2682. {
  2683. struct snd_kcontrol_new *knew;
  2684. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2685. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2686. /* array + terminator */
  2687. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2688. if (!knew)
  2689. return -ENOMEM;
  2690. if (spec->kctl_alloc) {
  2691. memcpy(knew, spec->kctl_alloc,
  2692. sizeof(*knew) * spec->num_kctl_alloc);
  2693. kfree(spec->kctl_alloc);
  2694. }
  2695. spec->kctl_alloc = knew;
  2696. spec->num_kctl_alloc = num;
  2697. }
  2698. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2699. *knew = alc880_control_templates[type];
  2700. knew->name = kstrdup(name, GFP_KERNEL);
  2701. if (!knew->name)
  2702. return -ENOMEM;
  2703. knew->private_value = val;
  2704. spec->num_kctl_used++;
  2705. return 0;
  2706. }
  2707. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2708. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2709. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2710. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2711. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2712. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2713. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2714. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2715. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2716. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2717. #define ALC880_PIN_CD_NID 0x1c
  2718. /* fill in the dac_nids table from the parsed pin configuration */
  2719. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2720. const struct auto_pin_cfg *cfg)
  2721. {
  2722. hda_nid_t nid;
  2723. int assigned[4];
  2724. int i, j;
  2725. memset(assigned, 0, sizeof(assigned));
  2726. spec->multiout.dac_nids = spec->private_dac_nids;
  2727. /* check the pins hardwired to audio widget */
  2728. for (i = 0; i < cfg->line_outs; i++) {
  2729. nid = cfg->line_out_pins[i];
  2730. if (alc880_is_fixed_pin(nid)) {
  2731. int idx = alc880_fixed_pin_idx(nid);
  2732. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2733. assigned[idx] = 1;
  2734. }
  2735. }
  2736. /* left pins can be connect to any audio widget */
  2737. for (i = 0; i < cfg->line_outs; i++) {
  2738. nid = cfg->line_out_pins[i];
  2739. if (alc880_is_fixed_pin(nid))
  2740. continue;
  2741. /* search for an empty channel */
  2742. for (j = 0; j < cfg->line_outs; j++) {
  2743. if (!assigned[j]) {
  2744. spec->multiout.dac_nids[i] =
  2745. alc880_idx_to_dac(j);
  2746. assigned[j] = 1;
  2747. break;
  2748. }
  2749. }
  2750. }
  2751. spec->multiout.num_dacs = cfg->line_outs;
  2752. return 0;
  2753. }
  2754. /* add playback controls from the parsed DAC table */
  2755. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2756. const struct auto_pin_cfg *cfg)
  2757. {
  2758. char name[32];
  2759. static const char *chname[4] = {
  2760. "Front", "Surround", NULL /*CLFE*/, "Side"
  2761. };
  2762. hda_nid_t nid;
  2763. int i, err;
  2764. for (i = 0; i < cfg->line_outs; i++) {
  2765. if (!spec->multiout.dac_nids[i])
  2766. continue;
  2767. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2768. if (i == 2) {
  2769. /* Center/LFE */
  2770. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2771. "Center Playback Volume",
  2772. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2773. HDA_OUTPUT));
  2774. if (err < 0)
  2775. return err;
  2776. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2777. "LFE Playback Volume",
  2778. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2779. HDA_OUTPUT));
  2780. if (err < 0)
  2781. return err;
  2782. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2783. "Center Playback Switch",
  2784. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2785. HDA_INPUT));
  2786. if (err < 0)
  2787. return err;
  2788. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2789. "LFE Playback Switch",
  2790. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2791. HDA_INPUT));
  2792. if (err < 0)
  2793. return err;
  2794. } else {
  2795. sprintf(name, "%s Playback Volume", chname[i]);
  2796. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2797. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2798. HDA_OUTPUT));
  2799. if (err < 0)
  2800. return err;
  2801. sprintf(name, "%s Playback Switch", chname[i]);
  2802. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2803. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2804. HDA_INPUT));
  2805. if (err < 0)
  2806. return err;
  2807. }
  2808. }
  2809. return 0;
  2810. }
  2811. /* add playback controls for speaker and HP outputs */
  2812. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2813. const char *pfx)
  2814. {
  2815. hda_nid_t nid;
  2816. int err;
  2817. char name[32];
  2818. if (!pin)
  2819. return 0;
  2820. if (alc880_is_fixed_pin(pin)) {
  2821. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2822. /* specify the DAC as the extra output */
  2823. if (!spec->multiout.hp_nid)
  2824. spec->multiout.hp_nid = nid;
  2825. else
  2826. spec->multiout.extra_out_nid[0] = nid;
  2827. /* control HP volume/switch on the output mixer amp */
  2828. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2829. sprintf(name, "%s Playback Volume", pfx);
  2830. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2831. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2832. if (err < 0)
  2833. return err;
  2834. sprintf(name, "%s Playback Switch", pfx);
  2835. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2836. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2837. if (err < 0)
  2838. return err;
  2839. } else if (alc880_is_multi_pin(pin)) {
  2840. /* set manual connection */
  2841. /* we have only a switch on HP-out PIN */
  2842. sprintf(name, "%s Playback Switch", pfx);
  2843. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2844. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2845. if (err < 0)
  2846. return err;
  2847. }
  2848. return 0;
  2849. }
  2850. /* create input playback/capture controls for the given pin */
  2851. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2852. const char *ctlname,
  2853. int idx, hda_nid_t mix_nid)
  2854. {
  2855. char name[32];
  2856. int err;
  2857. sprintf(name, "%s Playback Volume", ctlname);
  2858. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2859. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2860. if (err < 0)
  2861. return err;
  2862. sprintf(name, "%s Playback Switch", ctlname);
  2863. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2864. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2865. if (err < 0)
  2866. return err;
  2867. return 0;
  2868. }
  2869. /* create playback/capture controls for input pins */
  2870. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2871. const struct auto_pin_cfg *cfg)
  2872. {
  2873. struct hda_input_mux *imux = &spec->private_imux;
  2874. int i, err, idx;
  2875. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2876. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2877. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2878. err = new_analog_input(spec, cfg->input_pins[i],
  2879. auto_pin_cfg_labels[i],
  2880. idx, 0x0b);
  2881. if (err < 0)
  2882. return err;
  2883. imux->items[imux->num_items].label =
  2884. auto_pin_cfg_labels[i];
  2885. imux->items[imux->num_items].index =
  2886. alc880_input_pin_idx(cfg->input_pins[i]);
  2887. imux->num_items++;
  2888. }
  2889. }
  2890. return 0;
  2891. }
  2892. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2893. hda_nid_t nid, int pin_type,
  2894. int dac_idx)
  2895. {
  2896. /* set as output */
  2897. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2898. pin_type);
  2899. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2900. AMP_OUT_UNMUTE);
  2901. /* need the manual connection? */
  2902. if (alc880_is_multi_pin(nid)) {
  2903. struct alc_spec *spec = codec->spec;
  2904. int idx = alc880_multi_pin_idx(nid);
  2905. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2906. AC_VERB_SET_CONNECT_SEL,
  2907. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2908. }
  2909. }
  2910. static int get_pin_type(int line_out_type)
  2911. {
  2912. if (line_out_type == AUTO_PIN_HP_OUT)
  2913. return PIN_HP;
  2914. else
  2915. return PIN_OUT;
  2916. }
  2917. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2918. {
  2919. struct alc_spec *spec = codec->spec;
  2920. int i;
  2921. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2922. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2923. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2924. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2925. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2926. }
  2927. }
  2928. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2929. {
  2930. struct alc_spec *spec = codec->spec;
  2931. hda_nid_t pin;
  2932. pin = spec->autocfg.speaker_pins[0];
  2933. if (pin) /* connect to front */
  2934. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2935. pin = spec->autocfg.hp_pins[0];
  2936. if (pin) /* connect to front */
  2937. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2938. }
  2939. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2940. {
  2941. struct alc_spec *spec = codec->spec;
  2942. int i;
  2943. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2944. hda_nid_t nid = spec->autocfg.input_pins[i];
  2945. if (alc880_is_input_pin(nid)) {
  2946. snd_hda_codec_write(codec, nid, 0,
  2947. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2948. i <= AUTO_PIN_FRONT_MIC ?
  2949. PIN_VREF80 : PIN_IN);
  2950. if (nid != ALC880_PIN_CD_NID)
  2951. snd_hda_codec_write(codec, nid, 0,
  2952. AC_VERB_SET_AMP_GAIN_MUTE,
  2953. AMP_OUT_MUTE);
  2954. }
  2955. }
  2956. }
  2957. /* parse the BIOS configuration and set up the alc_spec */
  2958. /* return 1 if successful, 0 if the proper config is not found,
  2959. * or a negative error code
  2960. */
  2961. static int alc880_parse_auto_config(struct hda_codec *codec)
  2962. {
  2963. struct alc_spec *spec = codec->spec;
  2964. int err;
  2965. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2966. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2967. alc880_ignore);
  2968. if (err < 0)
  2969. return err;
  2970. if (!spec->autocfg.line_outs)
  2971. return 0; /* can't find valid BIOS pin config */
  2972. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2973. if (err < 0)
  2974. return err;
  2975. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2976. if (err < 0)
  2977. return err;
  2978. err = alc880_auto_create_extra_out(spec,
  2979. spec->autocfg.speaker_pins[0],
  2980. "Speaker");
  2981. if (err < 0)
  2982. return err;
  2983. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2984. "Headphone");
  2985. if (err < 0)
  2986. return err;
  2987. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2988. if (err < 0)
  2989. return err;
  2990. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2991. if (spec->autocfg.dig_out_pin)
  2992. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2993. if (spec->autocfg.dig_in_pin)
  2994. spec->dig_in_nid = ALC880_DIGIN_NID;
  2995. if (spec->kctl_alloc)
  2996. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2997. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2998. spec->num_mux_defs = 1;
  2999. spec->input_mux = &spec->private_imux;
  3000. return 1;
  3001. }
  3002. /* additional initialization for auto-configuration model */
  3003. static void alc880_auto_init(struct hda_codec *codec)
  3004. {
  3005. alc880_auto_init_multi_out(codec);
  3006. alc880_auto_init_extra_out(codec);
  3007. alc880_auto_init_analog_input(codec);
  3008. }
  3009. /*
  3010. * OK, here we have finally the patch for ALC880
  3011. */
  3012. static int patch_alc880(struct hda_codec *codec)
  3013. {
  3014. struct alc_spec *spec;
  3015. int board_config;
  3016. int err;
  3017. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3018. if (spec == NULL)
  3019. return -ENOMEM;
  3020. codec->spec = spec;
  3021. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3022. alc880_models,
  3023. alc880_cfg_tbl);
  3024. if (board_config < 0) {
  3025. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3026. "trying auto-probe from BIOS...\n");
  3027. board_config = ALC880_AUTO;
  3028. }
  3029. if (board_config == ALC880_AUTO) {
  3030. /* automatic parse from the BIOS config */
  3031. err = alc880_parse_auto_config(codec);
  3032. if (err < 0) {
  3033. alc_free(codec);
  3034. return err;
  3035. } else if (!err) {
  3036. printk(KERN_INFO
  3037. "hda_codec: Cannot set up configuration "
  3038. "from BIOS. Using 3-stack mode...\n");
  3039. board_config = ALC880_3ST;
  3040. }
  3041. }
  3042. if (board_config != ALC880_AUTO)
  3043. setup_preset(spec, &alc880_presets[board_config]);
  3044. spec->stream_name_analog = "ALC880 Analog";
  3045. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3046. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3047. spec->stream_name_digital = "ALC880 Digital";
  3048. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3049. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3050. if (!spec->adc_nids && spec->input_mux) {
  3051. /* check whether NID 0x07 is valid */
  3052. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3053. /* get type */
  3054. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3055. if (wcap != AC_WID_AUD_IN) {
  3056. spec->adc_nids = alc880_adc_nids_alt;
  3057. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3058. spec->mixers[spec->num_mixers] =
  3059. alc880_capture_alt_mixer;
  3060. spec->num_mixers++;
  3061. } else {
  3062. spec->adc_nids = alc880_adc_nids;
  3063. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3064. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3065. spec->num_mixers++;
  3066. }
  3067. }
  3068. codec->patch_ops = alc_patch_ops;
  3069. if (board_config == ALC880_AUTO)
  3070. spec->init_hook = alc880_auto_init;
  3071. return 0;
  3072. }
  3073. /*
  3074. * ALC260 support
  3075. */
  3076. static hda_nid_t alc260_dac_nids[1] = {
  3077. /* front */
  3078. 0x02,
  3079. };
  3080. static hda_nid_t alc260_adc_nids[1] = {
  3081. /* ADC0 */
  3082. 0x04,
  3083. };
  3084. static hda_nid_t alc260_adc_nids_alt[1] = {
  3085. /* ADC1 */
  3086. 0x05,
  3087. };
  3088. static hda_nid_t alc260_hp_adc_nids[2] = {
  3089. /* ADC1, 0 */
  3090. 0x05, 0x04
  3091. };
  3092. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3093. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3094. */
  3095. static hda_nid_t alc260_dual_adc_nids[2] = {
  3096. /* ADC0, ADC1 */
  3097. 0x04, 0x05
  3098. };
  3099. #define ALC260_DIGOUT_NID 0x03
  3100. #define ALC260_DIGIN_NID 0x06
  3101. static struct hda_input_mux alc260_capture_source = {
  3102. .num_items = 4,
  3103. .items = {
  3104. { "Mic", 0x0 },
  3105. { "Front Mic", 0x1 },
  3106. { "Line", 0x2 },
  3107. { "CD", 0x4 },
  3108. },
  3109. };
  3110. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3111. * headphone jack and the internal CD lines since these are the only pins at
  3112. * which audio can appear. For flexibility, also allow the option of
  3113. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3114. * connection to the mixer output).
  3115. */
  3116. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3117. {
  3118. .num_items = 3,
  3119. .items = {
  3120. { "Mic/Line", 0x0 },
  3121. { "CD", 0x4 },
  3122. { "Headphone", 0x2 },
  3123. },
  3124. },
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic/Line", 0x0 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x2 },
  3131. { "Mixer", 0x5 },
  3132. },
  3133. },
  3134. };
  3135. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3136. * the Fujitsu S702x, but jacks are marked differently.
  3137. */
  3138. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3139. {
  3140. .num_items = 4,
  3141. .items = {
  3142. { "Mic", 0x0 },
  3143. { "Line", 0x2 },
  3144. { "CD", 0x4 },
  3145. { "Headphone", 0x5 },
  3146. },
  3147. },
  3148. {
  3149. .num_items = 5,
  3150. .items = {
  3151. { "Mic", 0x0 },
  3152. { "Line", 0x2 },
  3153. { "CD", 0x4 },
  3154. { "Headphone", 0x6 },
  3155. { "Mixer", 0x5 },
  3156. },
  3157. },
  3158. };
  3159. /*
  3160. * This is just place-holder, so there's something for alc_build_pcms to look
  3161. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3162. * element which allows changing the channel mode, so the verb list is
  3163. * never used.
  3164. */
  3165. static struct hda_channel_mode alc260_modes[1] = {
  3166. { 2, NULL },
  3167. };
  3168. /* Mixer combinations
  3169. *
  3170. * basic: base_output + input + pc_beep + capture
  3171. * HP: base_output + input + capture_alt
  3172. * HP_3013: hp_3013 + input + capture
  3173. * fujitsu: fujitsu + capture
  3174. * acer: acer + capture
  3175. */
  3176. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3177. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3183. { } /* end */
  3184. };
  3185. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3186. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3194. { } /* end */
  3195. };
  3196. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3197. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3199. { } /* end */
  3200. };
  3201. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3202. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3210. { } /* end */
  3211. };
  3212. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3213. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3214. */
  3215. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3217. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3218. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3223. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3224. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3228. { } /* end */
  3229. };
  3230. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3231. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3232. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3233. * datasheet doesn't mention this restriction. At this stage it's not clear
  3234. * whether this behaviour is intentional or is a hardware bug in chip
  3235. * revisions available in early 2006. Therefore for now allow the
  3236. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3237. * that the lack of mic bias for this NID is intentional we could change the
  3238. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3239. *
  3240. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3241. * don't appear to make the mic bias available from the "line" jack, even
  3242. * though the NID used for this jack (0x14) can supply it. The theory is
  3243. * that perhaps Acer have included blocking capacitors between the ALC260
  3244. * and the output jack. If this turns out to be the case for all such
  3245. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3246. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3247. *
  3248. * The C20x Tablet series have a mono internal speaker which is controlled
  3249. * via the chip's Mono sum widget and pin complex, so include the necessary
  3250. * controls for such models. On models without a "mono speaker" the control
  3251. * won't do anything.
  3252. */
  3253. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3254. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3255. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3256. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3258. HDA_OUTPUT),
  3259. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3260. HDA_INPUT),
  3261. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3265. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3266. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3268. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3269. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3271. { } /* end */
  3272. };
  3273. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3274. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3275. */
  3276. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3277. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3278. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3281. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3282. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3284. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3285. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3289. { } /* end */
  3290. };
  3291. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3292. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3293. */
  3294. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3295. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3296. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3299. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3303. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3304. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3305. { } /* end */
  3306. };
  3307. /* capture mixer elements */
  3308. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3309. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3313. {
  3314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3315. /* The multiple "Capture Source" controls confuse alsamixer
  3316. * So call somewhat different..
  3317. * FIXME: the controls appear in the "playback" view!
  3318. */
  3319. /* .name = "Capture Source", */
  3320. .name = "Input Source",
  3321. .count = 2,
  3322. .info = alc_mux_enum_info,
  3323. .get = alc_mux_enum_get,
  3324. .put = alc_mux_enum_put,
  3325. },
  3326. { } /* end */
  3327. };
  3328. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3329. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3331. {
  3332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3333. /* The multiple "Capture Source" controls confuse alsamixer
  3334. * So call somewhat different..
  3335. * FIXME: the controls appear in the "playback" view!
  3336. */
  3337. /* .name = "Capture Source", */
  3338. .name = "Input Source",
  3339. .count = 1,
  3340. .info = alc_mux_enum_info,
  3341. .get = alc_mux_enum_get,
  3342. .put = alc_mux_enum_put,
  3343. },
  3344. { } /* end */
  3345. };
  3346. /*
  3347. * initialization verbs
  3348. */
  3349. static struct hda_verb alc260_init_verbs[] = {
  3350. /* Line In pin widget for input */
  3351. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* CD pin widget for input */
  3353. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* LINE-2 is used for line-out in rear */
  3359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3360. /* select line-out */
  3361. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3362. /* LINE-OUT pin */
  3363. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3364. /* enable HP */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3366. /* enable Mono */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3368. /* mute capture amp left and right */
  3369. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3370. /* set connection select to line in (default select for this ADC) */
  3371. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3372. /* mute capture amp left and right */
  3373. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* set vol=0 Line-Out mixer amp left and right */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. /* unmute pin widget amp left and right (no gain on this amp) */
  3379. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3380. /* set vol=0 HP mixer amp left and right */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3382. /* unmute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* set vol=0 Mono mixer amp left and right */
  3385. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3386. /* unmute pin widget amp left and right (no gain on this amp) */
  3387. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* unmute LINE-2 out pin */
  3389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* mute CD */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3395. /* mute Line In */
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3397. /* mute Mic */
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* mute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. /* mute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3409. { }
  3410. };
  3411. #if 0 /* should be identical with alc260_init_verbs? */
  3412. static struct hda_verb alc260_hp_init_verbs[] = {
  3413. /* Headphone and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Line-2 pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* unmute CD */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3444. /* unmute Line In */
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3446. /* unmute Mic */
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. #endif
  3461. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3462. /* Line out and output */
  3463. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* mono output */
  3465. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3467. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3469. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Line In pin widget for input */
  3471. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3472. /* Headphone pin widget for output */
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3474. /* CD pin widget for input */
  3475. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3476. /* unmute amp left and right */
  3477. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3478. /* set connection select to line in (default select for this ADC) */
  3479. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3480. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3482. /* mute pin widget amp left and right (no gain on this amp) */
  3483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3484. /* unmute HP mixer amp left and right (volume = 0) */
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3486. /* mute pin widget amp left and right (no gain on this amp) */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3488. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3489. * Line In 2 = 0x03
  3490. */
  3491. /* unmute CD */
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3493. /* unmute Line In */
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3495. /* unmute Mic */
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3497. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3498. /* Unmute Front out path */
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Headphone out path */
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. /* Unmute Mono out path */
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3507. { }
  3508. };
  3509. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3510. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3511. * audio = 0x16, internal speaker = 0x10.
  3512. */
  3513. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3514. /* Disable all GPIOs */
  3515. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3516. /* Internal speaker is connected to headphone pin */
  3517. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3518. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3520. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3521. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3522. /* Ensure all other unused pins are disabled and muted. */
  3523. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Disable digital (SPDIF) pins */
  3532. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3535. * when acting as an output.
  3536. */
  3537. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3538. /* Start with output sum widgets muted and their output gains at min */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3549. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3550. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3551. * If the pin mode is changed by the user the pin mode control will
  3552. * take care of enabling the pin's input/output buffers as needed.
  3553. * Therefore there's no need to enable the input buffer at this
  3554. * stage.
  3555. */
  3556. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3557. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3558. * mixer ctrl)
  3559. */
  3560. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* Mute capture amp left and right */
  3562. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. /* Set ADC connection select to match default mixer setting - line
  3564. * in (on mic1 pin)
  3565. */
  3566. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3567. /* Do the same for the second ADC: mute capture input amp and
  3568. * set ADC connection to line in (on mic1 pin)
  3569. */
  3570. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3571. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3572. /* Mute all inputs to mixer widget (even unconnected ones) */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3581. { }
  3582. };
  3583. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3584. * similar laptops (adapted from Fujitsu init verbs).
  3585. */
  3586. static struct hda_verb alc260_acer_init_verbs[] = {
  3587. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3588. * the headphone jack. Turn this on and rely on the standard mute
  3589. * methods whenever the user wants to turn these outputs off.
  3590. */
  3591. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3594. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3595. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3597. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3598. /* Line In jack is connected to Line1 pin */
  3599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3600. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3601. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3602. /* Ensure all other unused pins are disabled and muted. */
  3603. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. /* Disable digital (SPDIF) pins */
  3610. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3613. * bus when acting as outputs.
  3614. */
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3617. /* Start with output sum widgets muted and their output gains at min */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3627. /* Unmute Line-out pin widget amp left and right
  3628. * (no equiv mixer ctrl)
  3629. */
  3630. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3632. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3634. * inputs. If the pin mode is changed by the user the pin mode control
  3635. * will take care of enabling the pin's input/output buffers as needed.
  3636. * Therefore there's no need to enable the input buffer at this
  3637. * stage.
  3638. */
  3639. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. /* Mute capture amp left and right */
  3642. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3643. /* Set ADC connection select to match default mixer setting - mic
  3644. * (on mic1 pin)
  3645. */
  3646. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3647. /* Do similar with the second ADC: mute capture input amp and
  3648. * set ADC connection to mic to match ALSA's default state.
  3649. */
  3650. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3651. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. /* Mute all inputs to mixer widget (even unconnected ones) */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3661. { }
  3662. };
  3663. static struct hda_verb alc260_will_verbs[] = {
  3664. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3665. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3670. {}
  3671. };
  3672. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3673. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3674. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3675. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3676. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3679. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3680. {}
  3681. };
  3682. /* toggle speaker-output according to the hp-jack state */
  3683. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3684. {
  3685. unsigned int present;
  3686. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3687. present = snd_hda_codec_read(codec, 0x0f, 0,
  3688. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3689. if (present) {
  3690. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3691. snd_hda_codec_write(codec, 0x0f, 0,
  3692. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3693. } else {
  3694. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3695. snd_hda_codec_write(codec, 0x0f, 0,
  3696. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3697. }
  3698. }
  3699. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3700. unsigned int res)
  3701. {
  3702. if ((res >> 26) == ALC880_HP_EVENT)
  3703. alc260_replacer_672v_automute(codec);
  3704. }
  3705. /* Test configuration for debugging, modelled after the ALC880 test
  3706. * configuration.
  3707. */
  3708. #ifdef CONFIG_SND_DEBUG
  3709. static hda_nid_t alc260_test_dac_nids[1] = {
  3710. 0x02,
  3711. };
  3712. static hda_nid_t alc260_test_adc_nids[2] = {
  3713. 0x04, 0x05,
  3714. };
  3715. /* For testing the ALC260, each input MUX needs its own definition since
  3716. * the signal assignments are different. This assumes that the first ADC
  3717. * is NID 0x04.
  3718. */
  3719. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3720. {
  3721. .num_items = 7,
  3722. .items = {
  3723. { "MIC1 pin", 0x0 },
  3724. { "MIC2 pin", 0x1 },
  3725. { "LINE1 pin", 0x2 },
  3726. { "LINE2 pin", 0x3 },
  3727. { "CD pin", 0x4 },
  3728. { "LINE-OUT pin", 0x5 },
  3729. { "HP-OUT pin", 0x6 },
  3730. },
  3731. },
  3732. {
  3733. .num_items = 8,
  3734. .items = {
  3735. { "MIC1 pin", 0x0 },
  3736. { "MIC2 pin", 0x1 },
  3737. { "LINE1 pin", 0x2 },
  3738. { "LINE2 pin", 0x3 },
  3739. { "CD pin", 0x4 },
  3740. { "Mixer", 0x5 },
  3741. { "LINE-OUT pin", 0x6 },
  3742. { "HP-OUT pin", 0x7 },
  3743. },
  3744. },
  3745. };
  3746. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3747. /* Output driver widgets */
  3748. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3749. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3750. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3751. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3752. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3754. /* Modes for retasking pin widgets
  3755. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3756. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3757. * mention this restriction. At this stage it's not clear whether
  3758. * this behaviour is intentional or is a hardware bug in chip
  3759. * revisions available at least up until early 2006. Therefore for
  3760. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3761. * choices, but if it turns out that the lack of mic bias for these
  3762. * NIDs is intentional we could change their modes from
  3763. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3764. */
  3765. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3766. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3771. /* Loopback mixer controls */
  3772. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3773. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3774. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3775. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3776. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3777. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3779. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3781. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3783. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3785. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3787. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3788. /* Controls for GPIO pins, assuming they are configured as outputs */
  3789. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3792. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3793. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3794. * is ambigious as to which NID is which; testing on laptops which
  3795. * make this output available should provide clarification.
  3796. */
  3797. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3798. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3799. { } /* end */
  3800. };
  3801. static struct hda_verb alc260_test_init_verbs[] = {
  3802. /* Enable all GPIOs as outputs with an initial value of 0 */
  3803. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3804. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3805. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3806. /* Enable retasking pins as output, initially without power amp */
  3807. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3808. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. /* Disable digital (SPDIF) pins initially, but users can enable
  3814. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3815. * payload also sets the generation to 0, output to be in "consumer"
  3816. * PCM format, copyright asserted, no pre-emphasis and no validity
  3817. * control.
  3818. */
  3819. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3820. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3821. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3822. * OUT1 sum bus when acting as an output.
  3823. */
  3824. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3825. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3826. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3827. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3828. /* Start with output sum widgets muted and their output gains at min */
  3829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3832. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3835. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3837. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3838. /* Unmute retasking pin widget output buffers since the default
  3839. * state appears to be output. As the pin mode is changed by the
  3840. * user the pin mode control will take care of enabling the pin's
  3841. * input/output buffers as needed.
  3842. */
  3843. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. /* Also unmute the mono-out pin widget */
  3850. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. /* Mute capture amp left and right */
  3852. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3853. /* Set ADC connection select to match default mixer setting (mic1
  3854. * pin)
  3855. */
  3856. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3857. /* Do the same for the second ADC: mute capture input amp and
  3858. * set ADC connection to mic1 pin
  3859. */
  3860. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3861. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* Mute all inputs to mixer widget (even unconnected ones) */
  3863. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3871. { }
  3872. };
  3873. #endif
  3874. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3875. .substreams = 1,
  3876. .channels_min = 2,
  3877. .channels_max = 2,
  3878. };
  3879. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3880. .substreams = 1,
  3881. .channels_min = 2,
  3882. .channels_max = 2,
  3883. };
  3884. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3885. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3886. /*
  3887. * for BIOS auto-configuration
  3888. */
  3889. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3890. const char *pfx)
  3891. {
  3892. hda_nid_t nid_vol;
  3893. unsigned long vol_val, sw_val;
  3894. char name[32];
  3895. int err;
  3896. if (nid >= 0x0f && nid < 0x11) {
  3897. nid_vol = nid - 0x7;
  3898. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3899. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3900. } else if (nid == 0x11) {
  3901. nid_vol = nid - 0x7;
  3902. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3903. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3904. } else if (nid >= 0x12 && nid <= 0x15) {
  3905. nid_vol = 0x08;
  3906. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3907. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3908. } else
  3909. return 0; /* N/A */
  3910. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3911. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3912. if (err < 0)
  3913. return err;
  3914. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3915. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3916. if (err < 0)
  3917. return err;
  3918. return 1;
  3919. }
  3920. /* add playback controls from the parsed DAC table */
  3921. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3922. const struct auto_pin_cfg *cfg)
  3923. {
  3924. hda_nid_t nid;
  3925. int err;
  3926. spec->multiout.num_dacs = 1;
  3927. spec->multiout.dac_nids = spec->private_dac_nids;
  3928. spec->multiout.dac_nids[0] = 0x02;
  3929. nid = cfg->line_out_pins[0];
  3930. if (nid) {
  3931. err = alc260_add_playback_controls(spec, nid, "Front");
  3932. if (err < 0)
  3933. return err;
  3934. }
  3935. nid = cfg->speaker_pins[0];
  3936. if (nid) {
  3937. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3938. if (err < 0)
  3939. return err;
  3940. }
  3941. nid = cfg->hp_pins[0];
  3942. if (nid) {
  3943. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3944. if (err < 0)
  3945. return err;
  3946. }
  3947. return 0;
  3948. }
  3949. /* create playback/capture controls for input pins */
  3950. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3951. const struct auto_pin_cfg *cfg)
  3952. {
  3953. struct hda_input_mux *imux = &spec->private_imux;
  3954. int i, err, idx;
  3955. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3956. if (cfg->input_pins[i] >= 0x12) {
  3957. idx = cfg->input_pins[i] - 0x12;
  3958. err = new_analog_input(spec, cfg->input_pins[i],
  3959. auto_pin_cfg_labels[i], idx,
  3960. 0x07);
  3961. if (err < 0)
  3962. return err;
  3963. imux->items[imux->num_items].label =
  3964. auto_pin_cfg_labels[i];
  3965. imux->items[imux->num_items].index = idx;
  3966. imux->num_items++;
  3967. }
  3968. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3969. idx = cfg->input_pins[i] - 0x09;
  3970. err = new_analog_input(spec, cfg->input_pins[i],
  3971. auto_pin_cfg_labels[i], idx,
  3972. 0x07);
  3973. if (err < 0)
  3974. return err;
  3975. imux->items[imux->num_items].label =
  3976. auto_pin_cfg_labels[i];
  3977. imux->items[imux->num_items].index = idx;
  3978. imux->num_items++;
  3979. }
  3980. }
  3981. return 0;
  3982. }
  3983. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3984. hda_nid_t nid, int pin_type,
  3985. int sel_idx)
  3986. {
  3987. /* set as output */
  3988. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3989. pin_type);
  3990. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3991. AMP_OUT_UNMUTE);
  3992. /* need the manual connection? */
  3993. if (nid >= 0x12) {
  3994. int idx = nid - 0x12;
  3995. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3996. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3997. }
  3998. }
  3999. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4000. {
  4001. struct alc_spec *spec = codec->spec;
  4002. hda_nid_t nid;
  4003. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4004. nid = spec->autocfg.line_out_pins[0];
  4005. if (nid) {
  4006. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4007. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4008. }
  4009. nid = spec->autocfg.speaker_pins[0];
  4010. if (nid)
  4011. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4012. nid = spec->autocfg.hp_pins[0];
  4013. if (nid)
  4014. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4015. }
  4016. #define ALC260_PIN_CD_NID 0x16
  4017. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4018. {
  4019. struct alc_spec *spec = codec->spec;
  4020. int i;
  4021. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4022. hda_nid_t nid = spec->autocfg.input_pins[i];
  4023. if (nid >= 0x12) {
  4024. snd_hda_codec_write(codec, nid, 0,
  4025. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4026. i <= AUTO_PIN_FRONT_MIC ?
  4027. PIN_VREF80 : PIN_IN);
  4028. if (nid != ALC260_PIN_CD_NID)
  4029. snd_hda_codec_write(codec, nid, 0,
  4030. AC_VERB_SET_AMP_GAIN_MUTE,
  4031. AMP_OUT_MUTE);
  4032. }
  4033. }
  4034. }
  4035. /*
  4036. * generic initialization of ADC, input mixers and output mixers
  4037. */
  4038. static struct hda_verb alc260_volume_init_verbs[] = {
  4039. /*
  4040. * Unmute ADC0-1 and set the default input to mic-in
  4041. */
  4042. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4043. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4044. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4045. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4046. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4047. * mixer widget
  4048. * Note: PASD motherboards uses the Line In 2 as the input for
  4049. * front panel mic (mic 2)
  4050. */
  4051. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4052. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4053. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4057. /*
  4058. * Set up output mixers (0x08 - 0x0a)
  4059. */
  4060. /* set vol=0 to output mixers */
  4061. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4062. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4063. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4064. /* set up input amps for analog loopback */
  4065. /* Amp Indices: DAC = 0, mixer = 1 */
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4067. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4069. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4071. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4072. { }
  4073. };
  4074. static int alc260_parse_auto_config(struct hda_codec *codec)
  4075. {
  4076. struct alc_spec *spec = codec->spec;
  4077. unsigned int wcap;
  4078. int err;
  4079. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4080. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4081. alc260_ignore);
  4082. if (err < 0)
  4083. return err;
  4084. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4085. if (err < 0)
  4086. return err;
  4087. if (!spec->kctl_alloc)
  4088. return 0; /* can't find valid BIOS pin config */
  4089. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4090. if (err < 0)
  4091. return err;
  4092. spec->multiout.max_channels = 2;
  4093. if (spec->autocfg.dig_out_pin)
  4094. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4095. if (spec->kctl_alloc)
  4096. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4097. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4098. spec->num_mux_defs = 1;
  4099. spec->input_mux = &spec->private_imux;
  4100. /* check whether NID 0x04 is valid */
  4101. wcap = get_wcaps(codec, 0x04);
  4102. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4103. if (wcap != AC_WID_AUD_IN) {
  4104. spec->adc_nids = alc260_adc_nids_alt;
  4105. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4106. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4107. } else {
  4108. spec->adc_nids = alc260_adc_nids;
  4109. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4110. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4111. }
  4112. spec->num_mixers++;
  4113. return 1;
  4114. }
  4115. /* additional initialization for auto-configuration model */
  4116. static void alc260_auto_init(struct hda_codec *codec)
  4117. {
  4118. alc260_auto_init_multi_out(codec);
  4119. alc260_auto_init_analog_input(codec);
  4120. }
  4121. /*
  4122. * ALC260 configurations
  4123. */
  4124. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4125. [ALC260_BASIC] = "basic",
  4126. [ALC260_HP] = "hp",
  4127. [ALC260_HP_3013] = "hp-3013",
  4128. [ALC260_FUJITSU_S702X] = "fujitsu",
  4129. [ALC260_ACER] = "acer",
  4130. [ALC260_WILL] = "will",
  4131. [ALC260_REPLACER_672V] = "replacer",
  4132. #ifdef CONFIG_SND_DEBUG
  4133. [ALC260_TEST] = "test",
  4134. #endif
  4135. [ALC260_AUTO] = "auto",
  4136. };
  4137. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4138. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4139. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4140. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4141. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4142. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4143. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4144. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4145. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4146. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4147. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4148. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4149. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4150. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4151. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4152. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4153. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4154. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4155. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4156. {}
  4157. };
  4158. static struct alc_config_preset alc260_presets[] = {
  4159. [ALC260_BASIC] = {
  4160. .mixers = { alc260_base_output_mixer,
  4161. alc260_input_mixer,
  4162. alc260_pc_beep_mixer,
  4163. alc260_capture_mixer },
  4164. .init_verbs = { alc260_init_verbs },
  4165. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4166. .dac_nids = alc260_dac_nids,
  4167. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4168. .adc_nids = alc260_adc_nids,
  4169. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4170. .channel_mode = alc260_modes,
  4171. .input_mux = &alc260_capture_source,
  4172. },
  4173. [ALC260_HP] = {
  4174. .mixers = { alc260_base_output_mixer,
  4175. alc260_input_mixer,
  4176. alc260_capture_alt_mixer },
  4177. .init_verbs = { alc260_init_verbs },
  4178. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4179. .dac_nids = alc260_dac_nids,
  4180. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4181. .adc_nids = alc260_hp_adc_nids,
  4182. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4183. .channel_mode = alc260_modes,
  4184. .input_mux = &alc260_capture_source,
  4185. },
  4186. [ALC260_HP_3013] = {
  4187. .mixers = { alc260_hp_3013_mixer,
  4188. alc260_input_mixer,
  4189. alc260_capture_alt_mixer },
  4190. .init_verbs = { alc260_hp_3013_init_verbs },
  4191. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4192. .dac_nids = alc260_dac_nids,
  4193. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4194. .adc_nids = alc260_hp_adc_nids,
  4195. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4196. .channel_mode = alc260_modes,
  4197. .input_mux = &alc260_capture_source,
  4198. },
  4199. [ALC260_FUJITSU_S702X] = {
  4200. .mixers = { alc260_fujitsu_mixer,
  4201. alc260_capture_mixer },
  4202. .init_verbs = { alc260_fujitsu_init_verbs },
  4203. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4204. .dac_nids = alc260_dac_nids,
  4205. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4206. .adc_nids = alc260_dual_adc_nids,
  4207. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4208. .channel_mode = alc260_modes,
  4209. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4210. .input_mux = alc260_fujitsu_capture_sources,
  4211. },
  4212. [ALC260_ACER] = {
  4213. .mixers = { alc260_acer_mixer,
  4214. alc260_capture_mixer },
  4215. .init_verbs = { alc260_acer_init_verbs },
  4216. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4217. .dac_nids = alc260_dac_nids,
  4218. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4219. .adc_nids = alc260_dual_adc_nids,
  4220. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4221. .channel_mode = alc260_modes,
  4222. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4223. .input_mux = alc260_acer_capture_sources,
  4224. },
  4225. [ALC260_WILL] = {
  4226. .mixers = { alc260_will_mixer,
  4227. alc260_capture_mixer },
  4228. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4229. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4230. .dac_nids = alc260_dac_nids,
  4231. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4232. .adc_nids = alc260_adc_nids,
  4233. .dig_out_nid = ALC260_DIGOUT_NID,
  4234. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4235. .channel_mode = alc260_modes,
  4236. .input_mux = &alc260_capture_source,
  4237. },
  4238. [ALC260_REPLACER_672V] = {
  4239. .mixers = { alc260_replacer_672v_mixer,
  4240. alc260_capture_mixer },
  4241. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4242. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4243. .dac_nids = alc260_dac_nids,
  4244. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4245. .adc_nids = alc260_adc_nids,
  4246. .dig_out_nid = ALC260_DIGOUT_NID,
  4247. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4248. .channel_mode = alc260_modes,
  4249. .input_mux = &alc260_capture_source,
  4250. .unsol_event = alc260_replacer_672v_unsol_event,
  4251. .init_hook = alc260_replacer_672v_automute,
  4252. },
  4253. #ifdef CONFIG_SND_DEBUG
  4254. [ALC260_TEST] = {
  4255. .mixers = { alc260_test_mixer,
  4256. alc260_capture_mixer },
  4257. .init_verbs = { alc260_test_init_verbs },
  4258. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4259. .dac_nids = alc260_test_dac_nids,
  4260. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4261. .adc_nids = alc260_test_adc_nids,
  4262. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4263. .channel_mode = alc260_modes,
  4264. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4265. .input_mux = alc260_test_capture_sources,
  4266. },
  4267. #endif
  4268. };
  4269. static int patch_alc260(struct hda_codec *codec)
  4270. {
  4271. struct alc_spec *spec;
  4272. int err, board_config;
  4273. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4274. if (spec == NULL)
  4275. return -ENOMEM;
  4276. codec->spec = spec;
  4277. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4278. alc260_models,
  4279. alc260_cfg_tbl);
  4280. if (board_config < 0) {
  4281. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4282. "trying auto-probe from BIOS...\n");
  4283. board_config = ALC260_AUTO;
  4284. }
  4285. if (board_config == ALC260_AUTO) {
  4286. /* automatic parse from the BIOS config */
  4287. err = alc260_parse_auto_config(codec);
  4288. if (err < 0) {
  4289. alc_free(codec);
  4290. return err;
  4291. } else if (!err) {
  4292. printk(KERN_INFO
  4293. "hda_codec: Cannot set up configuration "
  4294. "from BIOS. Using base mode...\n");
  4295. board_config = ALC260_BASIC;
  4296. }
  4297. }
  4298. if (board_config != ALC260_AUTO)
  4299. setup_preset(spec, &alc260_presets[board_config]);
  4300. spec->stream_name_analog = "ALC260 Analog";
  4301. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4302. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4303. spec->stream_name_digital = "ALC260 Digital";
  4304. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4305. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4306. codec->patch_ops = alc_patch_ops;
  4307. if (board_config == ALC260_AUTO)
  4308. spec->init_hook = alc260_auto_init;
  4309. return 0;
  4310. }
  4311. /*
  4312. * ALC882 support
  4313. *
  4314. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4315. * configuration. Each pin widget can choose any input DACs and a mixer.
  4316. * Each ADC is connected from a mixer of all inputs. This makes possible
  4317. * 6-channel independent captures.
  4318. *
  4319. * In addition, an independent DAC for the multi-playback (not used in this
  4320. * driver yet).
  4321. */
  4322. #define ALC882_DIGOUT_NID 0x06
  4323. #define ALC882_DIGIN_NID 0x0a
  4324. static struct hda_channel_mode alc882_ch_modes[1] = {
  4325. { 8, NULL }
  4326. };
  4327. static hda_nid_t alc882_dac_nids[4] = {
  4328. /* front, rear, clfe, rear_surr */
  4329. 0x02, 0x03, 0x04, 0x05
  4330. };
  4331. /* identical with ALC880 */
  4332. #define alc882_adc_nids alc880_adc_nids
  4333. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4334. /* input MUX */
  4335. /* FIXME: should be a matrix-type input source selection */
  4336. static struct hda_input_mux alc882_capture_source = {
  4337. .num_items = 4,
  4338. .items = {
  4339. { "Mic", 0x0 },
  4340. { "Front Mic", 0x1 },
  4341. { "Line", 0x2 },
  4342. { "CD", 0x4 },
  4343. },
  4344. };
  4345. #define alc882_mux_enum_info alc_mux_enum_info
  4346. #define alc882_mux_enum_get alc_mux_enum_get
  4347. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4348. struct snd_ctl_elem_value *ucontrol)
  4349. {
  4350. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4351. struct alc_spec *spec = codec->spec;
  4352. const struct hda_input_mux *imux = spec->input_mux;
  4353. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4354. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4355. hda_nid_t nid = capture_mixers[adc_idx];
  4356. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4357. unsigned int i, idx;
  4358. idx = ucontrol->value.enumerated.item[0];
  4359. if (idx >= imux->num_items)
  4360. idx = imux->num_items - 1;
  4361. if (*cur_val == idx && !codec->in_resume)
  4362. return 0;
  4363. for (i = 0; i < imux->num_items; i++) {
  4364. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4365. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4366. v | (imux->items[i].index << 8));
  4367. }
  4368. *cur_val = idx;
  4369. return 1;
  4370. }
  4371. /*
  4372. * 2ch mode
  4373. */
  4374. static struct hda_verb alc882_3ST_ch2_init[] = {
  4375. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4376. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4377. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4378. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4379. { } /* end */
  4380. };
  4381. /*
  4382. * 6ch mode
  4383. */
  4384. static struct hda_verb alc882_3ST_ch6_init[] = {
  4385. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4386. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4387. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4388. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4389. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4390. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4391. { } /* end */
  4392. };
  4393. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4394. { 2, alc882_3ST_ch2_init },
  4395. { 6, alc882_3ST_ch6_init },
  4396. };
  4397. /*
  4398. * 6ch mode
  4399. */
  4400. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4401. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4402. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4403. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4404. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4405. { } /* end */
  4406. };
  4407. /*
  4408. * 8ch mode
  4409. */
  4410. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4411. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4412. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4413. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4414. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4415. { } /* end */
  4416. };
  4417. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4418. { 6, alc882_sixstack_ch6_init },
  4419. { 8, alc882_sixstack_ch8_init },
  4420. };
  4421. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4422. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4423. */
  4424. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4425. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4426. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4427. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4428. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4429. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4430. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4431. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4432. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4433. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4434. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4435. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4437. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4439. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4445. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4446. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4447. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4448. { } /* end */
  4449. };
  4450. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4451. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4452. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4453. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4454. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4456. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4459. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4461. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4462. { } /* end */
  4463. };
  4464. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4465. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4466. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4467. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4468. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4469. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4470. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4471. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4472. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4473. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4475. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4476. { } /* end */
  4477. };
  4478. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4479. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4480. */
  4481. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4482. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4486. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4487. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4491. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4492. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4493. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4494. { } /* end */
  4495. };
  4496. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4497. {
  4498. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4499. .name = "Channel Mode",
  4500. .info = alc_ch_mode_info,
  4501. .get = alc_ch_mode_get,
  4502. .put = alc_ch_mode_put,
  4503. },
  4504. { } /* end */
  4505. };
  4506. static struct hda_verb alc882_init_verbs[] = {
  4507. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4508. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4509. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4510. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4511. /* Rear mixer */
  4512. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4514. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4515. /* CLFE mixer */
  4516. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4517. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4518. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4519. /* Side mixer */
  4520. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4521. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4522. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4523. /* Front Pin: output 0 (0x0c) */
  4524. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4526. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4527. /* Rear Pin: output 1 (0x0d) */
  4528. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4529. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4530. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4531. /* CLFE Pin: output 2 (0x0e) */
  4532. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4533. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4534. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4535. /* Side Pin: output 3 (0x0f) */
  4536. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4537. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4538. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4539. /* Mic (rear) pin: input vref at 80% */
  4540. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4541. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4542. /* Front Mic pin: input vref at 80% */
  4543. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4544. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4545. /* Line In pin: input */
  4546. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4547. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4548. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4549. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4550. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4551. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4552. /* CD pin widget for input */
  4553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4554. /* FIXME: use matrix-type input source selection */
  4555. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4556. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4557. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4558. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4559. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4560. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4561. /* Input mixer2 */
  4562. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4563. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4564. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4565. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4566. /* Input mixer3 */
  4567. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4568. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4569. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4570. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4571. /* ADC1: mute amp left and right */
  4572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4573. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4574. /* ADC2: mute amp left and right */
  4575. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4576. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4577. /* ADC3: mute amp left and right */
  4578. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4579. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4580. { }
  4581. };
  4582. static struct hda_verb alc882_eapd_verbs[] = {
  4583. /* change to EAPD mode */
  4584. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4585. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4586. { }
  4587. };
  4588. /* Mac Pro test */
  4589. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4590. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4591. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4592. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4593. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4594. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4597. { } /* end */
  4598. };
  4599. static struct hda_verb alc882_macpro_init_verbs[] = {
  4600. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4601. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4602. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4604. /* Front Pin: output 0 (0x0c) */
  4605. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4606. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4607. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4608. /* Front Mic pin: input vref at 80% */
  4609. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4610. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4611. /* Speaker: output */
  4612. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4613. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4614. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4615. /* Headphone output (output 0 - 0x0c) */
  4616. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4617. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4618. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4619. /* FIXME: use matrix-type input source selection */
  4620. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4621. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4622. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4623. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4624. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4625. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4626. /* Input mixer2 */
  4627. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4629. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4630. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4631. /* Input mixer3 */
  4632. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4635. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4636. /* ADC1: mute amp left and right */
  4637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4638. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4639. /* ADC2: mute amp left and right */
  4640. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4641. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4642. /* ADC3: mute amp left and right */
  4643. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4644. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4645. { }
  4646. };
  4647. static struct hda_verb alc882_targa_verbs[] = {
  4648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4649. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4650. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4651. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4652. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4653. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4654. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4655. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4656. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4657. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4658. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4659. { } /* end */
  4660. };
  4661. /* toggle speaker-output according to the hp-jack state */
  4662. static void alc882_targa_automute(struct hda_codec *codec)
  4663. {
  4664. unsigned int present;
  4665. present = snd_hda_codec_read(codec, 0x14, 0,
  4666. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4667. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4668. 0x80, present ? 0x80 : 0);
  4669. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4670. 0x80, present ? 0x80 : 0);
  4671. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4672. }
  4673. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4674. {
  4675. /* Looks like the unsol event is incompatible with the standard
  4676. * definition. 4bit tag is placed at 26 bit!
  4677. */
  4678. if (((res >> 26) == ALC880_HP_EVENT)) {
  4679. alc882_targa_automute(codec);
  4680. }
  4681. }
  4682. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4684. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4685. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4686. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4687. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4688. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4689. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4690. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4691. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4692. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4693. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4694. { } /* end */
  4695. };
  4696. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4697. {
  4698. unsigned int gpiostate, gpiomask, gpiodir;
  4699. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4700. AC_VERB_GET_GPIO_DATA, 0);
  4701. if (!muted)
  4702. gpiostate |= (1 << pin);
  4703. else
  4704. gpiostate &= ~(1 << pin);
  4705. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4706. AC_VERB_GET_GPIO_MASK, 0);
  4707. gpiomask |= (1 << pin);
  4708. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4709. AC_VERB_GET_GPIO_DIRECTION, 0);
  4710. gpiodir |= (1 << pin);
  4711. snd_hda_codec_write(codec, codec->afg, 0,
  4712. AC_VERB_SET_GPIO_MASK, gpiomask);
  4713. snd_hda_codec_write(codec, codec->afg, 0,
  4714. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4715. msleep(1);
  4716. snd_hda_codec_write(codec, codec->afg, 0,
  4717. AC_VERB_SET_GPIO_DATA, gpiostate);
  4718. }
  4719. /*
  4720. * generic initialization of ADC, input mixers and output mixers
  4721. */
  4722. static struct hda_verb alc882_auto_init_verbs[] = {
  4723. /*
  4724. * Unmute ADC0-2 and set the default input to mic-in
  4725. */
  4726. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4727. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4728. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4729. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4730. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4731. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4732. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4733. * mixer widget
  4734. * Note: PASD motherboards uses the Line In 2 as the input for
  4735. * front panel mic (mic 2)
  4736. */
  4737. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4738. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4739. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4740. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4742. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4743. /*
  4744. * Set up output mixers (0x0c - 0x0f)
  4745. */
  4746. /* set vol=0 to output mixers */
  4747. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4748. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4749. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4750. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4751. /* set up input amps for analog loopback */
  4752. /* Amp Indices: DAC = 0, mixer = 1 */
  4753. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4754. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4755. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4756. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4757. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4758. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4759. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4760. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4761. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4762. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4763. /* FIXME: use matrix-type input source selection */
  4764. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4765. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4766. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4767. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4768. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4769. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4770. /* Input mixer2 */
  4771. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4772. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4773. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4774. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4775. /* Input mixer3 */
  4776. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4777. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4779. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4780. { }
  4781. };
  4782. /* capture mixer elements */
  4783. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4784. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4785. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4786. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4787. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4788. {
  4789. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4790. /* The multiple "Capture Source" controls confuse alsamixer
  4791. * So call somewhat different..
  4792. * FIXME: the controls appear in the "playback" view!
  4793. */
  4794. /* .name = "Capture Source", */
  4795. .name = "Input Source",
  4796. .count = 2,
  4797. .info = alc882_mux_enum_info,
  4798. .get = alc882_mux_enum_get,
  4799. .put = alc882_mux_enum_put,
  4800. },
  4801. { } /* end */
  4802. };
  4803. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4804. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4805. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4806. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4807. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4808. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4809. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4810. {
  4811. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4812. /* The multiple "Capture Source" controls confuse alsamixer
  4813. * So call somewhat different..
  4814. * FIXME: the controls appear in the "playback" view!
  4815. */
  4816. /* .name = "Capture Source", */
  4817. .name = "Input Source",
  4818. .count = 3,
  4819. .info = alc882_mux_enum_info,
  4820. .get = alc882_mux_enum_get,
  4821. .put = alc882_mux_enum_put,
  4822. },
  4823. { } /* end */
  4824. };
  4825. /* pcm configuration: identiacal with ALC880 */
  4826. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4827. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4828. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4829. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4830. /*
  4831. * configuration and preset
  4832. */
  4833. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4834. [ALC882_3ST_DIG] = "3stack-dig",
  4835. [ALC882_6ST_DIG] = "6stack-dig",
  4836. [ALC882_ARIMA] = "arima",
  4837. [ALC882_W2JC] = "w2jc",
  4838. [ALC885_MACPRO] = "macpro",
  4839. [ALC882_AUTO] = "auto",
  4840. };
  4841. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4842. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4843. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4844. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4845. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4846. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4847. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4848. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4849. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4850. {}
  4851. };
  4852. static struct alc_config_preset alc882_presets[] = {
  4853. [ALC882_3ST_DIG] = {
  4854. .mixers = { alc882_base_mixer },
  4855. .init_verbs = { alc882_init_verbs },
  4856. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4857. .dac_nids = alc882_dac_nids,
  4858. .dig_out_nid = ALC882_DIGOUT_NID,
  4859. .dig_in_nid = ALC882_DIGIN_NID,
  4860. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4861. .channel_mode = alc882_ch_modes,
  4862. .need_dac_fix = 1,
  4863. .input_mux = &alc882_capture_source,
  4864. },
  4865. [ALC882_6ST_DIG] = {
  4866. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4867. .init_verbs = { alc882_init_verbs },
  4868. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4869. .dac_nids = alc882_dac_nids,
  4870. .dig_out_nid = ALC882_DIGOUT_NID,
  4871. .dig_in_nid = ALC882_DIGIN_NID,
  4872. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4873. .channel_mode = alc882_sixstack_modes,
  4874. .input_mux = &alc882_capture_source,
  4875. },
  4876. [ALC882_ARIMA] = {
  4877. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4878. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4879. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4880. .dac_nids = alc882_dac_nids,
  4881. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4882. .channel_mode = alc882_sixstack_modes,
  4883. .input_mux = &alc882_capture_source,
  4884. },
  4885. [ALC882_W2JC] = {
  4886. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4887. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4888. alc880_gpio1_init_verbs },
  4889. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4890. .dac_nids = alc882_dac_nids,
  4891. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4892. .channel_mode = alc880_threestack_modes,
  4893. .need_dac_fix = 1,
  4894. .input_mux = &alc882_capture_source,
  4895. .dig_out_nid = ALC882_DIGOUT_NID,
  4896. },
  4897. [ALC885_MACPRO] = {
  4898. .mixers = { alc882_macpro_mixer },
  4899. .init_verbs = { alc882_macpro_init_verbs },
  4900. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4901. .dac_nids = alc882_dac_nids,
  4902. .dig_out_nid = ALC882_DIGOUT_NID,
  4903. .dig_in_nid = ALC882_DIGIN_NID,
  4904. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4905. .channel_mode = alc882_ch_modes,
  4906. .input_mux = &alc882_capture_source,
  4907. },
  4908. [ALC882_TARGA] = {
  4909. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4910. alc882_capture_mixer },
  4911. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4912. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4913. .dac_nids = alc882_dac_nids,
  4914. .dig_out_nid = ALC882_DIGOUT_NID,
  4915. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4916. .adc_nids = alc882_adc_nids,
  4917. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4918. .channel_mode = alc882_3ST_6ch_modes,
  4919. .need_dac_fix = 1,
  4920. .input_mux = &alc882_capture_source,
  4921. .unsol_event = alc882_targa_unsol_event,
  4922. .init_hook = alc882_targa_automute,
  4923. },
  4924. [ALC882_ASUS_A7J] = {
  4925. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4926. alc882_capture_mixer },
  4927. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4928. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4929. .dac_nids = alc882_dac_nids,
  4930. .dig_out_nid = ALC882_DIGOUT_NID,
  4931. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4932. .adc_nids = alc882_adc_nids,
  4933. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4934. .channel_mode = alc882_3ST_6ch_modes,
  4935. .need_dac_fix = 1,
  4936. .input_mux = &alc882_capture_source,
  4937. },
  4938. };
  4939. /*
  4940. * Pin config fixes
  4941. */
  4942. enum {
  4943. PINFIX_ABIT_AW9D_MAX
  4944. };
  4945. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  4946. { 0x15, 0x01080104 }, /* side */
  4947. { 0x16, 0x01011012 }, /* rear */
  4948. { 0x17, 0x01016011 }, /* clfe */
  4949. { }
  4950. };
  4951. static const struct alc_pincfg *alc882_pin_fixes[] = {
  4952. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  4953. };
  4954. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  4955. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  4956. {}
  4957. };
  4958. /*
  4959. * BIOS auto configuration
  4960. */
  4961. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4962. hda_nid_t nid, int pin_type,
  4963. int dac_idx)
  4964. {
  4965. /* set as output */
  4966. struct alc_spec *spec = codec->spec;
  4967. int idx;
  4968. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4969. idx = 4;
  4970. else
  4971. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4972. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4973. pin_type);
  4974. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4975. AMP_OUT_UNMUTE);
  4976. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4977. }
  4978. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4979. {
  4980. struct alc_spec *spec = codec->spec;
  4981. int i;
  4982. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4983. for (i = 0; i <= HDA_SIDE; i++) {
  4984. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4985. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4986. if (nid)
  4987. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4988. i);
  4989. }
  4990. }
  4991. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4992. {
  4993. struct alc_spec *spec = codec->spec;
  4994. hda_nid_t pin;
  4995. pin = spec->autocfg.hp_pins[0];
  4996. if (pin) /* connect to front */
  4997. /* use dac 0 */
  4998. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4999. }
  5000. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5001. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5002. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5003. {
  5004. struct alc_spec *spec = codec->spec;
  5005. int i;
  5006. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5007. hda_nid_t nid = spec->autocfg.input_pins[i];
  5008. if (alc882_is_input_pin(nid)) {
  5009. snd_hda_codec_write(codec, nid, 0,
  5010. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5011. i <= AUTO_PIN_FRONT_MIC ?
  5012. PIN_VREF80 : PIN_IN);
  5013. if (nid != ALC882_PIN_CD_NID)
  5014. snd_hda_codec_write(codec, nid, 0,
  5015. AC_VERB_SET_AMP_GAIN_MUTE,
  5016. AMP_OUT_MUTE);
  5017. }
  5018. }
  5019. }
  5020. /* almost identical with ALC880 parser... */
  5021. static int alc882_parse_auto_config(struct hda_codec *codec)
  5022. {
  5023. struct alc_spec *spec = codec->spec;
  5024. int err = alc880_parse_auto_config(codec);
  5025. if (err < 0)
  5026. return err;
  5027. else if (err > 0)
  5028. /* hack - override the init verbs */
  5029. spec->init_verbs[0] = alc882_auto_init_verbs;
  5030. return err;
  5031. }
  5032. /* additional initialization for auto-configuration model */
  5033. static void alc882_auto_init(struct hda_codec *codec)
  5034. {
  5035. alc882_auto_init_multi_out(codec);
  5036. alc882_auto_init_hp_out(codec);
  5037. alc882_auto_init_analog_input(codec);
  5038. }
  5039. static int patch_alc882(struct hda_codec *codec)
  5040. {
  5041. struct alc_spec *spec;
  5042. int err, board_config;
  5043. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5044. if (spec == NULL)
  5045. return -ENOMEM;
  5046. codec->spec = spec;
  5047. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5048. alc882_models,
  5049. alc882_cfg_tbl);
  5050. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5051. /* Pick up systems that don't supply PCI SSID */
  5052. switch (codec->subsystem_id) {
  5053. case 0x106b0c00: /* Mac Pro */
  5054. board_config = ALC885_MACPRO;
  5055. break;
  5056. default:
  5057. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5058. "trying auto-probe from BIOS...\n");
  5059. board_config = ALC882_AUTO;
  5060. }
  5061. }
  5062. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5063. if (board_config == ALC882_AUTO) {
  5064. /* automatic parse from the BIOS config */
  5065. err = alc882_parse_auto_config(codec);
  5066. if (err < 0) {
  5067. alc_free(codec);
  5068. return err;
  5069. } else if (!err) {
  5070. printk(KERN_INFO
  5071. "hda_codec: Cannot set up configuration "
  5072. "from BIOS. Using base mode...\n");
  5073. board_config = ALC882_3ST_DIG;
  5074. }
  5075. }
  5076. if (board_config != ALC882_AUTO)
  5077. setup_preset(spec, &alc882_presets[board_config]);
  5078. if (board_config == ALC885_MACPRO) {
  5079. alc882_gpio_mute(codec, 0, 0);
  5080. alc882_gpio_mute(codec, 1, 0);
  5081. }
  5082. spec->stream_name_analog = "ALC882 Analog";
  5083. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5084. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5085. spec->stream_name_digital = "ALC882 Digital";
  5086. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5087. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5088. if (!spec->adc_nids && spec->input_mux) {
  5089. /* check whether NID 0x07 is valid */
  5090. unsigned int wcap = get_wcaps(codec, 0x07);
  5091. /* get type */
  5092. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5093. if (wcap != AC_WID_AUD_IN) {
  5094. spec->adc_nids = alc882_adc_nids_alt;
  5095. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5096. spec->mixers[spec->num_mixers] =
  5097. alc882_capture_alt_mixer;
  5098. spec->num_mixers++;
  5099. } else {
  5100. spec->adc_nids = alc882_adc_nids;
  5101. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5102. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5103. spec->num_mixers++;
  5104. }
  5105. }
  5106. codec->patch_ops = alc_patch_ops;
  5107. if (board_config == ALC882_AUTO)
  5108. spec->init_hook = alc882_auto_init;
  5109. return 0;
  5110. }
  5111. /*
  5112. * ALC883 support
  5113. *
  5114. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5115. * configuration. Each pin widget can choose any input DACs and a mixer.
  5116. * Each ADC is connected from a mixer of all inputs. This makes possible
  5117. * 6-channel independent captures.
  5118. *
  5119. * In addition, an independent DAC for the multi-playback (not used in this
  5120. * driver yet).
  5121. */
  5122. #define ALC883_DIGOUT_NID 0x06
  5123. #define ALC883_DIGIN_NID 0x0a
  5124. static hda_nid_t alc883_dac_nids[4] = {
  5125. /* front, rear, clfe, rear_surr */
  5126. 0x02, 0x04, 0x03, 0x05
  5127. };
  5128. static hda_nid_t alc883_adc_nids[2] = {
  5129. /* ADC1-2 */
  5130. 0x08, 0x09,
  5131. };
  5132. /* input MUX */
  5133. /* FIXME: should be a matrix-type input source selection */
  5134. static struct hda_input_mux alc883_capture_source = {
  5135. .num_items = 4,
  5136. .items = {
  5137. { "Mic", 0x0 },
  5138. { "Front Mic", 0x1 },
  5139. { "Line", 0x2 },
  5140. { "CD", 0x4 },
  5141. },
  5142. };
  5143. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5144. .num_items = 2,
  5145. .items = {
  5146. { "Mic", 0x1 },
  5147. { "Line", 0x2 },
  5148. },
  5149. };
  5150. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5151. .num_items = 4,
  5152. .items = {
  5153. { "Mic", 0x0 },
  5154. { "iMic", 0x1 },
  5155. { "Line", 0x2 },
  5156. { "CD", 0x4 },
  5157. },
  5158. };
  5159. #define alc883_mux_enum_info alc_mux_enum_info
  5160. #define alc883_mux_enum_get alc_mux_enum_get
  5161. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5162. struct snd_ctl_elem_value *ucontrol)
  5163. {
  5164. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5165. struct alc_spec *spec = codec->spec;
  5166. const struct hda_input_mux *imux = spec->input_mux;
  5167. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5168. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5169. hda_nid_t nid = capture_mixers[adc_idx];
  5170. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5171. unsigned int i, idx;
  5172. idx = ucontrol->value.enumerated.item[0];
  5173. if (idx >= imux->num_items)
  5174. idx = imux->num_items - 1;
  5175. if (*cur_val == idx && !codec->in_resume)
  5176. return 0;
  5177. for (i = 0; i < imux->num_items; i++) {
  5178. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5179. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5180. v | (imux->items[i].index << 8));
  5181. }
  5182. *cur_val = idx;
  5183. return 1;
  5184. }
  5185. /*
  5186. * 2ch mode
  5187. */
  5188. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5189. { 2, NULL }
  5190. };
  5191. /*
  5192. * 2ch mode
  5193. */
  5194. static struct hda_verb alc883_3ST_ch2_init[] = {
  5195. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5196. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5197. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5198. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5199. { } /* end */
  5200. };
  5201. /*
  5202. * 6ch mode
  5203. */
  5204. static struct hda_verb alc883_3ST_ch6_init[] = {
  5205. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5206. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5207. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5208. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5209. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5210. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5211. { } /* end */
  5212. };
  5213. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5214. { 2, alc883_3ST_ch2_init },
  5215. { 6, alc883_3ST_ch6_init },
  5216. };
  5217. /*
  5218. * 6ch mode
  5219. */
  5220. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5221. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5222. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5223. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5224. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5225. { } /* end */
  5226. };
  5227. /*
  5228. * 8ch mode
  5229. */
  5230. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5231. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5232. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5233. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5234. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5235. { } /* end */
  5236. };
  5237. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5238. { 6, alc883_sixstack_ch6_init },
  5239. { 8, alc883_sixstack_ch8_init },
  5240. };
  5241. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5242. /* eanable EAPD on medion laptop */
  5243. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5244. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5245. { }
  5246. };
  5247. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5248. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5249. */
  5250. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5251. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5252. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5253. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5254. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5255. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5256. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5257. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5258. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5259. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5260. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5261. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5262. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5263. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5267. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5268. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5269. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5270. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5271. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5272. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5273. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5274. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5275. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5276. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5277. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5278. {
  5279. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5280. /* .name = "Capture Source", */
  5281. .name = "Input Source",
  5282. .count = 2,
  5283. .info = alc883_mux_enum_info,
  5284. .get = alc883_mux_enum_get,
  5285. .put = alc883_mux_enum_put,
  5286. },
  5287. { } /* end */
  5288. };
  5289. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5290. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5291. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5292. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5294. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5296. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5298. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5299. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5300. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5302. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5304. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5306. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5307. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5308. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5309. {
  5310. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5311. /* .name = "Capture Source", */
  5312. .name = "Input Source",
  5313. .count = 2,
  5314. .info = alc883_mux_enum_info,
  5315. .get = alc883_mux_enum_get,
  5316. .put = alc883_mux_enum_put,
  5317. },
  5318. { } /* end */
  5319. };
  5320. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5321. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5322. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5323. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5324. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5325. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5327. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5328. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5331. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5333. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5335. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5336. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5339. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5341. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5342. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5343. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5344. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5345. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5346. {
  5347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5348. /* .name = "Capture Source", */
  5349. .name = "Input Source",
  5350. .count = 2,
  5351. .info = alc883_mux_enum_info,
  5352. .get = alc883_mux_enum_get,
  5353. .put = alc883_mux_enum_put,
  5354. },
  5355. { } /* end */
  5356. };
  5357. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5358. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5359. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5360. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5361. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5362. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5363. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5364. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5365. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5366. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5367. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5368. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5369. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5370. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5371. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5372. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5373. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5374. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5376. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5377. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5378. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5380. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5381. {
  5382. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5383. /* .name = "Capture Source", */
  5384. .name = "Input Source",
  5385. .count = 1,
  5386. .info = alc883_mux_enum_info,
  5387. .get = alc883_mux_enum_get,
  5388. .put = alc883_mux_enum_put,
  5389. },
  5390. { } /* end */
  5391. };
  5392. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5393. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5394. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5395. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5396. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5397. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5398. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5399. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5400. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5401. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5402. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5403. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5410. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5411. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5412. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5413. {
  5414. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5415. /* .name = "Capture Source", */
  5416. .name = "Input Source",
  5417. .count = 2,
  5418. .info = alc883_mux_enum_info,
  5419. .get = alc883_mux_enum_get,
  5420. .put = alc883_mux_enum_put,
  5421. },
  5422. { } /* end */
  5423. };
  5424. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5425. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5426. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5429. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5434. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5435. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5436. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5437. {
  5438. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5439. /* .name = "Capture Source", */
  5440. .name = "Input Source",
  5441. .count = 2,
  5442. .info = alc883_mux_enum_info,
  5443. .get = alc883_mux_enum_get,
  5444. .put = alc883_mux_enum_put,
  5445. },
  5446. { } /* end */
  5447. };
  5448. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5449. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5450. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5451. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5452. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5454. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5455. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5456. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5457. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5458. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5459. {
  5460. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5461. /* .name = "Capture Source", */
  5462. .name = "Input Source",
  5463. .count = 1,
  5464. .info = alc883_mux_enum_info,
  5465. .get = alc883_mux_enum_get,
  5466. .put = alc883_mux_enum_put,
  5467. },
  5468. { } /* end */
  5469. };
  5470. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5471. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5472. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5473. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5474. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5475. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5476. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5477. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5478. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5479. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5480. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5481. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5482. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5483. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5484. {
  5485. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5486. /* .name = "Capture Source", */
  5487. .name = "Input Source",
  5488. .count = 2,
  5489. .info = alc883_mux_enum_info,
  5490. .get = alc883_mux_enum_get,
  5491. .put = alc883_mux_enum_put,
  5492. },
  5493. { } /* end */
  5494. };
  5495. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5496. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5497. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5498. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5499. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5500. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5501. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5502. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5504. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5505. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5506. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5507. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5508. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5509. {
  5510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5511. /* .name = "Capture Source", */
  5512. .name = "Input Source",
  5513. .count = 2,
  5514. .info = alc883_mux_enum_info,
  5515. .get = alc883_mux_enum_get,
  5516. .put = alc883_mux_enum_put,
  5517. },
  5518. { } /* end */
  5519. };
  5520. static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
  5521. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5522. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5524. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5525. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5526. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5527. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5528. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5530. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5531. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5532. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5533. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5534. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5535. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5536. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5537. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5538. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5539. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5540. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5541. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5542. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5543. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5544. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5545. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5546. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5547. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5548. {
  5549. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5550. /* .name = "Capture Source", */
  5551. .name = "Input Source",
  5552. .count = 2,
  5553. .info = alc883_mux_enum_info,
  5554. .get = alc883_mux_enum_get,
  5555. .put = alc883_mux_enum_put,
  5556. },
  5557. { } /* end */
  5558. };
  5559. static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
  5560. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5561. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5562. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5563. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5564. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5565. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5566. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5567. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5568. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5569. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5570. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5571. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5572. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5573. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5574. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5575. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5577. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5578. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5579. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5580. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5581. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5582. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5583. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5584. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5585. {
  5586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5587. /* .name = "Capture Source", */
  5588. .name = "Input Source",
  5589. .count = 2,
  5590. .info = alc883_mux_enum_info,
  5591. .get = alc883_mux_enum_get,
  5592. .put = alc883_mux_enum_put,
  5593. },
  5594. { } /* end */
  5595. };
  5596. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5597. {
  5598. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5599. .name = "Channel Mode",
  5600. .info = alc_ch_mode_info,
  5601. .get = alc_ch_mode_get,
  5602. .put = alc_ch_mode_put,
  5603. },
  5604. { } /* end */
  5605. };
  5606. static struct hda_verb alc883_init_verbs[] = {
  5607. /* ADC1: mute amp left and right */
  5608. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5609. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5610. /* ADC2: mute amp left and right */
  5611. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5612. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5613. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5614. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5615. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5616. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5617. /* Rear mixer */
  5618. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5619. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5620. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5621. /* CLFE mixer */
  5622. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5623. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5624. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5625. /* Side mixer */
  5626. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5627. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5628. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5634. /* Front Pin: output 0 (0x0c) */
  5635. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5636. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5637. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5638. /* Rear Pin: output 1 (0x0d) */
  5639. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5640. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5641. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5642. /* CLFE Pin: output 2 (0x0e) */
  5643. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5644. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5645. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5646. /* Side Pin: output 3 (0x0f) */
  5647. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5648. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5649. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5650. /* Mic (rear) pin: input vref at 80% */
  5651. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5652. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5653. /* Front Mic pin: input vref at 80% */
  5654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5655. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5656. /* Line In pin: input */
  5657. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5658. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5659. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5660. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5661. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5662. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5663. /* CD pin widget for input */
  5664. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5665. /* FIXME: use matrix-type input source selection */
  5666. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5667. /* Input mixer2 */
  5668. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5670. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5671. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5672. /* Input mixer3 */
  5673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5675. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5676. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5677. { }
  5678. };
  5679. static struct hda_verb alc883_tagra_verbs[] = {
  5680. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5682. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5683. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5684. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5685. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5686. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5687. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5688. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5689. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5690. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5691. { } /* end */
  5692. };
  5693. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5694. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5695. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5696. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5697. { } /* end */
  5698. };
  5699. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5700. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5701. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5702. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5703. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5704. { } /* end */
  5705. };
  5706. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5707. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5709. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5710. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5711. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5712. { } /* end */
  5713. };
  5714. static struct hda_verb alc888_hp_nettle_verbs[] = {
  5715. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5716. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5717. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5718. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5719. { }
  5720. };
  5721. static struct hda_verb alc888_hp_lucknow_verbs[] = {
  5722. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5723. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5724. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5725. { }
  5726. };
  5727. static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
  5728. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5729. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5730. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5731. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5732. { }
  5733. };
  5734. static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
  5735. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5736. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5737. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5738. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5739. { }
  5740. };
  5741. static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
  5742. { 2, alc888_hp_lucknow_2ch_init },
  5743. { 6, alc888_hp_lucknow_6ch_init },
  5744. };
  5745. /* toggle front-jack and RCA according to the hp-jack state */
  5746. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5747. {
  5748. unsigned int present;
  5749. present = snd_hda_codec_read(codec, 0x1b, 0,
  5750. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5751. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5752. 0x80, present ? 0x80 : 0);
  5753. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5754. 0x80, present ? 0x80 : 0);
  5755. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5756. 0x80, present ? 0x80 : 0);
  5757. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5758. 0x80, present ? 0x80 : 0);
  5759. }
  5760. /* toggle RCA according to the front-jack state */
  5761. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5762. {
  5763. unsigned int present;
  5764. present = snd_hda_codec_read(codec, 0x14, 0,
  5765. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5766. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5767. 0x80, present ? 0x80 : 0);
  5768. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5769. 0x80, present ? 0x80 : 0);
  5770. }
  5771. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5772. unsigned int res)
  5773. {
  5774. if ((res >> 26) == ALC880_HP_EVENT)
  5775. alc888_lenovo_ms7195_front_automute(codec);
  5776. if ((res >> 26) == ALC880_FRONT_EVENT)
  5777. alc888_lenovo_ms7195_rca_automute(codec);
  5778. }
  5779. static struct hda_verb alc883_medion_md2_verbs[] = {
  5780. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5781. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5782. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5783. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5784. { } /* end */
  5785. };
  5786. /* toggle speaker-output according to the hp-jack state */
  5787. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5788. {
  5789. unsigned int present;
  5790. present = snd_hda_codec_read(codec, 0x14, 0,
  5791. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5792. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5793. 0x80, present ? 0x80 : 0);
  5794. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5795. 0x80, present ? 0x80 : 0);
  5796. }
  5797. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5798. unsigned int res)
  5799. {
  5800. if ((res >> 26) == ALC880_HP_EVENT)
  5801. alc883_medion_md2_automute(codec);
  5802. }
  5803. /* toggle speaker-output according to the hp-jack state */
  5804. static void alc883_tagra_automute(struct hda_codec *codec)
  5805. {
  5806. unsigned int present;
  5807. unsigned char bits;
  5808. present = snd_hda_codec_read(codec, 0x14, 0,
  5809. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5810. bits = present ? 0x80 : 0;
  5811. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5812. 0x80, bits);
  5813. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5814. 0x80, bits);
  5815. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5816. present ? 1 : 3);
  5817. }
  5818. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5819. {
  5820. if ((res >> 26) == ALC880_HP_EVENT)
  5821. alc883_tagra_automute(codec);
  5822. }
  5823. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5824. {
  5825. unsigned int present;
  5826. unsigned char bits;
  5827. present = snd_hda_codec_read(codec, 0x14, 0,
  5828. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5829. bits = present ? 0x80 : 0;
  5830. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5831. 0x80, bits);
  5832. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5833. 0x80, bits);
  5834. }
  5835. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5836. {
  5837. unsigned int present;
  5838. unsigned char bits;
  5839. present = snd_hda_codec_read(codec, 0x1b, 0,
  5840. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5841. bits = present ? 0x80 : 0;
  5842. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5843. 0x80, bits);
  5844. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5845. 0x80, bits);
  5846. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5847. 0x80, bits);
  5848. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5849. 0x80, bits);
  5850. }
  5851. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5852. unsigned int res)
  5853. {
  5854. if ((res >> 26) == ALC880_HP_EVENT)
  5855. alc883_lenovo_101e_all_automute(codec);
  5856. if ((res >> 26) == ALC880_FRONT_EVENT)
  5857. alc883_lenovo_101e_ispeaker_automute(codec);
  5858. }
  5859. /*
  5860. * generic initialization of ADC, input mixers and output mixers
  5861. */
  5862. static struct hda_verb alc883_auto_init_verbs[] = {
  5863. /*
  5864. * Unmute ADC0-2 and set the default input to mic-in
  5865. */
  5866. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5867. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5868. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5869. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5870. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5871. * mixer widget
  5872. * Note: PASD motherboards uses the Line In 2 as the input for
  5873. * front panel mic (mic 2)
  5874. */
  5875. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5881. /*
  5882. * Set up output mixers (0x0c - 0x0f)
  5883. */
  5884. /* set vol=0 to output mixers */
  5885. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5886. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5887. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5888. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5889. /* set up input amps for analog loopback */
  5890. /* Amp Indices: DAC = 0, mixer = 1 */
  5891. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5892. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5893. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5894. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5895. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5896. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5897. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5898. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5899. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5900. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5901. /* FIXME: use matrix-type input source selection */
  5902. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5903. /* Input mixer1 */
  5904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5905. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5906. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5907. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5908. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5909. /* Input mixer2 */
  5910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5913. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5914. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5915. { }
  5916. };
  5917. /* capture mixer elements */
  5918. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5919. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5920. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5921. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5922. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5923. {
  5924. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5925. /* The multiple "Capture Source" controls confuse alsamixer
  5926. * So call somewhat different..
  5927. * FIXME: the controls appear in the "playback" view!
  5928. */
  5929. /* .name = "Capture Source", */
  5930. .name = "Input Source",
  5931. .count = 2,
  5932. .info = alc882_mux_enum_info,
  5933. .get = alc882_mux_enum_get,
  5934. .put = alc882_mux_enum_put,
  5935. },
  5936. { } /* end */
  5937. };
  5938. /* pcm configuration: identiacal with ALC880 */
  5939. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5940. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5941. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5942. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5943. /*
  5944. * configuration and preset
  5945. */
  5946. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5947. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5948. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5949. [ALC883_3ST_6ch] = "3stack-6ch",
  5950. [ALC883_6ST_DIG] = "6stack-dig",
  5951. [ALC883_TARGA_DIG] = "targa-dig",
  5952. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5953. [ALC883_ACER] = "acer",
  5954. [ALC883_MEDION] = "medion",
  5955. [ALC883_MEDION_MD2] = "medion-md2",
  5956. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5957. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5958. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5959. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5960. [ALC888_HP_NETTLE] = "hp-nettle",
  5961. [ALC888_HP_LUCKNOW] = "hp-lucknow",
  5962. [ALC883_AUTO] = "auto",
  5963. };
  5964. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5965. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5966. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5967. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5968. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5969. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5970. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5971. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5972. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5973. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5974. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5975. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  5976. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5977. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5978. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5979. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5980. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5981. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5982. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5983. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5984. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5985. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5986. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5987. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5988. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5989. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5990. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5991. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5992. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5993. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5994. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5995. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5996. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
  5997. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
  5998. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5999. {}
  6000. };
  6001. static struct alc_config_preset alc883_presets[] = {
  6002. [ALC883_3ST_2ch_DIG] = {
  6003. .mixers = { alc883_3ST_2ch_mixer },
  6004. .init_verbs = { alc883_init_verbs },
  6005. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6006. .dac_nids = alc883_dac_nids,
  6007. .dig_out_nid = ALC883_DIGOUT_NID,
  6008. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6009. .adc_nids = alc883_adc_nids,
  6010. .dig_in_nid = ALC883_DIGIN_NID,
  6011. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6012. .channel_mode = alc883_3ST_2ch_modes,
  6013. .input_mux = &alc883_capture_source,
  6014. },
  6015. [ALC883_3ST_6ch_DIG] = {
  6016. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6017. .init_verbs = { alc883_init_verbs },
  6018. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6019. .dac_nids = alc883_dac_nids,
  6020. .dig_out_nid = ALC883_DIGOUT_NID,
  6021. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6022. .adc_nids = alc883_adc_nids,
  6023. .dig_in_nid = ALC883_DIGIN_NID,
  6024. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6025. .channel_mode = alc883_3ST_6ch_modes,
  6026. .need_dac_fix = 1,
  6027. .input_mux = &alc883_capture_source,
  6028. },
  6029. [ALC883_3ST_6ch] = {
  6030. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6031. .init_verbs = { alc883_init_verbs },
  6032. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6033. .dac_nids = alc883_dac_nids,
  6034. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6035. .adc_nids = alc883_adc_nids,
  6036. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6037. .channel_mode = alc883_3ST_6ch_modes,
  6038. .need_dac_fix = 1,
  6039. .input_mux = &alc883_capture_source,
  6040. },
  6041. [ALC883_6ST_DIG] = {
  6042. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6043. .init_verbs = { alc883_init_verbs },
  6044. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6045. .dac_nids = alc883_dac_nids,
  6046. .dig_out_nid = ALC883_DIGOUT_NID,
  6047. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6048. .adc_nids = alc883_adc_nids,
  6049. .dig_in_nid = ALC883_DIGIN_NID,
  6050. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6051. .channel_mode = alc883_sixstack_modes,
  6052. .input_mux = &alc883_capture_source,
  6053. },
  6054. [ALC883_TARGA_DIG] = {
  6055. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6056. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6057. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6058. .dac_nids = alc883_dac_nids,
  6059. .dig_out_nid = ALC883_DIGOUT_NID,
  6060. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6061. .adc_nids = alc883_adc_nids,
  6062. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6063. .channel_mode = alc883_3ST_6ch_modes,
  6064. .need_dac_fix = 1,
  6065. .input_mux = &alc883_capture_source,
  6066. .unsol_event = alc883_tagra_unsol_event,
  6067. .init_hook = alc883_tagra_automute,
  6068. },
  6069. [ALC883_TARGA_2ch_DIG] = {
  6070. .mixers = { alc883_tagra_2ch_mixer},
  6071. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6072. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6073. .dac_nids = alc883_dac_nids,
  6074. .dig_out_nid = ALC883_DIGOUT_NID,
  6075. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6076. .adc_nids = alc883_adc_nids,
  6077. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6078. .channel_mode = alc883_3ST_2ch_modes,
  6079. .input_mux = &alc883_capture_source,
  6080. .unsol_event = alc883_tagra_unsol_event,
  6081. .init_hook = alc883_tagra_automute,
  6082. },
  6083. [ALC883_ACER] = {
  6084. .mixers = { alc883_base_mixer,
  6085. alc883_chmode_mixer },
  6086. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6087. * and the headphone jack. Turn this on and rely on the
  6088. * standard mute methods whenever the user wants to turn
  6089. * these outputs off.
  6090. */
  6091. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6092. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6093. .dac_nids = alc883_dac_nids,
  6094. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6095. .adc_nids = alc883_adc_nids,
  6096. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6097. .channel_mode = alc883_3ST_2ch_modes,
  6098. .input_mux = &alc883_capture_source,
  6099. },
  6100. [ALC883_MEDION] = {
  6101. .mixers = { alc883_fivestack_mixer,
  6102. alc883_chmode_mixer },
  6103. .init_verbs = { alc883_init_verbs,
  6104. alc883_medion_eapd_verbs },
  6105. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6106. .dac_nids = alc883_dac_nids,
  6107. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6108. .adc_nids = alc883_adc_nids,
  6109. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6110. .channel_mode = alc883_sixstack_modes,
  6111. .input_mux = &alc883_capture_source,
  6112. },
  6113. [ALC883_MEDION_MD2] = {
  6114. .mixers = { alc883_medion_md2_mixer},
  6115. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6116. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6117. .dac_nids = alc883_dac_nids,
  6118. .dig_out_nid = ALC883_DIGOUT_NID,
  6119. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6120. .adc_nids = alc883_adc_nids,
  6121. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6122. .channel_mode = alc883_3ST_2ch_modes,
  6123. .input_mux = &alc883_capture_source,
  6124. .unsol_event = alc883_medion_md2_unsol_event,
  6125. .init_hook = alc883_medion_md2_automute,
  6126. },
  6127. [ALC883_LAPTOP_EAPD] = {
  6128. .mixers = { alc883_base_mixer,
  6129. alc883_chmode_mixer },
  6130. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6131. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6132. .dac_nids = alc883_dac_nids,
  6133. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6134. .adc_nids = alc883_adc_nids,
  6135. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6136. .channel_mode = alc883_3ST_2ch_modes,
  6137. .input_mux = &alc883_capture_source,
  6138. },
  6139. [ALC883_LENOVO_101E_2ch] = {
  6140. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6141. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6142. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6143. .dac_nids = alc883_dac_nids,
  6144. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6145. .adc_nids = alc883_adc_nids,
  6146. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6147. .channel_mode = alc883_3ST_2ch_modes,
  6148. .input_mux = &alc883_lenovo_101e_capture_source,
  6149. .unsol_event = alc883_lenovo_101e_unsol_event,
  6150. .init_hook = alc883_lenovo_101e_all_automute,
  6151. },
  6152. [ALC883_LENOVO_NB0763] = {
  6153. .mixers = { alc883_lenovo_nb0763_mixer },
  6154. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6155. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6156. .dac_nids = alc883_dac_nids,
  6157. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6158. .adc_nids = alc883_adc_nids,
  6159. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6160. .channel_mode = alc883_3ST_2ch_modes,
  6161. .need_dac_fix = 1,
  6162. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6163. .unsol_event = alc883_medion_md2_unsol_event,
  6164. .init_hook = alc883_medion_md2_automute,
  6165. },
  6166. [ALC888_LENOVO_MS7195_DIG] = {
  6167. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6168. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6169. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6170. .dac_nids = alc883_dac_nids,
  6171. .dig_out_nid = ALC883_DIGOUT_NID,
  6172. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6173. .adc_nids = alc883_adc_nids,
  6174. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6175. .channel_mode = alc883_3ST_6ch_modes,
  6176. .need_dac_fix = 1,
  6177. .input_mux = &alc883_capture_source,
  6178. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6179. .init_hook = alc888_lenovo_ms7195_front_automute,
  6180. },
  6181. [ALC888_HP_NETTLE] = {
  6182. .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
  6183. .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
  6184. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6185. .dac_nids = alc883_dac_nids,
  6186. .dig_out_nid = ALC883_DIGOUT_NID,
  6187. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6188. .adc_nids = alc883_adc_nids,
  6189. .dig_in_nid = ALC883_DIGIN_NID,
  6190. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6191. .channel_mode = alc883_sixstack_modes,
  6192. .input_mux = &alc883_capture_source,
  6193. },
  6194. [ALC888_HP_LUCKNOW] = {
  6195. .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
  6196. .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
  6197. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6198. .dac_nids = alc883_dac_nids,
  6199. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6200. .adc_nids = alc883_adc_nids,
  6201. .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
  6202. .channel_mode = alc888_hp_lucknow_modes,
  6203. .need_dac_fix = 1,
  6204. .input_mux = &alc883_capture_source,
  6205. },
  6206. };
  6207. /*
  6208. * BIOS auto configuration
  6209. */
  6210. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6211. hda_nid_t nid, int pin_type,
  6212. int dac_idx)
  6213. {
  6214. /* set as output */
  6215. struct alc_spec *spec = codec->spec;
  6216. int idx;
  6217. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6218. idx = 4;
  6219. else
  6220. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6221. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6222. pin_type);
  6223. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6224. AMP_OUT_UNMUTE);
  6225. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6226. }
  6227. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6228. {
  6229. struct alc_spec *spec = codec->spec;
  6230. int i;
  6231. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6232. for (i = 0; i <= HDA_SIDE; i++) {
  6233. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6234. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6235. if (nid)
  6236. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6237. i);
  6238. }
  6239. }
  6240. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6241. {
  6242. struct alc_spec *spec = codec->spec;
  6243. hda_nid_t pin;
  6244. pin = spec->autocfg.hp_pins[0];
  6245. if (pin) /* connect to front */
  6246. /* use dac 0 */
  6247. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6248. }
  6249. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6250. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6251. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6252. {
  6253. struct alc_spec *spec = codec->spec;
  6254. int i;
  6255. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6256. hda_nid_t nid = spec->autocfg.input_pins[i];
  6257. if (alc883_is_input_pin(nid)) {
  6258. snd_hda_codec_write(codec, nid, 0,
  6259. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6260. (i <= AUTO_PIN_FRONT_MIC ?
  6261. PIN_VREF80 : PIN_IN));
  6262. if (nid != ALC883_PIN_CD_NID)
  6263. snd_hda_codec_write(codec, nid, 0,
  6264. AC_VERB_SET_AMP_GAIN_MUTE,
  6265. AMP_OUT_MUTE);
  6266. }
  6267. }
  6268. }
  6269. /* almost identical with ALC880 parser... */
  6270. static int alc883_parse_auto_config(struct hda_codec *codec)
  6271. {
  6272. struct alc_spec *spec = codec->spec;
  6273. int err = alc880_parse_auto_config(codec);
  6274. if (err < 0)
  6275. return err;
  6276. else if (err > 0)
  6277. /* hack - override the init verbs */
  6278. spec->init_verbs[0] = alc883_auto_init_verbs;
  6279. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6280. spec->num_mixers++;
  6281. return err;
  6282. }
  6283. /* additional initialization for auto-configuration model */
  6284. static void alc883_auto_init(struct hda_codec *codec)
  6285. {
  6286. alc883_auto_init_multi_out(codec);
  6287. alc883_auto_init_hp_out(codec);
  6288. alc883_auto_init_analog_input(codec);
  6289. }
  6290. static int patch_alc883(struct hda_codec *codec)
  6291. {
  6292. struct alc_spec *spec;
  6293. int err, board_config;
  6294. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6295. if (spec == NULL)
  6296. return -ENOMEM;
  6297. codec->spec = spec;
  6298. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6299. alc883_models,
  6300. alc883_cfg_tbl);
  6301. if (board_config < 0) {
  6302. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6303. "trying auto-probe from BIOS...\n");
  6304. board_config = ALC883_AUTO;
  6305. }
  6306. if (board_config == ALC883_AUTO) {
  6307. /* automatic parse from the BIOS config */
  6308. err = alc883_parse_auto_config(codec);
  6309. if (err < 0) {
  6310. alc_free(codec);
  6311. return err;
  6312. } else if (!err) {
  6313. printk(KERN_INFO
  6314. "hda_codec: Cannot set up configuration "
  6315. "from BIOS. Using base mode...\n");
  6316. board_config = ALC883_3ST_2ch_DIG;
  6317. }
  6318. }
  6319. if (board_config != ALC883_AUTO)
  6320. setup_preset(spec, &alc883_presets[board_config]);
  6321. spec->stream_name_analog = "ALC883 Analog";
  6322. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6323. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6324. spec->stream_name_digital = "ALC883 Digital";
  6325. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6326. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6327. if (!spec->adc_nids && spec->input_mux) {
  6328. spec->adc_nids = alc883_adc_nids;
  6329. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6330. }
  6331. codec->patch_ops = alc_patch_ops;
  6332. if (board_config == ALC883_AUTO)
  6333. spec->init_hook = alc883_auto_init;
  6334. return 0;
  6335. }
  6336. /*
  6337. * ALC262 support
  6338. */
  6339. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6340. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6341. #define alc262_dac_nids alc260_dac_nids
  6342. #define alc262_adc_nids alc882_adc_nids
  6343. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6344. #define alc262_modes alc260_modes
  6345. #define alc262_capture_source alc882_capture_source
  6346. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6347. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6348. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6349. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6350. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6351. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6352. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6353. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6354. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6355. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6356. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6357. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6358. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6359. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6360. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6361. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6362. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6363. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6364. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6365. { } /* end */
  6366. };
  6367. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6368. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6369. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6370. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6371. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6372. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6373. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6374. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6375. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6376. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6377. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6378. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6379. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6380. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6381. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6382. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6383. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6384. { } /* end */
  6385. };
  6386. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6387. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6388. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6389. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6390. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6391. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6392. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6393. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6394. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6395. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6396. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6397. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6398. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6399. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6400. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6401. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6402. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6403. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6404. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6405. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6406. { } /* end */
  6407. };
  6408. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6409. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6410. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6411. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6412. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6413. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6414. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6415. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6416. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6417. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6418. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6419. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6420. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6421. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6422. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6423. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6424. { } /* end */
  6425. };
  6426. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6427. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6428. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6429. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6430. { } /* end */
  6431. };
  6432. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6433. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6434. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6435. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6436. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6437. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6438. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6439. { } /* end */
  6440. };
  6441. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6442. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6443. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6444. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6445. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6446. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6447. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6448. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6449. { } /* end */
  6450. };
  6451. #define alc262_capture_mixer alc882_capture_mixer
  6452. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6453. /*
  6454. * generic initialization of ADC, input mixers and output mixers
  6455. */
  6456. static struct hda_verb alc262_init_verbs[] = {
  6457. /*
  6458. * Unmute ADC0-2 and set the default input to mic-in
  6459. */
  6460. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6461. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6462. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6463. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6464. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6465. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6466. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6467. * mixer widget
  6468. * Note: PASD motherboards uses the Line In 2 as the input for
  6469. * front panel mic (mic 2)
  6470. */
  6471. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6472. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6473. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6474. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6475. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6476. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6477. /*
  6478. * Set up output mixers (0x0c - 0x0e)
  6479. */
  6480. /* set vol=0 to output mixers */
  6481. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6482. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6483. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6484. /* set up input amps for analog loopback */
  6485. /* Amp Indices: DAC = 0, mixer = 1 */
  6486. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6487. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6488. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6489. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6490. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6491. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6492. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6493. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6494. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6495. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6496. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6497. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6500. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6501. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6502. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6503. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6504. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6505. /* FIXME: use matrix-type input source selection */
  6506. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6507. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6511. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6512. /* Input mixer2 */
  6513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6517. /* Input mixer3 */
  6518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6522. { }
  6523. };
  6524. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6525. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6526. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6527. {}
  6528. };
  6529. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6530. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6531. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6532. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6533. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6534. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6535. {}
  6536. };
  6537. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6538. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6539. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6540. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6541. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6542. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6543. };
  6544. /* mute/unmute internal speaker according to the hp jack and mute state */
  6545. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6546. {
  6547. struct alc_spec *spec = codec->spec;
  6548. unsigned int mute;
  6549. if (force || !spec->sense_updated) {
  6550. unsigned int present;
  6551. /* need to execute and sync at first */
  6552. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6553. present = snd_hda_codec_read(codec, 0x15, 0,
  6554. AC_VERB_GET_PIN_SENSE, 0);
  6555. spec->jack_present = (present & 0x80000000) != 0;
  6556. spec->sense_updated = 1;
  6557. }
  6558. if (spec->jack_present) {
  6559. /* mute internal speaker */
  6560. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6561. 0x80, 0x80);
  6562. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6563. 0x80, 0x80);
  6564. } else {
  6565. /* unmute internal speaker if necessary */
  6566. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6567. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6568. 0x80, mute & 0x80);
  6569. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6570. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6571. 0x80, mute & 0x80);
  6572. }
  6573. }
  6574. /* unsolicited event for HP jack sensing */
  6575. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6576. unsigned int res)
  6577. {
  6578. if ((res >> 26) != ALC880_HP_EVENT)
  6579. return;
  6580. alc262_hippo_automute(codec, 1);
  6581. }
  6582. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6583. {
  6584. struct alc_spec *spec = codec->spec;
  6585. unsigned int mute;
  6586. if (force || !spec->sense_updated) {
  6587. unsigned int present;
  6588. /* need to execute and sync at first */
  6589. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6590. present = snd_hda_codec_read(codec, 0x1b, 0,
  6591. AC_VERB_GET_PIN_SENSE, 0);
  6592. spec->jack_present = (present & 0x80000000) != 0;
  6593. spec->sense_updated = 1;
  6594. }
  6595. if (spec->jack_present) {
  6596. /* mute internal speaker */
  6597. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6598. 0x80, 0x80);
  6599. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6600. 0x80, 0x80);
  6601. } else {
  6602. /* unmute internal speaker if necessary */
  6603. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6604. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6605. 0x80, mute & 0x80);
  6606. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6607. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6608. 0x80, mute & 0x80);
  6609. }
  6610. }
  6611. /* unsolicited event for HP jack sensing */
  6612. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6613. unsigned int res)
  6614. {
  6615. if ((res >> 26) != ALC880_HP_EVENT)
  6616. return;
  6617. alc262_hippo1_automute(codec, 1);
  6618. }
  6619. /*
  6620. * fujitsu model
  6621. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6622. */
  6623. #define ALC_HP_EVENT 0x37
  6624. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6625. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6626. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6627. {}
  6628. };
  6629. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6630. .num_items = 2,
  6631. .items = {
  6632. { "Mic", 0x0 },
  6633. { "CD", 0x4 },
  6634. },
  6635. };
  6636. static struct hda_input_mux alc262_HP_capture_source = {
  6637. .num_items = 5,
  6638. .items = {
  6639. { "Mic", 0x0 },
  6640. { "Front Mic", 0x3 },
  6641. { "Line", 0x2 },
  6642. { "CD", 0x4 },
  6643. { "AUX IN", 0x6 },
  6644. },
  6645. };
  6646. /* mute/unmute internal speaker according to the hp jack and mute state */
  6647. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6648. {
  6649. struct alc_spec *spec = codec->spec;
  6650. unsigned int mute;
  6651. if (force || !spec->sense_updated) {
  6652. unsigned int present;
  6653. /* need to execute and sync at first */
  6654. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6655. present = snd_hda_codec_read(codec, 0x14, 0,
  6656. AC_VERB_GET_PIN_SENSE, 0);
  6657. spec->jack_present = (present & 0x80000000) != 0;
  6658. spec->sense_updated = 1;
  6659. }
  6660. if (spec->jack_present) {
  6661. /* mute internal speaker */
  6662. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6663. 0x80, 0x80);
  6664. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6665. 0x80, 0x80);
  6666. } else {
  6667. /* unmute internal speaker if necessary */
  6668. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6669. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6670. 0x80, mute & 0x80);
  6671. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6672. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6673. 0x80, mute & 0x80);
  6674. }
  6675. }
  6676. /* unsolicited event for HP jack sensing */
  6677. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6678. unsigned int res)
  6679. {
  6680. if ((res >> 26) != ALC_HP_EVENT)
  6681. return;
  6682. alc262_fujitsu_automute(codec, 1);
  6683. }
  6684. /* bind volumes of both NID 0x0c and 0x0d */
  6685. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6686. struct snd_ctl_elem_value *ucontrol)
  6687. {
  6688. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6689. long *valp = ucontrol->value.integer.value;
  6690. int change;
  6691. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6692. 0x7f, valp[0] & 0x7f);
  6693. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6694. 0x7f, valp[1] & 0x7f);
  6695. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6696. 0x7f, valp[0] & 0x7f);
  6697. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6698. 0x7f, valp[1] & 0x7f);
  6699. return change;
  6700. }
  6701. /* bind hp and internal speaker mute (with plug check) */
  6702. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6703. struct snd_ctl_elem_value *ucontrol)
  6704. {
  6705. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6706. long *valp = ucontrol->value.integer.value;
  6707. int change;
  6708. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6709. 0x80, valp[0] ? 0 : 0x80);
  6710. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6711. 0x80, valp[1] ? 0 : 0x80);
  6712. if (change || codec->in_resume)
  6713. alc262_fujitsu_automute(codec, codec->in_resume);
  6714. return change;
  6715. }
  6716. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6717. {
  6718. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6719. .name = "Master Playback Volume",
  6720. .info = snd_hda_mixer_amp_volume_info,
  6721. .get = snd_hda_mixer_amp_volume_get,
  6722. .put = alc262_fujitsu_master_vol_put,
  6723. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6724. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6725. },
  6726. {
  6727. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6728. .name = "Master Playback Switch",
  6729. .info = snd_hda_mixer_amp_switch_info,
  6730. .get = snd_hda_mixer_amp_switch_get,
  6731. .put = alc262_fujitsu_master_sw_put,
  6732. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6733. },
  6734. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6735. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6736. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6737. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6738. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6739. { } /* end */
  6740. };
  6741. /* additional init verbs for Benq laptops */
  6742. static struct hda_verb alc262_EAPD_verbs[] = {
  6743. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6744. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6745. {}
  6746. };
  6747. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6748. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6749. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6750. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6751. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6752. {}
  6753. };
  6754. /* add playback controls from the parsed DAC table */
  6755. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6756. const struct auto_pin_cfg *cfg)
  6757. {
  6758. hda_nid_t nid;
  6759. int err;
  6760. spec->multiout.num_dacs = 1; /* only use one dac */
  6761. spec->multiout.dac_nids = spec->private_dac_nids;
  6762. spec->multiout.dac_nids[0] = 2;
  6763. nid = cfg->line_out_pins[0];
  6764. if (nid) {
  6765. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6766. "Front Playback Volume",
  6767. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6768. if (err < 0)
  6769. return err;
  6770. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6771. "Front Playback Switch",
  6772. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6773. if (err < 0)
  6774. return err;
  6775. }
  6776. nid = cfg->speaker_pins[0];
  6777. if (nid) {
  6778. if (nid == 0x16) {
  6779. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6780. "Speaker Playback Volume",
  6781. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6782. HDA_OUTPUT));
  6783. if (err < 0)
  6784. return err;
  6785. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6786. "Speaker Playback Switch",
  6787. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6788. HDA_OUTPUT));
  6789. if (err < 0)
  6790. return err;
  6791. } else {
  6792. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6793. "Speaker Playback Switch",
  6794. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6795. HDA_OUTPUT));
  6796. if (err < 0)
  6797. return err;
  6798. }
  6799. }
  6800. nid = cfg->hp_pins[0];
  6801. if (nid) {
  6802. /* spec->multiout.hp_nid = 2; */
  6803. if (nid == 0x16) {
  6804. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6805. "Headphone Playback Volume",
  6806. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6807. HDA_OUTPUT));
  6808. if (err < 0)
  6809. return err;
  6810. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6811. "Headphone Playback Switch",
  6812. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6813. HDA_OUTPUT));
  6814. if (err < 0)
  6815. return err;
  6816. } else {
  6817. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6818. "Headphone Playback Switch",
  6819. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6820. HDA_OUTPUT));
  6821. if (err < 0)
  6822. return err;
  6823. }
  6824. }
  6825. return 0;
  6826. }
  6827. /* identical with ALC880 */
  6828. #define alc262_auto_create_analog_input_ctls \
  6829. alc880_auto_create_analog_input_ctls
  6830. /*
  6831. * generic initialization of ADC, input mixers and output mixers
  6832. */
  6833. static struct hda_verb alc262_volume_init_verbs[] = {
  6834. /*
  6835. * Unmute ADC0-2 and set the default input to mic-in
  6836. */
  6837. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6838. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6839. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6840. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6841. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6842. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6843. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6844. * mixer widget
  6845. * Note: PASD motherboards uses the Line In 2 as the input for
  6846. * front panel mic (mic 2)
  6847. */
  6848. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6849. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6850. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6852. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6853. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6854. /*
  6855. * Set up output mixers (0x0c - 0x0f)
  6856. */
  6857. /* set vol=0 to output mixers */
  6858. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6859. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6860. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6861. /* set up input amps for analog loopback */
  6862. /* Amp Indices: DAC = 0, mixer = 1 */
  6863. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6864. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6865. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6866. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6867. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6868. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6869. /* FIXME: use matrix-type input source selection */
  6870. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6871. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6872. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6873. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6874. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6875. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6876. /* Input mixer2 */
  6877. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6878. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6879. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6880. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6881. /* Input mixer3 */
  6882. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6883. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6884. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6885. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6886. { }
  6887. };
  6888. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6889. /*
  6890. * Unmute ADC0-2 and set the default input to mic-in
  6891. */
  6892. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6893. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6894. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6895. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6896. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6897. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6898. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6899. * mixer widget
  6900. * Note: PASD motherboards uses the Line In 2 as the input for
  6901. * front panel mic (mic 2)
  6902. */
  6903. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6904. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6905. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6906. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6907. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6908. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6909. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6910. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6911. /*
  6912. * Set up output mixers (0x0c - 0x0e)
  6913. */
  6914. /* set vol=0 to output mixers */
  6915. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6916. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6917. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6918. /* set up input amps for analog loopback */
  6919. /* Amp Indices: DAC = 0, mixer = 1 */
  6920. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6921. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6922. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6923. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6924. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6925. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6926. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6927. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6928. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6929. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6930. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6931. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6932. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6933. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6934. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6935. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6936. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6937. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6938. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6939. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6940. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6941. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6942. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6943. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6944. /* FIXME: use matrix-type input source selection */
  6945. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6946. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6947. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6949. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6950. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6951. /* Input mixer2 */
  6952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6954. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6955. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6956. /* Input mixer3 */
  6957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6960. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6961. { }
  6962. };
  6963. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6964. /*
  6965. * Unmute ADC0-2 and set the default input to mic-in
  6966. */
  6967. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6968. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6969. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6970. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6971. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6972. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6973. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6974. * mixer widget
  6975. * Note: PASD motherboards uses the Line In 2 as the input for front
  6976. * panel mic (mic 2)
  6977. */
  6978. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6980. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6982. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6985. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6986. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6987. /*
  6988. * Set up output mixers (0x0c - 0x0e)
  6989. */
  6990. /* set vol=0 to output mixers */
  6991. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6992. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6993. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6994. /* set up input amps for analog loopback */
  6995. /* Amp Indices: DAC = 0, mixer = 1 */
  6996. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6997. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6998. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6999. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7000. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7001. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7002. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7003. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7004. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7005. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7006. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7007. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7008. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7009. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7010. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7011. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7012. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7013. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7014. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7015. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7016. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7017. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7018. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7019. /* FIXME: use matrix-type input source selection */
  7020. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7021. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7022. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7023. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7024. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7025. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7026. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7027. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7028. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7029. /* Input mixer2 */
  7030. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7031. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7032. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7033. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7034. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7035. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7036. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7037. /* Input mixer3 */
  7038. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7041. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7042. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7043. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7044. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7045. { }
  7046. };
  7047. /* pcm configuration: identiacal with ALC880 */
  7048. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7049. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7050. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7051. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7052. /*
  7053. * BIOS auto configuration
  7054. */
  7055. static int alc262_parse_auto_config(struct hda_codec *codec)
  7056. {
  7057. struct alc_spec *spec = codec->spec;
  7058. int err;
  7059. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7060. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7061. alc262_ignore);
  7062. if (err < 0)
  7063. return err;
  7064. if (!spec->autocfg.line_outs)
  7065. return 0; /* can't find valid BIOS pin config */
  7066. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7067. if (err < 0)
  7068. return err;
  7069. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7070. if (err < 0)
  7071. return err;
  7072. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7073. if (spec->autocfg.dig_out_pin)
  7074. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7075. if (spec->autocfg.dig_in_pin)
  7076. spec->dig_in_nid = ALC262_DIGIN_NID;
  7077. if (spec->kctl_alloc)
  7078. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7079. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7080. spec->num_mux_defs = 1;
  7081. spec->input_mux = &spec->private_imux;
  7082. return 1;
  7083. }
  7084. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7085. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7086. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7087. /* init callback for auto-configuration model -- overriding the default init */
  7088. static void alc262_auto_init(struct hda_codec *codec)
  7089. {
  7090. alc262_auto_init_multi_out(codec);
  7091. alc262_auto_init_hp_out(codec);
  7092. alc262_auto_init_analog_input(codec);
  7093. }
  7094. /*
  7095. * configuration and preset
  7096. */
  7097. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7098. [ALC262_BASIC] = "basic",
  7099. [ALC262_HIPPO] = "hippo",
  7100. [ALC262_HIPPO_1] = "hippo_1",
  7101. [ALC262_FUJITSU] = "fujitsu",
  7102. [ALC262_HP_BPC] = "hp-bpc",
  7103. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7104. [ALC262_BENQ_ED8] = "benq",
  7105. [ALC262_BENQ_T31] = "benq-t31",
  7106. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7107. [ALC262_AUTO] = "auto",
  7108. };
  7109. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7110. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7111. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7112. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7113. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7114. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7115. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7116. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7117. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7118. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7119. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7120. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7121. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7122. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7123. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7124. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7125. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7126. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7127. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7128. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7129. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7130. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7131. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7132. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7133. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7134. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7135. {}
  7136. };
  7137. static struct alc_config_preset alc262_presets[] = {
  7138. [ALC262_BASIC] = {
  7139. .mixers = { alc262_base_mixer },
  7140. .init_verbs = { alc262_init_verbs },
  7141. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7142. .dac_nids = alc262_dac_nids,
  7143. .hp_nid = 0x03,
  7144. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7145. .channel_mode = alc262_modes,
  7146. .input_mux = &alc262_capture_source,
  7147. },
  7148. [ALC262_HIPPO] = {
  7149. .mixers = { alc262_base_mixer },
  7150. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7151. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7152. .dac_nids = alc262_dac_nids,
  7153. .hp_nid = 0x03,
  7154. .dig_out_nid = ALC262_DIGOUT_NID,
  7155. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7156. .channel_mode = alc262_modes,
  7157. .input_mux = &alc262_capture_source,
  7158. .unsol_event = alc262_hippo_unsol_event,
  7159. },
  7160. [ALC262_HIPPO_1] = {
  7161. .mixers = { alc262_hippo1_mixer },
  7162. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7163. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7164. .dac_nids = alc262_dac_nids,
  7165. .hp_nid = 0x02,
  7166. .dig_out_nid = ALC262_DIGOUT_NID,
  7167. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7168. .channel_mode = alc262_modes,
  7169. .input_mux = &alc262_capture_source,
  7170. .unsol_event = alc262_hippo1_unsol_event,
  7171. },
  7172. [ALC262_FUJITSU] = {
  7173. .mixers = { alc262_fujitsu_mixer },
  7174. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7175. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7176. .dac_nids = alc262_dac_nids,
  7177. .hp_nid = 0x03,
  7178. .dig_out_nid = ALC262_DIGOUT_NID,
  7179. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7180. .channel_mode = alc262_modes,
  7181. .input_mux = &alc262_fujitsu_capture_source,
  7182. .unsol_event = alc262_fujitsu_unsol_event,
  7183. },
  7184. [ALC262_HP_BPC] = {
  7185. .mixers = { alc262_HP_BPC_mixer },
  7186. .init_verbs = { alc262_HP_BPC_init_verbs },
  7187. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7188. .dac_nids = alc262_dac_nids,
  7189. .hp_nid = 0x03,
  7190. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7191. .channel_mode = alc262_modes,
  7192. .input_mux = &alc262_HP_capture_source,
  7193. },
  7194. [ALC262_HP_BPC_D7000_WF] = {
  7195. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7196. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7197. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7198. .dac_nids = alc262_dac_nids,
  7199. .hp_nid = 0x03,
  7200. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7201. .channel_mode = alc262_modes,
  7202. .input_mux = &alc262_HP_capture_source,
  7203. },
  7204. [ALC262_HP_BPC_D7000_WL] = {
  7205. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7206. alc262_HP_BPC_WildWest_option_mixer },
  7207. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7208. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7209. .dac_nids = alc262_dac_nids,
  7210. .hp_nid = 0x03,
  7211. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7212. .channel_mode = alc262_modes,
  7213. .input_mux = &alc262_HP_capture_source,
  7214. },
  7215. [ALC262_BENQ_ED8] = {
  7216. .mixers = { alc262_base_mixer },
  7217. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7218. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7219. .dac_nids = alc262_dac_nids,
  7220. .hp_nid = 0x03,
  7221. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7222. .channel_mode = alc262_modes,
  7223. .input_mux = &alc262_capture_source,
  7224. },
  7225. [ALC262_SONY_ASSAMD] = {
  7226. .mixers = { alc262_sony_mixer },
  7227. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7228. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7229. .dac_nids = alc262_dac_nids,
  7230. .hp_nid = 0x02,
  7231. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7232. .channel_mode = alc262_modes,
  7233. .input_mux = &alc262_capture_source,
  7234. .unsol_event = alc262_hippo_unsol_event,
  7235. },
  7236. [ALC262_BENQ_T31] = {
  7237. .mixers = { alc262_benq_t31_mixer },
  7238. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7239. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7240. .dac_nids = alc262_dac_nids,
  7241. .hp_nid = 0x03,
  7242. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7243. .channel_mode = alc262_modes,
  7244. .input_mux = &alc262_capture_source,
  7245. .unsol_event = alc262_hippo_unsol_event,
  7246. },
  7247. };
  7248. static int patch_alc262(struct hda_codec *codec)
  7249. {
  7250. struct alc_spec *spec;
  7251. int board_config;
  7252. int err;
  7253. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7254. if (spec == NULL)
  7255. return -ENOMEM;
  7256. codec->spec = spec;
  7257. #if 0
  7258. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7259. * under-run
  7260. */
  7261. {
  7262. int tmp;
  7263. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7264. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7265. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7266. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7267. }
  7268. #endif
  7269. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7270. alc262_models,
  7271. alc262_cfg_tbl);
  7272. if (board_config < 0) {
  7273. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7274. "trying auto-probe from BIOS...\n");
  7275. board_config = ALC262_AUTO;
  7276. }
  7277. if (board_config == ALC262_AUTO) {
  7278. /* automatic parse from the BIOS config */
  7279. err = alc262_parse_auto_config(codec);
  7280. if (err < 0) {
  7281. alc_free(codec);
  7282. return err;
  7283. } else if (!err) {
  7284. printk(KERN_INFO
  7285. "hda_codec: Cannot set up configuration "
  7286. "from BIOS. Using base mode...\n");
  7287. board_config = ALC262_BASIC;
  7288. }
  7289. }
  7290. if (board_config != ALC262_AUTO)
  7291. setup_preset(spec, &alc262_presets[board_config]);
  7292. spec->stream_name_analog = "ALC262 Analog";
  7293. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7294. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7295. spec->stream_name_digital = "ALC262 Digital";
  7296. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7297. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7298. if (!spec->adc_nids && spec->input_mux) {
  7299. /* check whether NID 0x07 is valid */
  7300. unsigned int wcap = get_wcaps(codec, 0x07);
  7301. /* get type */
  7302. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7303. if (wcap != AC_WID_AUD_IN) {
  7304. spec->adc_nids = alc262_adc_nids_alt;
  7305. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7306. spec->mixers[spec->num_mixers] =
  7307. alc262_capture_alt_mixer;
  7308. spec->num_mixers++;
  7309. } else {
  7310. spec->adc_nids = alc262_adc_nids;
  7311. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7312. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7313. spec->num_mixers++;
  7314. }
  7315. }
  7316. codec->patch_ops = alc_patch_ops;
  7317. if (board_config == ALC262_AUTO)
  7318. spec->init_hook = alc262_auto_init;
  7319. return 0;
  7320. }
  7321. /*
  7322. * ALC268 channel source setting (2 channel)
  7323. */
  7324. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7325. #define alc268_modes alc260_modes
  7326. static hda_nid_t alc268_dac_nids[2] = {
  7327. /* front, hp */
  7328. 0x02, 0x03
  7329. };
  7330. static hda_nid_t alc268_adc_nids[2] = {
  7331. /* ADC0-1 */
  7332. 0x08, 0x07
  7333. };
  7334. static hda_nid_t alc268_adc_nids_alt[1] = {
  7335. /* ADC0 */
  7336. 0x08
  7337. };
  7338. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7339. /* output mixer control */
  7340. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7341. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7342. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7343. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7344. { }
  7345. };
  7346. /*
  7347. * generic initialization of ADC, input mixers and output mixers
  7348. */
  7349. static struct hda_verb alc268_base_init_verbs[] = {
  7350. /* Unmute DAC0-1 and set vol = 0 */
  7351. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7352. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7353. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7354. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7355. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7356. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7357. /*
  7358. * Set up output mixers (0x0c - 0x0e)
  7359. */
  7360. /* set vol=0 to output mixers */
  7361. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7362. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7363. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7364. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7365. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7366. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7367. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7368. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7369. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7370. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7371. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7372. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7373. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7374. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7375. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7378. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7379. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7380. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7381. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7382. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7383. /* FIXME: use matrix-type input source selection */
  7384. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7385. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7386. /* Input mixer2 */
  7387. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7388. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7389. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7390. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7391. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7394. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7395. { }
  7396. };
  7397. /*
  7398. * generic initialization of ADC, input mixers and output mixers
  7399. */
  7400. static struct hda_verb alc268_volume_init_verbs[] = {
  7401. /* set output DAC */
  7402. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7403. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7404. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7405. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7406. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7407. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7408. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7409. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7410. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7411. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7412. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7413. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7414. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7415. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7416. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7417. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7418. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7419. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7420. /* set PCBEEP vol = 0 */
  7421. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7422. { }
  7423. };
  7424. #define alc268_mux_enum_info alc_mux_enum_info
  7425. #define alc268_mux_enum_get alc_mux_enum_get
  7426. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7427. struct snd_ctl_elem_value *ucontrol)
  7428. {
  7429. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7430. struct alc_spec *spec = codec->spec;
  7431. const struct hda_input_mux *imux = spec->input_mux;
  7432. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7433. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7434. hda_nid_t nid = capture_mixers[adc_idx];
  7435. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7436. unsigned int i, idx;
  7437. idx = ucontrol->value.enumerated.item[0];
  7438. if (idx >= imux->num_items)
  7439. idx = imux->num_items - 1;
  7440. if (*cur_val == idx && !codec->in_resume)
  7441. return 0;
  7442. for (i = 0; i < imux->num_items; i++) {
  7443. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7444. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7445. v | (imux->items[i].index << 8));
  7446. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7447. idx );
  7448. }
  7449. *cur_val = idx;
  7450. return 1;
  7451. }
  7452. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7453. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7454. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7455. {
  7456. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7457. /* The multiple "Capture Source" controls confuse alsamixer
  7458. * So call somewhat different..
  7459. * FIXME: the controls appear in the "playback" view!
  7460. */
  7461. /* .name = "Capture Source", */
  7462. .name = "Input Source",
  7463. .count = 1,
  7464. .info = alc268_mux_enum_info,
  7465. .get = alc268_mux_enum_get,
  7466. .put = alc268_mux_enum_put,
  7467. },
  7468. { } /* end */
  7469. };
  7470. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7471. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7472. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7473. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7474. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7475. {
  7476. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7477. /* The multiple "Capture Source" controls confuse alsamixer
  7478. * So call somewhat different..
  7479. * FIXME: the controls appear in the "playback" view!
  7480. */
  7481. /* .name = "Capture Source", */
  7482. .name = "Input Source",
  7483. .count = 2,
  7484. .info = alc268_mux_enum_info,
  7485. .get = alc268_mux_enum_get,
  7486. .put = alc268_mux_enum_put,
  7487. },
  7488. { } /* end */
  7489. };
  7490. static struct hda_input_mux alc268_capture_source = {
  7491. .num_items = 4,
  7492. .items = {
  7493. { "Mic", 0x0 },
  7494. { "Front Mic", 0x1 },
  7495. { "Line", 0x2 },
  7496. { "CD", 0x3 },
  7497. },
  7498. };
  7499. /* create input playback/capture controls for the given pin */
  7500. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7501. const char *ctlname, int idx)
  7502. {
  7503. char name[32];
  7504. int err;
  7505. sprintf(name, "%s Playback Volume", ctlname);
  7506. if (nid == 0x14) {
  7507. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7508. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7509. HDA_OUTPUT));
  7510. if (err < 0)
  7511. return err;
  7512. } else if (nid == 0x15) {
  7513. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7514. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7515. HDA_OUTPUT));
  7516. if (err < 0)
  7517. return err;
  7518. } else
  7519. return -1;
  7520. sprintf(name, "%s Playback Switch", ctlname);
  7521. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7522. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7523. if (err < 0)
  7524. return err;
  7525. return 0;
  7526. }
  7527. /* add playback controls from the parsed DAC table */
  7528. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7529. const struct auto_pin_cfg *cfg)
  7530. {
  7531. hda_nid_t nid;
  7532. int err;
  7533. spec->multiout.num_dacs = 2; /* only use one dac */
  7534. spec->multiout.dac_nids = spec->private_dac_nids;
  7535. spec->multiout.dac_nids[0] = 2;
  7536. spec->multiout.dac_nids[1] = 3;
  7537. nid = cfg->line_out_pins[0];
  7538. if (nid)
  7539. alc268_new_analog_output(spec, nid, "Front", 0);
  7540. nid = cfg->speaker_pins[0];
  7541. if (nid == 0x1d) {
  7542. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7543. "Speaker Playback Volume",
  7544. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7545. if (err < 0)
  7546. return err;
  7547. }
  7548. nid = cfg->hp_pins[0];
  7549. if (nid)
  7550. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7551. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7552. if (nid == 0x16) {
  7553. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7554. "Mono Playback Switch",
  7555. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7556. if (err < 0)
  7557. return err;
  7558. }
  7559. return 0;
  7560. }
  7561. /* create playback/capture controls for input pins */
  7562. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7563. const struct auto_pin_cfg *cfg)
  7564. {
  7565. struct hda_input_mux *imux = &spec->private_imux;
  7566. int i, idx1;
  7567. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7568. switch(cfg->input_pins[i]) {
  7569. case 0x18:
  7570. idx1 = 0; /* Mic 1 */
  7571. break;
  7572. case 0x19:
  7573. idx1 = 1; /* Mic 2 */
  7574. break;
  7575. case 0x1a:
  7576. idx1 = 2; /* Line In */
  7577. break;
  7578. case 0x1c:
  7579. idx1 = 3; /* CD */
  7580. break;
  7581. default:
  7582. continue;
  7583. }
  7584. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7585. imux->items[imux->num_items].index = idx1;
  7586. imux->num_items++;
  7587. }
  7588. return 0;
  7589. }
  7590. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7591. {
  7592. struct alc_spec *spec = codec->spec;
  7593. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7594. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7595. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7596. unsigned int dac_vol1, dac_vol2;
  7597. if (speaker_nid) {
  7598. snd_hda_codec_write(codec, speaker_nid, 0,
  7599. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7600. snd_hda_codec_write(codec, 0x0f, 0,
  7601. AC_VERB_SET_AMP_GAIN_MUTE,
  7602. AMP_IN_UNMUTE(1));
  7603. snd_hda_codec_write(codec, 0x10, 0,
  7604. AC_VERB_SET_AMP_GAIN_MUTE,
  7605. AMP_IN_UNMUTE(1));
  7606. } else {
  7607. snd_hda_codec_write(codec, 0x0f, 0,
  7608. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7609. snd_hda_codec_write(codec, 0x10, 0,
  7610. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7611. }
  7612. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7613. if (line_nid == 0x14)
  7614. dac_vol2 = AMP_OUT_ZERO;
  7615. else if (line_nid == 0x15)
  7616. dac_vol1 = AMP_OUT_ZERO;
  7617. if (hp_nid == 0x14)
  7618. dac_vol2 = AMP_OUT_ZERO;
  7619. else if (hp_nid == 0x15)
  7620. dac_vol1 = AMP_OUT_ZERO;
  7621. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7622. spec->autocfg.line_out_pins[1] != 0x16 ||
  7623. spec->autocfg.line_out_pins[2] != 0x16)
  7624. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7625. snd_hda_codec_write(codec, 0x02, 0,
  7626. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7627. snd_hda_codec_write(codec, 0x03, 0,
  7628. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7629. }
  7630. /* pcm configuration: identiacal with ALC880 */
  7631. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7632. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7633. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7634. /*
  7635. * BIOS auto configuration
  7636. */
  7637. static int alc268_parse_auto_config(struct hda_codec *codec)
  7638. {
  7639. struct alc_spec *spec = codec->spec;
  7640. int err;
  7641. static hda_nid_t alc268_ignore[] = { 0 };
  7642. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7643. alc268_ignore);
  7644. if (err < 0)
  7645. return err;
  7646. if (!spec->autocfg.line_outs)
  7647. return 0; /* can't find valid BIOS pin config */
  7648. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7649. if (err < 0)
  7650. return err;
  7651. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7652. if (err < 0)
  7653. return err;
  7654. spec->multiout.max_channels = 2;
  7655. /* digital only support output */
  7656. if (spec->autocfg.dig_out_pin)
  7657. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7658. if (spec->kctl_alloc)
  7659. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7660. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7661. spec->num_mux_defs = 1;
  7662. spec->input_mux = &spec->private_imux;
  7663. return 1;
  7664. }
  7665. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7666. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7667. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7668. /* init callback for auto-configuration model -- overriding the default init */
  7669. static void alc268_auto_init(struct hda_codec *codec)
  7670. {
  7671. alc268_auto_init_multi_out(codec);
  7672. alc268_auto_init_hp_out(codec);
  7673. alc268_auto_init_mono_speaker_out(codec);
  7674. alc268_auto_init_analog_input(codec);
  7675. }
  7676. /*
  7677. * configuration and preset
  7678. */
  7679. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7680. [ALC268_3ST] = "3stack",
  7681. [ALC268_AUTO] = "auto",
  7682. };
  7683. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7684. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7685. {}
  7686. };
  7687. static struct alc_config_preset alc268_presets[] = {
  7688. [ALC268_3ST] = {
  7689. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7690. .init_verbs = { alc268_base_init_verbs },
  7691. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7692. .dac_nids = alc268_dac_nids,
  7693. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7694. .adc_nids = alc268_adc_nids_alt,
  7695. .hp_nid = 0x03,
  7696. .dig_out_nid = ALC268_DIGOUT_NID,
  7697. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7698. .channel_mode = alc268_modes,
  7699. .input_mux = &alc268_capture_source,
  7700. },
  7701. };
  7702. static int patch_alc268(struct hda_codec *codec)
  7703. {
  7704. struct alc_spec *spec;
  7705. int board_config;
  7706. int err;
  7707. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7708. if (spec == NULL)
  7709. return -ENOMEM;
  7710. codec->spec = spec;
  7711. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7712. alc268_models,
  7713. alc268_cfg_tbl);
  7714. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7715. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7716. "trying auto-probe from BIOS...\n");
  7717. board_config = ALC268_AUTO;
  7718. }
  7719. if (board_config == ALC268_AUTO) {
  7720. /* automatic parse from the BIOS config */
  7721. err = alc268_parse_auto_config(codec);
  7722. if (err < 0) {
  7723. alc_free(codec);
  7724. return err;
  7725. } else if (!err) {
  7726. printk(KERN_INFO
  7727. "hda_codec: Cannot set up configuration "
  7728. "from BIOS. Using base mode...\n");
  7729. board_config = ALC268_3ST;
  7730. }
  7731. }
  7732. if (board_config != ALC268_AUTO)
  7733. setup_preset(spec, &alc268_presets[board_config]);
  7734. spec->stream_name_analog = "ALC268 Analog";
  7735. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7736. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7737. spec->stream_name_digital = "ALC268 Digital";
  7738. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7739. if (board_config == ALC268_AUTO) {
  7740. if (!spec->adc_nids && spec->input_mux) {
  7741. /* check whether NID 0x07 is valid */
  7742. unsigned int wcap = get_wcaps(codec, 0x07);
  7743. /* get type */
  7744. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7745. if (wcap != AC_WID_AUD_IN) {
  7746. spec->adc_nids = alc268_adc_nids_alt;
  7747. spec->num_adc_nids =
  7748. ARRAY_SIZE(alc268_adc_nids_alt);
  7749. spec->mixers[spec->num_mixers] =
  7750. alc268_capture_alt_mixer;
  7751. spec->num_mixers++;
  7752. } else {
  7753. spec->adc_nids = alc268_adc_nids;
  7754. spec->num_adc_nids =
  7755. ARRAY_SIZE(alc268_adc_nids);
  7756. spec->mixers[spec->num_mixers] =
  7757. alc268_capture_mixer;
  7758. spec->num_mixers++;
  7759. }
  7760. }
  7761. }
  7762. codec->patch_ops = alc_patch_ops;
  7763. if (board_config == ALC268_AUTO)
  7764. spec->init_hook = alc268_auto_init;
  7765. return 0;
  7766. }
  7767. /*
  7768. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7769. */
  7770. /*
  7771. * set the path ways for 2 channel output
  7772. * need to set the codec line out and mic 1 pin widgets to inputs
  7773. */
  7774. static struct hda_verb alc861_threestack_ch2_init[] = {
  7775. /* set pin widget 1Ah (line in) for input */
  7776. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7777. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7778. * the vref
  7779. */
  7780. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7781. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7782. #if 0
  7783. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7784. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7785. #endif
  7786. { } /* end */
  7787. };
  7788. /*
  7789. * 6ch mode
  7790. * need to set the codec line out and mic 1 pin widgets to outputs
  7791. */
  7792. static struct hda_verb alc861_threestack_ch6_init[] = {
  7793. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7794. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7795. /* set pin widget 18h (mic1) for output (CLFE)*/
  7796. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7797. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7798. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7799. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7800. #if 0
  7801. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7802. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7803. #endif
  7804. { } /* end */
  7805. };
  7806. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7807. { 2, alc861_threestack_ch2_init },
  7808. { 6, alc861_threestack_ch6_init },
  7809. };
  7810. /* Set mic1 as input and unmute the mixer */
  7811. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7812. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7813. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7814. { } /* end */
  7815. };
  7816. /* Set mic1 as output and mute mixer */
  7817. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7818. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7819. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7820. { } /* end */
  7821. };
  7822. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7823. { 2, alc861_uniwill_m31_ch2_init },
  7824. { 4, alc861_uniwill_m31_ch4_init },
  7825. };
  7826. /* Set mic1 and line-in as input and unmute the mixer */
  7827. static struct hda_verb alc861_asus_ch2_init[] = {
  7828. /* set pin widget 1Ah (line in) for input */
  7829. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7830. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7831. * the vref
  7832. */
  7833. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7834. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7835. #if 0
  7836. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7837. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7838. #endif
  7839. { } /* end */
  7840. };
  7841. /* Set mic1 nad line-in as output and mute mixer */
  7842. static struct hda_verb alc861_asus_ch6_init[] = {
  7843. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7844. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7845. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7846. /* set pin widget 18h (mic1) for output (CLFE)*/
  7847. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7848. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7849. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7850. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7851. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7852. #if 0
  7853. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7854. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7855. #endif
  7856. { } /* end */
  7857. };
  7858. static struct hda_channel_mode alc861_asus_modes[2] = {
  7859. { 2, alc861_asus_ch2_init },
  7860. { 6, alc861_asus_ch6_init },
  7861. };
  7862. /* patch-ALC861 */
  7863. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7864. /* output mixer control */
  7865. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7866. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7867. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7868. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7869. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7870. /*Input mixer control */
  7871. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7872. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7873. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7874. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7875. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7876. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7877. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7878. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7879. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7880. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7881. /* Capture mixer control */
  7882. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7883. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7884. {
  7885. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7886. .name = "Capture Source",
  7887. .count = 1,
  7888. .info = alc_mux_enum_info,
  7889. .get = alc_mux_enum_get,
  7890. .put = alc_mux_enum_put,
  7891. },
  7892. { } /* end */
  7893. };
  7894. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7895. /* output mixer control */
  7896. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7897. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7898. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7899. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7900. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7901. /* Input mixer control */
  7902. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7903. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7904. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7905. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7906. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7907. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7908. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7909. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7910. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7911. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7912. /* Capture mixer control */
  7913. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7914. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7915. {
  7916. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7917. .name = "Capture Source",
  7918. .count = 1,
  7919. .info = alc_mux_enum_info,
  7920. .get = alc_mux_enum_get,
  7921. .put = alc_mux_enum_put,
  7922. },
  7923. {
  7924. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7925. .name = "Channel Mode",
  7926. .info = alc_ch_mode_info,
  7927. .get = alc_ch_mode_get,
  7928. .put = alc_ch_mode_put,
  7929. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7930. },
  7931. { } /* end */
  7932. };
  7933. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7934. /* output mixer control */
  7935. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7936. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7937. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7938. /*Capture mixer control */
  7939. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7940. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7941. {
  7942. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7943. .name = "Capture Source",
  7944. .count = 1,
  7945. .info = alc_mux_enum_info,
  7946. .get = alc_mux_enum_get,
  7947. .put = alc_mux_enum_put,
  7948. },
  7949. { } /* end */
  7950. };
  7951. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7952. /* output mixer control */
  7953. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7954. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7955. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7956. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7957. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7958. /* Input mixer control */
  7959. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7960. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7961. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7962. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7963. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7964. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7965. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7966. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7967. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7968. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7969. /* Capture mixer control */
  7970. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7971. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7972. {
  7973. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7974. .name = "Capture Source",
  7975. .count = 1,
  7976. .info = alc_mux_enum_info,
  7977. .get = alc_mux_enum_get,
  7978. .put = alc_mux_enum_put,
  7979. },
  7980. {
  7981. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7982. .name = "Channel Mode",
  7983. .info = alc_ch_mode_info,
  7984. .get = alc_ch_mode_get,
  7985. .put = alc_ch_mode_put,
  7986. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7987. },
  7988. { } /* end */
  7989. };
  7990. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7991. /* output mixer control */
  7992. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7993. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7994. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7995. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7996. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7997. /* Input mixer control */
  7998. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7999. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8000. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8001. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8002. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8003. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8004. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8005. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8006. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8007. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8008. /* Capture mixer control */
  8009. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8010. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8011. {
  8012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8013. .name = "Capture Source",
  8014. .count = 1,
  8015. .info = alc_mux_enum_info,
  8016. .get = alc_mux_enum_get,
  8017. .put = alc_mux_enum_put,
  8018. },
  8019. {
  8020. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8021. .name = "Channel Mode",
  8022. .info = alc_ch_mode_info,
  8023. .get = alc_ch_mode_get,
  8024. .put = alc_ch_mode_put,
  8025. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8026. },
  8027. { }
  8028. };
  8029. /* additional mixer */
  8030. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8031. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8032. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8033. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8034. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8035. { }
  8036. };
  8037. /*
  8038. * generic initialization of ADC, input mixers and output mixers
  8039. */
  8040. static struct hda_verb alc861_base_init_verbs[] = {
  8041. /*
  8042. * Unmute ADC0 and set the default input to mic-in
  8043. */
  8044. /* port-A for surround (rear panel) */
  8045. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8046. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8047. /* port-B for mic-in (rear panel) with vref */
  8048. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8049. /* port-C for line-in (rear panel) */
  8050. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8051. /* port-D for Front */
  8052. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8053. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8054. /* port-E for HP out (front panel) */
  8055. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8056. /* route front PCM to HP */
  8057. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8058. /* port-F for mic-in (front panel) with vref */
  8059. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8060. /* port-G for CLFE (rear panel) */
  8061. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8062. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8063. /* port-H for side (rear panel) */
  8064. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8065. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8066. /* CD-in */
  8067. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8068. /* route front mic to ADC1*/
  8069. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8070. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8071. /* Unmute DAC0~3 & spdif out*/
  8072. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8073. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8074. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8075. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8076. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8077. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8078. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8079. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8080. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8081. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8082. /* Unmute Stereo Mixer 15 */
  8083. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8084. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8085. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8086. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8087. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8088. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8089. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8090. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8091. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8092. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8093. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8094. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8095. /* hp used DAC 3 (Front) */
  8096. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8097. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8098. { }
  8099. };
  8100. static struct hda_verb alc861_threestack_init_verbs[] = {
  8101. /*
  8102. * Unmute ADC0 and set the default input to mic-in
  8103. */
  8104. /* port-A for surround (rear panel) */
  8105. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8106. /* port-B for mic-in (rear panel) with vref */
  8107. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8108. /* port-C for line-in (rear panel) */
  8109. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8110. /* port-D for Front */
  8111. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8112. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8113. /* port-E for HP out (front panel) */
  8114. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8115. /* route front PCM to HP */
  8116. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8117. /* port-F for mic-in (front panel) with vref */
  8118. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8119. /* port-G for CLFE (rear panel) */
  8120. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8121. /* port-H for side (rear panel) */
  8122. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8123. /* CD-in */
  8124. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8125. /* route front mic to ADC1*/
  8126. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8127. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8128. /* Unmute DAC0~3 & spdif out*/
  8129. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8130. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8131. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8132. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8134. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8135. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8136. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8137. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8138. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8139. /* Unmute Stereo Mixer 15 */
  8140. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8141. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8142. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8144. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8145. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8146. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8147. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8148. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8149. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8150. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8151. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8152. /* hp used DAC 3 (Front) */
  8153. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8154. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8155. { }
  8156. };
  8157. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8158. /*
  8159. * Unmute ADC0 and set the default input to mic-in
  8160. */
  8161. /* port-A for surround (rear panel) */
  8162. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8163. /* port-B for mic-in (rear panel) with vref */
  8164. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8165. /* port-C for line-in (rear panel) */
  8166. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8167. /* port-D for Front */
  8168. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8169. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8170. /* port-E for HP out (front panel) */
  8171. /* this has to be set to VREF80 */
  8172. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8173. /* route front PCM to HP */
  8174. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8175. /* port-F for mic-in (front panel) with vref */
  8176. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8177. /* port-G for CLFE (rear panel) */
  8178. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8179. /* port-H for side (rear panel) */
  8180. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8181. /* CD-in */
  8182. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8183. /* route front mic to ADC1*/
  8184. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8185. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8186. /* Unmute DAC0~3 & spdif out*/
  8187. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8188. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8189. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8190. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8191. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8192. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8193. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8194. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8195. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8196. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8197. /* Unmute Stereo Mixer 15 */
  8198. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8199. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8200. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8201. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8202. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8203. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8204. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8205. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8206. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8207. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8208. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8209. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8210. /* hp used DAC 3 (Front) */
  8211. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8212. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8213. { }
  8214. };
  8215. static struct hda_verb alc861_asus_init_verbs[] = {
  8216. /*
  8217. * Unmute ADC0 and set the default input to mic-in
  8218. */
  8219. /* port-A for surround (rear panel)
  8220. * according to codec#0 this is the HP jack
  8221. */
  8222. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8223. /* route front PCM to HP */
  8224. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8225. /* port-B for mic-in (rear panel) with vref */
  8226. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8227. /* port-C for line-in (rear panel) */
  8228. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8229. /* port-D for Front */
  8230. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8231. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8232. /* port-E for HP out (front panel) */
  8233. /* this has to be set to VREF80 */
  8234. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8235. /* route front PCM to HP */
  8236. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8237. /* port-F for mic-in (front panel) with vref */
  8238. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8239. /* port-G for CLFE (rear panel) */
  8240. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8241. /* port-H for side (rear panel) */
  8242. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8243. /* CD-in */
  8244. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8245. /* route front mic to ADC1*/
  8246. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8247. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8248. /* Unmute DAC0~3 & spdif out*/
  8249. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8250. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8251. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8252. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8253. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8254. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8255. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8256. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8257. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8258. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8259. /* Unmute Stereo Mixer 15 */
  8260. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8261. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8262. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8263. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8264. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8265. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8266. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8267. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8268. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8269. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8270. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8271. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8272. /* hp used DAC 3 (Front) */
  8273. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8274. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8275. { }
  8276. };
  8277. /* additional init verbs for ASUS laptops */
  8278. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8279. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8280. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8281. { }
  8282. };
  8283. /*
  8284. * generic initialization of ADC, input mixers and output mixers
  8285. */
  8286. static struct hda_verb alc861_auto_init_verbs[] = {
  8287. /*
  8288. * Unmute ADC0 and set the default input to mic-in
  8289. */
  8290. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8291. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8292. /* Unmute DAC0~3 & spdif out*/
  8293. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8294. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8295. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8296. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8297. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8298. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8299. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8300. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8301. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8302. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8303. /* Unmute Stereo Mixer 15 */
  8304. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8306. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8307. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8308. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8309. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8310. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8311. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8312. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8313. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8314. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8315. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8316. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8317. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8318. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8319. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8320. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8321. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8322. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8323. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8324. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8325. { }
  8326. };
  8327. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8328. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8329. { }
  8330. };
  8331. /* toggle speaker-output according to the hp-jack state */
  8332. static void alc861_toshiba_automute(struct hda_codec *codec)
  8333. {
  8334. unsigned int present;
  8335. present = snd_hda_codec_read(codec, 0x0f, 0,
  8336. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8337. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8338. 0x80, present ? 0x80 : 0);
  8339. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8340. 0x80, present ? 0x80 : 0);
  8341. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8342. 0x80, present ? 0 : 0x80);
  8343. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8344. 0x80, present ? 0 : 0x80);
  8345. }
  8346. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8347. unsigned int res)
  8348. {
  8349. if ((res >> 26) == ALC880_HP_EVENT)
  8350. alc861_toshiba_automute(codec);
  8351. }
  8352. /* pcm configuration: identiacal with ALC880 */
  8353. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8354. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8355. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8356. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8357. #define ALC861_DIGOUT_NID 0x07
  8358. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8359. { 8, NULL }
  8360. };
  8361. static hda_nid_t alc861_dac_nids[4] = {
  8362. /* front, surround, clfe, side */
  8363. 0x03, 0x06, 0x05, 0x04
  8364. };
  8365. static hda_nid_t alc660_dac_nids[3] = {
  8366. /* front, clfe, surround */
  8367. 0x03, 0x05, 0x06
  8368. };
  8369. static hda_nid_t alc861_adc_nids[1] = {
  8370. /* ADC0-2 */
  8371. 0x08,
  8372. };
  8373. static struct hda_input_mux alc861_capture_source = {
  8374. .num_items = 5,
  8375. .items = {
  8376. { "Mic", 0x0 },
  8377. { "Front Mic", 0x3 },
  8378. { "Line", 0x1 },
  8379. { "CD", 0x4 },
  8380. { "Mixer", 0x5 },
  8381. },
  8382. };
  8383. /* fill in the dac_nids table from the parsed pin configuration */
  8384. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8385. const struct auto_pin_cfg *cfg)
  8386. {
  8387. int i;
  8388. hda_nid_t nid;
  8389. spec->multiout.dac_nids = spec->private_dac_nids;
  8390. for (i = 0; i < cfg->line_outs; i++) {
  8391. nid = cfg->line_out_pins[i];
  8392. if (nid) {
  8393. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8394. continue;
  8395. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8396. }
  8397. }
  8398. spec->multiout.num_dacs = cfg->line_outs;
  8399. return 0;
  8400. }
  8401. /* add playback controls from the parsed DAC table */
  8402. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8403. const struct auto_pin_cfg *cfg)
  8404. {
  8405. char name[32];
  8406. static const char *chname[4] = {
  8407. "Front", "Surround", NULL /*CLFE*/, "Side"
  8408. };
  8409. hda_nid_t nid;
  8410. int i, idx, err;
  8411. for (i = 0; i < cfg->line_outs; i++) {
  8412. nid = spec->multiout.dac_nids[i];
  8413. if (!nid)
  8414. continue;
  8415. if (nid == 0x05) {
  8416. /* Center/LFE */
  8417. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8418. "Center Playback Switch",
  8419. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8420. HDA_OUTPUT));
  8421. if (err < 0)
  8422. return err;
  8423. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8424. "LFE Playback Switch",
  8425. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8426. HDA_OUTPUT));
  8427. if (err < 0)
  8428. return err;
  8429. } else {
  8430. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8431. idx++)
  8432. if (nid == alc861_dac_nids[idx])
  8433. break;
  8434. sprintf(name, "%s Playback Switch", chname[idx]);
  8435. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8436. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8437. HDA_OUTPUT));
  8438. if (err < 0)
  8439. return err;
  8440. }
  8441. }
  8442. return 0;
  8443. }
  8444. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8445. {
  8446. int err;
  8447. hda_nid_t nid;
  8448. if (!pin)
  8449. return 0;
  8450. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8451. nid = 0x03;
  8452. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8453. "Headphone Playback Switch",
  8454. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8455. if (err < 0)
  8456. return err;
  8457. spec->multiout.hp_nid = nid;
  8458. }
  8459. return 0;
  8460. }
  8461. /* create playback/capture controls for input pins */
  8462. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8463. const struct auto_pin_cfg *cfg)
  8464. {
  8465. struct hda_input_mux *imux = &spec->private_imux;
  8466. int i, err, idx, idx1;
  8467. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8468. switch (cfg->input_pins[i]) {
  8469. case 0x0c:
  8470. idx1 = 1;
  8471. idx = 2; /* Line In */
  8472. break;
  8473. case 0x0f:
  8474. idx1 = 2;
  8475. idx = 2; /* Line In */
  8476. break;
  8477. case 0x0d:
  8478. idx1 = 0;
  8479. idx = 1; /* Mic In */
  8480. break;
  8481. case 0x10:
  8482. idx1 = 3;
  8483. idx = 1; /* Mic In */
  8484. break;
  8485. case 0x11:
  8486. idx1 = 4;
  8487. idx = 0; /* CD */
  8488. break;
  8489. default:
  8490. continue;
  8491. }
  8492. err = new_analog_input(spec, cfg->input_pins[i],
  8493. auto_pin_cfg_labels[i], idx, 0x15);
  8494. if (err < 0)
  8495. return err;
  8496. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8497. imux->items[imux->num_items].index = idx1;
  8498. imux->num_items++;
  8499. }
  8500. return 0;
  8501. }
  8502. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8503. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8504. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8505. {
  8506. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8507. /* The multiple "Capture Source" controls confuse alsamixer
  8508. * So call somewhat different..
  8509. *FIXME: the controls appear in the "playback" view!
  8510. */
  8511. /* .name = "Capture Source", */
  8512. .name = "Input Source",
  8513. .count = 1,
  8514. .info = alc_mux_enum_info,
  8515. .get = alc_mux_enum_get,
  8516. .put = alc_mux_enum_put,
  8517. },
  8518. { } /* end */
  8519. };
  8520. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8521. hda_nid_t nid,
  8522. int pin_type, int dac_idx)
  8523. {
  8524. /* set as output */
  8525. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8526. pin_type);
  8527. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8528. AMP_OUT_UNMUTE);
  8529. }
  8530. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8531. {
  8532. struct alc_spec *spec = codec->spec;
  8533. int i;
  8534. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8535. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8536. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8537. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8538. if (nid)
  8539. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8540. spec->multiout.dac_nids[i]);
  8541. }
  8542. }
  8543. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8544. {
  8545. struct alc_spec *spec = codec->spec;
  8546. hda_nid_t pin;
  8547. pin = spec->autocfg.hp_pins[0];
  8548. if (pin) /* connect to front */
  8549. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8550. spec->multiout.dac_nids[0]);
  8551. }
  8552. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8553. {
  8554. struct alc_spec *spec = codec->spec;
  8555. int i;
  8556. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8557. hda_nid_t nid = spec->autocfg.input_pins[i];
  8558. if (nid >= 0x0c && nid <= 0x11) {
  8559. snd_hda_codec_write(codec, nid, 0,
  8560. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8561. i <= AUTO_PIN_FRONT_MIC ?
  8562. PIN_VREF80 : PIN_IN);
  8563. }
  8564. }
  8565. }
  8566. /* parse the BIOS configuration and set up the alc_spec */
  8567. /* return 1 if successful, 0 if the proper config is not found,
  8568. * or a negative error code
  8569. */
  8570. static int alc861_parse_auto_config(struct hda_codec *codec)
  8571. {
  8572. struct alc_spec *spec = codec->spec;
  8573. int err;
  8574. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8575. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8576. alc861_ignore);
  8577. if (err < 0)
  8578. return err;
  8579. if (!spec->autocfg.line_outs)
  8580. return 0; /* can't find valid BIOS pin config */
  8581. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8582. if (err < 0)
  8583. return err;
  8584. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8585. if (err < 0)
  8586. return err;
  8587. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8588. if (err < 0)
  8589. return err;
  8590. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8591. if (err < 0)
  8592. return err;
  8593. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8594. if (spec->autocfg.dig_out_pin)
  8595. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8596. if (spec->kctl_alloc)
  8597. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8598. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8599. spec->num_mux_defs = 1;
  8600. spec->input_mux = &spec->private_imux;
  8601. spec->adc_nids = alc861_adc_nids;
  8602. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8603. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8604. spec->num_mixers++;
  8605. return 1;
  8606. }
  8607. /* additional initialization for auto-configuration model */
  8608. static void alc861_auto_init(struct hda_codec *codec)
  8609. {
  8610. alc861_auto_init_multi_out(codec);
  8611. alc861_auto_init_hp_out(codec);
  8612. alc861_auto_init_analog_input(codec);
  8613. }
  8614. /*
  8615. * configuration and preset
  8616. */
  8617. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8618. [ALC861_3ST] = "3stack",
  8619. [ALC660_3ST] = "3stack-660",
  8620. [ALC861_3ST_DIG] = "3stack-dig",
  8621. [ALC861_6ST_DIG] = "6stack-dig",
  8622. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8623. [ALC861_TOSHIBA] = "toshiba",
  8624. [ALC861_ASUS] = "asus",
  8625. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8626. [ALC861_AUTO] = "auto",
  8627. };
  8628. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8629. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8630. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8631. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8632. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8633. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8634. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8635. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8636. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8637. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8638. * Any other models that need this preset?
  8639. */
  8640. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8641. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8642. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8643. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8644. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8645. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8646. {}
  8647. };
  8648. static struct alc_config_preset alc861_presets[] = {
  8649. [ALC861_3ST] = {
  8650. .mixers = { alc861_3ST_mixer },
  8651. .init_verbs = { alc861_threestack_init_verbs },
  8652. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8653. .dac_nids = alc861_dac_nids,
  8654. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8655. .channel_mode = alc861_threestack_modes,
  8656. .need_dac_fix = 1,
  8657. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8658. .adc_nids = alc861_adc_nids,
  8659. .input_mux = &alc861_capture_source,
  8660. },
  8661. [ALC861_3ST_DIG] = {
  8662. .mixers = { alc861_base_mixer },
  8663. .init_verbs = { alc861_threestack_init_verbs },
  8664. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8665. .dac_nids = alc861_dac_nids,
  8666. .dig_out_nid = ALC861_DIGOUT_NID,
  8667. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8668. .channel_mode = alc861_threestack_modes,
  8669. .need_dac_fix = 1,
  8670. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8671. .adc_nids = alc861_adc_nids,
  8672. .input_mux = &alc861_capture_source,
  8673. },
  8674. [ALC861_6ST_DIG] = {
  8675. .mixers = { alc861_base_mixer },
  8676. .init_verbs = { alc861_base_init_verbs },
  8677. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8678. .dac_nids = alc861_dac_nids,
  8679. .dig_out_nid = ALC861_DIGOUT_NID,
  8680. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8681. .channel_mode = alc861_8ch_modes,
  8682. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8683. .adc_nids = alc861_adc_nids,
  8684. .input_mux = &alc861_capture_source,
  8685. },
  8686. [ALC660_3ST] = {
  8687. .mixers = { alc861_3ST_mixer },
  8688. .init_verbs = { alc861_threestack_init_verbs },
  8689. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8690. .dac_nids = alc660_dac_nids,
  8691. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8692. .channel_mode = alc861_threestack_modes,
  8693. .need_dac_fix = 1,
  8694. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8695. .adc_nids = alc861_adc_nids,
  8696. .input_mux = &alc861_capture_source,
  8697. },
  8698. [ALC861_UNIWILL_M31] = {
  8699. .mixers = { alc861_uniwill_m31_mixer },
  8700. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8701. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8702. .dac_nids = alc861_dac_nids,
  8703. .dig_out_nid = ALC861_DIGOUT_NID,
  8704. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8705. .channel_mode = alc861_uniwill_m31_modes,
  8706. .need_dac_fix = 1,
  8707. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8708. .adc_nids = alc861_adc_nids,
  8709. .input_mux = &alc861_capture_source,
  8710. },
  8711. [ALC861_TOSHIBA] = {
  8712. .mixers = { alc861_toshiba_mixer },
  8713. .init_verbs = { alc861_base_init_verbs,
  8714. alc861_toshiba_init_verbs },
  8715. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8716. .dac_nids = alc861_dac_nids,
  8717. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8718. .channel_mode = alc883_3ST_2ch_modes,
  8719. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8720. .adc_nids = alc861_adc_nids,
  8721. .input_mux = &alc861_capture_source,
  8722. .unsol_event = alc861_toshiba_unsol_event,
  8723. .init_hook = alc861_toshiba_automute,
  8724. },
  8725. [ALC861_ASUS] = {
  8726. .mixers = { alc861_asus_mixer },
  8727. .init_verbs = { alc861_asus_init_verbs },
  8728. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8729. .dac_nids = alc861_dac_nids,
  8730. .dig_out_nid = ALC861_DIGOUT_NID,
  8731. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8732. .channel_mode = alc861_asus_modes,
  8733. .need_dac_fix = 1,
  8734. .hp_nid = 0x06,
  8735. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8736. .adc_nids = alc861_adc_nids,
  8737. .input_mux = &alc861_capture_source,
  8738. },
  8739. [ALC861_ASUS_LAPTOP] = {
  8740. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8741. .init_verbs = { alc861_asus_init_verbs,
  8742. alc861_asus_laptop_init_verbs },
  8743. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8744. .dac_nids = alc861_dac_nids,
  8745. .dig_out_nid = ALC861_DIGOUT_NID,
  8746. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8747. .channel_mode = alc883_3ST_2ch_modes,
  8748. .need_dac_fix = 1,
  8749. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8750. .adc_nids = alc861_adc_nids,
  8751. .input_mux = &alc861_capture_source,
  8752. },
  8753. };
  8754. static int patch_alc861(struct hda_codec *codec)
  8755. {
  8756. struct alc_spec *spec;
  8757. int board_config;
  8758. int err;
  8759. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8760. if (spec == NULL)
  8761. return -ENOMEM;
  8762. codec->spec = spec;
  8763. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8764. alc861_models,
  8765. alc861_cfg_tbl);
  8766. if (board_config < 0) {
  8767. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8768. "trying auto-probe from BIOS...\n");
  8769. board_config = ALC861_AUTO;
  8770. }
  8771. if (board_config == ALC861_AUTO) {
  8772. /* automatic parse from the BIOS config */
  8773. err = alc861_parse_auto_config(codec);
  8774. if (err < 0) {
  8775. alc_free(codec);
  8776. return err;
  8777. } else if (!err) {
  8778. printk(KERN_INFO
  8779. "hda_codec: Cannot set up configuration "
  8780. "from BIOS. Using base mode...\n");
  8781. board_config = ALC861_3ST_DIG;
  8782. }
  8783. }
  8784. if (board_config != ALC861_AUTO)
  8785. setup_preset(spec, &alc861_presets[board_config]);
  8786. spec->stream_name_analog = "ALC861 Analog";
  8787. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8788. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8789. spec->stream_name_digital = "ALC861 Digital";
  8790. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8791. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8792. codec->patch_ops = alc_patch_ops;
  8793. if (board_config == ALC861_AUTO)
  8794. spec->init_hook = alc861_auto_init;
  8795. return 0;
  8796. }
  8797. /*
  8798. * ALC861-VD support
  8799. *
  8800. * Based on ALC882
  8801. *
  8802. * In addition, an independent DAC
  8803. */
  8804. #define ALC861VD_DIGOUT_NID 0x06
  8805. static hda_nid_t alc861vd_dac_nids[4] = {
  8806. /* front, surr, clfe, side surr */
  8807. 0x02, 0x03, 0x04, 0x05
  8808. };
  8809. /* dac_nids for ALC660vd are in a different order - according to
  8810. * Realtek's driver.
  8811. * This should probably tesult in a different mixer for 6stack models
  8812. * of ALC660vd codecs, but for now there is only 3stack mixer
  8813. * - and it is the same as in 861vd.
  8814. * adc_nids in ALC660vd are (is) the same as in 861vd
  8815. */
  8816. static hda_nid_t alc660vd_dac_nids[3] = {
  8817. /* front, rear, clfe, rear_surr */
  8818. 0x02, 0x04, 0x03
  8819. };
  8820. static hda_nid_t alc861vd_adc_nids[1] = {
  8821. /* ADC0 */
  8822. 0x09,
  8823. };
  8824. /* input MUX */
  8825. /* FIXME: should be a matrix-type input source selection */
  8826. static struct hda_input_mux alc861vd_capture_source = {
  8827. .num_items = 4,
  8828. .items = {
  8829. { "Mic", 0x0 },
  8830. { "Front Mic", 0x1 },
  8831. { "Line", 0x2 },
  8832. { "CD", 0x4 },
  8833. },
  8834. };
  8835. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8836. .num_items = 3,
  8837. .items = {
  8838. { "Front Mic", 0x0 },
  8839. { "ATAPI Mic", 0x1 },
  8840. { "Line In", 0x5 },
  8841. },
  8842. };
  8843. #define alc861vd_mux_enum_info alc_mux_enum_info
  8844. #define alc861vd_mux_enum_get alc_mux_enum_get
  8845. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8846. struct snd_ctl_elem_value *ucontrol)
  8847. {
  8848. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8849. struct alc_spec *spec = codec->spec;
  8850. const struct hda_input_mux *imux = spec->input_mux;
  8851. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8852. static hda_nid_t capture_mixers[1] = { 0x22 };
  8853. hda_nid_t nid = capture_mixers[adc_idx];
  8854. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8855. unsigned int i, idx;
  8856. idx = ucontrol->value.enumerated.item[0];
  8857. if (idx >= imux->num_items)
  8858. idx = imux->num_items - 1;
  8859. if (*cur_val == idx && !codec->in_resume)
  8860. return 0;
  8861. for (i = 0; i < imux->num_items; i++) {
  8862. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8863. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8864. v | (imux->items[i].index << 8));
  8865. }
  8866. *cur_val = idx;
  8867. return 1;
  8868. }
  8869. /*
  8870. * 2ch mode
  8871. */
  8872. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8873. { 2, NULL }
  8874. };
  8875. /*
  8876. * 6ch mode
  8877. */
  8878. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8879. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8880. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8881. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8882. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8883. { } /* end */
  8884. };
  8885. /*
  8886. * 8ch mode
  8887. */
  8888. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8889. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8890. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8891. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8892. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8893. { } /* end */
  8894. };
  8895. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8896. { 6, alc861vd_6stack_ch6_init },
  8897. { 8, alc861vd_6stack_ch8_init },
  8898. };
  8899. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8900. {
  8901. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8902. .name = "Channel Mode",
  8903. .info = alc_ch_mode_info,
  8904. .get = alc_ch_mode_get,
  8905. .put = alc_ch_mode_put,
  8906. },
  8907. { } /* end */
  8908. };
  8909. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8910. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8911. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8912. {
  8913. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8914. /* The multiple "Capture Source" controls confuse alsamixer
  8915. * So call somewhat different..
  8916. *FIXME: the controls appear in the "playback" view!
  8917. */
  8918. /* .name = "Capture Source", */
  8919. .name = "Input Source",
  8920. .count = 1,
  8921. .info = alc861vd_mux_enum_info,
  8922. .get = alc861vd_mux_enum_get,
  8923. .put = alc861vd_mux_enum_put,
  8924. },
  8925. { } /* end */
  8926. };
  8927. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8928. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8929. */
  8930. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8931. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8932. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8933. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8934. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8935. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8936. HDA_OUTPUT),
  8937. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8938. HDA_OUTPUT),
  8939. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8940. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8941. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8942. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8943. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8944. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8945. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8946. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8947. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8948. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8949. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8950. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8951. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8952. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8953. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8954. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8955. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8956. { } /* end */
  8957. };
  8958. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8959. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8960. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8961. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8962. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8963. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8964. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8965. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8966. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8967. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8968. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8969. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8970. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8971. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8972. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8973. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8974. { } /* end */
  8975. };
  8976. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8977. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8978. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8979. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8980. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8981. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8982. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8983. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8984. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8985. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8986. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8987. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8988. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8989. { } /* end */
  8990. };
  8991. /* Pin assignment: Front=0x14, HP = 0x15,
  8992. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8993. */
  8994. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8995. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8996. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8997. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8998. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8999. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9000. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9001. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9002. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9003. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9004. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9005. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9006. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9007. {
  9008. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9009. /* .name = "Capture Source", */
  9010. .name = "Input Source",
  9011. .count = 1,
  9012. .info = alc882_mux_enum_info,
  9013. .get = alc882_mux_enum_get,
  9014. .put = alc882_mux_enum_put,
  9015. },
  9016. { } /* end */
  9017. };
  9018. /*
  9019. * generic initialization of ADC, input mixers and output mixers
  9020. */
  9021. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9022. /*
  9023. * Unmute ADC0 and set the default input to mic-in
  9024. */
  9025. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9026. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9027. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9028. * the analog-loopback mixer widget
  9029. */
  9030. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9031. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9032. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9033. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9034. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9035. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9036. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9037. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9038. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9041. /*
  9042. * Set up output mixers (0x02 - 0x05)
  9043. */
  9044. /* set vol=0 to output mixers */
  9045. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9046. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9047. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9048. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9049. /* set up input amps for analog loopback */
  9050. /* Amp Indices: DAC = 0, mixer = 1 */
  9051. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9052. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9053. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9054. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9055. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9056. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9057. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9058. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9059. { }
  9060. };
  9061. /*
  9062. * 3-stack pin configuration:
  9063. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9064. */
  9065. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9066. /*
  9067. * Set pin mode and muting
  9068. */
  9069. /* set front pin widgets 0x14 for output */
  9070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9071. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9072. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9073. /* Mic (rear) pin: input vref at 80% */
  9074. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9075. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9076. /* Front Mic pin: input vref at 80% */
  9077. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9078. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9079. /* Line In pin: input */
  9080. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9081. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9082. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9083. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9084. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9085. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9086. /* CD pin widget for input */
  9087. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9088. { }
  9089. };
  9090. /*
  9091. * 6-stack pin configuration:
  9092. */
  9093. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9094. /*
  9095. * Set pin mode and muting
  9096. */
  9097. /* set front pin widgets 0x14 for output */
  9098. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9099. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9100. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9101. /* Rear Pin: output 1 (0x0d) */
  9102. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9103. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9104. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9105. /* CLFE Pin: output 2 (0x0e) */
  9106. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9107. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9108. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9109. /* Side Pin: output 3 (0x0f) */
  9110. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9111. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9112. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9113. /* Mic (rear) pin: input vref at 80% */
  9114. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9115. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9116. /* Front Mic pin: input vref at 80% */
  9117. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9118. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9119. /* Line In pin: input */
  9120. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9121. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9122. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9123. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9124. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9125. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9126. /* CD pin widget for input */
  9127. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9128. { }
  9129. };
  9130. static struct hda_verb alc861vd_eapd_verbs[] = {
  9131. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9132. { }
  9133. };
  9134. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9135. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9136. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9137. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9138. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9139. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9140. {}
  9141. };
  9142. /* toggle speaker-output according to the hp-jack state */
  9143. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9144. {
  9145. unsigned int present;
  9146. unsigned char bits;
  9147. present = snd_hda_codec_read(codec, 0x1b, 0,
  9148. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9149. bits = present ? 0x80 : 0;
  9150. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9151. 0x80, bits);
  9152. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9153. 0x80, bits);
  9154. }
  9155. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9156. {
  9157. unsigned int present;
  9158. unsigned char bits;
  9159. present = snd_hda_codec_read(codec, 0x18, 0,
  9160. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9161. bits = present ? 0x80 : 0;
  9162. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9163. 0x80, bits);
  9164. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9165. 0x80, bits);
  9166. }
  9167. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9168. {
  9169. alc861vd_lenovo_hp_automute(codec);
  9170. alc861vd_lenovo_mic_automute(codec);
  9171. }
  9172. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9173. unsigned int res)
  9174. {
  9175. switch (res >> 26) {
  9176. case ALC880_HP_EVENT:
  9177. alc861vd_lenovo_hp_automute(codec);
  9178. break;
  9179. case ALC880_MIC_EVENT:
  9180. alc861vd_lenovo_mic_automute(codec);
  9181. break;
  9182. }
  9183. }
  9184. static struct hda_verb alc861vd_dallas_verbs[] = {
  9185. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9186. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9187. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9188. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9197. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9198. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9199. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9200. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9201. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9202. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9203. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9204. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9205. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9206. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9207. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9208. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9209. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9210. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9211. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9212. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9213. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9214. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9215. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9216. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9217. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9218. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9219. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9220. { } /* end */
  9221. };
  9222. /* toggle speaker-output according to the hp-jack state */
  9223. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9224. {
  9225. unsigned int present;
  9226. present = snd_hda_codec_read(codec, 0x15, 0,
  9227. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9228. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9229. 0x80, present ? 0x80 : 0);
  9230. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9231. 0x80, present ? 0x80 : 0);
  9232. }
  9233. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9234. {
  9235. if ((res >> 26) == ALC880_HP_EVENT)
  9236. alc861vd_dallas_automute(codec);
  9237. }
  9238. /* pcm configuration: identiacal with ALC880 */
  9239. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9240. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9241. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9242. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9243. /*
  9244. * configuration and preset
  9245. */
  9246. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9247. [ALC660VD_3ST] = "3stack-660",
  9248. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9249. [ALC861VD_3ST] = "3stack",
  9250. [ALC861VD_3ST_DIG] = "3stack-digout",
  9251. [ALC861VD_6ST_DIG] = "6stack-digout",
  9252. [ALC861VD_LENOVO] = "lenovo",
  9253. [ALC861VD_DALLAS] = "dallas",
  9254. [ALC861VD_AUTO] = "auto",
  9255. };
  9256. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9257. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9258. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9259. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9260. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9261. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9262. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9263. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9264. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9265. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9266. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9267. {}
  9268. };
  9269. static struct alc_config_preset alc861vd_presets[] = {
  9270. [ALC660VD_3ST] = {
  9271. .mixers = { alc861vd_3st_mixer },
  9272. .init_verbs = { alc861vd_volume_init_verbs,
  9273. alc861vd_3stack_init_verbs },
  9274. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9275. .dac_nids = alc660vd_dac_nids,
  9276. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9277. .adc_nids = alc861vd_adc_nids,
  9278. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9279. .channel_mode = alc861vd_3stack_2ch_modes,
  9280. .input_mux = &alc861vd_capture_source,
  9281. },
  9282. [ALC660VD_3ST_DIG] = {
  9283. .mixers = { alc861vd_3st_mixer },
  9284. .init_verbs = { alc861vd_volume_init_verbs,
  9285. alc861vd_3stack_init_verbs },
  9286. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9287. .dac_nids = alc660vd_dac_nids,
  9288. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9289. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9290. .adc_nids = alc861vd_adc_nids,
  9291. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9292. .channel_mode = alc861vd_3stack_2ch_modes,
  9293. .input_mux = &alc861vd_capture_source,
  9294. },
  9295. [ALC861VD_3ST] = {
  9296. .mixers = { alc861vd_3st_mixer },
  9297. .init_verbs = { alc861vd_volume_init_verbs,
  9298. alc861vd_3stack_init_verbs },
  9299. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9300. .dac_nids = alc861vd_dac_nids,
  9301. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9302. .channel_mode = alc861vd_3stack_2ch_modes,
  9303. .input_mux = &alc861vd_capture_source,
  9304. },
  9305. [ALC861VD_3ST_DIG] = {
  9306. .mixers = { alc861vd_3st_mixer },
  9307. .init_verbs = { alc861vd_volume_init_verbs,
  9308. alc861vd_3stack_init_verbs },
  9309. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9310. .dac_nids = alc861vd_dac_nids,
  9311. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9312. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9313. .channel_mode = alc861vd_3stack_2ch_modes,
  9314. .input_mux = &alc861vd_capture_source,
  9315. },
  9316. [ALC861VD_6ST_DIG] = {
  9317. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9318. .init_verbs = { alc861vd_volume_init_verbs,
  9319. alc861vd_6stack_init_verbs },
  9320. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9321. .dac_nids = alc861vd_dac_nids,
  9322. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9323. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9324. .channel_mode = alc861vd_6stack_modes,
  9325. .input_mux = &alc861vd_capture_source,
  9326. },
  9327. [ALC861VD_LENOVO] = {
  9328. .mixers = { alc861vd_lenovo_mixer },
  9329. .init_verbs = { alc861vd_volume_init_verbs,
  9330. alc861vd_3stack_init_verbs,
  9331. alc861vd_eapd_verbs,
  9332. alc861vd_lenovo_unsol_verbs },
  9333. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9334. .dac_nids = alc660vd_dac_nids,
  9335. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9336. .adc_nids = alc861vd_adc_nids,
  9337. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9338. .channel_mode = alc861vd_3stack_2ch_modes,
  9339. .input_mux = &alc861vd_capture_source,
  9340. .unsol_event = alc861vd_lenovo_unsol_event,
  9341. .init_hook = alc861vd_lenovo_automute,
  9342. },
  9343. [ALC861VD_DALLAS] = {
  9344. .mixers = { alc861vd_dallas_mixer },
  9345. .init_verbs = { alc861vd_dallas_verbs },
  9346. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9347. .dac_nids = alc861vd_dac_nids,
  9348. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9349. .adc_nids = alc861vd_adc_nids,
  9350. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9351. .channel_mode = alc861vd_3stack_2ch_modes,
  9352. .input_mux = &alc861vd_dallas_capture_source,
  9353. .unsol_event = alc861vd_dallas_unsol_event,
  9354. .init_hook = alc861vd_dallas_automute,
  9355. },
  9356. };
  9357. /*
  9358. * BIOS auto configuration
  9359. */
  9360. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9361. hda_nid_t nid, int pin_type, int dac_idx)
  9362. {
  9363. /* set as output */
  9364. snd_hda_codec_write(codec, nid, 0,
  9365. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9366. snd_hda_codec_write(codec, nid, 0,
  9367. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9368. }
  9369. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9370. {
  9371. struct alc_spec *spec = codec->spec;
  9372. int i;
  9373. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9374. for (i = 0; i <= HDA_SIDE; i++) {
  9375. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9376. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9377. if (nid)
  9378. alc861vd_auto_set_output_and_unmute(codec, nid,
  9379. pin_type, i);
  9380. }
  9381. }
  9382. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9383. {
  9384. struct alc_spec *spec = codec->spec;
  9385. hda_nid_t pin;
  9386. pin = spec->autocfg.hp_pins[0];
  9387. if (pin) /* connect to front and use dac 0 */
  9388. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9389. }
  9390. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9391. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9392. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9393. {
  9394. struct alc_spec *spec = codec->spec;
  9395. int i;
  9396. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9397. hda_nid_t nid = spec->autocfg.input_pins[i];
  9398. if (alc861vd_is_input_pin(nid)) {
  9399. snd_hda_codec_write(codec, nid, 0,
  9400. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9401. i <= AUTO_PIN_FRONT_MIC ?
  9402. PIN_VREF80 : PIN_IN);
  9403. if (nid != ALC861VD_PIN_CD_NID)
  9404. snd_hda_codec_write(codec, nid, 0,
  9405. AC_VERB_SET_AMP_GAIN_MUTE,
  9406. AMP_OUT_MUTE);
  9407. }
  9408. }
  9409. }
  9410. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9411. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9412. /* add playback controls from the parsed DAC table */
  9413. /* Based on ALC880 version. But ALC861VD has separate,
  9414. * different NIDs for mute/unmute switch and volume control */
  9415. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9416. const struct auto_pin_cfg *cfg)
  9417. {
  9418. char name[32];
  9419. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9420. hda_nid_t nid_v, nid_s;
  9421. int i, err;
  9422. for (i = 0; i < cfg->line_outs; i++) {
  9423. if (!spec->multiout.dac_nids[i])
  9424. continue;
  9425. nid_v = alc861vd_idx_to_mixer_vol(
  9426. alc880_dac_to_idx(
  9427. spec->multiout.dac_nids[i]));
  9428. nid_s = alc861vd_idx_to_mixer_switch(
  9429. alc880_dac_to_idx(
  9430. spec->multiout.dac_nids[i]));
  9431. if (i == 2) {
  9432. /* Center/LFE */
  9433. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9434. "Center Playback Volume",
  9435. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9436. HDA_OUTPUT));
  9437. if (err < 0)
  9438. return err;
  9439. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9440. "LFE Playback Volume",
  9441. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9442. HDA_OUTPUT));
  9443. if (err < 0)
  9444. return err;
  9445. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9446. "Center Playback Switch",
  9447. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9448. HDA_INPUT));
  9449. if (err < 0)
  9450. return err;
  9451. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9452. "LFE Playback Switch",
  9453. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9454. HDA_INPUT));
  9455. if (err < 0)
  9456. return err;
  9457. } else {
  9458. sprintf(name, "%s Playback Volume", chname[i]);
  9459. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9460. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9461. HDA_OUTPUT));
  9462. if (err < 0)
  9463. return err;
  9464. sprintf(name, "%s Playback Switch", chname[i]);
  9465. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9466. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9467. HDA_INPUT));
  9468. if (err < 0)
  9469. return err;
  9470. }
  9471. }
  9472. return 0;
  9473. }
  9474. /* add playback controls for speaker and HP outputs */
  9475. /* Based on ALC880 version. But ALC861VD has separate,
  9476. * different NIDs for mute/unmute switch and volume control */
  9477. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9478. hda_nid_t pin, const char *pfx)
  9479. {
  9480. hda_nid_t nid_v, nid_s;
  9481. int err;
  9482. char name[32];
  9483. if (!pin)
  9484. return 0;
  9485. if (alc880_is_fixed_pin(pin)) {
  9486. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9487. /* specify the DAC as the extra output */
  9488. if (!spec->multiout.hp_nid)
  9489. spec->multiout.hp_nid = nid_v;
  9490. else
  9491. spec->multiout.extra_out_nid[0] = nid_v;
  9492. /* control HP volume/switch on the output mixer amp */
  9493. nid_v = alc861vd_idx_to_mixer_vol(
  9494. alc880_fixed_pin_idx(pin));
  9495. nid_s = alc861vd_idx_to_mixer_switch(
  9496. alc880_fixed_pin_idx(pin));
  9497. sprintf(name, "%s Playback Volume", pfx);
  9498. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9499. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9500. if (err < 0)
  9501. return err;
  9502. sprintf(name, "%s Playback Switch", pfx);
  9503. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9504. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9505. if (err < 0)
  9506. return err;
  9507. } else if (alc880_is_multi_pin(pin)) {
  9508. /* set manual connection */
  9509. /* we have only a switch on HP-out PIN */
  9510. sprintf(name, "%s Playback Switch", pfx);
  9511. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9512. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9513. if (err < 0)
  9514. return err;
  9515. }
  9516. return 0;
  9517. }
  9518. /* parse the BIOS configuration and set up the alc_spec
  9519. * return 1 if successful, 0 if the proper config is not found,
  9520. * or a negative error code
  9521. * Based on ALC880 version - had to change it to override
  9522. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9523. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9524. {
  9525. struct alc_spec *spec = codec->spec;
  9526. int err;
  9527. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9528. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9529. alc861vd_ignore);
  9530. if (err < 0)
  9531. return err;
  9532. if (!spec->autocfg.line_outs)
  9533. return 0; /* can't find valid BIOS pin config */
  9534. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9535. if (err < 0)
  9536. return err;
  9537. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9538. if (err < 0)
  9539. return err;
  9540. err = alc861vd_auto_create_extra_out(spec,
  9541. spec->autocfg.speaker_pins[0],
  9542. "Speaker");
  9543. if (err < 0)
  9544. return err;
  9545. err = alc861vd_auto_create_extra_out(spec,
  9546. spec->autocfg.hp_pins[0],
  9547. "Headphone");
  9548. if (err < 0)
  9549. return err;
  9550. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9551. if (err < 0)
  9552. return err;
  9553. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9554. if (spec->autocfg.dig_out_pin)
  9555. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9556. if (spec->kctl_alloc)
  9557. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9558. spec->init_verbs[spec->num_init_verbs++]
  9559. = alc861vd_volume_init_verbs;
  9560. spec->num_mux_defs = 1;
  9561. spec->input_mux = &spec->private_imux;
  9562. return 1;
  9563. }
  9564. /* additional initialization for auto-configuration model */
  9565. static void alc861vd_auto_init(struct hda_codec *codec)
  9566. {
  9567. alc861vd_auto_init_multi_out(codec);
  9568. alc861vd_auto_init_hp_out(codec);
  9569. alc861vd_auto_init_analog_input(codec);
  9570. }
  9571. static int patch_alc861vd(struct hda_codec *codec)
  9572. {
  9573. struct alc_spec *spec;
  9574. int err, board_config;
  9575. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9576. if (spec == NULL)
  9577. return -ENOMEM;
  9578. codec->spec = spec;
  9579. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9580. alc861vd_models,
  9581. alc861vd_cfg_tbl);
  9582. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9583. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9584. "ALC861VD, trying auto-probe from BIOS...\n");
  9585. board_config = ALC861VD_AUTO;
  9586. }
  9587. if (board_config == ALC861VD_AUTO) {
  9588. /* automatic parse from the BIOS config */
  9589. err = alc861vd_parse_auto_config(codec);
  9590. if (err < 0) {
  9591. alc_free(codec);
  9592. return err;
  9593. } else if (!err) {
  9594. printk(KERN_INFO
  9595. "hda_codec: Cannot set up configuration "
  9596. "from BIOS. Using base mode...\n");
  9597. board_config = ALC861VD_3ST;
  9598. }
  9599. }
  9600. if (board_config != ALC861VD_AUTO)
  9601. setup_preset(spec, &alc861vd_presets[board_config]);
  9602. spec->stream_name_analog = "ALC861VD Analog";
  9603. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9604. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9605. spec->stream_name_digital = "ALC861VD Digital";
  9606. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9607. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9608. spec->adc_nids = alc861vd_adc_nids;
  9609. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9610. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9611. spec->num_mixers++;
  9612. codec->patch_ops = alc_patch_ops;
  9613. if (board_config == ALC861VD_AUTO)
  9614. spec->init_hook = alc861vd_auto_init;
  9615. return 0;
  9616. }
  9617. /*
  9618. * ALC662 support
  9619. *
  9620. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9621. * configuration. Each pin widget can choose any input DACs and a mixer.
  9622. * Each ADC is connected from a mixer of all inputs. This makes possible
  9623. * 6-channel independent captures.
  9624. *
  9625. * In addition, an independent DAC for the multi-playback (not used in this
  9626. * driver yet).
  9627. */
  9628. #define ALC662_DIGOUT_NID 0x06
  9629. #define ALC662_DIGIN_NID 0x0a
  9630. static hda_nid_t alc662_dac_nids[4] = {
  9631. /* front, rear, clfe, rear_surr */
  9632. 0x02, 0x03, 0x04
  9633. };
  9634. static hda_nid_t alc662_adc_nids[1] = {
  9635. /* ADC1-2 */
  9636. 0x09,
  9637. };
  9638. /* input MUX */
  9639. /* FIXME: should be a matrix-type input source selection */
  9640. static struct hda_input_mux alc662_capture_source = {
  9641. .num_items = 4,
  9642. .items = {
  9643. { "Mic", 0x0 },
  9644. { "Front Mic", 0x1 },
  9645. { "Line", 0x2 },
  9646. { "CD", 0x4 },
  9647. },
  9648. };
  9649. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9650. .num_items = 2,
  9651. .items = {
  9652. { "Mic", 0x1 },
  9653. { "Line", 0x2 },
  9654. },
  9655. };
  9656. #define alc662_mux_enum_info alc_mux_enum_info
  9657. #define alc662_mux_enum_get alc_mux_enum_get
  9658. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9659. struct snd_ctl_elem_value *ucontrol)
  9660. {
  9661. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9662. struct alc_spec *spec = codec->spec;
  9663. const struct hda_input_mux *imux = spec->input_mux;
  9664. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9665. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9666. hda_nid_t nid = capture_mixers[adc_idx];
  9667. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9668. unsigned int i, idx;
  9669. idx = ucontrol->value.enumerated.item[0];
  9670. if (idx >= imux->num_items)
  9671. idx = imux->num_items - 1;
  9672. if (*cur_val == idx && !codec->in_resume)
  9673. return 0;
  9674. for (i = 0; i < imux->num_items; i++) {
  9675. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9676. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9677. v | (imux->items[i].index << 8));
  9678. }
  9679. *cur_val = idx;
  9680. return 1;
  9681. }
  9682. /*
  9683. * 2ch mode
  9684. */
  9685. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9686. { 2, NULL }
  9687. };
  9688. /*
  9689. * 2ch mode
  9690. */
  9691. static struct hda_verb alc662_3ST_ch2_init[] = {
  9692. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9693. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9694. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9695. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9696. { } /* end */
  9697. };
  9698. /*
  9699. * 6ch mode
  9700. */
  9701. static struct hda_verb alc662_3ST_ch6_init[] = {
  9702. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9703. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9704. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9705. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9706. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9707. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9708. { } /* end */
  9709. };
  9710. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9711. { 2, alc662_3ST_ch2_init },
  9712. { 6, alc662_3ST_ch6_init },
  9713. };
  9714. /*
  9715. * 2ch mode
  9716. */
  9717. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9718. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9719. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9720. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9721. { } /* end */
  9722. };
  9723. /*
  9724. * 6ch mode
  9725. */
  9726. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9727. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9728. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9729. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9730. { } /* end */
  9731. };
  9732. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9733. { 2, alc662_sixstack_ch6_init },
  9734. { 6, alc662_sixstack_ch8_init },
  9735. };
  9736. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9737. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9738. */
  9739. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9740. /* output mixer control */
  9741. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9742. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9743. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9744. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9745. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9746. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9747. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9748. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9749. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9750. /*Input mixer control */
  9751. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9752. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9753. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9754. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9755. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9756. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9757. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9758. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9759. /* Capture mixer control */
  9760. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9761. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9762. {
  9763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9764. .name = "Capture Source",
  9765. .count = 1,
  9766. .info = alc_mux_enum_info,
  9767. .get = alc_mux_enum_get,
  9768. .put = alc_mux_enum_put,
  9769. },
  9770. { } /* end */
  9771. };
  9772. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9773. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9774. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9775. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9776. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9777. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9778. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9779. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9780. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9781. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9782. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9783. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9784. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9785. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9786. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9787. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9788. {
  9789. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9790. /* .name = "Capture Source", */
  9791. .name = "Input Source",
  9792. .count = 1,
  9793. .info = alc662_mux_enum_info,
  9794. .get = alc662_mux_enum_get,
  9795. .put = alc662_mux_enum_put,
  9796. },
  9797. { } /* end */
  9798. };
  9799. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9800. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9801. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9802. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9803. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9804. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9805. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9806. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9807. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9808. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9809. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9810. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9811. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9812. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9813. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9814. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9815. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9816. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9817. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9818. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9819. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9820. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9821. {
  9822. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9823. /* .name = "Capture Source", */
  9824. .name = "Input Source",
  9825. .count = 1,
  9826. .info = alc662_mux_enum_info,
  9827. .get = alc662_mux_enum_get,
  9828. .put = alc662_mux_enum_put,
  9829. },
  9830. { } /* end */
  9831. };
  9832. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9833. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9834. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9835. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9836. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9837. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9838. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9839. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9840. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9841. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9842. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9843. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9844. {
  9845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9846. /* .name = "Capture Source", */
  9847. .name = "Input Source",
  9848. .count = 1,
  9849. .info = alc662_mux_enum_info,
  9850. .get = alc662_mux_enum_get,
  9851. .put = alc662_mux_enum_put,
  9852. },
  9853. { } /* end */
  9854. };
  9855. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9856. {
  9857. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9858. .name = "Channel Mode",
  9859. .info = alc_ch_mode_info,
  9860. .get = alc_ch_mode_get,
  9861. .put = alc_ch_mode_put,
  9862. },
  9863. { } /* end */
  9864. };
  9865. static struct hda_verb alc662_init_verbs[] = {
  9866. /* ADC: mute amp left and right */
  9867. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9868. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9869. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9870. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9871. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9872. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9873. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9874. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9875. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9876. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9877. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9878. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9879. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9880. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9881. /* Front Pin: output 0 (0x0c) */
  9882. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9883. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9884. /* Rear Pin: output 1 (0x0d) */
  9885. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9886. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9887. /* CLFE Pin: output 2 (0x0e) */
  9888. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9889. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9890. /* Mic (rear) pin: input vref at 80% */
  9891. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9892. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9893. /* Front Mic pin: input vref at 80% */
  9894. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9895. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9896. /* Line In pin: input */
  9897. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9898. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9899. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9900. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9901. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9902. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9903. /* CD pin widget for input */
  9904. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9905. /* FIXME: use matrix-type input source selection */
  9906. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9907. /* Input mixer */
  9908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9912. { }
  9913. };
  9914. static struct hda_verb alc662_sue_init_verbs[] = {
  9915. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9916. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9917. {}
  9918. };
  9919. /*
  9920. * generic initialization of ADC, input mixers and output mixers
  9921. */
  9922. static struct hda_verb alc662_auto_init_verbs[] = {
  9923. /*
  9924. * Unmute ADC and set the default input to mic-in
  9925. */
  9926. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9927. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9928. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9929. * mixer widget
  9930. * Note: PASD motherboards uses the Line In 2 as the input for front
  9931. * panel mic (mic 2)
  9932. */
  9933. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9934. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9937. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9938. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9939. /*
  9940. * Set up output mixers (0x0c - 0x0f)
  9941. */
  9942. /* set vol=0 to output mixers */
  9943. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9944. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9945. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9946. /* set up input amps for analog loopback */
  9947. /* Amp Indices: DAC = 0, mixer = 1 */
  9948. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9949. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9950. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9951. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9952. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9953. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9954. /* FIXME: use matrix-type input source selection */
  9955. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9956. /* Input mixer */
  9957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9960. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9962. { }
  9963. };
  9964. /* capture mixer elements */
  9965. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9966. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9967. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9968. {
  9969. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9970. /* The multiple "Capture Source" controls confuse alsamixer
  9971. * So call somewhat different..
  9972. * FIXME: the controls appear in the "playback" view!
  9973. */
  9974. /* .name = "Capture Source", */
  9975. .name = "Input Source",
  9976. .count = 1,
  9977. .info = alc882_mux_enum_info,
  9978. .get = alc882_mux_enum_get,
  9979. .put = alc882_mux_enum_put,
  9980. },
  9981. { } /* end */
  9982. };
  9983. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9984. {
  9985. unsigned int present;
  9986. unsigned char bits;
  9987. present = snd_hda_codec_read(codec, 0x14, 0,
  9988. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9989. bits = present ? 0x80 : 0;
  9990. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9991. 0x80, bits);
  9992. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9993. 0x80, bits);
  9994. }
  9995. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9996. {
  9997. unsigned int present;
  9998. unsigned char bits;
  9999. present = snd_hda_codec_read(codec, 0x1b, 0,
  10000. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10001. bits = present ? 0x80 : 0;
  10002. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10003. 0x80, bits);
  10004. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10005. 0x80, bits);
  10006. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10007. 0x80, bits);
  10008. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10009. 0x80, bits);
  10010. }
  10011. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10012. unsigned int res)
  10013. {
  10014. if ((res >> 26) == ALC880_HP_EVENT)
  10015. alc662_lenovo_101e_all_automute(codec);
  10016. if ((res >> 26) == ALC880_FRONT_EVENT)
  10017. alc662_lenovo_101e_ispeaker_automute(codec);
  10018. }
  10019. /* pcm configuration: identiacal with ALC880 */
  10020. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10021. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10022. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10023. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10024. /*
  10025. * configuration and preset
  10026. */
  10027. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10028. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10029. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10030. [ALC662_3ST_6ch] = "3stack-6ch",
  10031. [ALC662_5ST_DIG] = "6stack-dig",
  10032. [ALC662_LENOVO_101E] = "lenovo-101e",
  10033. [ALC662_AUTO] = "auto",
  10034. };
  10035. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10036. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10037. {}
  10038. };
  10039. static struct alc_config_preset alc662_presets[] = {
  10040. [ALC662_3ST_2ch_DIG] = {
  10041. .mixers = { alc662_3ST_2ch_mixer },
  10042. .init_verbs = { alc662_init_verbs },
  10043. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10044. .dac_nids = alc662_dac_nids,
  10045. .dig_out_nid = ALC662_DIGOUT_NID,
  10046. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10047. .adc_nids = alc662_adc_nids,
  10048. .dig_in_nid = ALC662_DIGIN_NID,
  10049. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10050. .channel_mode = alc662_3ST_2ch_modes,
  10051. .input_mux = &alc662_capture_source,
  10052. },
  10053. [ALC662_3ST_6ch_DIG] = {
  10054. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10055. .init_verbs = { alc662_init_verbs },
  10056. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10057. .dac_nids = alc662_dac_nids,
  10058. .dig_out_nid = ALC662_DIGOUT_NID,
  10059. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10060. .adc_nids = alc662_adc_nids,
  10061. .dig_in_nid = ALC662_DIGIN_NID,
  10062. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10063. .channel_mode = alc662_3ST_6ch_modes,
  10064. .need_dac_fix = 1,
  10065. .input_mux = &alc662_capture_source,
  10066. },
  10067. [ALC662_3ST_6ch] = {
  10068. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10069. .init_verbs = { alc662_init_verbs },
  10070. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10071. .dac_nids = alc662_dac_nids,
  10072. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10073. .adc_nids = alc662_adc_nids,
  10074. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10075. .channel_mode = alc662_3ST_6ch_modes,
  10076. .need_dac_fix = 1,
  10077. .input_mux = &alc662_capture_source,
  10078. },
  10079. [ALC662_5ST_DIG] = {
  10080. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10081. .init_verbs = { alc662_init_verbs },
  10082. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10083. .dac_nids = alc662_dac_nids,
  10084. .dig_out_nid = ALC662_DIGOUT_NID,
  10085. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10086. .adc_nids = alc662_adc_nids,
  10087. .dig_in_nid = ALC662_DIGIN_NID,
  10088. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10089. .channel_mode = alc662_5stack_modes,
  10090. .input_mux = &alc662_capture_source,
  10091. },
  10092. [ALC662_LENOVO_101E] = {
  10093. .mixers = { alc662_lenovo_101e_mixer },
  10094. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10095. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10096. .dac_nids = alc662_dac_nids,
  10097. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10098. .adc_nids = alc662_adc_nids,
  10099. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10100. .channel_mode = alc662_3ST_2ch_modes,
  10101. .input_mux = &alc662_lenovo_101e_capture_source,
  10102. .unsol_event = alc662_lenovo_101e_unsol_event,
  10103. .init_hook = alc662_lenovo_101e_all_automute,
  10104. },
  10105. };
  10106. /*
  10107. * BIOS auto configuration
  10108. */
  10109. /* add playback controls from the parsed DAC table */
  10110. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10111. const struct auto_pin_cfg *cfg)
  10112. {
  10113. char name[32];
  10114. static const char *chname[4] = {
  10115. "Front", "Surround", NULL /*CLFE*/, "Side"
  10116. };
  10117. hda_nid_t nid;
  10118. int i, err;
  10119. for (i = 0; i < cfg->line_outs; i++) {
  10120. if (!spec->multiout.dac_nids[i])
  10121. continue;
  10122. nid = alc880_idx_to_mixer(i);
  10123. if (i == 2) {
  10124. /* Center/LFE */
  10125. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10126. "Center Playback Volume",
  10127. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10128. HDA_OUTPUT));
  10129. if (err < 0)
  10130. return err;
  10131. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10132. "LFE Playback Volume",
  10133. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10134. HDA_OUTPUT));
  10135. if (err < 0)
  10136. return err;
  10137. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10138. "Center Playback Switch",
  10139. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10140. HDA_INPUT));
  10141. if (err < 0)
  10142. return err;
  10143. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10144. "LFE Playback Switch",
  10145. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10146. HDA_INPUT));
  10147. if (err < 0)
  10148. return err;
  10149. } else {
  10150. sprintf(name, "%s Playback Volume", chname[i]);
  10151. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10152. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10153. HDA_OUTPUT));
  10154. if (err < 0)
  10155. return err;
  10156. sprintf(name, "%s Playback Switch", chname[i]);
  10157. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10158. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10159. HDA_INPUT));
  10160. if (err < 0)
  10161. return err;
  10162. }
  10163. }
  10164. return 0;
  10165. }
  10166. /* add playback controls for speaker and HP outputs */
  10167. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10168. const char *pfx)
  10169. {
  10170. hda_nid_t nid;
  10171. int err;
  10172. char name[32];
  10173. if (!pin)
  10174. return 0;
  10175. if (alc880_is_fixed_pin(pin)) {
  10176. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10177. /* printk("DAC nid=%x\n",nid); */
  10178. /* specify the DAC as the extra output */
  10179. if (!spec->multiout.hp_nid)
  10180. spec->multiout.hp_nid = nid;
  10181. else
  10182. spec->multiout.extra_out_nid[0] = nid;
  10183. /* control HP volume/switch on the output mixer amp */
  10184. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10185. sprintf(name, "%s Playback Volume", pfx);
  10186. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10187. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10188. if (err < 0)
  10189. return err;
  10190. sprintf(name, "%s Playback Switch", pfx);
  10191. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10192. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10193. if (err < 0)
  10194. return err;
  10195. } else if (alc880_is_multi_pin(pin)) {
  10196. /* set manual connection */
  10197. /* we have only a switch on HP-out PIN */
  10198. sprintf(name, "%s Playback Switch", pfx);
  10199. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10200. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10201. if (err < 0)
  10202. return err;
  10203. }
  10204. return 0;
  10205. }
  10206. /* create playback/capture controls for input pins */
  10207. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10208. const struct auto_pin_cfg *cfg)
  10209. {
  10210. struct hda_input_mux *imux = &spec->private_imux;
  10211. int i, err, idx;
  10212. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10213. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10214. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10215. err = new_analog_input(spec, cfg->input_pins[i],
  10216. auto_pin_cfg_labels[i],
  10217. idx, 0x0b);
  10218. if (err < 0)
  10219. return err;
  10220. imux->items[imux->num_items].label =
  10221. auto_pin_cfg_labels[i];
  10222. imux->items[imux->num_items].index =
  10223. alc880_input_pin_idx(cfg->input_pins[i]);
  10224. imux->num_items++;
  10225. }
  10226. }
  10227. return 0;
  10228. }
  10229. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10230. hda_nid_t nid, int pin_type,
  10231. int dac_idx)
  10232. {
  10233. /* set as output */
  10234. snd_hda_codec_write(codec, nid, 0,
  10235. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10236. snd_hda_codec_write(codec, nid, 0,
  10237. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10238. /* need the manual connection? */
  10239. if (alc880_is_multi_pin(nid)) {
  10240. struct alc_spec *spec = codec->spec;
  10241. int idx = alc880_multi_pin_idx(nid);
  10242. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10243. AC_VERB_SET_CONNECT_SEL,
  10244. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10245. }
  10246. }
  10247. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10248. {
  10249. struct alc_spec *spec = codec->spec;
  10250. int i;
  10251. for (i = 0; i <= HDA_SIDE; i++) {
  10252. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10253. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10254. if (nid)
  10255. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10256. i);
  10257. }
  10258. }
  10259. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10260. {
  10261. struct alc_spec *spec = codec->spec;
  10262. hda_nid_t pin;
  10263. pin = spec->autocfg.hp_pins[0];
  10264. if (pin) /* connect to front */
  10265. /* use dac 0 */
  10266. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10267. }
  10268. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10269. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10270. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10271. {
  10272. struct alc_spec *spec = codec->spec;
  10273. int i;
  10274. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10275. hda_nid_t nid = spec->autocfg.input_pins[i];
  10276. if (alc662_is_input_pin(nid)) {
  10277. snd_hda_codec_write(codec, nid, 0,
  10278. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10279. (i <= AUTO_PIN_FRONT_MIC ?
  10280. PIN_VREF80 : PIN_IN));
  10281. if (nid != ALC662_PIN_CD_NID)
  10282. snd_hda_codec_write(codec, nid, 0,
  10283. AC_VERB_SET_AMP_GAIN_MUTE,
  10284. AMP_OUT_MUTE);
  10285. }
  10286. }
  10287. }
  10288. static int alc662_parse_auto_config(struct hda_codec *codec)
  10289. {
  10290. struct alc_spec *spec = codec->spec;
  10291. int err;
  10292. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10293. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10294. alc662_ignore);
  10295. if (err < 0)
  10296. return err;
  10297. if (!spec->autocfg.line_outs)
  10298. return 0; /* can't find valid BIOS pin config */
  10299. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10300. if (err < 0)
  10301. return err;
  10302. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10303. if (err < 0)
  10304. return err;
  10305. err = alc662_auto_create_extra_out(spec,
  10306. spec->autocfg.speaker_pins[0],
  10307. "Speaker");
  10308. if (err < 0)
  10309. return err;
  10310. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10311. "Headphone");
  10312. if (err < 0)
  10313. return err;
  10314. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10315. if (err < 0)
  10316. return err;
  10317. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10318. if (spec->autocfg.dig_out_pin)
  10319. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10320. if (spec->kctl_alloc)
  10321. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10322. spec->num_mux_defs = 1;
  10323. spec->input_mux = &spec->private_imux;
  10324. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10325. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10326. spec->num_mixers++;
  10327. return 1;
  10328. }
  10329. /* additional initialization for auto-configuration model */
  10330. static void alc662_auto_init(struct hda_codec *codec)
  10331. {
  10332. alc662_auto_init_multi_out(codec);
  10333. alc662_auto_init_hp_out(codec);
  10334. alc662_auto_init_analog_input(codec);
  10335. }
  10336. static int patch_alc662(struct hda_codec *codec)
  10337. {
  10338. struct alc_spec *spec;
  10339. int err, board_config;
  10340. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10341. if (!spec)
  10342. return -ENOMEM;
  10343. codec->spec = spec;
  10344. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10345. alc662_models,
  10346. alc662_cfg_tbl);
  10347. if (board_config < 0) {
  10348. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10349. "trying auto-probe from BIOS...\n");
  10350. board_config = ALC662_AUTO;
  10351. }
  10352. if (board_config == ALC662_AUTO) {
  10353. /* automatic parse from the BIOS config */
  10354. err = alc662_parse_auto_config(codec);
  10355. if (err < 0) {
  10356. alc_free(codec);
  10357. return err;
  10358. } else if (!err) {
  10359. printk(KERN_INFO
  10360. "hda_codec: Cannot set up configuration "
  10361. "from BIOS. Using base mode...\n");
  10362. board_config = ALC662_3ST_2ch_DIG;
  10363. }
  10364. }
  10365. if (board_config != ALC662_AUTO)
  10366. setup_preset(spec, &alc662_presets[board_config]);
  10367. spec->stream_name_analog = "ALC662 Analog";
  10368. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10369. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10370. spec->stream_name_digital = "ALC662 Digital";
  10371. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10372. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10373. if (!spec->adc_nids && spec->input_mux) {
  10374. spec->adc_nids = alc662_adc_nids;
  10375. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10376. }
  10377. codec->patch_ops = alc_patch_ops;
  10378. if (board_config == ALC662_AUTO)
  10379. spec->init_hook = alc662_auto_init;
  10380. return 0;
  10381. }
  10382. /*
  10383. * patch entries
  10384. */
  10385. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10386. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10387. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10388. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10389. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10390. .patch = patch_alc861 },
  10391. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10392. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10393. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10394. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10395. .patch = patch_alc883 },
  10396. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10397. .patch = patch_alc662 },
  10398. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10399. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10400. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10401. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10402. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10403. {} /* terminator */
  10404. };