patch_realtek.c 356 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741
  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_AUTO,
  93. ALC262_MODEL_LAST /* last tag */
  94. };
  95. /* ALC861 models */
  96. enum {
  97. ALC861_3ST,
  98. ALC660_3ST,
  99. ALC861_3ST_DIG,
  100. ALC861_6ST_DIG,
  101. ALC861_UNIWILL_M31,
  102. ALC861_TOSHIBA,
  103. ALC861_ASUS,
  104. ALC861_ASUS_LAPTOP,
  105. ALC861_AUTO,
  106. ALC861_MODEL_LAST,
  107. };
  108. /* ALC861-VD models */
  109. enum {
  110. ALC660VD_3ST,
  111. ALC861VD_3ST,
  112. ALC861VD_3ST_DIG,
  113. ALC861VD_6ST_DIG,
  114. ALC861VD_LENOVO,
  115. ALC861VD_DALLAS,
  116. ALC861VD_AUTO,
  117. ALC861VD_MODEL_LAST,
  118. };
  119. /* ALC662 models */
  120. enum {
  121. ALC662_3ST_2ch_DIG,
  122. ALC662_3ST_6ch_DIG,
  123. ALC662_3ST_6ch,
  124. ALC662_5ST_DIG,
  125. ALC662_LENOVO_101E,
  126. ALC662_AUTO,
  127. ALC662_MODEL_LAST,
  128. };
  129. /* ALC882 models */
  130. enum {
  131. ALC882_3ST_DIG,
  132. ALC882_6ST_DIG,
  133. ALC882_ARIMA,
  134. ALC882_W2JC,
  135. ALC882_TARGA,
  136. ALC882_ASUS_A7J,
  137. ALC885_MACPRO,
  138. ALC882_AUTO,
  139. ALC882_MODEL_LAST,
  140. };
  141. /* ALC883 models */
  142. enum {
  143. ALC883_3ST_2ch_DIG,
  144. ALC883_3ST_6ch_DIG,
  145. ALC883_3ST_6ch,
  146. ALC883_6ST_DIG,
  147. ALC883_TARGA_DIG,
  148. ALC883_TARGA_2ch_DIG,
  149. ALC883_ACER,
  150. ALC883_MEDION,
  151. ALC883_MEDION_MD2,
  152. ALC883_LAPTOP_EAPD,
  153. ALC883_LENOVO_101E_2ch,
  154. ALC883_LENOVO_NB0763,
  155. ALC888_LENOVO_MS7195_DIG,
  156. ALC883_AUTO,
  157. ALC883_MODEL_LAST,
  158. };
  159. /* for GPIO Poll */
  160. #define GPIO_MASK 0x03
  161. struct alc_spec {
  162. /* codec parameterization */
  163. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  164. unsigned int num_mixers;
  165. const struct hda_verb *init_verbs[5]; /* initialization verbs
  166. * don't forget NULL
  167. * termination!
  168. */
  169. unsigned int num_init_verbs;
  170. char *stream_name_analog; /* analog PCM stream */
  171. struct hda_pcm_stream *stream_analog_playback;
  172. struct hda_pcm_stream *stream_analog_capture;
  173. char *stream_name_digital; /* digital PCM stream */
  174. struct hda_pcm_stream *stream_digital_playback;
  175. struct hda_pcm_stream *stream_digital_capture;
  176. /* playback */
  177. struct hda_multi_out multiout; /* playback set-up
  178. * max_channels, dacs must be set
  179. * dig_out_nid and hp_nid are optional
  180. */
  181. /* capture */
  182. unsigned int num_adc_nids;
  183. hda_nid_t *adc_nids;
  184. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  185. /* capture source */
  186. unsigned int num_mux_defs;
  187. const struct hda_input_mux *input_mux;
  188. unsigned int cur_mux[3];
  189. /* channel model */
  190. const struct hda_channel_mode *channel_mode;
  191. int num_channel_mode;
  192. int need_dac_fix;
  193. /* PCM information */
  194. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  195. /* dynamic controls, init_verbs and input_mux */
  196. struct auto_pin_cfg autocfg;
  197. unsigned int num_kctl_alloc, num_kctl_used;
  198. struct snd_kcontrol_new *kctl_alloc;
  199. struct hda_input_mux private_imux;
  200. hda_nid_t private_dac_nids[5];
  201. /* hooks */
  202. void (*init_hook)(struct hda_codec *codec);
  203. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  204. /* for pin sensing */
  205. unsigned int sense_updated: 1;
  206. unsigned int jack_present: 1;
  207. };
  208. /*
  209. * configuration template - to be copied to the spec instance
  210. */
  211. struct alc_config_preset {
  212. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  213. * with spec
  214. */
  215. const struct hda_verb *init_verbs[5];
  216. unsigned int num_dacs;
  217. hda_nid_t *dac_nids;
  218. hda_nid_t dig_out_nid; /* optional */
  219. hda_nid_t hp_nid; /* optional */
  220. unsigned int num_adc_nids;
  221. hda_nid_t *adc_nids;
  222. hda_nid_t dig_in_nid;
  223. unsigned int num_channel_mode;
  224. const struct hda_channel_mode *channel_mode;
  225. int need_dac_fix;
  226. unsigned int num_mux_defs;
  227. const struct hda_input_mux *input_mux;
  228. void (*unsol_event)(struct hda_codec *, unsigned int);
  229. void (*init_hook)(struct hda_codec *);
  230. };
  231. /*
  232. * input MUX handling
  233. */
  234. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  235. struct snd_ctl_elem_info *uinfo)
  236. {
  237. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  238. struct alc_spec *spec = codec->spec;
  239. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  240. if (mux_idx >= spec->num_mux_defs)
  241. mux_idx = 0;
  242. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  243. }
  244. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  245. struct snd_ctl_elem_value *ucontrol)
  246. {
  247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  248. struct alc_spec *spec = codec->spec;
  249. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  250. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  251. return 0;
  252. }
  253. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  254. struct snd_ctl_elem_value *ucontrol)
  255. {
  256. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  257. struct alc_spec *spec = codec->spec;
  258. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  259. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  260. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  261. spec->adc_nids[adc_idx],
  262. &spec->cur_mux[adc_idx]);
  263. }
  264. /*
  265. * channel mode setting
  266. */
  267. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_info *uinfo)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  273. spec->num_channel_mode);
  274. }
  275. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  276. struct snd_ctl_elem_value *ucontrol)
  277. {
  278. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  279. struct alc_spec *spec = codec->spec;
  280. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  281. spec->num_channel_mode,
  282. spec->multiout.max_channels);
  283. }
  284. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  285. struct snd_ctl_elem_value *ucontrol)
  286. {
  287. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  288. struct alc_spec *spec = codec->spec;
  289. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  290. spec->num_channel_mode,
  291. &spec->multiout.max_channels);
  292. if (err >= 0 && spec->need_dac_fix)
  293. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  294. return err;
  295. }
  296. /*
  297. * Control the mode of pin widget settings via the mixer. "pc" is used
  298. * instead of "%" to avoid consequences of accidently treating the % as
  299. * being part of a format specifier. Maximum allowed length of a value is
  300. * 63 characters plus NULL terminator.
  301. *
  302. * Note: some retasking pin complexes seem to ignore requests for input
  303. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  304. * are requested. Therefore order this list so that this behaviour will not
  305. * cause problems when mixer clients move through the enum sequentially.
  306. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  307. * March 2006.
  308. */
  309. static char *alc_pin_mode_names[] = {
  310. "Mic 50pc bias", "Mic 80pc bias",
  311. "Line in", "Line out", "Headphone out",
  312. };
  313. static unsigned char alc_pin_mode_values[] = {
  314. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  315. };
  316. /* The control can present all 5 options, or it can limit the options based
  317. * in the pin being assumed to be exclusively an input or an output pin. In
  318. * addition, "input" pins may or may not process the mic bias option
  319. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  320. * accept requests for bias as of chip versions up to March 2006) and/or
  321. * wiring in the computer.
  322. */
  323. #define ALC_PIN_DIR_IN 0x00
  324. #define ALC_PIN_DIR_OUT 0x01
  325. #define ALC_PIN_DIR_INOUT 0x02
  326. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  327. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  328. /* Info about the pin modes supported by the different pin direction modes.
  329. * For each direction the minimum and maximum values are given.
  330. */
  331. static signed char alc_pin_mode_dir_info[5][2] = {
  332. { 0, 2 }, /* ALC_PIN_DIR_IN */
  333. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  334. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  335. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  336. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  337. };
  338. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  339. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  340. #define alc_pin_mode_n_items(_dir) \
  341. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  342. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  343. struct snd_ctl_elem_info *uinfo)
  344. {
  345. unsigned int item_num = uinfo->value.enumerated.item;
  346. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  347. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  348. uinfo->count = 1;
  349. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  350. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  351. item_num = alc_pin_mode_min(dir);
  352. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  353. return 0;
  354. }
  355. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  356. struct snd_ctl_elem_value *ucontrol)
  357. {
  358. unsigned int i;
  359. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  360. hda_nid_t nid = kcontrol->private_value & 0xffff;
  361. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  362. long *valp = ucontrol->value.integer.value;
  363. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  364. AC_VERB_GET_PIN_WIDGET_CONTROL,
  365. 0x00);
  366. /* Find enumerated value for current pinctl setting */
  367. i = alc_pin_mode_min(dir);
  368. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  369. i++;
  370. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  371. return 0;
  372. }
  373. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  374. struct snd_ctl_elem_value *ucontrol)
  375. {
  376. signed int change;
  377. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  378. hda_nid_t nid = kcontrol->private_value & 0xffff;
  379. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  380. long val = *ucontrol->value.integer.value;
  381. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  382. AC_VERB_GET_PIN_WIDGET_CONTROL,
  383. 0x00);
  384. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  385. val = alc_pin_mode_min(dir);
  386. change = pinctl != alc_pin_mode_values[val];
  387. if (change) {
  388. /* Set pin mode to that requested */
  389. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  390. alc_pin_mode_values[val]);
  391. /* Also enable the retasking pin's input/output as required
  392. * for the requested pin mode. Enum values of 2 or less are
  393. * input modes.
  394. *
  395. * Dynamically switching the input/output buffers probably
  396. * reduces noise slightly (particularly on input) so we'll
  397. * do it. However, having both input and output buffers
  398. * enabled simultaneously doesn't seem to be problematic if
  399. * this turns out to be necessary in the future.
  400. */
  401. if (val <= 2) {
  402. snd_hda_codec_write(codec, nid, 0,
  403. AC_VERB_SET_AMP_GAIN_MUTE,
  404. AMP_OUT_MUTE);
  405. snd_hda_codec_write(codec, nid, 0,
  406. AC_VERB_SET_AMP_GAIN_MUTE,
  407. AMP_IN_UNMUTE(0));
  408. } else {
  409. snd_hda_codec_write(codec, nid, 0,
  410. AC_VERB_SET_AMP_GAIN_MUTE,
  411. AMP_IN_MUTE(0));
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_OUT_UNMUTE);
  415. }
  416. }
  417. return change;
  418. }
  419. #define ALC_PIN_MODE(xname, nid, dir) \
  420. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  421. .info = alc_pin_mode_info, \
  422. .get = alc_pin_mode_get, \
  423. .put = alc_pin_mode_put, \
  424. .private_value = nid | (dir<<16) }
  425. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  426. * together using a mask with more than one bit set. This control is
  427. * currently used only by the ALC260 test model. At this stage they are not
  428. * needed for any "production" models.
  429. */
  430. #ifdef CONFIG_SND_DEBUG
  431. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_info *uinfo)
  433. {
  434. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  435. uinfo->count = 1;
  436. uinfo->value.integer.min = 0;
  437. uinfo->value.integer.max = 1;
  438. return 0;
  439. }
  440. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  441. struct snd_ctl_elem_value *ucontrol)
  442. {
  443. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  444. hda_nid_t nid = kcontrol->private_value & 0xffff;
  445. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  446. long *valp = ucontrol->value.integer.value;
  447. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  448. AC_VERB_GET_GPIO_DATA, 0x00);
  449. *valp = (val & mask) != 0;
  450. return 0;
  451. }
  452. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  453. struct snd_ctl_elem_value *ucontrol)
  454. {
  455. signed int change;
  456. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  457. hda_nid_t nid = kcontrol->private_value & 0xffff;
  458. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  459. long val = *ucontrol->value.integer.value;
  460. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  461. AC_VERB_GET_GPIO_DATA,
  462. 0x00);
  463. /* Set/unset the masked GPIO bit(s) as needed */
  464. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  465. if (val == 0)
  466. gpio_data &= ~mask;
  467. else
  468. gpio_data |= mask;
  469. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  470. return change;
  471. }
  472. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  473. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  474. .info = alc_gpio_data_info, \
  475. .get = alc_gpio_data_get, \
  476. .put = alc_gpio_data_put, \
  477. .private_value = nid | (mask<<16) }
  478. #endif /* CONFIG_SND_DEBUG */
  479. /* A switch control to allow the enabling of the digital IO pins on the
  480. * ALC260. This is incredibly simplistic; the intention of this control is
  481. * to provide something in the test model allowing digital outputs to be
  482. * identified if present. If models are found which can utilise these
  483. * outputs a more complete mixer control can be devised for those models if
  484. * necessary.
  485. */
  486. #ifdef CONFIG_SND_DEBUG
  487. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  488. struct snd_ctl_elem_info *uinfo)
  489. {
  490. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  491. uinfo->count = 1;
  492. uinfo->value.integer.min = 0;
  493. uinfo->value.integer.max = 1;
  494. return 0;
  495. }
  496. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  497. struct snd_ctl_elem_value *ucontrol)
  498. {
  499. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  500. hda_nid_t nid = kcontrol->private_value & 0xffff;
  501. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  502. long *valp = ucontrol->value.integer.value;
  503. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  504. AC_VERB_GET_DIGI_CONVERT, 0x00);
  505. *valp = (val & mask) != 0;
  506. return 0;
  507. }
  508. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  509. struct snd_ctl_elem_value *ucontrol)
  510. {
  511. signed int change;
  512. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  513. hda_nid_t nid = kcontrol->private_value & 0xffff;
  514. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  515. long val = *ucontrol->value.integer.value;
  516. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  517. AC_VERB_GET_DIGI_CONVERT,
  518. 0x00);
  519. /* Set/unset the masked control bit(s) as needed */
  520. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  521. if (val==0)
  522. ctrl_data &= ~mask;
  523. else
  524. ctrl_data |= mask;
  525. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  526. ctrl_data);
  527. return change;
  528. }
  529. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  530. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  531. .info = alc_spdif_ctrl_info, \
  532. .get = alc_spdif_ctrl_get, \
  533. .put = alc_spdif_ctrl_put, \
  534. .private_value = nid | (mask<<16) }
  535. #endif /* CONFIG_SND_DEBUG */
  536. /*
  537. * set up from the preset table
  538. */
  539. static void setup_preset(struct alc_spec *spec,
  540. const struct alc_config_preset *preset)
  541. {
  542. int i;
  543. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  544. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  545. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  546. i++)
  547. spec->init_verbs[spec->num_init_verbs++] =
  548. preset->init_verbs[i];
  549. spec->channel_mode = preset->channel_mode;
  550. spec->num_channel_mode = preset->num_channel_mode;
  551. spec->need_dac_fix = preset->need_dac_fix;
  552. spec->multiout.max_channels = spec->channel_mode[0].channels;
  553. spec->multiout.num_dacs = preset->num_dacs;
  554. spec->multiout.dac_nids = preset->dac_nids;
  555. spec->multiout.dig_out_nid = preset->dig_out_nid;
  556. spec->multiout.hp_nid = preset->hp_nid;
  557. spec->num_mux_defs = preset->num_mux_defs;
  558. if (!spec->num_mux_defs)
  559. spec->num_mux_defs = 1;
  560. spec->input_mux = preset->input_mux;
  561. spec->num_adc_nids = preset->num_adc_nids;
  562. spec->adc_nids = preset->adc_nids;
  563. spec->dig_in_nid = preset->dig_in_nid;
  564. spec->unsol_event = preset->unsol_event;
  565. spec->init_hook = preset->init_hook;
  566. }
  567. /* Enable GPIO mask and set output */
  568. static struct hda_verb alc_gpio1_init_verbs[] = {
  569. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  570. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  571. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  572. { }
  573. };
  574. static struct hda_verb alc_gpio2_init_verbs[] = {
  575. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  576. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  577. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  578. { }
  579. };
  580. static struct hda_verb alc_gpio3_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  584. { }
  585. };
  586. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  587. * 31 ~ 16 : Manufacture ID
  588. * 15 ~ 8 : SKU ID
  589. * 7 ~ 0 : Assembly ID
  590. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  591. */
  592. static void alc_subsystem_id(struct hda_codec *codec,
  593. unsigned int porta, unsigned int porte,
  594. unsigned int portd)
  595. {
  596. unsigned int ass, tmp;
  597. ass = codec->subsystem_id;
  598. if (!(ass & 1))
  599. return;
  600. /* Override */
  601. tmp = (ass & 0x38) >> 3; /* external Amp control */
  602. switch (tmp) {
  603. case 1:
  604. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  605. break;
  606. case 3:
  607. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  608. break;
  609. case 7:
  610. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  611. break;
  612. case 5:
  613. switch (codec->vendor_id) {
  614. case 0x10ec0862:
  615. case 0x10ec0660:
  616. case 0x10ec0662:
  617. case 0x10ec0267:
  618. case 0x10ec0268:
  619. snd_hda_codec_write(codec, 0x14, 0,
  620. AC_VERB_SET_EAPD_BTLENABLE, 2);
  621. snd_hda_codec_write(codec, 0x15, 0,
  622. AC_VERB_SET_EAPD_BTLENABLE, 2);
  623. return;
  624. }
  625. case 6:
  626. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  627. hda_nid_t port = 0;
  628. tmp = (ass & 0x1800) >> 11;
  629. switch (tmp) {
  630. case 0: port = porta; break;
  631. case 1: port = porte; break;
  632. case 2: port = portd; break;
  633. }
  634. if (port)
  635. snd_hda_codec_write(codec, port, 0,
  636. AC_VERB_SET_EAPD_BTLENABLE,
  637. 2);
  638. }
  639. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  640. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  641. (tmp == 5 ? 0x3040 : 0x3050));
  642. break;
  643. }
  644. }
  645. /*
  646. * ALC880 3-stack model
  647. *
  648. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  649. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  650. * F-Mic = 0x1b, HP = 0x19
  651. */
  652. static hda_nid_t alc880_dac_nids[4] = {
  653. /* front, rear, clfe, rear_surr */
  654. 0x02, 0x05, 0x04, 0x03
  655. };
  656. static hda_nid_t alc880_adc_nids[3] = {
  657. /* ADC0-2 */
  658. 0x07, 0x08, 0x09,
  659. };
  660. /* The datasheet says the node 0x07 is connected from inputs,
  661. * but it shows zero connection in the real implementation on some devices.
  662. * Note: this is a 915GAV bug, fixed on 915GLV
  663. */
  664. static hda_nid_t alc880_adc_nids_alt[2] = {
  665. /* ADC1-2 */
  666. 0x08, 0x09,
  667. };
  668. #define ALC880_DIGOUT_NID 0x06
  669. #define ALC880_DIGIN_NID 0x0a
  670. static struct hda_input_mux alc880_capture_source = {
  671. .num_items = 4,
  672. .items = {
  673. { "Mic", 0x0 },
  674. { "Front Mic", 0x3 },
  675. { "Line", 0x2 },
  676. { "CD", 0x4 },
  677. },
  678. };
  679. /* channel source setting (2/6 channel selection for 3-stack) */
  680. /* 2ch mode */
  681. static struct hda_verb alc880_threestack_ch2_init[] = {
  682. /* set line-in to input, mute it */
  683. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  684. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  685. /* set mic-in to input vref 80%, mute it */
  686. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  687. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  688. { } /* end */
  689. };
  690. /* 6ch mode */
  691. static struct hda_verb alc880_threestack_ch6_init[] = {
  692. /* set line-in to output, unmute it */
  693. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  694. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  695. /* set mic-in to output, unmute it */
  696. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  697. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  698. { } /* end */
  699. };
  700. static struct hda_channel_mode alc880_threestack_modes[2] = {
  701. { 2, alc880_threestack_ch2_init },
  702. { 6, alc880_threestack_ch6_init },
  703. };
  704. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  705. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  706. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  707. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  708. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  709. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  710. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  711. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  712. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  713. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  714. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  715. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  716. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  717. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  718. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  719. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  720. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  721. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  722. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  723. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  724. {
  725. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  726. .name = "Channel Mode",
  727. .info = alc_ch_mode_info,
  728. .get = alc_ch_mode_get,
  729. .put = alc_ch_mode_put,
  730. },
  731. { } /* end */
  732. };
  733. /* capture mixer elements */
  734. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  735. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  736. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  737. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  738. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  739. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  740. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  741. {
  742. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  743. /* The multiple "Capture Source" controls confuse alsamixer
  744. * So call somewhat different..
  745. * FIXME: the controls appear in the "playback" view!
  746. */
  747. /* .name = "Capture Source", */
  748. .name = "Input Source",
  749. .count = 3,
  750. .info = alc_mux_enum_info,
  751. .get = alc_mux_enum_get,
  752. .put = alc_mux_enum_put,
  753. },
  754. { } /* end */
  755. };
  756. /* capture mixer elements (in case NID 0x07 not available) */
  757. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  758. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  759. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  760. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  761. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  762. {
  763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  764. /* The multiple "Capture Source" controls confuse alsamixer
  765. * So call somewhat different..
  766. * FIXME: the controls appear in the "playback" view!
  767. */
  768. /* .name = "Capture Source", */
  769. .name = "Input Source",
  770. .count = 2,
  771. .info = alc_mux_enum_info,
  772. .get = alc_mux_enum_get,
  773. .put = alc_mux_enum_put,
  774. },
  775. { } /* end */
  776. };
  777. /*
  778. * ALC880 5-stack model
  779. *
  780. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  781. * Side = 0x02 (0xd)
  782. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  783. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  784. */
  785. /* additional mixers to alc880_three_stack_mixer */
  786. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  787. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  788. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  789. { } /* end */
  790. };
  791. /* channel source setting (6/8 channel selection for 5-stack) */
  792. /* 6ch mode */
  793. static struct hda_verb alc880_fivestack_ch6_init[] = {
  794. /* set line-in to input, mute it */
  795. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  796. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  797. { } /* end */
  798. };
  799. /* 8ch mode */
  800. static struct hda_verb alc880_fivestack_ch8_init[] = {
  801. /* set line-in to output, unmute it */
  802. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  803. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  804. { } /* end */
  805. };
  806. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  807. { 6, alc880_fivestack_ch6_init },
  808. { 8, alc880_fivestack_ch8_init },
  809. };
  810. /*
  811. * ALC880 6-stack model
  812. *
  813. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  814. * Side = 0x05 (0x0f)
  815. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  816. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  817. */
  818. static hda_nid_t alc880_6st_dac_nids[4] = {
  819. /* front, rear, clfe, rear_surr */
  820. 0x02, 0x03, 0x04, 0x05
  821. };
  822. static struct hda_input_mux alc880_6stack_capture_source = {
  823. .num_items = 4,
  824. .items = {
  825. { "Mic", 0x0 },
  826. { "Front Mic", 0x1 },
  827. { "Line", 0x2 },
  828. { "CD", 0x4 },
  829. },
  830. };
  831. /* fixed 8-channels */
  832. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  833. { 8, NULL },
  834. };
  835. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  836. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  837. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  838. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  839. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  840. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  841. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  842. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  843. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  844. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  845. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  846. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  847. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  848. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  849. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  850. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  851. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  852. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  853. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  854. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  855. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  856. {
  857. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  858. .name = "Channel Mode",
  859. .info = alc_ch_mode_info,
  860. .get = alc_ch_mode_get,
  861. .put = alc_ch_mode_put,
  862. },
  863. { } /* end */
  864. };
  865. /*
  866. * ALC880 W810 model
  867. *
  868. * W810 has rear IO for:
  869. * Front (DAC 02)
  870. * Surround (DAC 03)
  871. * Center/LFE (DAC 04)
  872. * Digital out (06)
  873. *
  874. * The system also has a pair of internal speakers, and a headphone jack.
  875. * These are both connected to Line2 on the codec, hence to DAC 02.
  876. *
  877. * There is a variable resistor to control the speaker or headphone
  878. * volume. This is a hardware-only device without a software API.
  879. *
  880. * Plugging headphones in will disable the internal speakers. This is
  881. * implemented in hardware, not via the driver using jack sense. In
  882. * a similar fashion, plugging into the rear socket marked "front" will
  883. * disable both the speakers and headphones.
  884. *
  885. * For input, there's a microphone jack, and an "audio in" jack.
  886. * These may not do anything useful with this driver yet, because I
  887. * haven't setup any initialization verbs for these yet...
  888. */
  889. static hda_nid_t alc880_w810_dac_nids[3] = {
  890. /* front, rear/surround, clfe */
  891. 0x02, 0x03, 0x04
  892. };
  893. /* fixed 6 channels */
  894. static struct hda_channel_mode alc880_w810_modes[1] = {
  895. { 6, NULL }
  896. };
  897. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  898. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  899. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  900. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  901. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  902. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  903. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  904. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  905. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  906. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  907. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  908. { } /* end */
  909. };
  910. /*
  911. * Z710V model
  912. *
  913. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  914. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  915. * Line = 0x1a
  916. */
  917. static hda_nid_t alc880_z71v_dac_nids[1] = {
  918. 0x02
  919. };
  920. #define ALC880_Z71V_HP_DAC 0x03
  921. /* fixed 2 channels */
  922. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  923. { 2, NULL }
  924. };
  925. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  926. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  927. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  928. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  929. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  930. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  931. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  932. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  933. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  934. { } /* end */
  935. };
  936. /* FIXME! */
  937. /*
  938. * ALC880 F1734 model
  939. *
  940. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  941. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  942. */
  943. static hda_nid_t alc880_f1734_dac_nids[1] = {
  944. 0x03
  945. };
  946. #define ALC880_F1734_HP_DAC 0x02
  947. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  948. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  949. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  950. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  951. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  952. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  953. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  954. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  955. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  956. { } /* end */
  957. };
  958. /* FIXME! */
  959. /*
  960. * ALC880 ASUS model
  961. *
  962. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  963. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  964. * Mic = 0x18, Line = 0x1a
  965. */
  966. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  967. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  968. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  969. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  970. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  971. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  972. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  973. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  974. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  975. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  976. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  977. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  978. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  979. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  980. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  981. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  982. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  983. {
  984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  985. .name = "Channel Mode",
  986. .info = alc_ch_mode_info,
  987. .get = alc_ch_mode_get,
  988. .put = alc_ch_mode_put,
  989. },
  990. { } /* end */
  991. };
  992. /* FIXME! */
  993. /*
  994. * ALC880 ASUS W1V model
  995. *
  996. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  997. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  998. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  999. */
  1000. /* additional mixers to alc880_asus_mixer */
  1001. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1002. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1003. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1004. { } /* end */
  1005. };
  1006. /* additional mixers to alc880_asus_mixer */
  1007. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1008. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1009. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1010. { } /* end */
  1011. };
  1012. /* TCL S700 */
  1013. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1014. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1015. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1016. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1017. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1018. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1020. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1021. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1022. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1023. {
  1024. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1025. /* The multiple "Capture Source" controls confuse alsamixer
  1026. * So call somewhat different..
  1027. * FIXME: the controls appear in the "playback" view!
  1028. */
  1029. /* .name = "Capture Source", */
  1030. .name = "Input Source",
  1031. .count = 1,
  1032. .info = alc_mux_enum_info,
  1033. .get = alc_mux_enum_get,
  1034. .put = alc_mux_enum_put,
  1035. },
  1036. { } /* end */
  1037. };
  1038. /* Uniwill */
  1039. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1040. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1041. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1042. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1043. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1044. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1045. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1046. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1047. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1048. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1049. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1050. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1051. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1052. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1053. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1057. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1058. {
  1059. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1060. .name = "Channel Mode",
  1061. .info = alc_ch_mode_info,
  1062. .get = alc_ch_mode_get,
  1063. .put = alc_ch_mode_put,
  1064. },
  1065. { } /* end */
  1066. };
  1067. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1068. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1069. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1070. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1071. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1072. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1073. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1074. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1075. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1077. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1078. { } /* end */
  1079. };
  1080. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1081. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1082. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1084. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1087. { } /* end */
  1088. };
  1089. /*
  1090. * build control elements
  1091. */
  1092. static int alc_build_controls(struct hda_codec *codec)
  1093. {
  1094. struct alc_spec *spec = codec->spec;
  1095. int err;
  1096. int i;
  1097. for (i = 0; i < spec->num_mixers; i++) {
  1098. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1099. if (err < 0)
  1100. return err;
  1101. }
  1102. if (spec->multiout.dig_out_nid) {
  1103. err = snd_hda_create_spdif_out_ctls(codec,
  1104. spec->multiout.dig_out_nid);
  1105. if (err < 0)
  1106. return err;
  1107. }
  1108. if (spec->dig_in_nid) {
  1109. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1110. if (err < 0)
  1111. return err;
  1112. }
  1113. return 0;
  1114. }
  1115. /*
  1116. * initialize the codec volumes, etc
  1117. */
  1118. /*
  1119. * generic initialization of ADC, input mixers and output mixers
  1120. */
  1121. static struct hda_verb alc880_volume_init_verbs[] = {
  1122. /*
  1123. * Unmute ADC0-2 and set the default input to mic-in
  1124. */
  1125. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1126. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1127. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1128. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1129. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1130. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1131. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1132. * mixer widget
  1133. * Note: PASD motherboards uses the Line In 2 as the input for front
  1134. * panel mic (mic 2)
  1135. */
  1136. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1137. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1138. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1139. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1140. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1141. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1142. /*
  1143. * Set up output mixers (0x0c - 0x0f)
  1144. */
  1145. /* set vol=0 to output mixers */
  1146. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1147. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1148. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1149. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1150. /* set up input amps for analog loopback */
  1151. /* Amp Indices: DAC = 0, mixer = 1 */
  1152. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1153. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1154. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1155. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1156. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1157. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1158. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1159. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1160. { }
  1161. };
  1162. /*
  1163. * 3-stack pin configuration:
  1164. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1165. */
  1166. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1167. /*
  1168. * preset connection lists of input pins
  1169. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1170. */
  1171. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1172. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1173. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1174. /*
  1175. * Set pin mode and muting
  1176. */
  1177. /* set front pin widgets 0x14 for output */
  1178. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1179. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1180. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1181. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1182. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1183. /* Mic2 (as headphone out) for HP output */
  1184. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1185. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. /* Line In pin widget for input */
  1187. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1188. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1190. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1191. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1192. /* CD pin widget for input */
  1193. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. { }
  1195. };
  1196. /*
  1197. * 5-stack pin configuration:
  1198. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1199. * line-in/side = 0x1a, f-mic = 0x1b
  1200. */
  1201. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1202. /*
  1203. * preset connection lists of input pins
  1204. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1205. */
  1206. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1207. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1208. /*
  1209. * Set pin mode and muting
  1210. */
  1211. /* set pin widgets 0x14-0x17 for output */
  1212. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1213. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1214. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1215. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. /* unmute pins for output (no gain on this amp) */
  1217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1219. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1220. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1221. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1222. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1223. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1224. /* Mic2 (as headphone out) for HP output */
  1225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1226. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. /* Line In pin widget for input */
  1228. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1229. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1231. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1232. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1233. /* CD pin widget for input */
  1234. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1235. { }
  1236. };
  1237. /*
  1238. * W810 pin configuration:
  1239. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1240. */
  1241. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1242. /* hphone/speaker input selector: front DAC */
  1243. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1244. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1245. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1246. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1247. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1248. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1249. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1250. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1251. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1252. { }
  1253. };
  1254. /*
  1255. * Z71V pin configuration:
  1256. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1257. */
  1258. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1259. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1261. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1262. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1263. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1264. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1265. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1266. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. { }
  1268. };
  1269. /*
  1270. * 6-stack pin configuration:
  1271. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1272. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1273. */
  1274. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1275. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1276. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1277. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1278. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1279. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1280. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1281. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1282. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1285. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1286. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1287. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1288. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1289. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1290. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1291. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1292. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1293. { }
  1294. };
  1295. /*
  1296. * Uniwill pin configuration:
  1297. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1298. * line = 0x1a
  1299. */
  1300. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1301. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1302. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1303. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1304. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1306. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1307. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1308. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1309. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1311. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1312. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1313. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1314. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1315. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1316. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1317. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1318. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1320. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1321. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1323. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1324. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1325. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1326. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1327. { }
  1328. };
  1329. /*
  1330. * Uniwill P53
  1331. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1332. */
  1333. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1334. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1335. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1336. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1337. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1338. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1339. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1342. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1343. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1344. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1345. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1346. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1347. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1348. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1349. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1350. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1351. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1352. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1353. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1354. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1355. { }
  1356. };
  1357. static struct hda_verb alc880_beep_init_verbs[] = {
  1358. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1359. { }
  1360. };
  1361. /* toggle speaker-output according to the hp-jack state */
  1362. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1363. {
  1364. unsigned int present;
  1365. unsigned char bits;
  1366. present = snd_hda_codec_read(codec, 0x14, 0,
  1367. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1368. bits = present ? 0x80 : 0;
  1369. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1370. 0x80, bits);
  1371. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1372. 0x80, bits);
  1373. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1374. 0x80, bits);
  1375. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1376. 0x80, bits);
  1377. }
  1378. /* auto-toggle front mic */
  1379. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1380. {
  1381. unsigned int present;
  1382. unsigned char bits;
  1383. present = snd_hda_codec_read(codec, 0x18, 0,
  1384. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1385. bits = present ? 0x80 : 0;
  1386. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1387. 0x80, bits);
  1388. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1389. 0x80, bits);
  1390. }
  1391. static void alc880_uniwill_automute(struct hda_codec *codec)
  1392. {
  1393. alc880_uniwill_hp_automute(codec);
  1394. alc880_uniwill_mic_automute(codec);
  1395. }
  1396. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1397. unsigned int res)
  1398. {
  1399. /* Looks like the unsol event is incompatible with the standard
  1400. * definition. 4bit tag is placed at 28 bit!
  1401. */
  1402. switch (res >> 28) {
  1403. case ALC880_HP_EVENT:
  1404. alc880_uniwill_hp_automute(codec);
  1405. break;
  1406. case ALC880_MIC_EVENT:
  1407. alc880_uniwill_mic_automute(codec);
  1408. break;
  1409. }
  1410. }
  1411. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1412. {
  1413. unsigned int present;
  1414. unsigned char bits;
  1415. present = snd_hda_codec_read(codec, 0x14, 0,
  1416. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1417. bits = present ? 0x80 : 0;
  1418. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1419. 0x80, bits);
  1420. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1421. 0x80, bits);
  1422. }
  1423. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1424. {
  1425. unsigned int present;
  1426. present = snd_hda_codec_read(codec, 0x21, 0,
  1427. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1428. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1429. 0x7f, present);
  1430. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1431. 0x7f, present);
  1432. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1433. 0x7f, present);
  1434. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1435. 0x7f, present);
  1436. }
  1437. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1438. unsigned int res)
  1439. {
  1440. /* Looks like the unsol event is incompatible with the standard
  1441. * definition. 4bit tag is placed at 28 bit!
  1442. */
  1443. if ((res >> 28) == ALC880_HP_EVENT)
  1444. alc880_uniwill_p53_hp_automute(codec);
  1445. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1446. alc880_uniwill_p53_dcvol_automute(codec);
  1447. }
  1448. /* FIXME! */
  1449. /*
  1450. * F1734 pin configuration:
  1451. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1452. */
  1453. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1454. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1455. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1456. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1457. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1458. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1459. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1460. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1461. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1462. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1463. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1464. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1465. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1466. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1467. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1468. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1469. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1470. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1471. { }
  1472. };
  1473. /* FIXME! */
  1474. /*
  1475. * ASUS pin configuration:
  1476. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1477. */
  1478. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1479. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1480. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1482. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1486. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1487. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1488. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1489. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1492. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1493. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1495. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1497. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1499. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1500. { }
  1501. };
  1502. /* Enable GPIO mask and set output */
  1503. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1504. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1505. /* Clevo m520g init */
  1506. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1507. /* headphone output */
  1508. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1509. /* line-out */
  1510. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. /* Line-in */
  1513. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1514. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. /* CD */
  1516. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1517. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1518. /* Mic1 (rear panel) */
  1519. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1520. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. /* Mic2 (front panel) */
  1522. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1523. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. /* headphone */
  1525. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1526. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1527. /* change to EAPD mode */
  1528. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1529. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1530. { }
  1531. };
  1532. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1533. /* change to EAPD mode */
  1534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1536. /* Headphone output */
  1537. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1538. /* Front output*/
  1539. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1540. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1541. /* Line In pin widget for input */
  1542. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1543. /* CD pin widget for input */
  1544. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1545. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1546. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1547. /* change to EAPD mode */
  1548. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1549. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1550. { }
  1551. };
  1552. /*
  1553. * LG m1 express dual
  1554. *
  1555. * Pin assignment:
  1556. * Rear Line-In/Out (blue): 0x14
  1557. * Build-in Mic-In: 0x15
  1558. * Speaker-out: 0x17
  1559. * HP-Out (green): 0x1b
  1560. * Mic-In/Out (red): 0x19
  1561. * SPDIF-Out: 0x1e
  1562. */
  1563. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1564. static hda_nid_t alc880_lg_dac_nids[3] = {
  1565. 0x05, 0x02, 0x03
  1566. };
  1567. /* seems analog CD is not working */
  1568. static struct hda_input_mux alc880_lg_capture_source = {
  1569. .num_items = 3,
  1570. .items = {
  1571. { "Mic", 0x1 },
  1572. { "Line", 0x5 },
  1573. { "Internal Mic", 0x6 },
  1574. },
  1575. };
  1576. /* 2,4,6 channel modes */
  1577. static struct hda_verb alc880_lg_ch2_init[] = {
  1578. /* set line-in and mic-in to input */
  1579. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1580. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1581. { }
  1582. };
  1583. static struct hda_verb alc880_lg_ch4_init[] = {
  1584. /* set line-in to out and mic-in to input */
  1585. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1586. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1587. { }
  1588. };
  1589. static struct hda_verb alc880_lg_ch6_init[] = {
  1590. /* set line-in and mic-in to output */
  1591. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1592. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1593. { }
  1594. };
  1595. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1596. { 2, alc880_lg_ch2_init },
  1597. { 4, alc880_lg_ch4_init },
  1598. { 6, alc880_lg_ch6_init },
  1599. };
  1600. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1601. /* FIXME: it's not really "master" but front channels */
  1602. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1603. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1604. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1605. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1606. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1607. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1608. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1609. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1610. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1611. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1612. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1613. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1614. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1615. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1616. {
  1617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1618. .name = "Channel Mode",
  1619. .info = alc_ch_mode_info,
  1620. .get = alc_ch_mode_get,
  1621. .put = alc_ch_mode_put,
  1622. },
  1623. { } /* end */
  1624. };
  1625. static struct hda_verb alc880_lg_init_verbs[] = {
  1626. /* set capture source to mic-in */
  1627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1628. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1629. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1630. /* mute all amp mixer inputs */
  1631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1634. /* line-in to input */
  1635. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1636. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1637. /* built-in mic */
  1638. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1639. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1640. /* speaker-out */
  1641. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1642. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1643. /* mic-in to input */
  1644. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1645. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1646. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* HP-out */
  1648. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1649. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1650. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1651. /* jack sense */
  1652. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1653. { }
  1654. };
  1655. /* toggle speaker-output according to the hp-jack state */
  1656. static void alc880_lg_automute(struct hda_codec *codec)
  1657. {
  1658. unsigned int present;
  1659. unsigned char bits;
  1660. present = snd_hda_codec_read(codec, 0x1b, 0,
  1661. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1662. bits = present ? 0x80 : 0;
  1663. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1664. 0x80, bits);
  1665. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1666. 0x80, bits);
  1667. }
  1668. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1669. {
  1670. /* Looks like the unsol event is incompatible with the standard
  1671. * definition. 4bit tag is placed at 28 bit!
  1672. */
  1673. if ((res >> 28) == 0x01)
  1674. alc880_lg_automute(codec);
  1675. }
  1676. /*
  1677. * LG LW20
  1678. *
  1679. * Pin assignment:
  1680. * Speaker-out: 0x14
  1681. * Mic-In: 0x18
  1682. * Built-in Mic-In: 0x19 (?)
  1683. * HP-Out: 0x1b
  1684. * SPDIF-Out: 0x1e
  1685. */
  1686. /* seems analog CD is not working */
  1687. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1688. .num_items = 2,
  1689. .items = {
  1690. { "Mic", 0x0 },
  1691. { "Internal Mic", 0x1 },
  1692. },
  1693. };
  1694. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1695. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1696. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1697. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1698. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1699. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1700. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1701. { } /* end */
  1702. };
  1703. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1704. /* set capture source to mic-in */
  1705. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1706. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1707. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1709. /* speaker-out */
  1710. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1711. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1712. /* HP-out */
  1713. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1714. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1715. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1716. /* mic-in to input */
  1717. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1718. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1719. /* built-in mic */
  1720. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1721. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1722. /* jack sense */
  1723. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1724. { }
  1725. };
  1726. /* toggle speaker-output according to the hp-jack state */
  1727. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1728. {
  1729. unsigned int present;
  1730. unsigned char bits;
  1731. present = snd_hda_codec_read(codec, 0x1b, 0,
  1732. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1733. bits = present ? 0x80 : 0;
  1734. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1735. 0x80, bits);
  1736. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1737. 0x80, bits);
  1738. }
  1739. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1740. {
  1741. /* Looks like the unsol event is incompatible with the standard
  1742. * definition. 4bit tag is placed at 28 bit!
  1743. */
  1744. if ((res >> 28) == 0x01)
  1745. alc880_lg_lw_automute(codec);
  1746. }
  1747. /*
  1748. * Common callbacks
  1749. */
  1750. static int alc_init(struct hda_codec *codec)
  1751. {
  1752. struct alc_spec *spec = codec->spec;
  1753. unsigned int i;
  1754. for (i = 0; i < spec->num_init_verbs; i++)
  1755. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1756. if (spec->init_hook)
  1757. spec->init_hook(codec);
  1758. return 0;
  1759. }
  1760. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1761. {
  1762. struct alc_spec *spec = codec->spec;
  1763. if (spec->unsol_event)
  1764. spec->unsol_event(codec, res);
  1765. }
  1766. #ifdef CONFIG_PM
  1767. /*
  1768. * resume
  1769. */
  1770. static int alc_resume(struct hda_codec *codec)
  1771. {
  1772. struct alc_spec *spec = codec->spec;
  1773. int i;
  1774. alc_init(codec);
  1775. for (i = 0; i < spec->num_mixers; i++)
  1776. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1777. if (spec->multiout.dig_out_nid)
  1778. snd_hda_resume_spdif_out(codec);
  1779. if (spec->dig_in_nid)
  1780. snd_hda_resume_spdif_in(codec);
  1781. return 0;
  1782. }
  1783. #endif
  1784. /*
  1785. * Analog playback callbacks
  1786. */
  1787. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1788. struct hda_codec *codec,
  1789. struct snd_pcm_substream *substream)
  1790. {
  1791. struct alc_spec *spec = codec->spec;
  1792. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1793. }
  1794. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1795. struct hda_codec *codec,
  1796. unsigned int stream_tag,
  1797. unsigned int format,
  1798. struct snd_pcm_substream *substream)
  1799. {
  1800. struct alc_spec *spec = codec->spec;
  1801. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1802. stream_tag, format, substream);
  1803. }
  1804. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1805. struct hda_codec *codec,
  1806. struct snd_pcm_substream *substream)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1810. }
  1811. /*
  1812. * Digital out
  1813. */
  1814. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1815. struct hda_codec *codec,
  1816. struct snd_pcm_substream *substream)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1820. }
  1821. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1822. struct hda_codec *codec,
  1823. unsigned int stream_tag,
  1824. unsigned int format,
  1825. struct snd_pcm_substream *substream)
  1826. {
  1827. struct alc_spec *spec = codec->spec;
  1828. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1829. stream_tag, format, substream);
  1830. }
  1831. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1832. struct hda_codec *codec,
  1833. struct snd_pcm_substream *substream)
  1834. {
  1835. struct alc_spec *spec = codec->spec;
  1836. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1837. }
  1838. /*
  1839. * Analog capture
  1840. */
  1841. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1842. struct hda_codec *codec,
  1843. unsigned int stream_tag,
  1844. unsigned int format,
  1845. struct snd_pcm_substream *substream)
  1846. {
  1847. struct alc_spec *spec = codec->spec;
  1848. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1849. stream_tag, 0, format);
  1850. return 0;
  1851. }
  1852. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1853. struct hda_codec *codec,
  1854. struct snd_pcm_substream *substream)
  1855. {
  1856. struct alc_spec *spec = codec->spec;
  1857. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1858. 0, 0, 0);
  1859. return 0;
  1860. }
  1861. /*
  1862. */
  1863. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1864. .substreams = 1,
  1865. .channels_min = 2,
  1866. .channels_max = 8,
  1867. /* NID is set in alc_build_pcms */
  1868. .ops = {
  1869. .open = alc880_playback_pcm_open,
  1870. .prepare = alc880_playback_pcm_prepare,
  1871. .cleanup = alc880_playback_pcm_cleanup
  1872. },
  1873. };
  1874. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1875. .substreams = 2,
  1876. .channels_min = 2,
  1877. .channels_max = 2,
  1878. /* NID is set in alc_build_pcms */
  1879. .ops = {
  1880. .prepare = alc880_capture_pcm_prepare,
  1881. .cleanup = alc880_capture_pcm_cleanup
  1882. },
  1883. };
  1884. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1885. .substreams = 1,
  1886. .channels_min = 2,
  1887. .channels_max = 2,
  1888. /* NID is set in alc_build_pcms */
  1889. .ops = {
  1890. .open = alc880_dig_playback_pcm_open,
  1891. .close = alc880_dig_playback_pcm_close,
  1892. .prepare = alc880_dig_playback_pcm_prepare
  1893. },
  1894. };
  1895. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1896. .substreams = 1,
  1897. .channels_min = 2,
  1898. .channels_max = 2,
  1899. /* NID is set in alc_build_pcms */
  1900. };
  1901. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1902. static struct hda_pcm_stream alc_pcm_null_playback = {
  1903. .substreams = 0,
  1904. .channels_min = 0,
  1905. .channels_max = 0,
  1906. };
  1907. static int alc_build_pcms(struct hda_codec *codec)
  1908. {
  1909. struct alc_spec *spec = codec->spec;
  1910. struct hda_pcm *info = spec->pcm_rec;
  1911. int i;
  1912. codec->num_pcms = 1;
  1913. codec->pcm_info = info;
  1914. info->name = spec->stream_name_analog;
  1915. if (spec->stream_analog_playback) {
  1916. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1917. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1918. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1919. }
  1920. if (spec->stream_analog_capture) {
  1921. snd_assert(spec->adc_nids, return -EINVAL);
  1922. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1923. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1924. }
  1925. if (spec->channel_mode) {
  1926. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1927. for (i = 0; i < spec->num_channel_mode; i++) {
  1928. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1929. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1930. }
  1931. }
  1932. }
  1933. /* SPDIF for stream index #1 */
  1934. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1935. codec->num_pcms = 2;
  1936. info = spec->pcm_rec + 1;
  1937. info->name = spec->stream_name_digital;
  1938. if (spec->multiout.dig_out_nid &&
  1939. spec->stream_digital_playback) {
  1940. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1941. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1942. }
  1943. if (spec->dig_in_nid &&
  1944. spec->stream_digital_capture) {
  1945. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1946. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1947. }
  1948. }
  1949. /* If the use of more than one ADC is requested for the current
  1950. * model, configure a second analog capture-only PCM.
  1951. */
  1952. /* Additional Analaog capture for index #2 */
  1953. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1954. spec->adc_nids) {
  1955. codec->num_pcms = 3;
  1956. info = spec->pcm_rec + 2;
  1957. info->name = spec->stream_name_analog;
  1958. /* No playback stream for second PCM */
  1959. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1960. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1961. if (spec->stream_analog_capture) {
  1962. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1963. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1964. }
  1965. }
  1966. return 0;
  1967. }
  1968. static void alc_free(struct hda_codec *codec)
  1969. {
  1970. struct alc_spec *spec = codec->spec;
  1971. unsigned int i;
  1972. if (!spec)
  1973. return;
  1974. if (spec->kctl_alloc) {
  1975. for (i = 0; i < spec->num_kctl_used; i++)
  1976. kfree(spec->kctl_alloc[i].name);
  1977. kfree(spec->kctl_alloc);
  1978. }
  1979. kfree(spec);
  1980. }
  1981. /*
  1982. */
  1983. static struct hda_codec_ops alc_patch_ops = {
  1984. .build_controls = alc_build_controls,
  1985. .build_pcms = alc_build_pcms,
  1986. .init = alc_init,
  1987. .free = alc_free,
  1988. .unsol_event = alc_unsol_event,
  1989. #ifdef CONFIG_PM
  1990. .resume = alc_resume,
  1991. #endif
  1992. };
  1993. /*
  1994. * Test configuration for debugging
  1995. *
  1996. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1997. * enum controls.
  1998. */
  1999. #ifdef CONFIG_SND_DEBUG
  2000. static hda_nid_t alc880_test_dac_nids[4] = {
  2001. 0x02, 0x03, 0x04, 0x05
  2002. };
  2003. static struct hda_input_mux alc880_test_capture_source = {
  2004. .num_items = 7,
  2005. .items = {
  2006. { "In-1", 0x0 },
  2007. { "In-2", 0x1 },
  2008. { "In-3", 0x2 },
  2009. { "In-4", 0x3 },
  2010. { "CD", 0x4 },
  2011. { "Front", 0x5 },
  2012. { "Surround", 0x6 },
  2013. },
  2014. };
  2015. static struct hda_channel_mode alc880_test_modes[4] = {
  2016. { 2, NULL },
  2017. { 4, NULL },
  2018. { 6, NULL },
  2019. { 8, NULL },
  2020. };
  2021. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2022. struct snd_ctl_elem_info *uinfo)
  2023. {
  2024. static char *texts[] = {
  2025. "N/A", "Line Out", "HP Out",
  2026. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2027. };
  2028. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2029. uinfo->count = 1;
  2030. uinfo->value.enumerated.items = 8;
  2031. if (uinfo->value.enumerated.item >= 8)
  2032. uinfo->value.enumerated.item = 7;
  2033. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2034. return 0;
  2035. }
  2036. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2037. struct snd_ctl_elem_value *ucontrol)
  2038. {
  2039. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2040. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2041. unsigned int pin_ctl, item = 0;
  2042. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2043. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2044. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2045. if (pin_ctl & AC_PINCTL_HP_EN)
  2046. item = 2;
  2047. else
  2048. item = 1;
  2049. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2050. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2051. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2052. case AC_PINCTL_VREF_50: item = 4; break;
  2053. case AC_PINCTL_VREF_GRD: item = 5; break;
  2054. case AC_PINCTL_VREF_80: item = 6; break;
  2055. case AC_PINCTL_VREF_100: item = 7; break;
  2056. }
  2057. }
  2058. ucontrol->value.enumerated.item[0] = item;
  2059. return 0;
  2060. }
  2061. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2062. struct snd_ctl_elem_value *ucontrol)
  2063. {
  2064. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2065. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2066. static unsigned int ctls[] = {
  2067. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2068. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2069. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2070. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2071. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2072. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2073. };
  2074. unsigned int old_ctl, new_ctl;
  2075. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2076. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2077. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2078. if (old_ctl != new_ctl) {
  2079. snd_hda_codec_write(codec, nid, 0,
  2080. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2081. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2082. (ucontrol->value.enumerated.item[0] >= 3 ?
  2083. 0xb080 : 0xb000));
  2084. return 1;
  2085. }
  2086. return 0;
  2087. }
  2088. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2089. struct snd_ctl_elem_info *uinfo)
  2090. {
  2091. static char *texts[] = {
  2092. "Front", "Surround", "CLFE", "Side"
  2093. };
  2094. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2095. uinfo->count = 1;
  2096. uinfo->value.enumerated.items = 4;
  2097. if (uinfo->value.enumerated.item >= 4)
  2098. uinfo->value.enumerated.item = 3;
  2099. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2100. return 0;
  2101. }
  2102. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2103. struct snd_ctl_elem_value *ucontrol)
  2104. {
  2105. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2106. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2107. unsigned int sel;
  2108. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2109. ucontrol->value.enumerated.item[0] = sel & 3;
  2110. return 0;
  2111. }
  2112. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2113. struct snd_ctl_elem_value *ucontrol)
  2114. {
  2115. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2116. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2117. unsigned int sel;
  2118. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2119. if (ucontrol->value.enumerated.item[0] != sel) {
  2120. sel = ucontrol->value.enumerated.item[0] & 3;
  2121. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2122. return 1;
  2123. }
  2124. return 0;
  2125. }
  2126. #define PIN_CTL_TEST(xname,nid) { \
  2127. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2128. .name = xname, \
  2129. .info = alc_test_pin_ctl_info, \
  2130. .get = alc_test_pin_ctl_get, \
  2131. .put = alc_test_pin_ctl_put, \
  2132. .private_value = nid \
  2133. }
  2134. #define PIN_SRC_TEST(xname,nid) { \
  2135. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2136. .name = xname, \
  2137. .info = alc_test_pin_src_info, \
  2138. .get = alc_test_pin_src_get, \
  2139. .put = alc_test_pin_src_put, \
  2140. .private_value = nid \
  2141. }
  2142. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2143. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2144. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2145. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2146. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2147. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2148. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2149. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2150. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2151. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2152. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2153. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2154. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2155. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2156. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2157. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2158. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2159. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2160. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2161. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2162. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2163. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2164. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2165. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2166. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2167. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2168. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2169. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2170. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2171. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2172. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2173. {
  2174. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2175. .name = "Channel Mode",
  2176. .info = alc_ch_mode_info,
  2177. .get = alc_ch_mode_get,
  2178. .put = alc_ch_mode_put,
  2179. },
  2180. { } /* end */
  2181. };
  2182. static struct hda_verb alc880_test_init_verbs[] = {
  2183. /* Unmute inputs of 0x0c - 0x0f */
  2184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2189. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2190. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2191. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2192. /* Vol output for 0x0c-0x0f */
  2193. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2197. /* Set output pins 0x14-0x17 */
  2198. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2199. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2200. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2201. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2202. /* Unmute output pins 0x14-0x17 */
  2203. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2204. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2205. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2206. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2207. /* Set input pins 0x18-0x1c */
  2208. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2209. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2210. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2211. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2212. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2213. /* Mute input pins 0x18-0x1b */
  2214. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2215. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2216. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2217. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2218. /* ADC set up */
  2219. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2220. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2221. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2222. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2223. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2224. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2225. /* Analog input/passthru */
  2226. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2227. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2230. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2231. { }
  2232. };
  2233. #endif
  2234. /*
  2235. */
  2236. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2237. [ALC880_3ST] = "3stack",
  2238. [ALC880_TCL_S700] = "tcl",
  2239. [ALC880_3ST_DIG] = "3stack-digout",
  2240. [ALC880_CLEVO] = "clevo",
  2241. [ALC880_5ST] = "5stack",
  2242. [ALC880_5ST_DIG] = "5stack-digout",
  2243. [ALC880_W810] = "w810",
  2244. [ALC880_Z71V] = "z71v",
  2245. [ALC880_6ST] = "6stack",
  2246. [ALC880_6ST_DIG] = "6stack-digout",
  2247. [ALC880_ASUS] = "asus",
  2248. [ALC880_ASUS_W1V] = "asus-w1v",
  2249. [ALC880_ASUS_DIG] = "asus-dig",
  2250. [ALC880_ASUS_DIG2] = "asus-dig2",
  2251. [ALC880_UNIWILL_DIG] = "uniwill",
  2252. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2253. [ALC880_FUJITSU] = "fujitsu",
  2254. [ALC880_F1734] = "F1734",
  2255. [ALC880_LG] = "lg",
  2256. [ALC880_LG_LW] = "lg-lw",
  2257. #ifdef CONFIG_SND_DEBUG
  2258. [ALC880_TEST] = "test",
  2259. #endif
  2260. [ALC880_AUTO] = "auto",
  2261. };
  2262. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2263. /* Broken BIOS configuration */
  2264. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2265. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2266. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2267. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2268. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2269. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2270. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2271. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2273. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2274. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2275. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2276. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2277. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2278. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2279. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2280. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2281. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2282. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2283. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2284. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2285. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2288. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2290. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2291. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2292. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2293. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2294. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2295. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2296. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2297. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2298. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2299. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2300. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2301. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2302. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2303. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2304. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2305. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2306. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2307. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2308. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2309. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2310. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2311. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2312. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2313. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2314. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2315. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2316. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2317. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2318. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2319. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2320. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2321. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2322. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2323. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2324. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2325. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2326. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2327. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2328. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2329. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2333. {}
  2334. };
  2335. /*
  2336. * ALC880 codec presets
  2337. */
  2338. static struct alc_config_preset alc880_presets[] = {
  2339. [ALC880_3ST] = {
  2340. .mixers = { alc880_three_stack_mixer },
  2341. .init_verbs = { alc880_volume_init_verbs,
  2342. alc880_pin_3stack_init_verbs },
  2343. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2344. .dac_nids = alc880_dac_nids,
  2345. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2346. .channel_mode = alc880_threestack_modes,
  2347. .need_dac_fix = 1,
  2348. .input_mux = &alc880_capture_source,
  2349. },
  2350. [ALC880_3ST_DIG] = {
  2351. .mixers = { alc880_three_stack_mixer },
  2352. .init_verbs = { alc880_volume_init_verbs,
  2353. alc880_pin_3stack_init_verbs },
  2354. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2355. .dac_nids = alc880_dac_nids,
  2356. .dig_out_nid = ALC880_DIGOUT_NID,
  2357. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2358. .channel_mode = alc880_threestack_modes,
  2359. .need_dac_fix = 1,
  2360. .input_mux = &alc880_capture_source,
  2361. },
  2362. [ALC880_TCL_S700] = {
  2363. .mixers = { alc880_tcl_s700_mixer },
  2364. .init_verbs = { alc880_volume_init_verbs,
  2365. alc880_pin_tcl_S700_init_verbs,
  2366. alc880_gpio2_init_verbs },
  2367. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2368. .dac_nids = alc880_dac_nids,
  2369. .hp_nid = 0x03,
  2370. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2371. .channel_mode = alc880_2_jack_modes,
  2372. .input_mux = &alc880_capture_source,
  2373. },
  2374. [ALC880_5ST] = {
  2375. .mixers = { alc880_three_stack_mixer,
  2376. alc880_five_stack_mixer},
  2377. .init_verbs = { alc880_volume_init_verbs,
  2378. alc880_pin_5stack_init_verbs },
  2379. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2380. .dac_nids = alc880_dac_nids,
  2381. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2382. .channel_mode = alc880_fivestack_modes,
  2383. .input_mux = &alc880_capture_source,
  2384. },
  2385. [ALC880_5ST_DIG] = {
  2386. .mixers = { alc880_three_stack_mixer,
  2387. alc880_five_stack_mixer },
  2388. .init_verbs = { alc880_volume_init_verbs,
  2389. alc880_pin_5stack_init_verbs },
  2390. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2391. .dac_nids = alc880_dac_nids,
  2392. .dig_out_nid = ALC880_DIGOUT_NID,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2394. .channel_mode = alc880_fivestack_modes,
  2395. .input_mux = &alc880_capture_source,
  2396. },
  2397. [ALC880_6ST] = {
  2398. .mixers = { alc880_six_stack_mixer },
  2399. .init_verbs = { alc880_volume_init_verbs,
  2400. alc880_pin_6stack_init_verbs },
  2401. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2402. .dac_nids = alc880_6st_dac_nids,
  2403. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2404. .channel_mode = alc880_sixstack_modes,
  2405. .input_mux = &alc880_6stack_capture_source,
  2406. },
  2407. [ALC880_6ST_DIG] = {
  2408. .mixers = { alc880_six_stack_mixer },
  2409. .init_verbs = { alc880_volume_init_verbs,
  2410. alc880_pin_6stack_init_verbs },
  2411. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2412. .dac_nids = alc880_6st_dac_nids,
  2413. .dig_out_nid = ALC880_DIGOUT_NID,
  2414. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2415. .channel_mode = alc880_sixstack_modes,
  2416. .input_mux = &alc880_6stack_capture_source,
  2417. },
  2418. [ALC880_W810] = {
  2419. .mixers = { alc880_w810_base_mixer },
  2420. .init_verbs = { alc880_volume_init_verbs,
  2421. alc880_pin_w810_init_verbs,
  2422. alc880_gpio2_init_verbs },
  2423. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2424. .dac_nids = alc880_w810_dac_nids,
  2425. .dig_out_nid = ALC880_DIGOUT_NID,
  2426. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2427. .channel_mode = alc880_w810_modes,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_Z71V] = {
  2431. .mixers = { alc880_z71v_mixer },
  2432. .init_verbs = { alc880_volume_init_verbs,
  2433. alc880_pin_z71v_init_verbs },
  2434. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2435. .dac_nids = alc880_z71v_dac_nids,
  2436. .dig_out_nid = ALC880_DIGOUT_NID,
  2437. .hp_nid = 0x03,
  2438. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2439. .channel_mode = alc880_2_jack_modes,
  2440. .input_mux = &alc880_capture_source,
  2441. },
  2442. [ALC880_F1734] = {
  2443. .mixers = { alc880_f1734_mixer },
  2444. .init_verbs = { alc880_volume_init_verbs,
  2445. alc880_pin_f1734_init_verbs },
  2446. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2447. .dac_nids = alc880_f1734_dac_nids,
  2448. .hp_nid = 0x02,
  2449. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2450. .channel_mode = alc880_2_jack_modes,
  2451. .input_mux = &alc880_capture_source,
  2452. },
  2453. [ALC880_ASUS] = {
  2454. .mixers = { alc880_asus_mixer },
  2455. .init_verbs = { alc880_volume_init_verbs,
  2456. alc880_pin_asus_init_verbs,
  2457. alc880_gpio1_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2459. .dac_nids = alc880_asus_dac_nids,
  2460. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2461. .channel_mode = alc880_asus_modes,
  2462. .need_dac_fix = 1,
  2463. .input_mux = &alc880_capture_source,
  2464. },
  2465. [ALC880_ASUS_DIG] = {
  2466. .mixers = { alc880_asus_mixer },
  2467. .init_verbs = { alc880_volume_init_verbs,
  2468. alc880_pin_asus_init_verbs,
  2469. alc880_gpio1_init_verbs },
  2470. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2471. .dac_nids = alc880_asus_dac_nids,
  2472. .dig_out_nid = ALC880_DIGOUT_NID,
  2473. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2474. .channel_mode = alc880_asus_modes,
  2475. .need_dac_fix = 1,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_ASUS_DIG2] = {
  2479. .mixers = { alc880_asus_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_asus_init_verbs,
  2482. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2483. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2484. .dac_nids = alc880_asus_dac_nids,
  2485. .dig_out_nid = ALC880_DIGOUT_NID,
  2486. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2487. .channel_mode = alc880_asus_modes,
  2488. .need_dac_fix = 1,
  2489. .input_mux = &alc880_capture_source,
  2490. },
  2491. [ALC880_ASUS_W1V] = {
  2492. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2493. .init_verbs = { alc880_volume_init_verbs,
  2494. alc880_pin_asus_init_verbs,
  2495. alc880_gpio1_init_verbs },
  2496. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2497. .dac_nids = alc880_asus_dac_nids,
  2498. .dig_out_nid = ALC880_DIGOUT_NID,
  2499. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2500. .channel_mode = alc880_asus_modes,
  2501. .need_dac_fix = 1,
  2502. .input_mux = &alc880_capture_source,
  2503. },
  2504. [ALC880_UNIWILL_DIG] = {
  2505. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2506. .init_verbs = { alc880_volume_init_verbs,
  2507. alc880_pin_asus_init_verbs },
  2508. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2509. .dac_nids = alc880_asus_dac_nids,
  2510. .dig_out_nid = ALC880_DIGOUT_NID,
  2511. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2512. .channel_mode = alc880_asus_modes,
  2513. .need_dac_fix = 1,
  2514. .input_mux = &alc880_capture_source,
  2515. },
  2516. [ALC880_UNIWILL] = {
  2517. .mixers = { alc880_uniwill_mixer },
  2518. .init_verbs = { alc880_volume_init_verbs,
  2519. alc880_uniwill_init_verbs },
  2520. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2521. .dac_nids = alc880_asus_dac_nids,
  2522. .dig_out_nid = ALC880_DIGOUT_NID,
  2523. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2524. .channel_mode = alc880_threestack_modes,
  2525. .need_dac_fix = 1,
  2526. .input_mux = &alc880_capture_source,
  2527. .unsol_event = alc880_uniwill_unsol_event,
  2528. .init_hook = alc880_uniwill_automute,
  2529. },
  2530. [ALC880_UNIWILL_P53] = {
  2531. .mixers = { alc880_uniwill_p53_mixer },
  2532. .init_verbs = { alc880_volume_init_verbs,
  2533. alc880_uniwill_p53_init_verbs },
  2534. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2535. .dac_nids = alc880_asus_dac_nids,
  2536. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2537. .channel_mode = alc880_threestack_modes,
  2538. .input_mux = &alc880_capture_source,
  2539. .unsol_event = alc880_uniwill_p53_unsol_event,
  2540. .init_hook = alc880_uniwill_p53_hp_automute,
  2541. },
  2542. [ALC880_FUJITSU] = {
  2543. .mixers = { alc880_fujitsu_mixer,
  2544. alc880_pcbeep_mixer, },
  2545. .init_verbs = { alc880_volume_init_verbs,
  2546. alc880_uniwill_p53_init_verbs,
  2547. alc880_beep_init_verbs },
  2548. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2549. .dac_nids = alc880_dac_nids,
  2550. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2551. .channel_mode = alc880_2_jack_modes,
  2552. .input_mux = &alc880_capture_source,
  2553. .unsol_event = alc880_uniwill_p53_unsol_event,
  2554. .init_hook = alc880_uniwill_p53_hp_automute,
  2555. },
  2556. [ALC880_CLEVO] = {
  2557. .mixers = { alc880_three_stack_mixer },
  2558. .init_verbs = { alc880_volume_init_verbs,
  2559. alc880_pin_clevo_init_verbs },
  2560. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2561. .dac_nids = alc880_dac_nids,
  2562. .hp_nid = 0x03,
  2563. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2564. .channel_mode = alc880_threestack_modes,
  2565. .need_dac_fix = 1,
  2566. .input_mux = &alc880_capture_source,
  2567. },
  2568. [ALC880_LG] = {
  2569. .mixers = { alc880_lg_mixer },
  2570. .init_verbs = { alc880_volume_init_verbs,
  2571. alc880_lg_init_verbs },
  2572. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2573. .dac_nids = alc880_lg_dac_nids,
  2574. .dig_out_nid = ALC880_DIGOUT_NID,
  2575. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2576. .channel_mode = alc880_lg_ch_modes,
  2577. .need_dac_fix = 1,
  2578. .input_mux = &alc880_lg_capture_source,
  2579. .unsol_event = alc880_lg_unsol_event,
  2580. .init_hook = alc880_lg_automute,
  2581. },
  2582. [ALC880_LG_LW] = {
  2583. .mixers = { alc880_lg_lw_mixer },
  2584. .init_verbs = { alc880_volume_init_verbs,
  2585. alc880_lg_lw_init_verbs },
  2586. .num_dacs = 1,
  2587. .dac_nids = alc880_dac_nids,
  2588. .dig_out_nid = ALC880_DIGOUT_NID,
  2589. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2590. .channel_mode = alc880_2_jack_modes,
  2591. .input_mux = &alc880_lg_lw_capture_source,
  2592. .unsol_event = alc880_lg_lw_unsol_event,
  2593. .init_hook = alc880_lg_lw_automute,
  2594. },
  2595. #ifdef CONFIG_SND_DEBUG
  2596. [ALC880_TEST] = {
  2597. .mixers = { alc880_test_mixer },
  2598. .init_verbs = { alc880_test_init_verbs },
  2599. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2600. .dac_nids = alc880_test_dac_nids,
  2601. .dig_out_nid = ALC880_DIGOUT_NID,
  2602. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2603. .channel_mode = alc880_test_modes,
  2604. .input_mux = &alc880_test_capture_source,
  2605. },
  2606. #endif
  2607. };
  2608. /*
  2609. * Automatic parse of I/O pins from the BIOS configuration
  2610. */
  2611. #define NUM_CONTROL_ALLOC 32
  2612. #define NUM_VERB_ALLOC 32
  2613. enum {
  2614. ALC_CTL_WIDGET_VOL,
  2615. ALC_CTL_WIDGET_MUTE,
  2616. ALC_CTL_BIND_MUTE,
  2617. };
  2618. static struct snd_kcontrol_new alc880_control_templates[] = {
  2619. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2620. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2621. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2622. };
  2623. /* add dynamic controls */
  2624. static int add_control(struct alc_spec *spec, int type, const char *name,
  2625. unsigned long val)
  2626. {
  2627. struct snd_kcontrol_new *knew;
  2628. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2629. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2630. /* array + terminator */
  2631. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2632. if (!knew)
  2633. return -ENOMEM;
  2634. if (spec->kctl_alloc) {
  2635. memcpy(knew, spec->kctl_alloc,
  2636. sizeof(*knew) * spec->num_kctl_alloc);
  2637. kfree(spec->kctl_alloc);
  2638. }
  2639. spec->kctl_alloc = knew;
  2640. spec->num_kctl_alloc = num;
  2641. }
  2642. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2643. *knew = alc880_control_templates[type];
  2644. knew->name = kstrdup(name, GFP_KERNEL);
  2645. if (!knew->name)
  2646. return -ENOMEM;
  2647. knew->private_value = val;
  2648. spec->num_kctl_used++;
  2649. return 0;
  2650. }
  2651. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2652. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2653. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2654. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2655. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2656. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2657. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2658. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2659. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2660. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2661. #define ALC880_PIN_CD_NID 0x1c
  2662. /* fill in the dac_nids table from the parsed pin configuration */
  2663. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2664. const struct auto_pin_cfg *cfg)
  2665. {
  2666. hda_nid_t nid;
  2667. int assigned[4];
  2668. int i, j;
  2669. memset(assigned, 0, sizeof(assigned));
  2670. spec->multiout.dac_nids = spec->private_dac_nids;
  2671. /* check the pins hardwired to audio widget */
  2672. for (i = 0; i < cfg->line_outs; i++) {
  2673. nid = cfg->line_out_pins[i];
  2674. if (alc880_is_fixed_pin(nid)) {
  2675. int idx = alc880_fixed_pin_idx(nid);
  2676. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2677. assigned[idx] = 1;
  2678. }
  2679. }
  2680. /* left pins can be connect to any audio widget */
  2681. for (i = 0; i < cfg->line_outs; i++) {
  2682. nid = cfg->line_out_pins[i];
  2683. if (alc880_is_fixed_pin(nid))
  2684. continue;
  2685. /* search for an empty channel */
  2686. for (j = 0; j < cfg->line_outs; j++) {
  2687. if (!assigned[j]) {
  2688. spec->multiout.dac_nids[i] =
  2689. alc880_idx_to_dac(j);
  2690. assigned[j] = 1;
  2691. break;
  2692. }
  2693. }
  2694. }
  2695. spec->multiout.num_dacs = cfg->line_outs;
  2696. return 0;
  2697. }
  2698. /* add playback controls from the parsed DAC table */
  2699. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2700. const struct auto_pin_cfg *cfg)
  2701. {
  2702. char name[32];
  2703. static const char *chname[4] = {
  2704. "Front", "Surround", NULL /*CLFE*/, "Side"
  2705. };
  2706. hda_nid_t nid;
  2707. int i, err;
  2708. for (i = 0; i < cfg->line_outs; i++) {
  2709. if (!spec->multiout.dac_nids[i])
  2710. continue;
  2711. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2712. if (i == 2) {
  2713. /* Center/LFE */
  2714. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2715. "Center Playback Volume",
  2716. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2717. HDA_OUTPUT));
  2718. if (err < 0)
  2719. return err;
  2720. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2721. "LFE Playback Volume",
  2722. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2723. HDA_OUTPUT));
  2724. if (err < 0)
  2725. return err;
  2726. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2727. "Center Playback Switch",
  2728. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2729. HDA_INPUT));
  2730. if (err < 0)
  2731. return err;
  2732. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2733. "LFE Playback Switch",
  2734. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2735. HDA_INPUT));
  2736. if (err < 0)
  2737. return err;
  2738. } else {
  2739. sprintf(name, "%s Playback Volume", chname[i]);
  2740. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2741. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2742. HDA_OUTPUT));
  2743. if (err < 0)
  2744. return err;
  2745. sprintf(name, "%s Playback Switch", chname[i]);
  2746. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2747. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2748. HDA_INPUT));
  2749. if (err < 0)
  2750. return err;
  2751. }
  2752. }
  2753. return 0;
  2754. }
  2755. /* add playback controls for speaker and HP outputs */
  2756. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2757. const char *pfx)
  2758. {
  2759. hda_nid_t nid;
  2760. int err;
  2761. char name[32];
  2762. if (!pin)
  2763. return 0;
  2764. if (alc880_is_fixed_pin(pin)) {
  2765. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2766. /* specify the DAC as the extra output */
  2767. if (!spec->multiout.hp_nid)
  2768. spec->multiout.hp_nid = nid;
  2769. else
  2770. spec->multiout.extra_out_nid[0] = nid;
  2771. /* control HP volume/switch on the output mixer amp */
  2772. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2773. sprintf(name, "%s Playback Volume", pfx);
  2774. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2775. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2776. if (err < 0)
  2777. return err;
  2778. sprintf(name, "%s Playback Switch", pfx);
  2779. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2780. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2781. if (err < 0)
  2782. return err;
  2783. } else if (alc880_is_multi_pin(pin)) {
  2784. /* set manual connection */
  2785. /* we have only a switch on HP-out PIN */
  2786. sprintf(name, "%s Playback Switch", pfx);
  2787. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2788. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2789. if (err < 0)
  2790. return err;
  2791. }
  2792. return 0;
  2793. }
  2794. /* create input playback/capture controls for the given pin */
  2795. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2796. const char *ctlname,
  2797. int idx, hda_nid_t mix_nid)
  2798. {
  2799. char name[32];
  2800. int err;
  2801. sprintf(name, "%s Playback Volume", ctlname);
  2802. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2803. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2804. if (err < 0)
  2805. return err;
  2806. sprintf(name, "%s Playback Switch", ctlname);
  2807. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2808. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2809. if (err < 0)
  2810. return err;
  2811. return 0;
  2812. }
  2813. /* create playback/capture controls for input pins */
  2814. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2815. const struct auto_pin_cfg *cfg)
  2816. {
  2817. struct hda_input_mux *imux = &spec->private_imux;
  2818. int i, err, idx;
  2819. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2820. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2821. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2822. err = new_analog_input(spec, cfg->input_pins[i],
  2823. auto_pin_cfg_labels[i],
  2824. idx, 0x0b);
  2825. if (err < 0)
  2826. return err;
  2827. imux->items[imux->num_items].label =
  2828. auto_pin_cfg_labels[i];
  2829. imux->items[imux->num_items].index =
  2830. alc880_input_pin_idx(cfg->input_pins[i]);
  2831. imux->num_items++;
  2832. }
  2833. }
  2834. return 0;
  2835. }
  2836. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2837. hda_nid_t nid, int pin_type,
  2838. int dac_idx)
  2839. {
  2840. /* set as output */
  2841. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2842. pin_type);
  2843. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2844. AMP_OUT_UNMUTE);
  2845. /* need the manual connection? */
  2846. if (alc880_is_multi_pin(nid)) {
  2847. struct alc_spec *spec = codec->spec;
  2848. int idx = alc880_multi_pin_idx(nid);
  2849. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2850. AC_VERB_SET_CONNECT_SEL,
  2851. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2852. }
  2853. }
  2854. static int get_pin_type(int line_out_type)
  2855. {
  2856. if (line_out_type == AUTO_PIN_HP_OUT)
  2857. return PIN_HP;
  2858. else
  2859. return PIN_OUT;
  2860. }
  2861. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2862. {
  2863. struct alc_spec *spec = codec->spec;
  2864. int i;
  2865. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2866. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2867. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2868. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2869. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2870. }
  2871. }
  2872. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2873. {
  2874. struct alc_spec *spec = codec->spec;
  2875. hda_nid_t pin;
  2876. pin = spec->autocfg.speaker_pins[0];
  2877. if (pin) /* connect to front */
  2878. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2879. pin = spec->autocfg.hp_pins[0];
  2880. if (pin) /* connect to front */
  2881. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2882. }
  2883. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2884. {
  2885. struct alc_spec *spec = codec->spec;
  2886. int i;
  2887. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2888. hda_nid_t nid = spec->autocfg.input_pins[i];
  2889. if (alc880_is_input_pin(nid)) {
  2890. snd_hda_codec_write(codec, nid, 0,
  2891. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2892. i <= AUTO_PIN_FRONT_MIC ?
  2893. PIN_VREF80 : PIN_IN);
  2894. if (nid != ALC880_PIN_CD_NID)
  2895. snd_hda_codec_write(codec, nid, 0,
  2896. AC_VERB_SET_AMP_GAIN_MUTE,
  2897. AMP_OUT_MUTE);
  2898. }
  2899. }
  2900. }
  2901. /* parse the BIOS configuration and set up the alc_spec */
  2902. /* return 1 if successful, 0 if the proper config is not found,
  2903. * or a negative error code
  2904. */
  2905. static int alc880_parse_auto_config(struct hda_codec *codec)
  2906. {
  2907. struct alc_spec *spec = codec->spec;
  2908. int err;
  2909. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2910. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2911. alc880_ignore);
  2912. if (err < 0)
  2913. return err;
  2914. if (!spec->autocfg.line_outs)
  2915. return 0; /* can't find valid BIOS pin config */
  2916. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2917. if (err < 0)
  2918. return err;
  2919. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2920. if (err < 0)
  2921. return err;
  2922. err = alc880_auto_create_extra_out(spec,
  2923. spec->autocfg.speaker_pins[0],
  2924. "Speaker");
  2925. if (err < 0)
  2926. return err;
  2927. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2928. "Headphone");
  2929. if (err < 0)
  2930. return err;
  2931. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2932. if (err < 0)
  2933. return err;
  2934. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2935. if (spec->autocfg.dig_out_pin)
  2936. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2937. if (spec->autocfg.dig_in_pin)
  2938. spec->dig_in_nid = ALC880_DIGIN_NID;
  2939. if (spec->kctl_alloc)
  2940. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2941. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2942. spec->num_mux_defs = 1;
  2943. spec->input_mux = &spec->private_imux;
  2944. return 1;
  2945. }
  2946. /* additional initialization for auto-configuration model */
  2947. static void alc880_auto_init(struct hda_codec *codec)
  2948. {
  2949. alc880_auto_init_multi_out(codec);
  2950. alc880_auto_init_extra_out(codec);
  2951. alc880_auto_init_analog_input(codec);
  2952. }
  2953. /*
  2954. * OK, here we have finally the patch for ALC880
  2955. */
  2956. static int patch_alc880(struct hda_codec *codec)
  2957. {
  2958. struct alc_spec *spec;
  2959. int board_config;
  2960. int err;
  2961. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2962. if (spec == NULL)
  2963. return -ENOMEM;
  2964. codec->spec = spec;
  2965. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2966. alc880_models,
  2967. alc880_cfg_tbl);
  2968. if (board_config < 0) {
  2969. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2970. "trying auto-probe from BIOS...\n");
  2971. board_config = ALC880_AUTO;
  2972. }
  2973. if (board_config == ALC880_AUTO) {
  2974. /* automatic parse from the BIOS config */
  2975. err = alc880_parse_auto_config(codec);
  2976. if (err < 0) {
  2977. alc_free(codec);
  2978. return err;
  2979. } else if (!err) {
  2980. printk(KERN_INFO
  2981. "hda_codec: Cannot set up configuration "
  2982. "from BIOS. Using 3-stack mode...\n");
  2983. board_config = ALC880_3ST;
  2984. }
  2985. }
  2986. if (board_config != ALC880_AUTO)
  2987. setup_preset(spec, &alc880_presets[board_config]);
  2988. spec->stream_name_analog = "ALC880 Analog";
  2989. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2990. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2991. spec->stream_name_digital = "ALC880 Digital";
  2992. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2993. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2994. if (!spec->adc_nids && spec->input_mux) {
  2995. /* check whether NID 0x07 is valid */
  2996. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2997. /* get type */
  2998. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  2999. if (wcap != AC_WID_AUD_IN) {
  3000. spec->adc_nids = alc880_adc_nids_alt;
  3001. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3002. spec->mixers[spec->num_mixers] =
  3003. alc880_capture_alt_mixer;
  3004. spec->num_mixers++;
  3005. } else {
  3006. spec->adc_nids = alc880_adc_nids;
  3007. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3008. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3009. spec->num_mixers++;
  3010. }
  3011. }
  3012. codec->patch_ops = alc_patch_ops;
  3013. if (board_config == ALC880_AUTO)
  3014. spec->init_hook = alc880_auto_init;
  3015. return 0;
  3016. }
  3017. /*
  3018. * ALC260 support
  3019. */
  3020. static hda_nid_t alc260_dac_nids[1] = {
  3021. /* front */
  3022. 0x02,
  3023. };
  3024. static hda_nid_t alc260_adc_nids[1] = {
  3025. /* ADC0 */
  3026. 0x04,
  3027. };
  3028. static hda_nid_t alc260_adc_nids_alt[1] = {
  3029. /* ADC1 */
  3030. 0x05,
  3031. };
  3032. static hda_nid_t alc260_hp_adc_nids[2] = {
  3033. /* ADC1, 0 */
  3034. 0x05, 0x04
  3035. };
  3036. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3037. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3038. */
  3039. static hda_nid_t alc260_dual_adc_nids[2] = {
  3040. /* ADC0, ADC1 */
  3041. 0x04, 0x05
  3042. };
  3043. #define ALC260_DIGOUT_NID 0x03
  3044. #define ALC260_DIGIN_NID 0x06
  3045. static struct hda_input_mux alc260_capture_source = {
  3046. .num_items = 4,
  3047. .items = {
  3048. { "Mic", 0x0 },
  3049. { "Front Mic", 0x1 },
  3050. { "Line", 0x2 },
  3051. { "CD", 0x4 },
  3052. },
  3053. };
  3054. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3055. * headphone jack and the internal CD lines since these are the only pins at
  3056. * which audio can appear. For flexibility, also allow the option of
  3057. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3058. * connection to the mixer output).
  3059. */
  3060. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3061. {
  3062. .num_items = 3,
  3063. .items = {
  3064. { "Mic/Line", 0x0 },
  3065. { "CD", 0x4 },
  3066. { "Headphone", 0x2 },
  3067. },
  3068. },
  3069. {
  3070. .num_items = 4,
  3071. .items = {
  3072. { "Mic/Line", 0x0 },
  3073. { "CD", 0x4 },
  3074. { "Headphone", 0x2 },
  3075. { "Mixer", 0x5 },
  3076. },
  3077. },
  3078. };
  3079. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3080. * the Fujitsu S702x, but jacks are marked differently.
  3081. */
  3082. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3083. {
  3084. .num_items = 4,
  3085. .items = {
  3086. { "Mic", 0x0 },
  3087. { "Line", 0x2 },
  3088. { "CD", 0x4 },
  3089. { "Headphone", 0x5 },
  3090. },
  3091. },
  3092. {
  3093. .num_items = 5,
  3094. .items = {
  3095. { "Mic", 0x0 },
  3096. { "Line", 0x2 },
  3097. { "CD", 0x4 },
  3098. { "Headphone", 0x6 },
  3099. { "Mixer", 0x5 },
  3100. },
  3101. },
  3102. };
  3103. /*
  3104. * This is just place-holder, so there's something for alc_build_pcms to look
  3105. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3106. * element which allows changing the channel mode, so the verb list is
  3107. * never used.
  3108. */
  3109. static struct hda_channel_mode alc260_modes[1] = {
  3110. { 2, NULL },
  3111. };
  3112. /* Mixer combinations
  3113. *
  3114. * basic: base_output + input + pc_beep + capture
  3115. * HP: base_output + input + capture_alt
  3116. * HP_3013: hp_3013 + input + capture
  3117. * fujitsu: fujitsu + capture
  3118. * acer: acer + capture
  3119. */
  3120. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3121. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3122. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3123. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3124. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3125. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3126. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3127. { } /* end */
  3128. };
  3129. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3130. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3131. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3132. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3133. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3134. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3135. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3136. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3137. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3138. { } /* end */
  3139. };
  3140. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3141. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3142. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3143. { } /* end */
  3144. };
  3145. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3146. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3147. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3148. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3149. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3150. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3151. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3152. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3153. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3154. { } /* end */
  3155. };
  3156. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3157. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3158. */
  3159. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3160. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3161. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3162. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3163. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3164. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3165. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3166. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3167. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3168. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3169. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3170. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3171. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3172. { } /* end */
  3173. };
  3174. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3175. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3176. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3177. * datasheet doesn't mention this restriction. At this stage it's not clear
  3178. * whether this behaviour is intentional or is a hardware bug in chip
  3179. * revisions available in early 2006. Therefore for now allow the
  3180. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3181. * that the lack of mic bias for this NID is intentional we could change the
  3182. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3183. *
  3184. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3185. * don't appear to make the mic bias available from the "line" jack, even
  3186. * though the NID used for this jack (0x14) can supply it. The theory is
  3187. * that perhaps Acer have included blocking capacitors between the ALC260
  3188. * and the output jack. If this turns out to be the case for all such
  3189. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3190. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3191. *
  3192. * The C20x Tablet series have a mono internal speaker which is controlled
  3193. * via the chip's Mono sum widget and pin complex, so include the necessary
  3194. * controls for such models. On models without a "mono speaker" the control
  3195. * won't do anything.
  3196. */
  3197. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3198. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3199. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3200. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3201. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3202. HDA_OUTPUT),
  3203. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3204. HDA_INPUT),
  3205. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3206. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3207. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3208. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3209. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3210. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3211. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3212. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3213. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3214. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3215. { } /* end */
  3216. };
  3217. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3218. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3219. */
  3220. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3221. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3222. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3224. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3225. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3226. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3227. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3228. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3229. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3230. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3231. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3232. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3233. { } /* end */
  3234. };
  3235. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3236. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3237. */
  3238. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3239. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3240. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3241. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3242. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3243. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3244. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3245. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3246. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3247. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3248. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3249. { } /* end */
  3250. };
  3251. /* capture mixer elements */
  3252. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3253. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3254. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3255. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3256. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3257. {
  3258. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3259. /* The multiple "Capture Source" controls confuse alsamixer
  3260. * So call somewhat different..
  3261. * FIXME: the controls appear in the "playback" view!
  3262. */
  3263. /* .name = "Capture Source", */
  3264. .name = "Input Source",
  3265. .count = 2,
  3266. .info = alc_mux_enum_info,
  3267. .get = alc_mux_enum_get,
  3268. .put = alc_mux_enum_put,
  3269. },
  3270. { } /* end */
  3271. };
  3272. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3273. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3274. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3275. {
  3276. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3277. /* The multiple "Capture Source" controls confuse alsamixer
  3278. * So call somewhat different..
  3279. * FIXME: the controls appear in the "playback" view!
  3280. */
  3281. /* .name = "Capture Source", */
  3282. .name = "Input Source",
  3283. .count = 1,
  3284. .info = alc_mux_enum_info,
  3285. .get = alc_mux_enum_get,
  3286. .put = alc_mux_enum_put,
  3287. },
  3288. { } /* end */
  3289. };
  3290. /*
  3291. * initialization verbs
  3292. */
  3293. static struct hda_verb alc260_init_verbs[] = {
  3294. /* Line In pin widget for input */
  3295. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3296. /* CD pin widget for input */
  3297. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3298. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3299. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3300. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3301. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3302. /* LINE-2 is used for line-out in rear */
  3303. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3304. /* select line-out */
  3305. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3306. /* LINE-OUT pin */
  3307. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3308. /* enable HP */
  3309. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3310. /* enable Mono */
  3311. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3312. /* mute capture amp left and right */
  3313. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3314. /* set connection select to line in (default select for this ADC) */
  3315. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3316. /* mute capture amp left and right */
  3317. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3318. /* set connection select to line in (default select for this ADC) */
  3319. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3320. /* set vol=0 Line-Out mixer amp left and right */
  3321. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3322. /* unmute pin widget amp left and right (no gain on this amp) */
  3323. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3324. /* set vol=0 HP mixer amp left and right */
  3325. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3326. /* unmute pin widget amp left and right (no gain on this amp) */
  3327. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3328. /* set vol=0 Mono mixer amp left and right */
  3329. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3330. /* unmute pin widget amp left and right (no gain on this amp) */
  3331. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3332. /* unmute LINE-2 out pin */
  3333. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3334. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3335. * Line In 2 = 0x03
  3336. */
  3337. /* mute CD */
  3338. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3339. /* mute Line In */
  3340. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3341. /* mute Mic */
  3342. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3343. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3344. /* mute Front out path */
  3345. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3347. /* mute Headphone out path */
  3348. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3349. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3350. /* mute Mono out path */
  3351. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3352. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3353. { }
  3354. };
  3355. #if 0 /* should be identical with alc260_init_verbs? */
  3356. static struct hda_verb alc260_hp_init_verbs[] = {
  3357. /* Headphone and output */
  3358. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3359. /* mono output */
  3360. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3361. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3362. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3363. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3364. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3365. /* Line In pin widget for input */
  3366. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3367. /* Line-2 pin widget for output */
  3368. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3369. /* CD pin widget for input */
  3370. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3371. /* unmute amp left and right */
  3372. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3373. /* set connection select to line in (default select for this ADC) */
  3374. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3375. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3376. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3377. /* mute pin widget amp left and right (no gain on this amp) */
  3378. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3379. /* unmute HP mixer amp left and right (volume = 0) */
  3380. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3381. /* mute pin widget amp left and right (no gain on this amp) */
  3382. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3383. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3384. * Line In 2 = 0x03
  3385. */
  3386. /* unmute CD */
  3387. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3388. /* unmute Line In */
  3389. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3390. /* unmute Mic */
  3391. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3392. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3393. /* Unmute Front out path */
  3394. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3395. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3396. /* Unmute Headphone out path */
  3397. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3398. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3399. /* Unmute Mono out path */
  3400. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3401. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3402. { }
  3403. };
  3404. #endif
  3405. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3406. /* Line out and output */
  3407. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3408. /* mono output */
  3409. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3410. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3411. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3412. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3413. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3414. /* Line In pin widget for input */
  3415. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3416. /* Headphone pin widget for output */
  3417. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3418. /* CD pin widget for input */
  3419. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3420. /* unmute amp left and right */
  3421. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3422. /* set connection select to line in (default select for this ADC) */
  3423. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3424. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3425. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3426. /* mute pin widget amp left and right (no gain on this amp) */
  3427. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3428. /* unmute HP mixer amp left and right (volume = 0) */
  3429. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3430. /* mute pin widget amp left and right (no gain on this amp) */
  3431. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3432. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3433. * Line In 2 = 0x03
  3434. */
  3435. /* unmute CD */
  3436. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3437. /* unmute Line In */
  3438. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3439. /* unmute Mic */
  3440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3441. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3442. /* Unmute Front out path */
  3443. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3444. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3445. /* Unmute Headphone out path */
  3446. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3447. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3448. /* Unmute Mono out path */
  3449. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3450. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3451. { }
  3452. };
  3453. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3454. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3455. * audio = 0x16, internal speaker = 0x10.
  3456. */
  3457. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3458. /* Disable all GPIOs */
  3459. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3460. /* Internal speaker is connected to headphone pin */
  3461. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3462. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3463. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3464. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3465. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3466. /* Ensure all other unused pins are disabled and muted. */
  3467. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3468. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3469. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3470. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3471. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3472. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3474. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. /* Disable digital (SPDIF) pins */
  3476. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3477. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3478. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3479. * when acting as an output.
  3480. */
  3481. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3482. /* Start with output sum widgets muted and their output gains at min */
  3483. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3484. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3487. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3488. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3489. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3493. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3494. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3495. * If the pin mode is changed by the user the pin mode control will
  3496. * take care of enabling the pin's input/output buffers as needed.
  3497. * Therefore there's no need to enable the input buffer at this
  3498. * stage.
  3499. */
  3500. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3501. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3502. * mixer ctrl)
  3503. */
  3504. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3505. /* Mute capture amp left and right */
  3506. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3507. /* Set ADC connection select to match default mixer setting - line
  3508. * in (on mic1 pin)
  3509. */
  3510. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3511. /* Do the same for the second ADC: mute capture input amp and
  3512. * set ADC connection to line in (on mic1 pin)
  3513. */
  3514. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3516. /* Mute all inputs to mixer widget (even unconnected ones) */
  3517. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3518. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3519. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3520. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3521. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3522. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3525. { }
  3526. };
  3527. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3528. * similar laptops (adapted from Fujitsu init verbs).
  3529. */
  3530. static struct hda_verb alc260_acer_init_verbs[] = {
  3531. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3532. * the headphone jack. Turn this on and rely on the standard mute
  3533. * methods whenever the user wants to turn these outputs off.
  3534. */
  3535. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3536. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3537. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3538. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3539. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3540. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3541. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3542. /* Line In jack is connected to Line1 pin */
  3543. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3544. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3545. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3546. /* Ensure all other unused pins are disabled and muted. */
  3547. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3548. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3549. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3550. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3551. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3552. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3553. /* Disable digital (SPDIF) pins */
  3554. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3555. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3556. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3557. * bus when acting as outputs.
  3558. */
  3559. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3560. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3561. /* Start with output sum widgets muted and their output gains at min */
  3562. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3564. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3565. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3566. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3567. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3568. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3569. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3570. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3571. /* Unmute Line-out pin widget amp left and right
  3572. * (no equiv mixer ctrl)
  3573. */
  3574. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3575. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3576. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3577. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3578. * inputs. If the pin mode is changed by the user the pin mode control
  3579. * will take care of enabling the pin's input/output buffers as needed.
  3580. * Therefore there's no need to enable the input buffer at this
  3581. * stage.
  3582. */
  3583. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3584. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3585. /* Mute capture amp left and right */
  3586. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3587. /* Set ADC connection select to match default mixer setting - mic
  3588. * (on mic1 pin)
  3589. */
  3590. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3591. /* Do similar with the second ADC: mute capture input amp and
  3592. * set ADC connection to mic to match ALSA's default state.
  3593. */
  3594. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3595. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3596. /* Mute all inputs to mixer widget (even unconnected ones) */
  3597. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3598. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3599. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3600. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3601. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3602. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3603. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3605. { }
  3606. };
  3607. static struct hda_verb alc260_will_verbs[] = {
  3608. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3609. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3610. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3611. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3612. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3613. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3614. {}
  3615. };
  3616. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3617. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3618. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3619. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3620. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3621. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3622. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3623. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3624. {}
  3625. };
  3626. /* toggle speaker-output according to the hp-jack state */
  3627. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3628. {
  3629. unsigned int present;
  3630. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3631. present = snd_hda_codec_read(codec, 0x0f, 0,
  3632. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3633. if (present) {
  3634. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3635. snd_hda_codec_write(codec, 0x0f, 0,
  3636. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3637. } else {
  3638. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3639. snd_hda_codec_write(codec, 0x0f, 0,
  3640. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3641. }
  3642. }
  3643. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3644. unsigned int res)
  3645. {
  3646. if ((res >> 26) == ALC880_HP_EVENT)
  3647. alc260_replacer_672v_automute(codec);
  3648. }
  3649. /* Test configuration for debugging, modelled after the ALC880 test
  3650. * configuration.
  3651. */
  3652. #ifdef CONFIG_SND_DEBUG
  3653. static hda_nid_t alc260_test_dac_nids[1] = {
  3654. 0x02,
  3655. };
  3656. static hda_nid_t alc260_test_adc_nids[2] = {
  3657. 0x04, 0x05,
  3658. };
  3659. /* For testing the ALC260, each input MUX needs its own definition since
  3660. * the signal assignments are different. This assumes that the first ADC
  3661. * is NID 0x04.
  3662. */
  3663. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3664. {
  3665. .num_items = 7,
  3666. .items = {
  3667. { "MIC1 pin", 0x0 },
  3668. { "MIC2 pin", 0x1 },
  3669. { "LINE1 pin", 0x2 },
  3670. { "LINE2 pin", 0x3 },
  3671. { "CD pin", 0x4 },
  3672. { "LINE-OUT pin", 0x5 },
  3673. { "HP-OUT pin", 0x6 },
  3674. },
  3675. },
  3676. {
  3677. .num_items = 8,
  3678. .items = {
  3679. { "MIC1 pin", 0x0 },
  3680. { "MIC2 pin", 0x1 },
  3681. { "LINE1 pin", 0x2 },
  3682. { "LINE2 pin", 0x3 },
  3683. { "CD pin", 0x4 },
  3684. { "Mixer", 0x5 },
  3685. { "LINE-OUT pin", 0x6 },
  3686. { "HP-OUT pin", 0x7 },
  3687. },
  3688. },
  3689. };
  3690. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3691. /* Output driver widgets */
  3692. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3693. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3694. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3695. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3696. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3697. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3698. /* Modes for retasking pin widgets
  3699. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3700. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3701. * mention this restriction. At this stage it's not clear whether
  3702. * this behaviour is intentional or is a hardware bug in chip
  3703. * revisions available at least up until early 2006. Therefore for
  3704. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3705. * choices, but if it turns out that the lack of mic bias for these
  3706. * NIDs is intentional we could change their modes from
  3707. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3708. */
  3709. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3710. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3711. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3712. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3713. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3714. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3715. /* Loopback mixer controls */
  3716. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3717. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3718. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3719. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3720. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3721. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3722. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3723. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3724. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3725. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3726. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3727. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3728. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3729. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3730. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3731. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3732. /* Controls for GPIO pins, assuming they are configured as outputs */
  3733. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3734. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3735. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3736. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3737. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3738. * is ambigious as to which NID is which; testing on laptops which
  3739. * make this output available should provide clarification.
  3740. */
  3741. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3742. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3743. { } /* end */
  3744. };
  3745. static struct hda_verb alc260_test_init_verbs[] = {
  3746. /* Enable all GPIOs as outputs with an initial value of 0 */
  3747. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3748. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3749. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3750. /* Enable retasking pins as output, initially without power amp */
  3751. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3752. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3753. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3754. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3755. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3756. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3757. /* Disable digital (SPDIF) pins initially, but users can enable
  3758. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3759. * payload also sets the generation to 0, output to be in "consumer"
  3760. * PCM format, copyright asserted, no pre-emphasis and no validity
  3761. * control.
  3762. */
  3763. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3764. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3765. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3766. * OUT1 sum bus when acting as an output.
  3767. */
  3768. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3769. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3770. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3771. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3772. /* Start with output sum widgets muted and their output gains at min */
  3773. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3774. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3775. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3776. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3777. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3778. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3779. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3781. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3782. /* Unmute retasking pin widget output buffers since the default
  3783. * state appears to be output. As the pin mode is changed by the
  3784. * user the pin mode control will take care of enabling the pin's
  3785. * input/output buffers as needed.
  3786. */
  3787. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3788. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3789. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3790. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3791. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3792. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3793. /* Also unmute the mono-out pin widget */
  3794. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. /* Mute capture amp left and right */
  3796. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3797. /* Set ADC connection select to match default mixer setting (mic1
  3798. * pin)
  3799. */
  3800. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3801. /* Do the same for the second ADC: mute capture input amp and
  3802. * set ADC connection to mic1 pin
  3803. */
  3804. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3805. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3806. /* Mute all inputs to mixer widget (even unconnected ones) */
  3807. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3808. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3809. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3810. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3811. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3812. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3813. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3815. { }
  3816. };
  3817. #endif
  3818. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3819. .substreams = 1,
  3820. .channels_min = 2,
  3821. .channels_max = 2,
  3822. };
  3823. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3824. .substreams = 1,
  3825. .channels_min = 2,
  3826. .channels_max = 2,
  3827. };
  3828. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3829. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3830. /*
  3831. * for BIOS auto-configuration
  3832. */
  3833. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3834. const char *pfx)
  3835. {
  3836. hda_nid_t nid_vol;
  3837. unsigned long vol_val, sw_val;
  3838. char name[32];
  3839. int err;
  3840. if (nid >= 0x0f && nid < 0x11) {
  3841. nid_vol = nid - 0x7;
  3842. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3843. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3844. } else if (nid == 0x11) {
  3845. nid_vol = nid - 0x7;
  3846. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3847. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3848. } else if (nid >= 0x12 && nid <= 0x15) {
  3849. nid_vol = 0x08;
  3850. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3851. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3852. } else
  3853. return 0; /* N/A */
  3854. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3855. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3856. if (err < 0)
  3857. return err;
  3858. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3859. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3860. if (err < 0)
  3861. return err;
  3862. return 1;
  3863. }
  3864. /* add playback controls from the parsed DAC table */
  3865. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3866. const struct auto_pin_cfg *cfg)
  3867. {
  3868. hda_nid_t nid;
  3869. int err;
  3870. spec->multiout.num_dacs = 1;
  3871. spec->multiout.dac_nids = spec->private_dac_nids;
  3872. spec->multiout.dac_nids[0] = 0x02;
  3873. nid = cfg->line_out_pins[0];
  3874. if (nid) {
  3875. err = alc260_add_playback_controls(spec, nid, "Front");
  3876. if (err < 0)
  3877. return err;
  3878. }
  3879. nid = cfg->speaker_pins[0];
  3880. if (nid) {
  3881. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3882. if (err < 0)
  3883. return err;
  3884. }
  3885. nid = cfg->hp_pins[0];
  3886. if (nid) {
  3887. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3888. if (err < 0)
  3889. return err;
  3890. }
  3891. return 0;
  3892. }
  3893. /* create playback/capture controls for input pins */
  3894. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3895. const struct auto_pin_cfg *cfg)
  3896. {
  3897. struct hda_input_mux *imux = &spec->private_imux;
  3898. int i, err, idx;
  3899. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3900. if (cfg->input_pins[i] >= 0x12) {
  3901. idx = cfg->input_pins[i] - 0x12;
  3902. err = new_analog_input(spec, cfg->input_pins[i],
  3903. auto_pin_cfg_labels[i], idx,
  3904. 0x07);
  3905. if (err < 0)
  3906. return err;
  3907. imux->items[imux->num_items].label =
  3908. auto_pin_cfg_labels[i];
  3909. imux->items[imux->num_items].index = idx;
  3910. imux->num_items++;
  3911. }
  3912. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3913. idx = cfg->input_pins[i] - 0x09;
  3914. err = new_analog_input(spec, cfg->input_pins[i],
  3915. auto_pin_cfg_labels[i], idx,
  3916. 0x07);
  3917. if (err < 0)
  3918. return err;
  3919. imux->items[imux->num_items].label =
  3920. auto_pin_cfg_labels[i];
  3921. imux->items[imux->num_items].index = idx;
  3922. imux->num_items++;
  3923. }
  3924. }
  3925. return 0;
  3926. }
  3927. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3928. hda_nid_t nid, int pin_type,
  3929. int sel_idx)
  3930. {
  3931. /* set as output */
  3932. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3933. pin_type);
  3934. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3935. AMP_OUT_UNMUTE);
  3936. /* need the manual connection? */
  3937. if (nid >= 0x12) {
  3938. int idx = nid - 0x12;
  3939. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3940. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3941. }
  3942. }
  3943. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3944. {
  3945. struct alc_spec *spec = codec->spec;
  3946. hda_nid_t nid;
  3947. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3948. nid = spec->autocfg.line_out_pins[0];
  3949. if (nid) {
  3950. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3951. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3952. }
  3953. nid = spec->autocfg.speaker_pins[0];
  3954. if (nid)
  3955. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3956. nid = spec->autocfg.hp_pins[0];
  3957. if (nid)
  3958. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3959. }
  3960. #define ALC260_PIN_CD_NID 0x16
  3961. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3962. {
  3963. struct alc_spec *spec = codec->spec;
  3964. int i;
  3965. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3966. hda_nid_t nid = spec->autocfg.input_pins[i];
  3967. if (nid >= 0x12) {
  3968. snd_hda_codec_write(codec, nid, 0,
  3969. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3970. i <= AUTO_PIN_FRONT_MIC ?
  3971. PIN_VREF80 : PIN_IN);
  3972. if (nid != ALC260_PIN_CD_NID)
  3973. snd_hda_codec_write(codec, nid, 0,
  3974. AC_VERB_SET_AMP_GAIN_MUTE,
  3975. AMP_OUT_MUTE);
  3976. }
  3977. }
  3978. }
  3979. /*
  3980. * generic initialization of ADC, input mixers and output mixers
  3981. */
  3982. static struct hda_verb alc260_volume_init_verbs[] = {
  3983. /*
  3984. * Unmute ADC0-1 and set the default input to mic-in
  3985. */
  3986. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3987. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3988. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3989. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3990. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3991. * mixer widget
  3992. * Note: PASD motherboards uses the Line In 2 as the input for
  3993. * front panel mic (mic 2)
  3994. */
  3995. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3996. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3997. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3998. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3999. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4000. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4001. /*
  4002. * Set up output mixers (0x08 - 0x0a)
  4003. */
  4004. /* set vol=0 to output mixers */
  4005. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4006. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4007. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4008. /* set up input amps for analog loopback */
  4009. /* Amp Indices: DAC = 0, mixer = 1 */
  4010. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4011. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4012. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4013. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4014. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4015. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4016. { }
  4017. };
  4018. static int alc260_parse_auto_config(struct hda_codec *codec)
  4019. {
  4020. struct alc_spec *spec = codec->spec;
  4021. unsigned int wcap;
  4022. int err;
  4023. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4024. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4025. alc260_ignore);
  4026. if (err < 0)
  4027. return err;
  4028. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4029. if (err < 0)
  4030. return err;
  4031. if (!spec->kctl_alloc)
  4032. return 0; /* can't find valid BIOS pin config */
  4033. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4034. if (err < 0)
  4035. return err;
  4036. spec->multiout.max_channels = 2;
  4037. if (spec->autocfg.dig_out_pin)
  4038. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4039. if (spec->kctl_alloc)
  4040. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4041. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4042. spec->num_mux_defs = 1;
  4043. spec->input_mux = &spec->private_imux;
  4044. /* check whether NID 0x04 is valid */
  4045. wcap = get_wcaps(codec, 0x04);
  4046. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4047. if (wcap != AC_WID_AUD_IN) {
  4048. spec->adc_nids = alc260_adc_nids_alt;
  4049. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4050. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4051. } else {
  4052. spec->adc_nids = alc260_adc_nids;
  4053. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4054. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4055. }
  4056. spec->num_mixers++;
  4057. return 1;
  4058. }
  4059. /* additional initialization for auto-configuration model */
  4060. static void alc260_auto_init(struct hda_codec *codec)
  4061. {
  4062. alc260_auto_init_multi_out(codec);
  4063. alc260_auto_init_analog_input(codec);
  4064. }
  4065. /*
  4066. * ALC260 configurations
  4067. */
  4068. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4069. [ALC260_BASIC] = "basic",
  4070. [ALC260_HP] = "hp",
  4071. [ALC260_HP_3013] = "hp-3013",
  4072. [ALC260_FUJITSU_S702X] = "fujitsu",
  4073. [ALC260_ACER] = "acer",
  4074. [ALC260_WILL] = "will",
  4075. [ALC260_REPLACER_672V] = "replacer",
  4076. #ifdef CONFIG_SND_DEBUG
  4077. [ALC260_TEST] = "test",
  4078. #endif
  4079. [ALC260_AUTO] = "auto",
  4080. };
  4081. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4082. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4083. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4084. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4085. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4086. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4087. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4088. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4089. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4090. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4091. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4092. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4093. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4094. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4095. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4096. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4097. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4098. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4099. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4100. {}
  4101. };
  4102. static struct alc_config_preset alc260_presets[] = {
  4103. [ALC260_BASIC] = {
  4104. .mixers = { alc260_base_output_mixer,
  4105. alc260_input_mixer,
  4106. alc260_pc_beep_mixer,
  4107. alc260_capture_mixer },
  4108. .init_verbs = { alc260_init_verbs },
  4109. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4110. .dac_nids = alc260_dac_nids,
  4111. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4112. .adc_nids = alc260_adc_nids,
  4113. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4114. .channel_mode = alc260_modes,
  4115. .input_mux = &alc260_capture_source,
  4116. },
  4117. [ALC260_HP] = {
  4118. .mixers = { alc260_base_output_mixer,
  4119. alc260_input_mixer,
  4120. alc260_capture_alt_mixer },
  4121. .init_verbs = { alc260_init_verbs },
  4122. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4123. .dac_nids = alc260_dac_nids,
  4124. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4125. .adc_nids = alc260_hp_adc_nids,
  4126. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4127. .channel_mode = alc260_modes,
  4128. .input_mux = &alc260_capture_source,
  4129. },
  4130. [ALC260_HP_3013] = {
  4131. .mixers = { alc260_hp_3013_mixer,
  4132. alc260_input_mixer,
  4133. alc260_capture_alt_mixer },
  4134. .init_verbs = { alc260_hp_3013_init_verbs },
  4135. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4136. .dac_nids = alc260_dac_nids,
  4137. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4138. .adc_nids = alc260_hp_adc_nids,
  4139. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4140. .channel_mode = alc260_modes,
  4141. .input_mux = &alc260_capture_source,
  4142. },
  4143. [ALC260_FUJITSU_S702X] = {
  4144. .mixers = { alc260_fujitsu_mixer,
  4145. alc260_capture_mixer },
  4146. .init_verbs = { alc260_fujitsu_init_verbs },
  4147. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4148. .dac_nids = alc260_dac_nids,
  4149. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4150. .adc_nids = alc260_dual_adc_nids,
  4151. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4152. .channel_mode = alc260_modes,
  4153. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4154. .input_mux = alc260_fujitsu_capture_sources,
  4155. },
  4156. [ALC260_ACER] = {
  4157. .mixers = { alc260_acer_mixer,
  4158. alc260_capture_mixer },
  4159. .init_verbs = { alc260_acer_init_verbs },
  4160. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4161. .dac_nids = alc260_dac_nids,
  4162. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4163. .adc_nids = alc260_dual_adc_nids,
  4164. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4165. .channel_mode = alc260_modes,
  4166. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4167. .input_mux = alc260_acer_capture_sources,
  4168. },
  4169. [ALC260_WILL] = {
  4170. .mixers = { alc260_will_mixer,
  4171. alc260_capture_mixer },
  4172. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4173. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4174. .dac_nids = alc260_dac_nids,
  4175. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4176. .adc_nids = alc260_adc_nids,
  4177. .dig_out_nid = ALC260_DIGOUT_NID,
  4178. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4179. .channel_mode = alc260_modes,
  4180. .input_mux = &alc260_capture_source,
  4181. },
  4182. [ALC260_REPLACER_672V] = {
  4183. .mixers = { alc260_replacer_672v_mixer,
  4184. alc260_capture_mixer },
  4185. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4186. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4187. .dac_nids = alc260_dac_nids,
  4188. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4189. .adc_nids = alc260_adc_nids,
  4190. .dig_out_nid = ALC260_DIGOUT_NID,
  4191. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4192. .channel_mode = alc260_modes,
  4193. .input_mux = &alc260_capture_source,
  4194. .unsol_event = alc260_replacer_672v_unsol_event,
  4195. .init_hook = alc260_replacer_672v_automute,
  4196. },
  4197. #ifdef CONFIG_SND_DEBUG
  4198. [ALC260_TEST] = {
  4199. .mixers = { alc260_test_mixer,
  4200. alc260_capture_mixer },
  4201. .init_verbs = { alc260_test_init_verbs },
  4202. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4203. .dac_nids = alc260_test_dac_nids,
  4204. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4205. .adc_nids = alc260_test_adc_nids,
  4206. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4207. .channel_mode = alc260_modes,
  4208. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4209. .input_mux = alc260_test_capture_sources,
  4210. },
  4211. #endif
  4212. };
  4213. static int patch_alc260(struct hda_codec *codec)
  4214. {
  4215. struct alc_spec *spec;
  4216. int err, board_config;
  4217. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4218. if (spec == NULL)
  4219. return -ENOMEM;
  4220. codec->spec = spec;
  4221. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4222. alc260_models,
  4223. alc260_cfg_tbl);
  4224. if (board_config < 0) {
  4225. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4226. "trying auto-probe from BIOS...\n");
  4227. board_config = ALC260_AUTO;
  4228. }
  4229. if (board_config == ALC260_AUTO) {
  4230. /* automatic parse from the BIOS config */
  4231. err = alc260_parse_auto_config(codec);
  4232. if (err < 0) {
  4233. alc_free(codec);
  4234. return err;
  4235. } else if (!err) {
  4236. printk(KERN_INFO
  4237. "hda_codec: Cannot set up configuration "
  4238. "from BIOS. Using base mode...\n");
  4239. board_config = ALC260_BASIC;
  4240. }
  4241. }
  4242. if (board_config != ALC260_AUTO)
  4243. setup_preset(spec, &alc260_presets[board_config]);
  4244. spec->stream_name_analog = "ALC260 Analog";
  4245. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4246. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4247. spec->stream_name_digital = "ALC260 Digital";
  4248. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4249. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4250. codec->patch_ops = alc_patch_ops;
  4251. if (board_config == ALC260_AUTO)
  4252. spec->init_hook = alc260_auto_init;
  4253. return 0;
  4254. }
  4255. /*
  4256. * ALC882 support
  4257. *
  4258. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4259. * configuration. Each pin widget can choose any input DACs and a mixer.
  4260. * Each ADC is connected from a mixer of all inputs. This makes possible
  4261. * 6-channel independent captures.
  4262. *
  4263. * In addition, an independent DAC for the multi-playback (not used in this
  4264. * driver yet).
  4265. */
  4266. #define ALC882_DIGOUT_NID 0x06
  4267. #define ALC882_DIGIN_NID 0x0a
  4268. static struct hda_channel_mode alc882_ch_modes[1] = {
  4269. { 8, NULL }
  4270. };
  4271. static hda_nid_t alc882_dac_nids[4] = {
  4272. /* front, rear, clfe, rear_surr */
  4273. 0x02, 0x03, 0x04, 0x05
  4274. };
  4275. /* identical with ALC880 */
  4276. #define alc882_adc_nids alc880_adc_nids
  4277. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4278. /* input MUX */
  4279. /* FIXME: should be a matrix-type input source selection */
  4280. static struct hda_input_mux alc882_capture_source = {
  4281. .num_items = 4,
  4282. .items = {
  4283. { "Mic", 0x0 },
  4284. { "Front Mic", 0x1 },
  4285. { "Line", 0x2 },
  4286. { "CD", 0x4 },
  4287. },
  4288. };
  4289. #define alc882_mux_enum_info alc_mux_enum_info
  4290. #define alc882_mux_enum_get alc_mux_enum_get
  4291. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4292. struct snd_ctl_elem_value *ucontrol)
  4293. {
  4294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4295. struct alc_spec *spec = codec->spec;
  4296. const struct hda_input_mux *imux = spec->input_mux;
  4297. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4298. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4299. hda_nid_t nid = capture_mixers[adc_idx];
  4300. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4301. unsigned int i, idx;
  4302. idx = ucontrol->value.enumerated.item[0];
  4303. if (idx >= imux->num_items)
  4304. idx = imux->num_items - 1;
  4305. if (*cur_val == idx && !codec->in_resume)
  4306. return 0;
  4307. for (i = 0; i < imux->num_items; i++) {
  4308. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4309. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4310. v | (imux->items[i].index << 8));
  4311. }
  4312. *cur_val = idx;
  4313. return 1;
  4314. }
  4315. /*
  4316. * 2ch mode
  4317. */
  4318. static struct hda_verb alc882_3ST_ch2_init[] = {
  4319. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4320. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4321. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4322. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4323. { } /* end */
  4324. };
  4325. /*
  4326. * 6ch mode
  4327. */
  4328. static struct hda_verb alc882_3ST_ch6_init[] = {
  4329. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4330. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4331. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4332. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4333. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4334. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4335. { } /* end */
  4336. };
  4337. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4338. { 2, alc882_3ST_ch2_init },
  4339. { 6, alc882_3ST_ch6_init },
  4340. };
  4341. /*
  4342. * 6ch mode
  4343. */
  4344. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4345. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4346. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4347. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4348. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4349. { } /* end */
  4350. };
  4351. /*
  4352. * 8ch mode
  4353. */
  4354. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4355. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4356. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4357. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4358. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4359. { } /* end */
  4360. };
  4361. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4362. { 6, alc882_sixstack_ch6_init },
  4363. { 8, alc882_sixstack_ch8_init },
  4364. };
  4365. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4366. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4367. */
  4368. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4369. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4370. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4371. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4372. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4373. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4374. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4375. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4376. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4378. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4379. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4380. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4381. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4382. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4383. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4385. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4386. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4387. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4391. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4392. { } /* end */
  4393. };
  4394. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4395. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4396. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4397. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4398. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4399. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4400. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4401. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4402. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4403. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4404. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4405. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4406. { } /* end */
  4407. };
  4408. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4409. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4410. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4411. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4412. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4413. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4414. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4415. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4416. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4417. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4418. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4419. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4420. { } /* end */
  4421. };
  4422. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4423. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4424. */
  4425. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4427. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4428. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4429. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4430. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4431. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4432. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4433. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4434. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4435. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4436. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4437. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4438. { } /* end */
  4439. };
  4440. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4441. {
  4442. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4443. .name = "Channel Mode",
  4444. .info = alc_ch_mode_info,
  4445. .get = alc_ch_mode_get,
  4446. .put = alc_ch_mode_put,
  4447. },
  4448. { } /* end */
  4449. };
  4450. static struct hda_verb alc882_init_verbs[] = {
  4451. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4452. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4453. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4454. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4455. /* Rear mixer */
  4456. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4457. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4458. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4459. /* CLFE mixer */
  4460. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4461. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4462. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4463. /* Side mixer */
  4464. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4465. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4466. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4467. /* Front Pin: output 0 (0x0c) */
  4468. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4469. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4470. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4471. /* Rear Pin: output 1 (0x0d) */
  4472. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4473. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4474. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4475. /* CLFE Pin: output 2 (0x0e) */
  4476. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4477. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4478. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4479. /* Side Pin: output 3 (0x0f) */
  4480. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4481. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4482. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4483. /* Mic (rear) pin: input vref at 80% */
  4484. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4485. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4486. /* Front Mic pin: input vref at 80% */
  4487. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4488. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4489. /* Line In pin: input */
  4490. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4492. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4493. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4494. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4495. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4496. /* CD pin widget for input */
  4497. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4498. /* FIXME: use matrix-type input source selection */
  4499. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4500. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4501. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4502. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4503. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4504. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4505. /* Input mixer2 */
  4506. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4507. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4508. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4509. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4510. /* Input mixer3 */
  4511. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4512. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4513. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4514. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4515. /* ADC1: mute amp left and right */
  4516. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4517. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4518. /* ADC2: mute amp left and right */
  4519. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4520. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4521. /* ADC3: mute amp left and right */
  4522. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4523. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4524. { }
  4525. };
  4526. static struct hda_verb alc882_eapd_verbs[] = {
  4527. /* change to EAPD mode */
  4528. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4529. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4530. { }
  4531. };
  4532. /* Mac Pro test */
  4533. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4534. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4535. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4536. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4537. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4538. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4539. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4540. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4541. { } /* end */
  4542. };
  4543. static struct hda_verb alc882_macpro_init_verbs[] = {
  4544. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4545. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4546. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4547. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4548. /* Front Pin: output 0 (0x0c) */
  4549. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4550. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4551. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4552. /* Front Mic pin: input vref at 80% */
  4553. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4554. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4555. /* Speaker: output */
  4556. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4557. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4558. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4559. /* Headphone output (output 0 - 0x0c) */
  4560. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4561. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4562. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4563. /* FIXME: use matrix-type input source selection */
  4564. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4565. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4566. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4567. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4568. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4569. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4570. /* Input mixer2 */
  4571. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4572. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4573. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4574. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4575. /* Input mixer3 */
  4576. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4577. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4578. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4579. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4580. /* ADC1: mute amp left and right */
  4581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4582. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4583. /* ADC2: mute amp left and right */
  4584. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4585. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4586. /* ADC3: mute amp left and right */
  4587. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4589. { }
  4590. };
  4591. static struct hda_verb alc882_targa_verbs[] = {
  4592. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4593. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4594. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4595. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4596. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4597. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4598. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4599. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4600. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4601. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4602. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4603. { } /* end */
  4604. };
  4605. /* toggle speaker-output according to the hp-jack state */
  4606. static void alc882_targa_automute(struct hda_codec *codec)
  4607. {
  4608. unsigned int present;
  4609. present = snd_hda_codec_read(codec, 0x14, 0,
  4610. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4611. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4612. 0x80, present ? 0x80 : 0);
  4613. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4614. 0x80, present ? 0x80 : 0);
  4615. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4616. }
  4617. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4618. {
  4619. /* Looks like the unsol event is incompatible with the standard
  4620. * definition. 4bit tag is placed at 26 bit!
  4621. */
  4622. if (((res >> 26) == ALC880_HP_EVENT)) {
  4623. alc882_targa_automute(codec);
  4624. }
  4625. }
  4626. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4627. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4629. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4630. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4631. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4632. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4633. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4634. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4635. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4636. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4637. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4638. { } /* end */
  4639. };
  4640. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4641. {
  4642. unsigned int gpiostate, gpiomask, gpiodir;
  4643. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4644. AC_VERB_GET_GPIO_DATA, 0);
  4645. if (!muted)
  4646. gpiostate |= (1 << pin);
  4647. else
  4648. gpiostate &= ~(1 << pin);
  4649. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4650. AC_VERB_GET_GPIO_MASK, 0);
  4651. gpiomask |= (1 << pin);
  4652. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4653. AC_VERB_GET_GPIO_DIRECTION, 0);
  4654. gpiodir |= (1 << pin);
  4655. snd_hda_codec_write(codec, codec->afg, 0,
  4656. AC_VERB_SET_GPIO_MASK, gpiomask);
  4657. snd_hda_codec_write(codec, codec->afg, 0,
  4658. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4659. msleep(1);
  4660. snd_hda_codec_write(codec, codec->afg, 0,
  4661. AC_VERB_SET_GPIO_DATA, gpiostate);
  4662. }
  4663. /*
  4664. * generic initialization of ADC, input mixers and output mixers
  4665. */
  4666. static struct hda_verb alc882_auto_init_verbs[] = {
  4667. /*
  4668. * Unmute ADC0-2 and set the default input to mic-in
  4669. */
  4670. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4671. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4672. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4673. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4674. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4675. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4676. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4677. * mixer widget
  4678. * Note: PASD motherboards uses the Line In 2 as the input for
  4679. * front panel mic (mic 2)
  4680. */
  4681. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4686. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4687. /*
  4688. * Set up output mixers (0x0c - 0x0f)
  4689. */
  4690. /* set vol=0 to output mixers */
  4691. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4692. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4693. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4694. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4695. /* set up input amps for analog loopback */
  4696. /* Amp Indices: DAC = 0, mixer = 1 */
  4697. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4700. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4701. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4703. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4704. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4705. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4706. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4707. /* FIXME: use matrix-type input source selection */
  4708. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4709. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4710. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4711. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4712. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4713. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4714. /* Input mixer2 */
  4715. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4716. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4717. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4718. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4719. /* Input mixer3 */
  4720. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4721. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4722. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4723. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4724. { }
  4725. };
  4726. /* capture mixer elements */
  4727. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4728. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4729. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4730. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4731. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4732. {
  4733. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4734. /* The multiple "Capture Source" controls confuse alsamixer
  4735. * So call somewhat different..
  4736. * FIXME: the controls appear in the "playback" view!
  4737. */
  4738. /* .name = "Capture Source", */
  4739. .name = "Input Source",
  4740. .count = 2,
  4741. .info = alc882_mux_enum_info,
  4742. .get = alc882_mux_enum_get,
  4743. .put = alc882_mux_enum_put,
  4744. },
  4745. { } /* end */
  4746. };
  4747. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4748. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4749. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4750. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4751. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4752. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4753. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4754. {
  4755. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4756. /* The multiple "Capture Source" controls confuse alsamixer
  4757. * So call somewhat different..
  4758. * FIXME: the controls appear in the "playback" view!
  4759. */
  4760. /* .name = "Capture Source", */
  4761. .name = "Input Source",
  4762. .count = 3,
  4763. .info = alc882_mux_enum_info,
  4764. .get = alc882_mux_enum_get,
  4765. .put = alc882_mux_enum_put,
  4766. },
  4767. { } /* end */
  4768. };
  4769. /* pcm configuration: identiacal with ALC880 */
  4770. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4771. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4772. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4773. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4774. /*
  4775. * configuration and preset
  4776. */
  4777. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4778. [ALC882_3ST_DIG] = "3stack-dig",
  4779. [ALC882_6ST_DIG] = "6stack-dig",
  4780. [ALC882_ARIMA] = "arima",
  4781. [ALC882_W2JC] = "w2jc",
  4782. [ALC885_MACPRO] = "macpro",
  4783. [ALC882_AUTO] = "auto",
  4784. };
  4785. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4786. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4787. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4788. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4789. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4790. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4791. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4792. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4793. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4794. {}
  4795. };
  4796. static struct alc_config_preset alc882_presets[] = {
  4797. [ALC882_3ST_DIG] = {
  4798. .mixers = { alc882_base_mixer },
  4799. .init_verbs = { alc882_init_verbs },
  4800. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4801. .dac_nids = alc882_dac_nids,
  4802. .dig_out_nid = ALC882_DIGOUT_NID,
  4803. .dig_in_nid = ALC882_DIGIN_NID,
  4804. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4805. .channel_mode = alc882_ch_modes,
  4806. .need_dac_fix = 1,
  4807. .input_mux = &alc882_capture_source,
  4808. },
  4809. [ALC882_6ST_DIG] = {
  4810. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4811. .init_verbs = { alc882_init_verbs },
  4812. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4813. .dac_nids = alc882_dac_nids,
  4814. .dig_out_nid = ALC882_DIGOUT_NID,
  4815. .dig_in_nid = ALC882_DIGIN_NID,
  4816. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4817. .channel_mode = alc882_sixstack_modes,
  4818. .input_mux = &alc882_capture_source,
  4819. },
  4820. [ALC882_ARIMA] = {
  4821. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4822. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4823. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4824. .dac_nids = alc882_dac_nids,
  4825. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4826. .channel_mode = alc882_sixstack_modes,
  4827. .input_mux = &alc882_capture_source,
  4828. },
  4829. [ALC882_W2JC] = {
  4830. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4831. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4832. alc880_gpio1_init_verbs },
  4833. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4834. .dac_nids = alc882_dac_nids,
  4835. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4836. .channel_mode = alc880_threestack_modes,
  4837. .need_dac_fix = 1,
  4838. .input_mux = &alc882_capture_source,
  4839. .dig_out_nid = ALC882_DIGOUT_NID,
  4840. },
  4841. [ALC885_MACPRO] = {
  4842. .mixers = { alc882_macpro_mixer },
  4843. .init_verbs = { alc882_macpro_init_verbs },
  4844. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4845. .dac_nids = alc882_dac_nids,
  4846. .dig_out_nid = ALC882_DIGOUT_NID,
  4847. .dig_in_nid = ALC882_DIGIN_NID,
  4848. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4849. .channel_mode = alc882_ch_modes,
  4850. .input_mux = &alc882_capture_source,
  4851. },
  4852. [ALC882_TARGA] = {
  4853. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4854. alc882_capture_mixer },
  4855. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4856. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4857. .dac_nids = alc882_dac_nids,
  4858. .dig_out_nid = ALC882_DIGOUT_NID,
  4859. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4860. .adc_nids = alc882_adc_nids,
  4861. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4862. .channel_mode = alc882_3ST_6ch_modes,
  4863. .need_dac_fix = 1,
  4864. .input_mux = &alc882_capture_source,
  4865. .unsol_event = alc882_targa_unsol_event,
  4866. .init_hook = alc882_targa_automute,
  4867. },
  4868. [ALC882_ASUS_A7J] = {
  4869. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4870. alc882_capture_mixer },
  4871. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4872. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4873. .dac_nids = alc882_dac_nids,
  4874. .dig_out_nid = ALC882_DIGOUT_NID,
  4875. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4876. .adc_nids = alc882_adc_nids,
  4877. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4878. .channel_mode = alc882_3ST_6ch_modes,
  4879. .need_dac_fix = 1,
  4880. .input_mux = &alc882_capture_source,
  4881. },
  4882. };
  4883. /*
  4884. * BIOS auto configuration
  4885. */
  4886. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4887. hda_nid_t nid, int pin_type,
  4888. int dac_idx)
  4889. {
  4890. /* set as output */
  4891. struct alc_spec *spec = codec->spec;
  4892. int idx;
  4893. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4894. idx = 4;
  4895. else
  4896. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4897. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4898. pin_type);
  4899. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4900. AMP_OUT_UNMUTE);
  4901. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4902. }
  4903. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4904. {
  4905. struct alc_spec *spec = codec->spec;
  4906. int i;
  4907. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4908. for (i = 0; i <= HDA_SIDE; i++) {
  4909. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4910. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4911. if (nid)
  4912. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4913. i);
  4914. }
  4915. }
  4916. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4917. {
  4918. struct alc_spec *spec = codec->spec;
  4919. hda_nid_t pin;
  4920. pin = spec->autocfg.hp_pins[0];
  4921. if (pin) /* connect to front */
  4922. /* use dac 0 */
  4923. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4924. }
  4925. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4926. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4927. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4928. {
  4929. struct alc_spec *spec = codec->spec;
  4930. int i;
  4931. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4932. hda_nid_t nid = spec->autocfg.input_pins[i];
  4933. if (alc882_is_input_pin(nid)) {
  4934. snd_hda_codec_write(codec, nid, 0,
  4935. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4936. i <= AUTO_PIN_FRONT_MIC ?
  4937. PIN_VREF80 : PIN_IN);
  4938. if (nid != ALC882_PIN_CD_NID)
  4939. snd_hda_codec_write(codec, nid, 0,
  4940. AC_VERB_SET_AMP_GAIN_MUTE,
  4941. AMP_OUT_MUTE);
  4942. }
  4943. }
  4944. }
  4945. /* almost identical with ALC880 parser... */
  4946. static int alc882_parse_auto_config(struct hda_codec *codec)
  4947. {
  4948. struct alc_spec *spec = codec->spec;
  4949. int err = alc880_parse_auto_config(codec);
  4950. if (err < 0)
  4951. return err;
  4952. else if (err > 0)
  4953. /* hack - override the init verbs */
  4954. spec->init_verbs[0] = alc882_auto_init_verbs;
  4955. return err;
  4956. }
  4957. /* additional initialization for auto-configuration model */
  4958. static void alc882_auto_init(struct hda_codec *codec)
  4959. {
  4960. alc882_auto_init_multi_out(codec);
  4961. alc882_auto_init_hp_out(codec);
  4962. alc882_auto_init_analog_input(codec);
  4963. }
  4964. static int patch_alc882(struct hda_codec *codec)
  4965. {
  4966. struct alc_spec *spec;
  4967. int err, board_config;
  4968. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4969. if (spec == NULL)
  4970. return -ENOMEM;
  4971. codec->spec = spec;
  4972. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4973. alc882_models,
  4974. alc882_cfg_tbl);
  4975. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4976. /* Pick up systems that don't supply PCI SSID */
  4977. switch (codec->subsystem_id) {
  4978. case 0x106b0c00: /* Mac Pro */
  4979. board_config = ALC885_MACPRO;
  4980. break;
  4981. default:
  4982. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4983. "trying auto-probe from BIOS...\n");
  4984. board_config = ALC882_AUTO;
  4985. }
  4986. }
  4987. if (board_config == ALC882_AUTO) {
  4988. /* automatic parse from the BIOS config */
  4989. err = alc882_parse_auto_config(codec);
  4990. if (err < 0) {
  4991. alc_free(codec);
  4992. return err;
  4993. } else if (!err) {
  4994. printk(KERN_INFO
  4995. "hda_codec: Cannot set up configuration "
  4996. "from BIOS. Using base mode...\n");
  4997. board_config = ALC882_3ST_DIG;
  4998. }
  4999. }
  5000. if (board_config != ALC882_AUTO)
  5001. setup_preset(spec, &alc882_presets[board_config]);
  5002. if (board_config == ALC885_MACPRO) {
  5003. alc882_gpio_mute(codec, 0, 0);
  5004. alc882_gpio_mute(codec, 1, 0);
  5005. }
  5006. spec->stream_name_analog = "ALC882 Analog";
  5007. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5008. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5009. spec->stream_name_digital = "ALC882 Digital";
  5010. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5011. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5012. if (!spec->adc_nids && spec->input_mux) {
  5013. /* check whether NID 0x07 is valid */
  5014. unsigned int wcap = get_wcaps(codec, 0x07);
  5015. /* get type */
  5016. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5017. if (wcap != AC_WID_AUD_IN) {
  5018. spec->adc_nids = alc882_adc_nids_alt;
  5019. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5020. spec->mixers[spec->num_mixers] =
  5021. alc882_capture_alt_mixer;
  5022. spec->num_mixers++;
  5023. } else {
  5024. spec->adc_nids = alc882_adc_nids;
  5025. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5026. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5027. spec->num_mixers++;
  5028. }
  5029. }
  5030. codec->patch_ops = alc_patch_ops;
  5031. if (board_config == ALC882_AUTO)
  5032. spec->init_hook = alc882_auto_init;
  5033. return 0;
  5034. }
  5035. /*
  5036. * ALC883 support
  5037. *
  5038. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5039. * configuration. Each pin widget can choose any input DACs and a mixer.
  5040. * Each ADC is connected from a mixer of all inputs. This makes possible
  5041. * 6-channel independent captures.
  5042. *
  5043. * In addition, an independent DAC for the multi-playback (not used in this
  5044. * driver yet).
  5045. */
  5046. #define ALC883_DIGOUT_NID 0x06
  5047. #define ALC883_DIGIN_NID 0x0a
  5048. static hda_nid_t alc883_dac_nids[4] = {
  5049. /* front, rear, clfe, rear_surr */
  5050. 0x02, 0x04, 0x03, 0x05
  5051. };
  5052. static hda_nid_t alc883_adc_nids[2] = {
  5053. /* ADC1-2 */
  5054. 0x08, 0x09,
  5055. };
  5056. /* input MUX */
  5057. /* FIXME: should be a matrix-type input source selection */
  5058. static struct hda_input_mux alc883_capture_source = {
  5059. .num_items = 4,
  5060. .items = {
  5061. { "Mic", 0x0 },
  5062. { "Front Mic", 0x1 },
  5063. { "Line", 0x2 },
  5064. { "CD", 0x4 },
  5065. },
  5066. };
  5067. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5068. .num_items = 2,
  5069. .items = {
  5070. { "Mic", 0x1 },
  5071. { "Line", 0x2 },
  5072. },
  5073. };
  5074. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5075. .num_items = 4,
  5076. .items = {
  5077. { "Mic", 0x0 },
  5078. { "iMic", 0x1 },
  5079. { "Line", 0x2 },
  5080. { "CD", 0x4 },
  5081. },
  5082. };
  5083. #define alc883_mux_enum_info alc_mux_enum_info
  5084. #define alc883_mux_enum_get alc_mux_enum_get
  5085. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5086. struct snd_ctl_elem_value *ucontrol)
  5087. {
  5088. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5089. struct alc_spec *spec = codec->spec;
  5090. const struct hda_input_mux *imux = spec->input_mux;
  5091. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5092. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5093. hda_nid_t nid = capture_mixers[adc_idx];
  5094. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5095. unsigned int i, idx;
  5096. idx = ucontrol->value.enumerated.item[0];
  5097. if (idx >= imux->num_items)
  5098. idx = imux->num_items - 1;
  5099. if (*cur_val == idx && !codec->in_resume)
  5100. return 0;
  5101. for (i = 0; i < imux->num_items; i++) {
  5102. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5103. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5104. v | (imux->items[i].index << 8));
  5105. }
  5106. *cur_val = idx;
  5107. return 1;
  5108. }
  5109. /*
  5110. * 2ch mode
  5111. */
  5112. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5113. { 2, NULL }
  5114. };
  5115. /*
  5116. * 2ch mode
  5117. */
  5118. static struct hda_verb alc883_3ST_ch2_init[] = {
  5119. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5120. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5121. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5122. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5123. { } /* end */
  5124. };
  5125. /*
  5126. * 6ch mode
  5127. */
  5128. static struct hda_verb alc883_3ST_ch6_init[] = {
  5129. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5130. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5131. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5132. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5133. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5134. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5135. { } /* end */
  5136. };
  5137. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5138. { 2, alc883_3ST_ch2_init },
  5139. { 6, alc883_3ST_ch6_init },
  5140. };
  5141. /*
  5142. * 6ch mode
  5143. */
  5144. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5145. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5146. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5147. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5148. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5149. { } /* end */
  5150. };
  5151. /*
  5152. * 8ch mode
  5153. */
  5154. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5155. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5156. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5157. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5158. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5159. { } /* end */
  5160. };
  5161. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5162. { 6, alc883_sixstack_ch6_init },
  5163. { 8, alc883_sixstack_ch8_init },
  5164. };
  5165. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5166. /* eanable EAPD on medion laptop */
  5167. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5168. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5169. { }
  5170. };
  5171. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5172. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5173. */
  5174. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5175. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5176. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5177. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5178. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5179. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5180. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5181. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5182. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5183. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5184. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5185. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5186. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5187. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5188. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5189. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5191. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5192. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5193. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5194. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5195. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5196. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5197. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5198. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5199. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5200. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5201. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5202. {
  5203. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5204. /* .name = "Capture Source", */
  5205. .name = "Input Source",
  5206. .count = 2,
  5207. .info = alc883_mux_enum_info,
  5208. .get = alc883_mux_enum_get,
  5209. .put = alc883_mux_enum_put,
  5210. },
  5211. { } /* end */
  5212. };
  5213. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5214. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5215. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5216. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5217. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5218. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5219. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5220. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5221. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5222. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5224. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5225. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5226. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5227. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5228. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5229. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5230. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5231. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5232. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5233. {
  5234. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5235. /* .name = "Capture Source", */
  5236. .name = "Input Source",
  5237. .count = 2,
  5238. .info = alc883_mux_enum_info,
  5239. .get = alc883_mux_enum_get,
  5240. .put = alc883_mux_enum_put,
  5241. },
  5242. { } /* end */
  5243. };
  5244. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5245. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5246. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5247. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5248. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5249. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5250. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5251. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5252. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5253. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5254. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5255. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5256. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5257. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5258. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5259. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5260. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5261. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5262. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5263. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5265. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5267. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5268. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5269. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5270. {
  5271. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5272. /* .name = "Capture Source", */
  5273. .name = "Input Source",
  5274. .count = 2,
  5275. .info = alc883_mux_enum_info,
  5276. .get = alc883_mux_enum_get,
  5277. .put = alc883_mux_enum_put,
  5278. },
  5279. { } /* end */
  5280. };
  5281. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5282. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5283. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5284. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5285. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5286. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5287. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5288. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5289. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5292. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5293. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5294. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5296. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5297. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5298. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5299. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5300. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5302. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5304. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5305. {
  5306. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5307. /* .name = "Capture Source", */
  5308. .name = "Input Source",
  5309. .count = 1,
  5310. .info = alc883_mux_enum_info,
  5311. .get = alc883_mux_enum_get,
  5312. .put = alc883_mux_enum_put,
  5313. },
  5314. { } /* end */
  5315. };
  5316. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5317. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5318. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5319. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5320. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5321. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5322. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5323. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5324. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5325. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5326. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5327. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5328. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5330. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5331. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5332. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5333. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5334. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5335. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5336. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5337. {
  5338. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5339. /* .name = "Capture Source", */
  5340. .name = "Input Source",
  5341. .count = 2,
  5342. .info = alc883_mux_enum_info,
  5343. .get = alc883_mux_enum_get,
  5344. .put = alc883_mux_enum_put,
  5345. },
  5346. { } /* end */
  5347. };
  5348. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5349. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5350. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5351. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5352. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5353. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5355. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5356. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5357. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5358. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5359. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5360. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5361. {
  5362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5363. /* .name = "Capture Source", */
  5364. .name = "Input Source",
  5365. .count = 2,
  5366. .info = alc883_mux_enum_info,
  5367. .get = alc883_mux_enum_get,
  5368. .put = alc883_mux_enum_put,
  5369. },
  5370. { } /* end */
  5371. };
  5372. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5374. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5376. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5377. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5378. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5380. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5382. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5383. {
  5384. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5385. /* .name = "Capture Source", */
  5386. .name = "Input Source",
  5387. .count = 1,
  5388. .info = alc883_mux_enum_info,
  5389. .get = alc883_mux_enum_get,
  5390. .put = alc883_mux_enum_put,
  5391. },
  5392. { } /* end */
  5393. };
  5394. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5395. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5396. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5397. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5398. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5399. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5400. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5401. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5402. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5403. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5406. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5407. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5408. {
  5409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5410. /* .name = "Capture Source", */
  5411. .name = "Input Source",
  5412. .count = 2,
  5413. .info = alc883_mux_enum_info,
  5414. .get = alc883_mux_enum_get,
  5415. .put = alc883_mux_enum_put,
  5416. },
  5417. { } /* end */
  5418. };
  5419. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5420. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5421. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5422. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5423. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5424. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5425. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5426. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5428. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5430. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5433. {
  5434. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5435. /* .name = "Capture Source", */
  5436. .name = "Input Source",
  5437. .count = 2,
  5438. .info = alc883_mux_enum_info,
  5439. .get = alc883_mux_enum_get,
  5440. .put = alc883_mux_enum_put,
  5441. },
  5442. { } /* end */
  5443. };
  5444. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5445. {
  5446. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5447. .name = "Channel Mode",
  5448. .info = alc_ch_mode_info,
  5449. .get = alc_ch_mode_get,
  5450. .put = alc_ch_mode_put,
  5451. },
  5452. { } /* end */
  5453. };
  5454. static struct hda_verb alc883_init_verbs[] = {
  5455. /* ADC1: mute amp left and right */
  5456. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5457. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5458. /* ADC2: mute amp left and right */
  5459. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5460. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5461. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5462. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5463. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5464. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5465. /* Rear mixer */
  5466. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5467. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5468. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5469. /* CLFE mixer */
  5470. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5471. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5472. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5473. /* Side mixer */
  5474. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5475. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5476. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5477. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5478. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5479. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5480. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5481. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5482. /* Front Pin: output 0 (0x0c) */
  5483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5485. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5486. /* Rear Pin: output 1 (0x0d) */
  5487. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5488. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5489. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5490. /* CLFE Pin: output 2 (0x0e) */
  5491. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5492. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5493. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5494. /* Side Pin: output 3 (0x0f) */
  5495. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5496. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5497. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5498. /* Mic (rear) pin: input vref at 80% */
  5499. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5500. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5501. /* Front Mic pin: input vref at 80% */
  5502. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5503. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5504. /* Line In pin: input */
  5505. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5506. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5507. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5508. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5509. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5510. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5511. /* CD pin widget for input */
  5512. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5513. /* FIXME: use matrix-type input source selection */
  5514. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5515. /* Input mixer2 */
  5516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5517. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5518. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5519. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5520. /* Input mixer3 */
  5521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5522. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5523. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5524. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5525. { }
  5526. };
  5527. static struct hda_verb alc883_tagra_verbs[] = {
  5528. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5529. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5530. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5531. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5532. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5533. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5534. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5535. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5536. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5537. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5538. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5539. { } /* end */
  5540. };
  5541. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5542. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5543. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5544. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5545. { } /* end */
  5546. };
  5547. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5548. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5549. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5550. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5551. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5552. { } /* end */
  5553. };
  5554. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5555. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5556. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5557. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5558. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5559. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5560. { } /* end */
  5561. };
  5562. /* toggle front-jack and RCA according to the hp-jack state */
  5563. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5564. {
  5565. unsigned int present;
  5566. present = snd_hda_codec_read(codec, 0x1b, 0,
  5567. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5568. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5569. 0x80, present ? 0x80 : 0);
  5570. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5571. 0x80, present ? 0x80 : 0);
  5572. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5573. 0x80, present ? 0x80 : 0);
  5574. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5575. 0x80, present ? 0x80 : 0);
  5576. }
  5577. /* toggle RCA according to the front-jack state */
  5578. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5579. {
  5580. unsigned int present;
  5581. present = snd_hda_codec_read(codec, 0x14, 0,
  5582. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5583. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5584. 0x80, present ? 0x80 : 0);
  5585. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5586. 0x80, present ? 0x80 : 0);
  5587. }
  5588. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5589. unsigned int res)
  5590. {
  5591. if ((res >> 26) == ALC880_HP_EVENT)
  5592. alc888_lenovo_ms7195_front_automute(codec);
  5593. if ((res >> 26) == ALC880_FRONT_EVENT)
  5594. alc888_lenovo_ms7195_rca_automute(codec);
  5595. }
  5596. static struct hda_verb alc883_medion_md2_verbs[] = {
  5597. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5598. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5600. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5601. { } /* end */
  5602. };
  5603. /* toggle speaker-output according to the hp-jack state */
  5604. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5605. {
  5606. unsigned int present;
  5607. present = snd_hda_codec_read(codec, 0x14, 0,
  5608. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5609. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5610. 0x80, present ? 0x80 : 0);
  5611. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5612. 0x80, present ? 0x80 : 0);
  5613. }
  5614. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5615. unsigned int res)
  5616. {
  5617. if ((res >> 26) == ALC880_HP_EVENT)
  5618. alc883_medion_md2_automute(codec);
  5619. }
  5620. /* toggle speaker-output according to the hp-jack state */
  5621. static void alc883_tagra_automute(struct hda_codec *codec)
  5622. {
  5623. unsigned int present;
  5624. unsigned char bits;
  5625. present = snd_hda_codec_read(codec, 0x14, 0,
  5626. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5627. bits = present ? 0x80 : 0;
  5628. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5629. 0x80, bits);
  5630. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5631. 0x80, bits);
  5632. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5633. present ? 1 : 3);
  5634. }
  5635. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5636. {
  5637. if ((res >> 26) == ALC880_HP_EVENT)
  5638. alc883_tagra_automute(codec);
  5639. }
  5640. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5641. {
  5642. unsigned int present;
  5643. unsigned char bits;
  5644. present = snd_hda_codec_read(codec, 0x14, 0,
  5645. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5646. bits = present ? 0x80 : 0;
  5647. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5648. 0x80, bits);
  5649. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5650. 0x80, bits);
  5651. }
  5652. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5653. {
  5654. unsigned int present;
  5655. unsigned char bits;
  5656. present = snd_hda_codec_read(codec, 0x1b, 0,
  5657. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5658. bits = present ? 0x80 : 0;
  5659. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5660. 0x80, bits);
  5661. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5662. 0x80, bits);
  5663. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5664. 0x80, bits);
  5665. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5666. 0x80, bits);
  5667. }
  5668. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5669. unsigned int res)
  5670. {
  5671. if ((res >> 26) == ALC880_HP_EVENT)
  5672. alc883_lenovo_101e_all_automute(codec);
  5673. if ((res >> 26) == ALC880_FRONT_EVENT)
  5674. alc883_lenovo_101e_ispeaker_automute(codec);
  5675. }
  5676. /*
  5677. * generic initialization of ADC, input mixers and output mixers
  5678. */
  5679. static struct hda_verb alc883_auto_init_verbs[] = {
  5680. /*
  5681. * Unmute ADC0-2 and set the default input to mic-in
  5682. */
  5683. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5684. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5685. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5686. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5687. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5688. * mixer widget
  5689. * Note: PASD motherboards uses the Line In 2 as the input for
  5690. * front panel mic (mic 2)
  5691. */
  5692. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5698. /*
  5699. * Set up output mixers (0x0c - 0x0f)
  5700. */
  5701. /* set vol=0 to output mixers */
  5702. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5703. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5704. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5705. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5706. /* set up input amps for analog loopback */
  5707. /* Amp Indices: DAC = 0, mixer = 1 */
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5710. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5711. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5712. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5713. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5714. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5715. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5716. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5717. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5718. /* FIXME: use matrix-type input source selection */
  5719. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5720. /* Input mixer1 */
  5721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5724. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5726. /* Input mixer2 */
  5727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5730. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5732. { }
  5733. };
  5734. /* capture mixer elements */
  5735. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5736. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5737. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5738. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5739. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5740. {
  5741. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5742. /* The multiple "Capture Source" controls confuse alsamixer
  5743. * So call somewhat different..
  5744. * FIXME: the controls appear in the "playback" view!
  5745. */
  5746. /* .name = "Capture Source", */
  5747. .name = "Input Source",
  5748. .count = 2,
  5749. .info = alc882_mux_enum_info,
  5750. .get = alc882_mux_enum_get,
  5751. .put = alc882_mux_enum_put,
  5752. },
  5753. { } /* end */
  5754. };
  5755. /* pcm configuration: identiacal with ALC880 */
  5756. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5757. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5758. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5759. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5760. /*
  5761. * configuration and preset
  5762. */
  5763. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5764. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5765. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5766. [ALC883_3ST_6ch] = "3stack-6ch",
  5767. [ALC883_6ST_DIG] = "6stack-dig",
  5768. [ALC883_TARGA_DIG] = "targa-dig",
  5769. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5770. [ALC883_ACER] = "acer",
  5771. [ALC883_MEDION] = "medion",
  5772. [ALC883_MEDION_MD2] = "medion-md2",
  5773. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5774. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5775. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5776. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5777. [ALC883_AUTO] = "auto",
  5778. };
  5779. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5780. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5781. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5782. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5783. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5784. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5785. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5786. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5787. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5788. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5789. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5790. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5791. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5792. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5799. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5800. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5801. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5802. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5803. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5804. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5805. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5806. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5807. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5808. {}
  5809. };
  5810. static struct alc_config_preset alc883_presets[] = {
  5811. [ALC883_3ST_2ch_DIG] = {
  5812. .mixers = { alc883_3ST_2ch_mixer },
  5813. .init_verbs = { alc883_init_verbs },
  5814. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5815. .dac_nids = alc883_dac_nids,
  5816. .dig_out_nid = ALC883_DIGOUT_NID,
  5817. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5818. .adc_nids = alc883_adc_nids,
  5819. .dig_in_nid = ALC883_DIGIN_NID,
  5820. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5821. .channel_mode = alc883_3ST_2ch_modes,
  5822. .input_mux = &alc883_capture_source,
  5823. },
  5824. [ALC883_3ST_6ch_DIG] = {
  5825. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5826. .init_verbs = { alc883_init_verbs },
  5827. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5828. .dac_nids = alc883_dac_nids,
  5829. .dig_out_nid = ALC883_DIGOUT_NID,
  5830. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5831. .adc_nids = alc883_adc_nids,
  5832. .dig_in_nid = ALC883_DIGIN_NID,
  5833. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5834. .channel_mode = alc883_3ST_6ch_modes,
  5835. .need_dac_fix = 1,
  5836. .input_mux = &alc883_capture_source,
  5837. },
  5838. [ALC883_3ST_6ch] = {
  5839. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5840. .init_verbs = { alc883_init_verbs },
  5841. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5842. .dac_nids = alc883_dac_nids,
  5843. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5844. .adc_nids = alc883_adc_nids,
  5845. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5846. .channel_mode = alc883_3ST_6ch_modes,
  5847. .need_dac_fix = 1,
  5848. .input_mux = &alc883_capture_source,
  5849. },
  5850. [ALC883_6ST_DIG] = {
  5851. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5852. .init_verbs = { alc883_init_verbs },
  5853. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5854. .dac_nids = alc883_dac_nids,
  5855. .dig_out_nid = ALC883_DIGOUT_NID,
  5856. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5857. .adc_nids = alc883_adc_nids,
  5858. .dig_in_nid = ALC883_DIGIN_NID,
  5859. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5860. .channel_mode = alc883_sixstack_modes,
  5861. .input_mux = &alc883_capture_source,
  5862. },
  5863. [ALC883_TARGA_DIG] = {
  5864. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5865. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5866. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5867. .dac_nids = alc883_dac_nids,
  5868. .dig_out_nid = ALC883_DIGOUT_NID,
  5869. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5870. .adc_nids = alc883_adc_nids,
  5871. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5872. .channel_mode = alc883_3ST_6ch_modes,
  5873. .need_dac_fix = 1,
  5874. .input_mux = &alc883_capture_source,
  5875. .unsol_event = alc883_tagra_unsol_event,
  5876. .init_hook = alc883_tagra_automute,
  5877. },
  5878. [ALC883_TARGA_2ch_DIG] = {
  5879. .mixers = { alc883_tagra_2ch_mixer},
  5880. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5881. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5882. .dac_nids = alc883_dac_nids,
  5883. .dig_out_nid = ALC883_DIGOUT_NID,
  5884. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5885. .adc_nids = alc883_adc_nids,
  5886. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5887. .channel_mode = alc883_3ST_2ch_modes,
  5888. .input_mux = &alc883_capture_source,
  5889. .unsol_event = alc883_tagra_unsol_event,
  5890. .init_hook = alc883_tagra_automute,
  5891. },
  5892. [ALC883_ACER] = {
  5893. .mixers = { alc883_base_mixer,
  5894. alc883_chmode_mixer },
  5895. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5896. * and the headphone jack. Turn this on and rely on the
  5897. * standard mute methods whenever the user wants to turn
  5898. * these outputs off.
  5899. */
  5900. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5901. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5902. .dac_nids = alc883_dac_nids,
  5903. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5904. .adc_nids = alc883_adc_nids,
  5905. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5906. .channel_mode = alc883_3ST_2ch_modes,
  5907. .input_mux = &alc883_capture_source,
  5908. },
  5909. [ALC883_MEDION] = {
  5910. .mixers = { alc883_fivestack_mixer,
  5911. alc883_chmode_mixer },
  5912. .init_verbs = { alc883_init_verbs,
  5913. alc883_medion_eapd_verbs },
  5914. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5915. .dac_nids = alc883_dac_nids,
  5916. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5917. .adc_nids = alc883_adc_nids,
  5918. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5919. .channel_mode = alc883_sixstack_modes,
  5920. .input_mux = &alc883_capture_source,
  5921. },
  5922. [ALC883_MEDION_MD2] = {
  5923. .mixers = { alc883_medion_md2_mixer},
  5924. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5925. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5926. .dac_nids = alc883_dac_nids,
  5927. .dig_out_nid = ALC883_DIGOUT_NID,
  5928. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5929. .adc_nids = alc883_adc_nids,
  5930. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5931. .channel_mode = alc883_3ST_2ch_modes,
  5932. .input_mux = &alc883_capture_source,
  5933. .unsol_event = alc883_medion_md2_unsol_event,
  5934. .init_hook = alc883_medion_md2_automute,
  5935. },
  5936. [ALC883_LAPTOP_EAPD] = {
  5937. .mixers = { alc883_base_mixer,
  5938. alc883_chmode_mixer },
  5939. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5940. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5941. .dac_nids = alc883_dac_nids,
  5942. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5943. .adc_nids = alc883_adc_nids,
  5944. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5945. .channel_mode = alc883_3ST_2ch_modes,
  5946. .input_mux = &alc883_capture_source,
  5947. },
  5948. [ALC883_LENOVO_101E_2ch] = {
  5949. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5950. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5951. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5952. .dac_nids = alc883_dac_nids,
  5953. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5954. .adc_nids = alc883_adc_nids,
  5955. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5956. .channel_mode = alc883_3ST_2ch_modes,
  5957. .input_mux = &alc883_lenovo_101e_capture_source,
  5958. .unsol_event = alc883_lenovo_101e_unsol_event,
  5959. .init_hook = alc883_lenovo_101e_all_automute,
  5960. },
  5961. [ALC883_LENOVO_NB0763] = {
  5962. .mixers = { alc883_lenovo_nb0763_mixer },
  5963. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5964. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5965. .dac_nids = alc883_dac_nids,
  5966. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5967. .adc_nids = alc883_adc_nids,
  5968. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5969. .channel_mode = alc883_3ST_2ch_modes,
  5970. .need_dac_fix = 1,
  5971. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5972. .unsol_event = alc883_medion_md2_unsol_event,
  5973. .init_hook = alc883_medion_md2_automute,
  5974. },
  5975. [ALC888_LENOVO_MS7195_DIG] = {
  5976. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5977. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5978. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5979. .dac_nids = alc883_dac_nids,
  5980. .dig_out_nid = ALC883_DIGOUT_NID,
  5981. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5982. .adc_nids = alc883_adc_nids,
  5983. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5984. .channel_mode = alc883_3ST_6ch_modes,
  5985. .need_dac_fix = 1,
  5986. .input_mux = &alc883_capture_source,
  5987. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5988. .init_hook = alc888_lenovo_ms7195_front_automute,
  5989. },
  5990. };
  5991. /*
  5992. * BIOS auto configuration
  5993. */
  5994. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5995. hda_nid_t nid, int pin_type,
  5996. int dac_idx)
  5997. {
  5998. /* set as output */
  5999. struct alc_spec *spec = codec->spec;
  6000. int idx;
  6001. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6002. idx = 4;
  6003. else
  6004. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6005. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6006. pin_type);
  6007. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6008. AMP_OUT_UNMUTE);
  6009. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6010. }
  6011. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6012. {
  6013. struct alc_spec *spec = codec->spec;
  6014. int i;
  6015. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6016. for (i = 0; i <= HDA_SIDE; i++) {
  6017. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6018. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6019. if (nid)
  6020. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6021. i);
  6022. }
  6023. }
  6024. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6025. {
  6026. struct alc_spec *spec = codec->spec;
  6027. hda_nid_t pin;
  6028. pin = spec->autocfg.hp_pins[0];
  6029. if (pin) /* connect to front */
  6030. /* use dac 0 */
  6031. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6032. }
  6033. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6034. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6035. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6036. {
  6037. struct alc_spec *spec = codec->spec;
  6038. int i;
  6039. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6040. hda_nid_t nid = spec->autocfg.input_pins[i];
  6041. if (alc883_is_input_pin(nid)) {
  6042. snd_hda_codec_write(codec, nid, 0,
  6043. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6044. (i <= AUTO_PIN_FRONT_MIC ?
  6045. PIN_VREF80 : PIN_IN));
  6046. if (nid != ALC883_PIN_CD_NID)
  6047. snd_hda_codec_write(codec, nid, 0,
  6048. AC_VERB_SET_AMP_GAIN_MUTE,
  6049. AMP_OUT_MUTE);
  6050. }
  6051. }
  6052. }
  6053. /* almost identical with ALC880 parser... */
  6054. static int alc883_parse_auto_config(struct hda_codec *codec)
  6055. {
  6056. struct alc_spec *spec = codec->spec;
  6057. int err = alc880_parse_auto_config(codec);
  6058. if (err < 0)
  6059. return err;
  6060. else if (err > 0)
  6061. /* hack - override the init verbs */
  6062. spec->init_verbs[0] = alc883_auto_init_verbs;
  6063. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6064. spec->num_mixers++;
  6065. return err;
  6066. }
  6067. /* additional initialization for auto-configuration model */
  6068. static void alc883_auto_init(struct hda_codec *codec)
  6069. {
  6070. alc883_auto_init_multi_out(codec);
  6071. alc883_auto_init_hp_out(codec);
  6072. alc883_auto_init_analog_input(codec);
  6073. }
  6074. static int patch_alc883(struct hda_codec *codec)
  6075. {
  6076. struct alc_spec *spec;
  6077. int err, board_config;
  6078. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6079. if (spec == NULL)
  6080. return -ENOMEM;
  6081. codec->spec = spec;
  6082. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6083. alc883_models,
  6084. alc883_cfg_tbl);
  6085. if (board_config < 0) {
  6086. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6087. "trying auto-probe from BIOS...\n");
  6088. board_config = ALC883_AUTO;
  6089. }
  6090. if (board_config == ALC883_AUTO) {
  6091. /* automatic parse from the BIOS config */
  6092. err = alc883_parse_auto_config(codec);
  6093. if (err < 0) {
  6094. alc_free(codec);
  6095. return err;
  6096. } else if (!err) {
  6097. printk(KERN_INFO
  6098. "hda_codec: Cannot set up configuration "
  6099. "from BIOS. Using base mode...\n");
  6100. board_config = ALC883_3ST_2ch_DIG;
  6101. }
  6102. }
  6103. if (board_config != ALC883_AUTO)
  6104. setup_preset(spec, &alc883_presets[board_config]);
  6105. spec->stream_name_analog = "ALC883 Analog";
  6106. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6107. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6108. spec->stream_name_digital = "ALC883 Digital";
  6109. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6110. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6111. if (!spec->adc_nids && spec->input_mux) {
  6112. spec->adc_nids = alc883_adc_nids;
  6113. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6114. }
  6115. codec->patch_ops = alc_patch_ops;
  6116. if (board_config == ALC883_AUTO)
  6117. spec->init_hook = alc883_auto_init;
  6118. return 0;
  6119. }
  6120. /*
  6121. * ALC262 support
  6122. */
  6123. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6124. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6125. #define alc262_dac_nids alc260_dac_nids
  6126. #define alc262_adc_nids alc882_adc_nids
  6127. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6128. #define alc262_modes alc260_modes
  6129. #define alc262_capture_source alc882_capture_source
  6130. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6131. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6132. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6133. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6134. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6135. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6136. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6137. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6138. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6139. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6140. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6141. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6142. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6143. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6144. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6145. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6146. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6147. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6148. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6149. { } /* end */
  6150. };
  6151. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6152. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6153. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6154. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6155. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6156. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6157. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6158. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6159. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6160. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6161. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6162. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6163. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6164. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6165. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6166. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6167. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6168. { } /* end */
  6169. };
  6170. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6171. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6172. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6173. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6174. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6175. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6176. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6177. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6178. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6179. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6180. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6181. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6182. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6183. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6184. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6185. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6186. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6187. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6188. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6189. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6190. { } /* end */
  6191. };
  6192. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6193. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6194. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6195. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6196. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6197. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6198. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6199. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6200. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6201. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6202. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6203. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6204. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6205. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6206. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6207. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6208. { } /* end */
  6209. };
  6210. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6211. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6212. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6213. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6214. { } /* end */
  6215. };
  6216. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6217. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6218. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6219. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6220. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6221. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6222. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6223. { } /* end */
  6224. };
  6225. #define alc262_capture_mixer alc882_capture_mixer
  6226. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6227. /*
  6228. * generic initialization of ADC, input mixers and output mixers
  6229. */
  6230. static struct hda_verb alc262_init_verbs[] = {
  6231. /*
  6232. * Unmute ADC0-2 and set the default input to mic-in
  6233. */
  6234. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6235. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6236. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6237. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6238. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6239. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6240. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6241. * mixer widget
  6242. * Note: PASD motherboards uses the Line In 2 as the input for
  6243. * front panel mic (mic 2)
  6244. */
  6245. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6246. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6247. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6248. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6249. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6250. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6251. /*
  6252. * Set up output mixers (0x0c - 0x0e)
  6253. */
  6254. /* set vol=0 to output mixers */
  6255. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6256. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6257. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6258. /* set up input amps for analog loopback */
  6259. /* Amp Indices: DAC = 0, mixer = 1 */
  6260. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6261. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6262. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6263. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6265. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6266. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6267. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6268. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6269. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6270. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6272. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6273. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6274. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6275. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6276. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6277. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6278. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6279. /* FIXME: use matrix-type input source selection */
  6280. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6281. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6282. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6283. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6284. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6285. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6286. /* Input mixer2 */
  6287. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6288. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6289. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6290. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6291. /* Input mixer3 */
  6292. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6293. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6294. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6295. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6296. { }
  6297. };
  6298. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6299. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6300. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6301. {}
  6302. };
  6303. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6304. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6305. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6306. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6307. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6308. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6309. {}
  6310. };
  6311. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6312. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6313. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6314. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6315. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6317. };
  6318. /* mute/unmute internal speaker according to the hp jack and mute state */
  6319. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6320. {
  6321. struct alc_spec *spec = codec->spec;
  6322. unsigned int mute;
  6323. if (force || !spec->sense_updated) {
  6324. unsigned int present;
  6325. /* need to execute and sync at first */
  6326. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6327. present = snd_hda_codec_read(codec, 0x15, 0,
  6328. AC_VERB_GET_PIN_SENSE, 0);
  6329. spec->jack_present = (present & 0x80000000) != 0;
  6330. spec->sense_updated = 1;
  6331. }
  6332. if (spec->jack_present) {
  6333. /* mute internal speaker */
  6334. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6335. 0x80, 0x80);
  6336. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6337. 0x80, 0x80);
  6338. } else {
  6339. /* unmute internal speaker if necessary */
  6340. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6341. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6342. 0x80, mute & 0x80);
  6343. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6344. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6345. 0x80, mute & 0x80);
  6346. }
  6347. }
  6348. /* unsolicited event for HP jack sensing */
  6349. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6350. unsigned int res)
  6351. {
  6352. if ((res >> 26) != ALC880_HP_EVENT)
  6353. return;
  6354. alc262_hippo_automute(codec, 1);
  6355. }
  6356. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6357. {
  6358. struct alc_spec *spec = codec->spec;
  6359. unsigned int mute;
  6360. if (force || !spec->sense_updated) {
  6361. unsigned int present;
  6362. /* need to execute and sync at first */
  6363. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6364. present = snd_hda_codec_read(codec, 0x1b, 0,
  6365. AC_VERB_GET_PIN_SENSE, 0);
  6366. spec->jack_present = (present & 0x80000000) != 0;
  6367. spec->sense_updated = 1;
  6368. }
  6369. if (spec->jack_present) {
  6370. /* mute internal speaker */
  6371. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6372. 0x80, 0x80);
  6373. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6374. 0x80, 0x80);
  6375. } else {
  6376. /* unmute internal speaker if necessary */
  6377. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6378. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6379. 0x80, mute & 0x80);
  6380. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6381. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6382. 0x80, mute & 0x80);
  6383. }
  6384. }
  6385. /* unsolicited event for HP jack sensing */
  6386. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6387. unsigned int res)
  6388. {
  6389. if ((res >> 26) != ALC880_HP_EVENT)
  6390. return;
  6391. alc262_hippo1_automute(codec, 1);
  6392. }
  6393. /*
  6394. * fujitsu model
  6395. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6396. */
  6397. #define ALC_HP_EVENT 0x37
  6398. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6399. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6400. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6401. {}
  6402. };
  6403. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6404. .num_items = 2,
  6405. .items = {
  6406. { "Mic", 0x0 },
  6407. { "CD", 0x4 },
  6408. },
  6409. };
  6410. static struct hda_input_mux alc262_HP_capture_source = {
  6411. .num_items = 5,
  6412. .items = {
  6413. { "Mic", 0x0 },
  6414. { "Front Mic", 0x3 },
  6415. { "Line", 0x2 },
  6416. { "CD", 0x4 },
  6417. { "AUX IN", 0x6 },
  6418. },
  6419. };
  6420. /* mute/unmute internal speaker according to the hp jack and mute state */
  6421. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6422. {
  6423. struct alc_spec *spec = codec->spec;
  6424. unsigned int mute;
  6425. if (force || !spec->sense_updated) {
  6426. unsigned int present;
  6427. /* need to execute and sync at first */
  6428. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6429. present = snd_hda_codec_read(codec, 0x14, 0,
  6430. AC_VERB_GET_PIN_SENSE, 0);
  6431. spec->jack_present = (present & 0x80000000) != 0;
  6432. spec->sense_updated = 1;
  6433. }
  6434. if (spec->jack_present) {
  6435. /* mute internal speaker */
  6436. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6437. 0x80, 0x80);
  6438. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6439. 0x80, 0x80);
  6440. } else {
  6441. /* unmute internal speaker if necessary */
  6442. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6443. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6444. 0x80, mute & 0x80);
  6445. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6446. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6447. 0x80, mute & 0x80);
  6448. }
  6449. }
  6450. /* unsolicited event for HP jack sensing */
  6451. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6452. unsigned int res)
  6453. {
  6454. if ((res >> 26) != ALC_HP_EVENT)
  6455. return;
  6456. alc262_fujitsu_automute(codec, 1);
  6457. }
  6458. /* bind volumes of both NID 0x0c and 0x0d */
  6459. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6460. struct snd_ctl_elem_value *ucontrol)
  6461. {
  6462. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6463. long *valp = ucontrol->value.integer.value;
  6464. int change;
  6465. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6466. 0x7f, valp[0] & 0x7f);
  6467. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6468. 0x7f, valp[1] & 0x7f);
  6469. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6470. 0x7f, valp[0] & 0x7f);
  6471. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6472. 0x7f, valp[1] & 0x7f);
  6473. return change;
  6474. }
  6475. /* bind hp and internal speaker mute (with plug check) */
  6476. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6477. struct snd_ctl_elem_value *ucontrol)
  6478. {
  6479. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6480. long *valp = ucontrol->value.integer.value;
  6481. int change;
  6482. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6483. 0x80, valp[0] ? 0 : 0x80);
  6484. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6485. 0x80, valp[1] ? 0 : 0x80);
  6486. if (change || codec->in_resume)
  6487. alc262_fujitsu_automute(codec, codec->in_resume);
  6488. return change;
  6489. }
  6490. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6491. {
  6492. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6493. .name = "Master Playback Volume",
  6494. .info = snd_hda_mixer_amp_volume_info,
  6495. .get = snd_hda_mixer_amp_volume_get,
  6496. .put = alc262_fujitsu_master_vol_put,
  6497. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6498. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6499. },
  6500. {
  6501. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6502. .name = "Master Playback Switch",
  6503. .info = snd_hda_mixer_amp_switch_info,
  6504. .get = snd_hda_mixer_amp_switch_get,
  6505. .put = alc262_fujitsu_master_sw_put,
  6506. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6507. },
  6508. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6509. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6510. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6511. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6512. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6513. { } /* end */
  6514. };
  6515. /* additional init verbs for Benq laptops */
  6516. static struct hda_verb alc262_EAPD_verbs[] = {
  6517. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6518. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6519. {}
  6520. };
  6521. /* add playback controls from the parsed DAC table */
  6522. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6523. const struct auto_pin_cfg *cfg)
  6524. {
  6525. hda_nid_t nid;
  6526. int err;
  6527. spec->multiout.num_dacs = 1; /* only use one dac */
  6528. spec->multiout.dac_nids = spec->private_dac_nids;
  6529. spec->multiout.dac_nids[0] = 2;
  6530. nid = cfg->line_out_pins[0];
  6531. if (nid) {
  6532. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6533. "Front Playback Volume",
  6534. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6535. if (err < 0)
  6536. return err;
  6537. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6538. "Front Playback Switch",
  6539. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6540. if (err < 0)
  6541. return err;
  6542. }
  6543. nid = cfg->speaker_pins[0];
  6544. if (nid) {
  6545. if (nid == 0x16) {
  6546. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6547. "Speaker Playback Volume",
  6548. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6549. HDA_OUTPUT));
  6550. if (err < 0)
  6551. return err;
  6552. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6553. "Speaker Playback Switch",
  6554. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6555. HDA_OUTPUT));
  6556. if (err < 0)
  6557. return err;
  6558. } else {
  6559. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6560. "Speaker Playback Switch",
  6561. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6562. HDA_OUTPUT));
  6563. if (err < 0)
  6564. return err;
  6565. }
  6566. }
  6567. nid = cfg->hp_pins[0];
  6568. if (nid) {
  6569. /* spec->multiout.hp_nid = 2; */
  6570. if (nid == 0x16) {
  6571. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6572. "Headphone Playback Volume",
  6573. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6574. HDA_OUTPUT));
  6575. if (err < 0)
  6576. return err;
  6577. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6578. "Headphone Playback Switch",
  6579. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6580. HDA_OUTPUT));
  6581. if (err < 0)
  6582. return err;
  6583. } else {
  6584. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6585. "Headphone Playback Switch",
  6586. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6587. HDA_OUTPUT));
  6588. if (err < 0)
  6589. return err;
  6590. }
  6591. }
  6592. return 0;
  6593. }
  6594. /* identical with ALC880 */
  6595. #define alc262_auto_create_analog_input_ctls \
  6596. alc880_auto_create_analog_input_ctls
  6597. /*
  6598. * generic initialization of ADC, input mixers and output mixers
  6599. */
  6600. static struct hda_verb alc262_volume_init_verbs[] = {
  6601. /*
  6602. * Unmute ADC0-2 and set the default input to mic-in
  6603. */
  6604. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6606. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6607. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6608. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6609. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6610. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6611. * mixer widget
  6612. * Note: PASD motherboards uses the Line In 2 as the input for
  6613. * front panel mic (mic 2)
  6614. */
  6615. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6616. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6617. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6618. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6619. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6620. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6621. /*
  6622. * Set up output mixers (0x0c - 0x0f)
  6623. */
  6624. /* set vol=0 to output mixers */
  6625. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6626. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6627. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6628. /* set up input amps for analog loopback */
  6629. /* Amp Indices: DAC = 0, mixer = 1 */
  6630. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6631. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6632. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6633. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6634. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6635. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6636. /* FIXME: use matrix-type input source selection */
  6637. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6638. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6640. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6641. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6642. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6643. /* Input mixer2 */
  6644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6645. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6646. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6647. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6648. /* Input mixer3 */
  6649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6651. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6652. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6653. { }
  6654. };
  6655. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6656. /*
  6657. * Unmute ADC0-2 and set the default input to mic-in
  6658. */
  6659. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6661. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6662. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6663. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6664. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6665. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6666. * mixer widget
  6667. * Note: PASD motherboards uses the Line In 2 as the input for
  6668. * front panel mic (mic 2)
  6669. */
  6670. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6671. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6672. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6673. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6674. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6675. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6676. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6677. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6678. /*
  6679. * Set up output mixers (0x0c - 0x0e)
  6680. */
  6681. /* set vol=0 to output mixers */
  6682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6683. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6684. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6685. /* set up input amps for analog loopback */
  6686. /* Amp Indices: DAC = 0, mixer = 1 */
  6687. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6688. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6689. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6690. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6693. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6694. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6695. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6696. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6697. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6698. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6699. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6700. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6701. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6702. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6703. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6704. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6705. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6706. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6707. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6708. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6709. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6710. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6711. /* FIXME: use matrix-type input source selection */
  6712. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6713. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6714. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6715. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6716. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6718. /* Input mixer2 */
  6719. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6720. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6723. /* Input mixer3 */
  6724. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6725. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6726. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6728. { }
  6729. };
  6730. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6731. /*
  6732. * Unmute ADC0-2 and set the default input to mic-in
  6733. */
  6734. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6735. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6736. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6737. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6738. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6739. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6740. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6741. * mixer widget
  6742. * Note: PASD motherboards uses the Line In 2 as the input for front
  6743. * panel mic (mic 2)
  6744. */
  6745. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6746. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6747. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6748. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6749. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6752. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6753. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6754. /*
  6755. * Set up output mixers (0x0c - 0x0e)
  6756. */
  6757. /* set vol=0 to output mixers */
  6758. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6759. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6760. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6761. /* set up input amps for analog loopback */
  6762. /* Amp Indices: DAC = 0, mixer = 1 */
  6763. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6764. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6765. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6766. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6767. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6768. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6769. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6770. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6771. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6772. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6773. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6774. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6775. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6776. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6777. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6778. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6779. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6780. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6781. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6782. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6783. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6784. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6785. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6786. /* FIXME: use matrix-type input source selection */
  6787. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6788. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6789. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6790. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6791. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6792. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6793. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6794. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6795. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6796. /* Input mixer2 */
  6797. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6798. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6799. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6800. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6801. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6802. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6803. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6804. /* Input mixer3 */
  6805. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6806. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6807. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6808. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6809. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6810. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6811. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6812. { }
  6813. };
  6814. /* pcm configuration: identiacal with ALC880 */
  6815. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6816. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6817. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6818. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6819. /*
  6820. * BIOS auto configuration
  6821. */
  6822. static int alc262_parse_auto_config(struct hda_codec *codec)
  6823. {
  6824. struct alc_spec *spec = codec->spec;
  6825. int err;
  6826. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6827. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6828. alc262_ignore);
  6829. if (err < 0)
  6830. return err;
  6831. if (!spec->autocfg.line_outs)
  6832. return 0; /* can't find valid BIOS pin config */
  6833. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6834. if (err < 0)
  6835. return err;
  6836. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6837. if (err < 0)
  6838. return err;
  6839. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6840. if (spec->autocfg.dig_out_pin)
  6841. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6842. if (spec->autocfg.dig_in_pin)
  6843. spec->dig_in_nid = ALC262_DIGIN_NID;
  6844. if (spec->kctl_alloc)
  6845. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6846. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6847. spec->num_mux_defs = 1;
  6848. spec->input_mux = &spec->private_imux;
  6849. return 1;
  6850. }
  6851. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6852. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6853. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6854. /* init callback for auto-configuration model -- overriding the default init */
  6855. static void alc262_auto_init(struct hda_codec *codec)
  6856. {
  6857. alc262_auto_init_multi_out(codec);
  6858. alc262_auto_init_hp_out(codec);
  6859. alc262_auto_init_analog_input(codec);
  6860. }
  6861. /*
  6862. * configuration and preset
  6863. */
  6864. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6865. [ALC262_BASIC] = "basic",
  6866. [ALC262_HIPPO] = "hippo",
  6867. [ALC262_HIPPO_1] = "hippo_1",
  6868. [ALC262_FUJITSU] = "fujitsu",
  6869. [ALC262_HP_BPC] = "hp-bpc",
  6870. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6871. [ALC262_BENQ_ED8] = "benq",
  6872. [ALC262_BENQ_ED8] = "sony-assamd",
  6873. [ALC262_AUTO] = "auto",
  6874. };
  6875. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6876. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6877. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6878. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6879. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6880. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6881. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6882. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6883. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6884. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6885. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6886. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6887. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6888. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6889. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6890. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6891. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6892. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6893. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6894. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6895. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6896. {}
  6897. };
  6898. static struct alc_config_preset alc262_presets[] = {
  6899. [ALC262_BASIC] = {
  6900. .mixers = { alc262_base_mixer },
  6901. .init_verbs = { alc262_init_verbs },
  6902. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6903. .dac_nids = alc262_dac_nids,
  6904. .hp_nid = 0x03,
  6905. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6906. .channel_mode = alc262_modes,
  6907. .input_mux = &alc262_capture_source,
  6908. },
  6909. [ALC262_HIPPO] = {
  6910. .mixers = { alc262_base_mixer },
  6911. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6912. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6913. .dac_nids = alc262_dac_nids,
  6914. .hp_nid = 0x03,
  6915. .dig_out_nid = ALC262_DIGOUT_NID,
  6916. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6917. .channel_mode = alc262_modes,
  6918. .input_mux = &alc262_capture_source,
  6919. .unsol_event = alc262_hippo_unsol_event,
  6920. },
  6921. [ALC262_HIPPO_1] = {
  6922. .mixers = { alc262_hippo1_mixer },
  6923. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6924. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6925. .dac_nids = alc262_dac_nids,
  6926. .hp_nid = 0x02,
  6927. .dig_out_nid = ALC262_DIGOUT_NID,
  6928. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6929. .channel_mode = alc262_modes,
  6930. .input_mux = &alc262_capture_source,
  6931. .unsol_event = alc262_hippo1_unsol_event,
  6932. },
  6933. [ALC262_FUJITSU] = {
  6934. .mixers = { alc262_fujitsu_mixer },
  6935. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6936. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6937. .dac_nids = alc262_dac_nids,
  6938. .hp_nid = 0x03,
  6939. .dig_out_nid = ALC262_DIGOUT_NID,
  6940. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6941. .channel_mode = alc262_modes,
  6942. .input_mux = &alc262_fujitsu_capture_source,
  6943. .unsol_event = alc262_fujitsu_unsol_event,
  6944. },
  6945. [ALC262_HP_BPC] = {
  6946. .mixers = { alc262_HP_BPC_mixer },
  6947. .init_verbs = { alc262_HP_BPC_init_verbs },
  6948. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6949. .dac_nids = alc262_dac_nids,
  6950. .hp_nid = 0x03,
  6951. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6952. .channel_mode = alc262_modes,
  6953. .input_mux = &alc262_HP_capture_source,
  6954. },
  6955. [ALC262_HP_BPC_D7000_WF] = {
  6956. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6957. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6958. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6959. .dac_nids = alc262_dac_nids,
  6960. .hp_nid = 0x03,
  6961. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6962. .channel_mode = alc262_modes,
  6963. .input_mux = &alc262_HP_capture_source,
  6964. },
  6965. [ALC262_HP_BPC_D7000_WL] = {
  6966. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6967. alc262_HP_BPC_WildWest_option_mixer },
  6968. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6969. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6970. .dac_nids = alc262_dac_nids,
  6971. .hp_nid = 0x03,
  6972. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6973. .channel_mode = alc262_modes,
  6974. .input_mux = &alc262_HP_capture_source,
  6975. },
  6976. [ALC262_BENQ_ED8] = {
  6977. .mixers = { alc262_base_mixer },
  6978. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6979. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6980. .dac_nids = alc262_dac_nids,
  6981. .hp_nid = 0x03,
  6982. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6983. .channel_mode = alc262_modes,
  6984. .input_mux = &alc262_capture_source,
  6985. },
  6986. [ALC262_SONY_ASSAMD] = {
  6987. .mixers = { alc262_sony_mixer },
  6988. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  6989. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6990. .dac_nids = alc262_dac_nids,
  6991. .hp_nid = 0x02,
  6992. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6993. .channel_mode = alc262_modes,
  6994. .input_mux = &alc262_capture_source,
  6995. .unsol_event = alc262_hippo_unsol_event,
  6996. },
  6997. };
  6998. static int patch_alc262(struct hda_codec *codec)
  6999. {
  7000. struct alc_spec *spec;
  7001. int board_config;
  7002. int err;
  7003. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7004. if (spec == NULL)
  7005. return -ENOMEM;
  7006. codec->spec = spec;
  7007. #if 0
  7008. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7009. * under-run
  7010. */
  7011. {
  7012. int tmp;
  7013. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7014. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7015. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7016. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7017. }
  7018. #endif
  7019. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7020. alc262_models,
  7021. alc262_cfg_tbl);
  7022. if (board_config < 0) {
  7023. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7024. "trying auto-probe from BIOS...\n");
  7025. board_config = ALC262_AUTO;
  7026. }
  7027. if (board_config == ALC262_AUTO) {
  7028. /* automatic parse from the BIOS config */
  7029. err = alc262_parse_auto_config(codec);
  7030. if (err < 0) {
  7031. alc_free(codec);
  7032. return err;
  7033. } else if (!err) {
  7034. printk(KERN_INFO
  7035. "hda_codec: Cannot set up configuration "
  7036. "from BIOS. Using base mode...\n");
  7037. board_config = ALC262_BASIC;
  7038. }
  7039. }
  7040. if (board_config != ALC262_AUTO)
  7041. setup_preset(spec, &alc262_presets[board_config]);
  7042. spec->stream_name_analog = "ALC262 Analog";
  7043. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7044. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7045. spec->stream_name_digital = "ALC262 Digital";
  7046. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7047. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7048. if (!spec->adc_nids && spec->input_mux) {
  7049. /* check whether NID 0x07 is valid */
  7050. unsigned int wcap = get_wcaps(codec, 0x07);
  7051. /* get type */
  7052. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7053. if (wcap != AC_WID_AUD_IN) {
  7054. spec->adc_nids = alc262_adc_nids_alt;
  7055. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7056. spec->mixers[spec->num_mixers] =
  7057. alc262_capture_alt_mixer;
  7058. spec->num_mixers++;
  7059. } else {
  7060. spec->adc_nids = alc262_adc_nids;
  7061. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7062. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7063. spec->num_mixers++;
  7064. }
  7065. }
  7066. codec->patch_ops = alc_patch_ops;
  7067. if (board_config == ALC262_AUTO)
  7068. spec->init_hook = alc262_auto_init;
  7069. return 0;
  7070. }
  7071. /*
  7072. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7073. */
  7074. /*
  7075. * set the path ways for 2 channel output
  7076. * need to set the codec line out and mic 1 pin widgets to inputs
  7077. */
  7078. static struct hda_verb alc861_threestack_ch2_init[] = {
  7079. /* set pin widget 1Ah (line in) for input */
  7080. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7081. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7082. * the vref
  7083. */
  7084. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7085. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7086. #if 0
  7087. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7088. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7089. #endif
  7090. { } /* end */
  7091. };
  7092. /*
  7093. * 6ch mode
  7094. * need to set the codec line out and mic 1 pin widgets to outputs
  7095. */
  7096. static struct hda_verb alc861_threestack_ch6_init[] = {
  7097. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7098. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7099. /* set pin widget 18h (mic1) for output (CLFE)*/
  7100. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7101. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7102. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7103. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7104. #if 0
  7105. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7106. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7107. #endif
  7108. { } /* end */
  7109. };
  7110. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7111. { 2, alc861_threestack_ch2_init },
  7112. { 6, alc861_threestack_ch6_init },
  7113. };
  7114. /* Set mic1 as input and unmute the mixer */
  7115. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7116. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7117. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7118. { } /* end */
  7119. };
  7120. /* Set mic1 as output and mute mixer */
  7121. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7122. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7123. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7124. { } /* end */
  7125. };
  7126. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7127. { 2, alc861_uniwill_m31_ch2_init },
  7128. { 4, alc861_uniwill_m31_ch4_init },
  7129. };
  7130. /* Set mic1 and line-in as input and unmute the mixer */
  7131. static struct hda_verb alc861_asus_ch2_init[] = {
  7132. /* set pin widget 1Ah (line in) for input */
  7133. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7134. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7135. * the vref
  7136. */
  7137. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7138. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7139. #if 0
  7140. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7141. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7142. #endif
  7143. { } /* end */
  7144. };
  7145. /* Set mic1 nad line-in as output and mute mixer */
  7146. static struct hda_verb alc861_asus_ch6_init[] = {
  7147. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7148. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7149. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7150. /* set pin widget 18h (mic1) for output (CLFE)*/
  7151. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7152. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7153. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7154. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7155. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7156. #if 0
  7157. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7158. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7159. #endif
  7160. { } /* end */
  7161. };
  7162. static struct hda_channel_mode alc861_asus_modes[2] = {
  7163. { 2, alc861_asus_ch2_init },
  7164. { 6, alc861_asus_ch6_init },
  7165. };
  7166. /* patch-ALC861 */
  7167. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7168. /* output mixer control */
  7169. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7170. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7171. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7172. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7173. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7174. /*Input mixer control */
  7175. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7176. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7177. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7178. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7179. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7180. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7181. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7182. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7183. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7184. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7185. /* Capture mixer control */
  7186. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7187. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7188. {
  7189. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7190. .name = "Capture Source",
  7191. .count = 1,
  7192. .info = alc_mux_enum_info,
  7193. .get = alc_mux_enum_get,
  7194. .put = alc_mux_enum_put,
  7195. },
  7196. { } /* end */
  7197. };
  7198. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7199. /* output mixer control */
  7200. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7201. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7202. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7203. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7204. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7205. /* Input mixer control */
  7206. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7207. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7208. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7209. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7210. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7211. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7212. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7213. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7214. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7215. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7216. /* Capture mixer control */
  7217. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7218. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7219. {
  7220. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7221. .name = "Capture Source",
  7222. .count = 1,
  7223. .info = alc_mux_enum_info,
  7224. .get = alc_mux_enum_get,
  7225. .put = alc_mux_enum_put,
  7226. },
  7227. {
  7228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7229. .name = "Channel Mode",
  7230. .info = alc_ch_mode_info,
  7231. .get = alc_ch_mode_get,
  7232. .put = alc_ch_mode_put,
  7233. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7234. },
  7235. { } /* end */
  7236. };
  7237. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7238. /* output mixer control */
  7239. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7240. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7241. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7242. /*Capture mixer control */
  7243. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7244. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7245. {
  7246. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7247. .name = "Capture Source",
  7248. .count = 1,
  7249. .info = alc_mux_enum_info,
  7250. .get = alc_mux_enum_get,
  7251. .put = alc_mux_enum_put,
  7252. },
  7253. { } /* end */
  7254. };
  7255. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7256. /* output mixer control */
  7257. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7258. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7259. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7260. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7261. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7262. /* Input mixer control */
  7263. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7264. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7265. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7266. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7267. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7268. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7269. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7270. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7271. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7272. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7273. /* Capture mixer control */
  7274. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7275. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7276. {
  7277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7278. .name = "Capture Source",
  7279. .count = 1,
  7280. .info = alc_mux_enum_info,
  7281. .get = alc_mux_enum_get,
  7282. .put = alc_mux_enum_put,
  7283. },
  7284. {
  7285. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7286. .name = "Channel Mode",
  7287. .info = alc_ch_mode_info,
  7288. .get = alc_ch_mode_get,
  7289. .put = alc_ch_mode_put,
  7290. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7291. },
  7292. { } /* end */
  7293. };
  7294. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7295. /* output mixer control */
  7296. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7297. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7298. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7299. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7300. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7301. /* Input mixer control */
  7302. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7303. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7304. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7305. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7306. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7307. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7308. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7309. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7310. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7311. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7312. /* Capture mixer control */
  7313. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7314. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7315. {
  7316. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7317. .name = "Capture Source",
  7318. .count = 1,
  7319. .info = alc_mux_enum_info,
  7320. .get = alc_mux_enum_get,
  7321. .put = alc_mux_enum_put,
  7322. },
  7323. {
  7324. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7325. .name = "Channel Mode",
  7326. .info = alc_ch_mode_info,
  7327. .get = alc_ch_mode_get,
  7328. .put = alc_ch_mode_put,
  7329. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7330. },
  7331. { }
  7332. };
  7333. /* additional mixer */
  7334. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7335. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7336. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7337. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7338. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7339. { }
  7340. };
  7341. /*
  7342. * generic initialization of ADC, input mixers and output mixers
  7343. */
  7344. static struct hda_verb alc861_base_init_verbs[] = {
  7345. /*
  7346. * Unmute ADC0 and set the default input to mic-in
  7347. */
  7348. /* port-A for surround (rear panel) */
  7349. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7350. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7351. /* port-B for mic-in (rear panel) with vref */
  7352. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7353. /* port-C for line-in (rear panel) */
  7354. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7355. /* port-D for Front */
  7356. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7357. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7358. /* port-E for HP out (front panel) */
  7359. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7360. /* route front PCM to HP */
  7361. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7362. /* port-F for mic-in (front panel) with vref */
  7363. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7364. /* port-G for CLFE (rear panel) */
  7365. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7366. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7367. /* port-H for side (rear panel) */
  7368. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7369. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7370. /* CD-in */
  7371. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7372. /* route front mic to ADC1*/
  7373. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7374. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7375. /* Unmute DAC0~3 & spdif out*/
  7376. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7377. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7378. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7379. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7380. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7381. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7382. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7383. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7384. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7385. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7386. /* Unmute Stereo Mixer 15 */
  7387. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7388. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7391. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7392. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7393. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7394. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7395. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7396. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7397. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7398. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7399. /* hp used DAC 3 (Front) */
  7400. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7401. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7402. { }
  7403. };
  7404. static struct hda_verb alc861_threestack_init_verbs[] = {
  7405. /*
  7406. * Unmute ADC0 and set the default input to mic-in
  7407. */
  7408. /* port-A for surround (rear panel) */
  7409. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7410. /* port-B for mic-in (rear panel) with vref */
  7411. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7412. /* port-C for line-in (rear panel) */
  7413. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7414. /* port-D for Front */
  7415. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7416. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7417. /* port-E for HP out (front panel) */
  7418. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7419. /* route front PCM to HP */
  7420. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7421. /* port-F for mic-in (front panel) with vref */
  7422. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7423. /* port-G for CLFE (rear panel) */
  7424. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7425. /* port-H for side (rear panel) */
  7426. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7427. /* CD-in */
  7428. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7429. /* route front mic to ADC1*/
  7430. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7431. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7432. /* Unmute DAC0~3 & spdif out*/
  7433. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7434. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7435. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7436. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7437. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7438. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7439. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7440. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7441. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7442. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7443. /* Unmute Stereo Mixer 15 */
  7444. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7445. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7446. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7447. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7448. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7449. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7450. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7451. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7452. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7453. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7454. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7455. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7456. /* hp used DAC 3 (Front) */
  7457. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7458. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7459. { }
  7460. };
  7461. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7462. /*
  7463. * Unmute ADC0 and set the default input to mic-in
  7464. */
  7465. /* port-A for surround (rear panel) */
  7466. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7467. /* port-B for mic-in (rear panel) with vref */
  7468. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7469. /* port-C for line-in (rear panel) */
  7470. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7471. /* port-D for Front */
  7472. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7473. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7474. /* port-E for HP out (front panel) */
  7475. /* this has to be set to VREF80 */
  7476. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7477. /* route front PCM to HP */
  7478. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7479. /* port-F for mic-in (front panel) with vref */
  7480. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7481. /* port-G for CLFE (rear panel) */
  7482. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7483. /* port-H for side (rear panel) */
  7484. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7485. /* CD-in */
  7486. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7487. /* route front mic to ADC1*/
  7488. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7490. /* Unmute DAC0~3 & spdif out*/
  7491. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7492. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7493. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7494. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7496. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7497. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7498. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7499. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7500. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7501. /* Unmute Stereo Mixer 15 */
  7502. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7503. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7504. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7506. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7507. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7508. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7509. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7510. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7511. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7512. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7513. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7514. /* hp used DAC 3 (Front) */
  7515. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7516. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7517. { }
  7518. };
  7519. static struct hda_verb alc861_asus_init_verbs[] = {
  7520. /*
  7521. * Unmute ADC0 and set the default input to mic-in
  7522. */
  7523. /* port-A for surround (rear panel)
  7524. * according to codec#0 this is the HP jack
  7525. */
  7526. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7527. /* route front PCM to HP */
  7528. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7529. /* port-B for mic-in (rear panel) with vref */
  7530. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7531. /* port-C for line-in (rear panel) */
  7532. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7533. /* port-D for Front */
  7534. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7535. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7536. /* port-E for HP out (front panel) */
  7537. /* this has to be set to VREF80 */
  7538. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7539. /* route front PCM to HP */
  7540. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7541. /* port-F for mic-in (front panel) with vref */
  7542. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7543. /* port-G for CLFE (rear panel) */
  7544. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7545. /* port-H for side (rear panel) */
  7546. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7547. /* CD-in */
  7548. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7549. /* route front mic to ADC1*/
  7550. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7551. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7552. /* Unmute DAC0~3 & spdif out*/
  7553. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7554. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7555. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7556. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7557. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7558. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7559. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7560. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7561. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7562. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7563. /* Unmute Stereo Mixer 15 */
  7564. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7565. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7566. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7567. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7568. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7569. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7570. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7571. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7572. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7573. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7574. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7575. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7576. /* hp used DAC 3 (Front) */
  7577. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7578. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7579. { }
  7580. };
  7581. /* additional init verbs for ASUS laptops */
  7582. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  7583. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  7584. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  7585. { }
  7586. };
  7587. /*
  7588. * generic initialization of ADC, input mixers and output mixers
  7589. */
  7590. static struct hda_verb alc861_auto_init_verbs[] = {
  7591. /*
  7592. * Unmute ADC0 and set the default input to mic-in
  7593. */
  7594. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  7595. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7596. /* Unmute DAC0~3 & spdif out*/
  7597. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7598. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7599. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7600. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7601. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7602. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7603. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7604. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7605. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7606. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7607. /* Unmute Stereo Mixer 15 */
  7608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7610. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7611. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  7612. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7613. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7614. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7615. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7616. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7617. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7618. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7619. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7620. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7621. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7622. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7623. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7624. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7625. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7626. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7627. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7628. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  7629. { }
  7630. };
  7631. static struct hda_verb alc861_toshiba_init_verbs[] = {
  7632. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7633. { }
  7634. };
  7635. /* toggle speaker-output according to the hp-jack state */
  7636. static void alc861_toshiba_automute(struct hda_codec *codec)
  7637. {
  7638. unsigned int present;
  7639. present = snd_hda_codec_read(codec, 0x0f, 0,
  7640. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  7641. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  7642. 0x80, present ? 0x80 : 0);
  7643. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  7644. 0x80, present ? 0x80 : 0);
  7645. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  7646. 0x80, present ? 0 : 0x80);
  7647. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  7648. 0x80, present ? 0 : 0x80);
  7649. }
  7650. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  7651. unsigned int res)
  7652. {
  7653. if ((res >> 26) == ALC880_HP_EVENT)
  7654. alc861_toshiba_automute(codec);
  7655. }
  7656. /* pcm configuration: identiacal with ALC880 */
  7657. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  7658. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  7659. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  7660. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  7661. #define ALC861_DIGOUT_NID 0x07
  7662. static struct hda_channel_mode alc861_8ch_modes[1] = {
  7663. { 8, NULL }
  7664. };
  7665. static hda_nid_t alc861_dac_nids[4] = {
  7666. /* front, surround, clfe, side */
  7667. 0x03, 0x06, 0x05, 0x04
  7668. };
  7669. static hda_nid_t alc660_dac_nids[3] = {
  7670. /* front, clfe, surround */
  7671. 0x03, 0x05, 0x06
  7672. };
  7673. static hda_nid_t alc861_adc_nids[1] = {
  7674. /* ADC0-2 */
  7675. 0x08,
  7676. };
  7677. static struct hda_input_mux alc861_capture_source = {
  7678. .num_items = 5,
  7679. .items = {
  7680. { "Mic", 0x0 },
  7681. { "Front Mic", 0x3 },
  7682. { "Line", 0x1 },
  7683. { "CD", 0x4 },
  7684. { "Mixer", 0x5 },
  7685. },
  7686. };
  7687. /* fill in the dac_nids table from the parsed pin configuration */
  7688. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  7689. const struct auto_pin_cfg *cfg)
  7690. {
  7691. int i;
  7692. hda_nid_t nid;
  7693. spec->multiout.dac_nids = spec->private_dac_nids;
  7694. for (i = 0; i < cfg->line_outs; i++) {
  7695. nid = cfg->line_out_pins[i];
  7696. if (nid) {
  7697. if (i >= ARRAY_SIZE(alc861_dac_nids))
  7698. continue;
  7699. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  7700. }
  7701. }
  7702. spec->multiout.num_dacs = cfg->line_outs;
  7703. return 0;
  7704. }
  7705. /* add playback controls from the parsed DAC table */
  7706. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  7707. const struct auto_pin_cfg *cfg)
  7708. {
  7709. char name[32];
  7710. static const char *chname[4] = {
  7711. "Front", "Surround", NULL /*CLFE*/, "Side"
  7712. };
  7713. hda_nid_t nid;
  7714. int i, idx, err;
  7715. for (i = 0; i < cfg->line_outs; i++) {
  7716. nid = spec->multiout.dac_nids[i];
  7717. if (!nid)
  7718. continue;
  7719. if (nid == 0x05) {
  7720. /* Center/LFE */
  7721. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7722. "Center Playback Switch",
  7723. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  7724. HDA_OUTPUT));
  7725. if (err < 0)
  7726. return err;
  7727. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7728. "LFE Playback Switch",
  7729. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7730. HDA_OUTPUT));
  7731. if (err < 0)
  7732. return err;
  7733. } else {
  7734. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  7735. idx++)
  7736. if (nid == alc861_dac_nids[idx])
  7737. break;
  7738. sprintf(name, "%s Playback Switch", chname[idx]);
  7739. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7740. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7741. HDA_OUTPUT));
  7742. if (err < 0)
  7743. return err;
  7744. }
  7745. }
  7746. return 0;
  7747. }
  7748. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  7749. {
  7750. int err;
  7751. hda_nid_t nid;
  7752. if (!pin)
  7753. return 0;
  7754. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  7755. nid = 0x03;
  7756. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7757. "Headphone Playback Switch",
  7758. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7759. if (err < 0)
  7760. return err;
  7761. spec->multiout.hp_nid = nid;
  7762. }
  7763. return 0;
  7764. }
  7765. /* create playback/capture controls for input pins */
  7766. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  7767. const struct auto_pin_cfg *cfg)
  7768. {
  7769. struct hda_input_mux *imux = &spec->private_imux;
  7770. int i, err, idx, idx1;
  7771. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7772. switch (cfg->input_pins[i]) {
  7773. case 0x0c:
  7774. idx1 = 1;
  7775. idx = 2; /* Line In */
  7776. break;
  7777. case 0x0f:
  7778. idx1 = 2;
  7779. idx = 2; /* Line In */
  7780. break;
  7781. case 0x0d:
  7782. idx1 = 0;
  7783. idx = 1; /* Mic In */
  7784. break;
  7785. case 0x10:
  7786. idx1 = 3;
  7787. idx = 1; /* Mic In */
  7788. break;
  7789. case 0x11:
  7790. idx1 = 4;
  7791. idx = 0; /* CD */
  7792. break;
  7793. default:
  7794. continue;
  7795. }
  7796. err = new_analog_input(spec, cfg->input_pins[i],
  7797. auto_pin_cfg_labels[i], idx, 0x15);
  7798. if (err < 0)
  7799. return err;
  7800. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7801. imux->items[imux->num_items].index = idx1;
  7802. imux->num_items++;
  7803. }
  7804. return 0;
  7805. }
  7806. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  7807. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7808. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7809. {
  7810. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7811. /* The multiple "Capture Source" controls confuse alsamixer
  7812. * So call somewhat different..
  7813. *FIXME: the controls appear in the "playback" view!
  7814. */
  7815. /* .name = "Capture Source", */
  7816. .name = "Input Source",
  7817. .count = 1,
  7818. .info = alc_mux_enum_info,
  7819. .get = alc_mux_enum_get,
  7820. .put = alc_mux_enum_put,
  7821. },
  7822. { } /* end */
  7823. };
  7824. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  7825. hda_nid_t nid,
  7826. int pin_type, int dac_idx)
  7827. {
  7828. /* set as output */
  7829. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  7830. pin_type);
  7831. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7832. AMP_OUT_UNMUTE);
  7833. }
  7834. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  7835. {
  7836. struct alc_spec *spec = codec->spec;
  7837. int i;
  7838. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  7839. for (i = 0; i < spec->autocfg.line_outs; i++) {
  7840. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7841. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  7842. if (nid)
  7843. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  7844. spec->multiout.dac_nids[i]);
  7845. }
  7846. }
  7847. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  7848. {
  7849. struct alc_spec *spec = codec->spec;
  7850. hda_nid_t pin;
  7851. pin = spec->autocfg.hp_pins[0];
  7852. if (pin) /* connect to front */
  7853. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  7854. spec->multiout.dac_nids[0]);
  7855. }
  7856. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  7857. {
  7858. struct alc_spec *spec = codec->spec;
  7859. int i;
  7860. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7861. hda_nid_t nid = spec->autocfg.input_pins[i];
  7862. if (nid >= 0x0c && nid <= 0x11) {
  7863. snd_hda_codec_write(codec, nid, 0,
  7864. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7865. i <= AUTO_PIN_FRONT_MIC ?
  7866. PIN_VREF80 : PIN_IN);
  7867. }
  7868. }
  7869. }
  7870. /* parse the BIOS configuration and set up the alc_spec */
  7871. /* return 1 if successful, 0 if the proper config is not found,
  7872. * or a negative error code
  7873. */
  7874. static int alc861_parse_auto_config(struct hda_codec *codec)
  7875. {
  7876. struct alc_spec *spec = codec->spec;
  7877. int err;
  7878. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  7879. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7880. alc861_ignore);
  7881. if (err < 0)
  7882. return err;
  7883. if (!spec->autocfg.line_outs)
  7884. return 0; /* can't find valid BIOS pin config */
  7885. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  7886. if (err < 0)
  7887. return err;
  7888. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7889. if (err < 0)
  7890. return err;
  7891. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  7892. if (err < 0)
  7893. return err;
  7894. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7895. if (err < 0)
  7896. return err;
  7897. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7898. if (spec->autocfg.dig_out_pin)
  7899. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7900. if (spec->kctl_alloc)
  7901. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7902. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7903. spec->num_mux_defs = 1;
  7904. spec->input_mux = &spec->private_imux;
  7905. spec->adc_nids = alc861_adc_nids;
  7906. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7907. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7908. spec->num_mixers++;
  7909. return 1;
  7910. }
  7911. /* additional initialization for auto-configuration model */
  7912. static void alc861_auto_init(struct hda_codec *codec)
  7913. {
  7914. alc861_auto_init_multi_out(codec);
  7915. alc861_auto_init_hp_out(codec);
  7916. alc861_auto_init_analog_input(codec);
  7917. }
  7918. /*
  7919. * configuration and preset
  7920. */
  7921. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7922. [ALC861_3ST] = "3stack",
  7923. [ALC660_3ST] = "3stack-660",
  7924. [ALC861_3ST_DIG] = "3stack-dig",
  7925. [ALC861_6ST_DIG] = "6stack-dig",
  7926. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7927. [ALC861_TOSHIBA] = "toshiba",
  7928. [ALC861_ASUS] = "asus",
  7929. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7930. [ALC861_AUTO] = "auto",
  7931. };
  7932. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7933. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7934. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7935. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7936. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  7937. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7938. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7939. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7940. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7941. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7942. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  7943. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7944. {}
  7945. };
  7946. static struct alc_config_preset alc861_presets[] = {
  7947. [ALC861_3ST] = {
  7948. .mixers = { alc861_3ST_mixer },
  7949. .init_verbs = { alc861_threestack_init_verbs },
  7950. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7951. .dac_nids = alc861_dac_nids,
  7952. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7953. .channel_mode = alc861_threestack_modes,
  7954. .need_dac_fix = 1,
  7955. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7956. .adc_nids = alc861_adc_nids,
  7957. .input_mux = &alc861_capture_source,
  7958. },
  7959. [ALC861_3ST_DIG] = {
  7960. .mixers = { alc861_base_mixer },
  7961. .init_verbs = { alc861_threestack_init_verbs },
  7962. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7963. .dac_nids = alc861_dac_nids,
  7964. .dig_out_nid = ALC861_DIGOUT_NID,
  7965. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7966. .channel_mode = alc861_threestack_modes,
  7967. .need_dac_fix = 1,
  7968. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7969. .adc_nids = alc861_adc_nids,
  7970. .input_mux = &alc861_capture_source,
  7971. },
  7972. [ALC861_6ST_DIG] = {
  7973. .mixers = { alc861_base_mixer },
  7974. .init_verbs = { alc861_base_init_verbs },
  7975. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7976. .dac_nids = alc861_dac_nids,
  7977. .dig_out_nid = ALC861_DIGOUT_NID,
  7978. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7979. .channel_mode = alc861_8ch_modes,
  7980. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7981. .adc_nids = alc861_adc_nids,
  7982. .input_mux = &alc861_capture_source,
  7983. },
  7984. [ALC660_3ST] = {
  7985. .mixers = { alc861_3ST_mixer },
  7986. .init_verbs = { alc861_threestack_init_verbs },
  7987. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7988. .dac_nids = alc660_dac_nids,
  7989. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7990. .channel_mode = alc861_threestack_modes,
  7991. .need_dac_fix = 1,
  7992. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7993. .adc_nids = alc861_adc_nids,
  7994. .input_mux = &alc861_capture_source,
  7995. },
  7996. [ALC861_UNIWILL_M31] = {
  7997. .mixers = { alc861_uniwill_m31_mixer },
  7998. .init_verbs = { alc861_uniwill_m31_init_verbs },
  7999. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8000. .dac_nids = alc861_dac_nids,
  8001. .dig_out_nid = ALC861_DIGOUT_NID,
  8002. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8003. .channel_mode = alc861_uniwill_m31_modes,
  8004. .need_dac_fix = 1,
  8005. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8006. .adc_nids = alc861_adc_nids,
  8007. .input_mux = &alc861_capture_source,
  8008. },
  8009. [ALC861_TOSHIBA] = {
  8010. .mixers = { alc861_toshiba_mixer },
  8011. .init_verbs = { alc861_base_init_verbs,
  8012. alc861_toshiba_init_verbs },
  8013. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8014. .dac_nids = alc861_dac_nids,
  8015. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8016. .channel_mode = alc883_3ST_2ch_modes,
  8017. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8018. .adc_nids = alc861_adc_nids,
  8019. .input_mux = &alc861_capture_source,
  8020. .unsol_event = alc861_toshiba_unsol_event,
  8021. .init_hook = alc861_toshiba_automute,
  8022. },
  8023. [ALC861_ASUS] = {
  8024. .mixers = { alc861_asus_mixer },
  8025. .init_verbs = { alc861_asus_init_verbs },
  8026. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8027. .dac_nids = alc861_dac_nids,
  8028. .dig_out_nid = ALC861_DIGOUT_NID,
  8029. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8030. .channel_mode = alc861_asus_modes,
  8031. .need_dac_fix = 1,
  8032. .hp_nid = 0x06,
  8033. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8034. .adc_nids = alc861_adc_nids,
  8035. .input_mux = &alc861_capture_source,
  8036. },
  8037. [ALC861_ASUS_LAPTOP] = {
  8038. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8039. .init_verbs = { alc861_asus_init_verbs,
  8040. alc861_asus_laptop_init_verbs },
  8041. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8042. .dac_nids = alc861_dac_nids,
  8043. .dig_out_nid = ALC861_DIGOUT_NID,
  8044. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8045. .channel_mode = alc883_3ST_2ch_modes,
  8046. .need_dac_fix = 1,
  8047. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8048. .adc_nids = alc861_adc_nids,
  8049. .input_mux = &alc861_capture_source,
  8050. },
  8051. };
  8052. static int patch_alc861(struct hda_codec *codec)
  8053. {
  8054. struct alc_spec *spec;
  8055. int board_config;
  8056. int err;
  8057. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8058. if (spec == NULL)
  8059. return -ENOMEM;
  8060. codec->spec = spec;
  8061. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8062. alc861_models,
  8063. alc861_cfg_tbl);
  8064. if (board_config < 0) {
  8065. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8066. "trying auto-probe from BIOS...\n");
  8067. board_config = ALC861_AUTO;
  8068. }
  8069. if (board_config == ALC861_AUTO) {
  8070. /* automatic parse from the BIOS config */
  8071. err = alc861_parse_auto_config(codec);
  8072. if (err < 0) {
  8073. alc_free(codec);
  8074. return err;
  8075. } else if (!err) {
  8076. printk(KERN_INFO
  8077. "hda_codec: Cannot set up configuration "
  8078. "from BIOS. Using base mode...\n");
  8079. board_config = ALC861_3ST_DIG;
  8080. }
  8081. }
  8082. if (board_config != ALC861_AUTO)
  8083. setup_preset(spec, &alc861_presets[board_config]);
  8084. spec->stream_name_analog = "ALC861 Analog";
  8085. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8086. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8087. spec->stream_name_digital = "ALC861 Digital";
  8088. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8089. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8090. codec->patch_ops = alc_patch_ops;
  8091. if (board_config == ALC861_AUTO)
  8092. spec->init_hook = alc861_auto_init;
  8093. return 0;
  8094. }
  8095. /*
  8096. * ALC861-VD support
  8097. *
  8098. * Based on ALC882
  8099. *
  8100. * In addition, an independent DAC
  8101. */
  8102. #define ALC861VD_DIGOUT_NID 0x06
  8103. static hda_nid_t alc861vd_dac_nids[4] = {
  8104. /* front, surr, clfe, side surr */
  8105. 0x02, 0x03, 0x04, 0x05
  8106. };
  8107. /* dac_nids for ALC660vd are in a different order - according to
  8108. * Realtek's driver.
  8109. * This should probably tesult in a different mixer for 6stack models
  8110. * of ALC660vd codecs, but for now there is only 3stack mixer
  8111. * - and it is the same as in 861vd.
  8112. * adc_nids in ALC660vd are (is) the same as in 861vd
  8113. */
  8114. static hda_nid_t alc660vd_dac_nids[3] = {
  8115. /* front, rear, clfe, rear_surr */
  8116. 0x02, 0x04, 0x03
  8117. };
  8118. static hda_nid_t alc861vd_adc_nids[1] = {
  8119. /* ADC0 */
  8120. 0x09,
  8121. };
  8122. /* input MUX */
  8123. /* FIXME: should be a matrix-type input source selection */
  8124. static struct hda_input_mux alc861vd_capture_source = {
  8125. .num_items = 4,
  8126. .items = {
  8127. { "Mic", 0x0 },
  8128. { "Front Mic", 0x1 },
  8129. { "Line", 0x2 },
  8130. { "CD", 0x4 },
  8131. },
  8132. };
  8133. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8134. .num_items = 3,
  8135. .items = {
  8136. { "Front Mic", 0x0 },
  8137. { "ATAPI Mic", 0x1 },
  8138. { "Line In", 0x5 },
  8139. },
  8140. };
  8141. #define alc861vd_mux_enum_info alc_mux_enum_info
  8142. #define alc861vd_mux_enum_get alc_mux_enum_get
  8143. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8144. struct snd_ctl_elem_value *ucontrol)
  8145. {
  8146. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8147. struct alc_spec *spec = codec->spec;
  8148. const struct hda_input_mux *imux = spec->input_mux;
  8149. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8150. static hda_nid_t capture_mixers[1] = { 0x22 };
  8151. hda_nid_t nid = capture_mixers[adc_idx];
  8152. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8153. unsigned int i, idx;
  8154. idx = ucontrol->value.enumerated.item[0];
  8155. if (idx >= imux->num_items)
  8156. idx = imux->num_items - 1;
  8157. if (*cur_val == idx && !codec->in_resume)
  8158. return 0;
  8159. for (i = 0; i < imux->num_items; i++) {
  8160. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8161. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8162. v | (imux->items[i].index << 8));
  8163. }
  8164. *cur_val = idx;
  8165. return 1;
  8166. }
  8167. /*
  8168. * 2ch mode
  8169. */
  8170. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8171. { 2, NULL }
  8172. };
  8173. /*
  8174. * 6ch mode
  8175. */
  8176. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8177. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8178. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8179. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8180. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8181. { } /* end */
  8182. };
  8183. /*
  8184. * 8ch mode
  8185. */
  8186. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8187. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8188. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8189. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8190. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8191. { } /* end */
  8192. };
  8193. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8194. { 6, alc861vd_6stack_ch6_init },
  8195. { 8, alc861vd_6stack_ch8_init },
  8196. };
  8197. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8198. {
  8199. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8200. .name = "Channel Mode",
  8201. .info = alc_ch_mode_info,
  8202. .get = alc_ch_mode_get,
  8203. .put = alc_ch_mode_put,
  8204. },
  8205. { } /* end */
  8206. };
  8207. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8208. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8209. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8210. {
  8211. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8212. /* The multiple "Capture Source" controls confuse alsamixer
  8213. * So call somewhat different..
  8214. *FIXME: the controls appear in the "playback" view!
  8215. */
  8216. /* .name = "Capture Source", */
  8217. .name = "Input Source",
  8218. .count = 1,
  8219. .info = alc861vd_mux_enum_info,
  8220. .get = alc861vd_mux_enum_get,
  8221. .put = alc861vd_mux_enum_put,
  8222. },
  8223. { } /* end */
  8224. };
  8225. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8226. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8227. */
  8228. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8229. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8230. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8231. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8232. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8233. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8234. HDA_OUTPUT),
  8235. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8236. HDA_OUTPUT),
  8237. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8238. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8239. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8240. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8241. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8242. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8243. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8244. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8245. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8246. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8247. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8248. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8249. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8250. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8251. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8252. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8253. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8254. { } /* end */
  8255. };
  8256. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8257. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8258. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8259. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8260. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8261. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8262. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8263. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8264. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8265. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8266. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8267. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8268. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8269. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8270. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8271. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8272. { } /* end */
  8273. };
  8274. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8275. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8276. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8277. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8278. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8279. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8281. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8282. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8283. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8284. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8285. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8286. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8287. { } /* end */
  8288. };
  8289. /* Pin assignment: Front=0x14, HP = 0x15,
  8290. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8291. */
  8292. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8293. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8294. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8295. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8296. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8297. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8298. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8299. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8300. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8301. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8302. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8303. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8304. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8305. {
  8306. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8307. /* .name = "Capture Source", */
  8308. .name = "Input Source",
  8309. .count = 1,
  8310. .info = alc882_mux_enum_info,
  8311. .get = alc882_mux_enum_get,
  8312. .put = alc882_mux_enum_put,
  8313. },
  8314. { } /* end */
  8315. };
  8316. /*
  8317. * generic initialization of ADC, input mixers and output mixers
  8318. */
  8319. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8320. /*
  8321. * Unmute ADC0 and set the default input to mic-in
  8322. */
  8323. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8324. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8325. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8326. * the analog-loopback mixer widget
  8327. */
  8328. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8329. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8330. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8331. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8332. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8333. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8334. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8335. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8336. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8337. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8338. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8339. /*
  8340. * Set up output mixers (0x02 - 0x05)
  8341. */
  8342. /* set vol=0 to output mixers */
  8343. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8344. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8345. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8346. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8347. /* set up input amps for analog loopback */
  8348. /* Amp Indices: DAC = 0, mixer = 1 */
  8349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8350. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8352. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8354. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8355. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8356. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8357. { }
  8358. };
  8359. /*
  8360. * 3-stack pin configuration:
  8361. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8362. */
  8363. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8364. /*
  8365. * Set pin mode and muting
  8366. */
  8367. /* set front pin widgets 0x14 for output */
  8368. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8369. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8370. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8371. /* Mic (rear) pin: input vref at 80% */
  8372. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8373. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8374. /* Front Mic pin: input vref at 80% */
  8375. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8376. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8377. /* Line In pin: input */
  8378. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8379. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8380. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8381. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8382. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8383. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8384. /* CD pin widget for input */
  8385. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8386. { }
  8387. };
  8388. /*
  8389. * 6-stack pin configuration:
  8390. */
  8391. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8392. /*
  8393. * Set pin mode and muting
  8394. */
  8395. /* set front pin widgets 0x14 for output */
  8396. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8397. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8398. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8399. /* Rear Pin: output 1 (0x0d) */
  8400. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8401. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8402. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8403. /* CLFE Pin: output 2 (0x0e) */
  8404. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8405. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8406. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8407. /* Side Pin: output 3 (0x0f) */
  8408. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8409. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8410. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8411. /* Mic (rear) pin: input vref at 80% */
  8412. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8413. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8414. /* Front Mic pin: input vref at 80% */
  8415. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8416. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8417. /* Line In pin: input */
  8418. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8419. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8420. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8421. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8422. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8423. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8424. /* CD pin widget for input */
  8425. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8426. { }
  8427. };
  8428. static struct hda_verb alc861vd_eapd_verbs[] = {
  8429. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8430. { }
  8431. };
  8432. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8433. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8434. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8435. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8436. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8437. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8438. {}
  8439. };
  8440. /* toggle speaker-output according to the hp-jack state */
  8441. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8442. {
  8443. unsigned int present;
  8444. unsigned char bits;
  8445. present = snd_hda_codec_read(codec, 0x1b, 0,
  8446. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8447. bits = present ? 0x80 : 0;
  8448. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8449. 0x80, bits);
  8450. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8451. 0x80, bits);
  8452. }
  8453. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8454. {
  8455. unsigned int present;
  8456. unsigned char bits;
  8457. present = snd_hda_codec_read(codec, 0x18, 0,
  8458. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8459. bits = present ? 0x80 : 0;
  8460. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8461. 0x80, bits);
  8462. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8463. 0x80, bits);
  8464. }
  8465. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8466. {
  8467. alc861vd_lenovo_hp_automute(codec);
  8468. alc861vd_lenovo_mic_automute(codec);
  8469. }
  8470. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8471. unsigned int res)
  8472. {
  8473. switch (res >> 26) {
  8474. case ALC880_HP_EVENT:
  8475. alc861vd_lenovo_hp_automute(codec);
  8476. break;
  8477. case ALC880_MIC_EVENT:
  8478. alc861vd_lenovo_mic_automute(codec);
  8479. break;
  8480. }
  8481. }
  8482. static struct hda_verb alc861vd_dallas_verbs[] = {
  8483. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8484. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8485. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8486. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8487. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8488. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8489. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8490. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8491. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8492. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8493. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8494. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8497. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8498. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8499. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8500. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8501. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8502. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8503. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8504. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8505. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8506. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8507. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8508. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8509. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8510. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8511. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8512. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8513. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8514. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8515. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8516. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8517. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8518. { } /* end */
  8519. };
  8520. /* toggle speaker-output according to the hp-jack state */
  8521. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8522. {
  8523. unsigned int present;
  8524. present = snd_hda_codec_read(codec, 0x15, 0,
  8525. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8526. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8527. 0x80, present ? 0x80 : 0);
  8528. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8529. 0x80, present ? 0x80 : 0);
  8530. }
  8531. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8532. {
  8533. if ((res >> 26) == ALC880_HP_EVENT)
  8534. alc861vd_dallas_automute(codec);
  8535. }
  8536. /* pcm configuration: identiacal with ALC880 */
  8537. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  8538. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  8539. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  8540. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  8541. /*
  8542. * configuration and preset
  8543. */
  8544. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  8545. [ALC660VD_3ST] = "3stack-660",
  8546. [ALC861VD_3ST] = "3stack",
  8547. [ALC861VD_3ST_DIG] = "3stack-digout",
  8548. [ALC861VD_6ST_DIG] = "6stack-digout",
  8549. [ALC861VD_LENOVO] = "lenovo",
  8550. [ALC861VD_DALLAS] = "dallas",
  8551. [ALC861VD_AUTO] = "auto",
  8552. };
  8553. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  8554. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  8555. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  8556. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
  8557. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  8558. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  8559. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  8560. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  8561. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  8562. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  8563. {}
  8564. };
  8565. static struct alc_config_preset alc861vd_presets[] = {
  8566. [ALC660VD_3ST] = {
  8567. .mixers = { alc861vd_3st_mixer },
  8568. .init_verbs = { alc861vd_volume_init_verbs,
  8569. alc861vd_3stack_init_verbs },
  8570. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  8571. .dac_nids = alc660vd_dac_nids,
  8572. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8573. .adc_nids = alc861vd_adc_nids,
  8574. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8575. .channel_mode = alc861vd_3stack_2ch_modes,
  8576. .input_mux = &alc861vd_capture_source,
  8577. },
  8578. [ALC861VD_3ST] = {
  8579. .mixers = { alc861vd_3st_mixer },
  8580. .init_verbs = { alc861vd_volume_init_verbs,
  8581. alc861vd_3stack_init_verbs },
  8582. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8583. .dac_nids = alc861vd_dac_nids,
  8584. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8585. .channel_mode = alc861vd_3stack_2ch_modes,
  8586. .input_mux = &alc861vd_capture_source,
  8587. },
  8588. [ALC861VD_3ST_DIG] = {
  8589. .mixers = { alc861vd_3st_mixer },
  8590. .init_verbs = { alc861vd_volume_init_verbs,
  8591. alc861vd_3stack_init_verbs },
  8592. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8593. .dac_nids = alc861vd_dac_nids,
  8594. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8595. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8596. .channel_mode = alc861vd_3stack_2ch_modes,
  8597. .input_mux = &alc861vd_capture_source,
  8598. },
  8599. [ALC861VD_6ST_DIG] = {
  8600. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  8601. .init_verbs = { alc861vd_volume_init_verbs,
  8602. alc861vd_6stack_init_verbs },
  8603. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8604. .dac_nids = alc861vd_dac_nids,
  8605. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8606. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  8607. .channel_mode = alc861vd_6stack_modes,
  8608. .input_mux = &alc861vd_capture_source,
  8609. },
  8610. [ALC861VD_LENOVO] = {
  8611. .mixers = { alc861vd_lenovo_mixer },
  8612. .init_verbs = { alc861vd_volume_init_verbs,
  8613. alc861vd_3stack_init_verbs,
  8614. alc861vd_eapd_verbs,
  8615. alc861vd_lenovo_unsol_verbs },
  8616. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  8617. .dac_nids = alc660vd_dac_nids,
  8618. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8619. .adc_nids = alc861vd_adc_nids,
  8620. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8621. .channel_mode = alc861vd_3stack_2ch_modes,
  8622. .input_mux = &alc861vd_capture_source,
  8623. .unsol_event = alc861vd_lenovo_unsol_event,
  8624. .init_hook = alc861vd_lenovo_automute,
  8625. },
  8626. [ALC861VD_DALLAS] = {
  8627. .mixers = { alc861vd_dallas_mixer },
  8628. .init_verbs = { alc861vd_dallas_verbs },
  8629. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8630. .dac_nids = alc861vd_dac_nids,
  8631. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  8632. .adc_nids = alc861vd_adc_nids,
  8633. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8634. .channel_mode = alc861vd_3stack_2ch_modes,
  8635. .input_mux = &alc861vd_dallas_capture_source,
  8636. .unsol_event = alc861vd_dallas_unsol_event,
  8637. .init_hook = alc861vd_dallas_automute,
  8638. },
  8639. };
  8640. /*
  8641. * BIOS auto configuration
  8642. */
  8643. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  8644. hda_nid_t nid, int pin_type, int dac_idx)
  8645. {
  8646. /* set as output */
  8647. snd_hda_codec_write(codec, nid, 0,
  8648. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8649. snd_hda_codec_write(codec, nid, 0,
  8650. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8651. }
  8652. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  8653. {
  8654. struct alc_spec *spec = codec->spec;
  8655. int i;
  8656. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  8657. for (i = 0; i <= HDA_SIDE; i++) {
  8658. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8659. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8660. if (nid)
  8661. alc861vd_auto_set_output_and_unmute(codec, nid,
  8662. pin_type, i);
  8663. }
  8664. }
  8665. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  8666. {
  8667. struct alc_spec *spec = codec->spec;
  8668. hda_nid_t pin;
  8669. pin = spec->autocfg.hp_pins[0];
  8670. if (pin) /* connect to front and use dac 0 */
  8671. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8672. }
  8673. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  8674. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  8675. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  8676. {
  8677. struct alc_spec *spec = codec->spec;
  8678. int i;
  8679. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8680. hda_nid_t nid = spec->autocfg.input_pins[i];
  8681. if (alc861vd_is_input_pin(nid)) {
  8682. snd_hda_codec_write(codec, nid, 0,
  8683. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8684. i <= AUTO_PIN_FRONT_MIC ?
  8685. PIN_VREF80 : PIN_IN);
  8686. if (nid != ALC861VD_PIN_CD_NID)
  8687. snd_hda_codec_write(codec, nid, 0,
  8688. AC_VERB_SET_AMP_GAIN_MUTE,
  8689. AMP_OUT_MUTE);
  8690. }
  8691. }
  8692. }
  8693. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  8694. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  8695. /* add playback controls from the parsed DAC table */
  8696. /* Based on ALC880 version. But ALC861VD has separate,
  8697. * different NIDs for mute/unmute switch and volume control */
  8698. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  8699. const struct auto_pin_cfg *cfg)
  8700. {
  8701. char name[32];
  8702. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  8703. hda_nid_t nid_v, nid_s;
  8704. int i, err;
  8705. for (i = 0; i < cfg->line_outs; i++) {
  8706. if (!spec->multiout.dac_nids[i])
  8707. continue;
  8708. nid_v = alc861vd_idx_to_mixer_vol(
  8709. alc880_dac_to_idx(
  8710. spec->multiout.dac_nids[i]));
  8711. nid_s = alc861vd_idx_to_mixer_switch(
  8712. alc880_dac_to_idx(
  8713. spec->multiout.dac_nids[i]));
  8714. if (i == 2) {
  8715. /* Center/LFE */
  8716. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8717. "Center Playback Volume",
  8718. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  8719. HDA_OUTPUT));
  8720. if (err < 0)
  8721. return err;
  8722. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8723. "LFE Playback Volume",
  8724. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  8725. HDA_OUTPUT));
  8726. if (err < 0)
  8727. return err;
  8728. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8729. "Center Playback Switch",
  8730. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  8731. HDA_INPUT));
  8732. if (err < 0)
  8733. return err;
  8734. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8735. "LFE Playback Switch",
  8736. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  8737. HDA_INPUT));
  8738. if (err < 0)
  8739. return err;
  8740. } else {
  8741. sprintf(name, "%s Playback Volume", chname[i]);
  8742. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8743. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  8744. HDA_OUTPUT));
  8745. if (err < 0)
  8746. return err;
  8747. sprintf(name, "%s Playback Switch", chname[i]);
  8748. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8749. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  8750. HDA_INPUT));
  8751. if (err < 0)
  8752. return err;
  8753. }
  8754. }
  8755. return 0;
  8756. }
  8757. /* add playback controls for speaker and HP outputs */
  8758. /* Based on ALC880 version. But ALC861VD has separate,
  8759. * different NIDs for mute/unmute switch and volume control */
  8760. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  8761. hda_nid_t pin, const char *pfx)
  8762. {
  8763. hda_nid_t nid_v, nid_s;
  8764. int err;
  8765. char name[32];
  8766. if (!pin)
  8767. return 0;
  8768. if (alc880_is_fixed_pin(pin)) {
  8769. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8770. /* specify the DAC as the extra output */
  8771. if (!spec->multiout.hp_nid)
  8772. spec->multiout.hp_nid = nid_v;
  8773. else
  8774. spec->multiout.extra_out_nid[0] = nid_v;
  8775. /* control HP volume/switch on the output mixer amp */
  8776. nid_v = alc861vd_idx_to_mixer_vol(
  8777. alc880_fixed_pin_idx(pin));
  8778. nid_s = alc861vd_idx_to_mixer_switch(
  8779. alc880_fixed_pin_idx(pin));
  8780. sprintf(name, "%s Playback Volume", pfx);
  8781. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8782. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  8783. if (err < 0)
  8784. return err;
  8785. sprintf(name, "%s Playback Switch", pfx);
  8786. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8787. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  8788. if (err < 0)
  8789. return err;
  8790. } else if (alc880_is_multi_pin(pin)) {
  8791. /* set manual connection */
  8792. /* we have only a switch on HP-out PIN */
  8793. sprintf(name, "%s Playback Switch", pfx);
  8794. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8795. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8796. if (err < 0)
  8797. return err;
  8798. }
  8799. return 0;
  8800. }
  8801. /* parse the BIOS configuration and set up the alc_spec
  8802. * return 1 if successful, 0 if the proper config is not found,
  8803. * or a negative error code
  8804. * Based on ALC880 version - had to change it to override
  8805. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  8806. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  8807. {
  8808. struct alc_spec *spec = codec->spec;
  8809. int err;
  8810. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  8811. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8812. alc861vd_ignore);
  8813. if (err < 0)
  8814. return err;
  8815. if (!spec->autocfg.line_outs)
  8816. return 0; /* can't find valid BIOS pin config */
  8817. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8818. if (err < 0)
  8819. return err;
  8820. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8821. if (err < 0)
  8822. return err;
  8823. err = alc861vd_auto_create_extra_out(spec,
  8824. spec->autocfg.speaker_pins[0],
  8825. "Speaker");
  8826. if (err < 0)
  8827. return err;
  8828. err = alc861vd_auto_create_extra_out(spec,
  8829. spec->autocfg.hp_pins[0],
  8830. "Headphone");
  8831. if (err < 0)
  8832. return err;
  8833. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8834. if (err < 0)
  8835. return err;
  8836. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8837. if (spec->autocfg.dig_out_pin)
  8838. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  8839. if (spec->kctl_alloc)
  8840. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8841. spec->init_verbs[spec->num_init_verbs++]
  8842. = alc861vd_volume_init_verbs;
  8843. spec->num_mux_defs = 1;
  8844. spec->input_mux = &spec->private_imux;
  8845. return 1;
  8846. }
  8847. /* additional initialization for auto-configuration model */
  8848. static void alc861vd_auto_init(struct hda_codec *codec)
  8849. {
  8850. alc861vd_auto_init_multi_out(codec);
  8851. alc861vd_auto_init_hp_out(codec);
  8852. alc861vd_auto_init_analog_input(codec);
  8853. }
  8854. static int patch_alc861vd(struct hda_codec *codec)
  8855. {
  8856. struct alc_spec *spec;
  8857. int err, board_config;
  8858. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8859. if (spec == NULL)
  8860. return -ENOMEM;
  8861. codec->spec = spec;
  8862. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  8863. alc861vd_models,
  8864. alc861vd_cfg_tbl);
  8865. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  8866. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  8867. "ALC861VD, trying auto-probe from BIOS...\n");
  8868. board_config = ALC861VD_AUTO;
  8869. }
  8870. if (board_config == ALC861VD_AUTO) {
  8871. /* automatic parse from the BIOS config */
  8872. err = alc861vd_parse_auto_config(codec);
  8873. if (err < 0) {
  8874. alc_free(codec);
  8875. return err;
  8876. } else if (!err) {
  8877. printk(KERN_INFO
  8878. "hda_codec: Cannot set up configuration "
  8879. "from BIOS. Using base mode...\n");
  8880. board_config = ALC861VD_3ST;
  8881. }
  8882. }
  8883. if (board_config != ALC861VD_AUTO)
  8884. setup_preset(spec, &alc861vd_presets[board_config]);
  8885. spec->stream_name_analog = "ALC861VD Analog";
  8886. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  8887. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  8888. spec->stream_name_digital = "ALC861VD Digital";
  8889. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  8890. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  8891. spec->adc_nids = alc861vd_adc_nids;
  8892. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  8893. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  8894. spec->num_mixers++;
  8895. codec->patch_ops = alc_patch_ops;
  8896. if (board_config == ALC861VD_AUTO)
  8897. spec->init_hook = alc861vd_auto_init;
  8898. return 0;
  8899. }
  8900. /*
  8901. * ALC662 support
  8902. *
  8903. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  8904. * configuration. Each pin widget can choose any input DACs and a mixer.
  8905. * Each ADC is connected from a mixer of all inputs. This makes possible
  8906. * 6-channel independent captures.
  8907. *
  8908. * In addition, an independent DAC for the multi-playback (not used in this
  8909. * driver yet).
  8910. */
  8911. #define ALC662_DIGOUT_NID 0x06
  8912. #define ALC662_DIGIN_NID 0x0a
  8913. static hda_nid_t alc662_dac_nids[4] = {
  8914. /* front, rear, clfe, rear_surr */
  8915. 0x02, 0x03, 0x04
  8916. };
  8917. static hda_nid_t alc662_adc_nids[1] = {
  8918. /* ADC1-2 */
  8919. 0x09,
  8920. };
  8921. /* input MUX */
  8922. /* FIXME: should be a matrix-type input source selection */
  8923. static struct hda_input_mux alc662_capture_source = {
  8924. .num_items = 4,
  8925. .items = {
  8926. { "Mic", 0x0 },
  8927. { "Front Mic", 0x1 },
  8928. { "Line", 0x2 },
  8929. { "CD", 0x4 },
  8930. },
  8931. };
  8932. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  8933. .num_items = 2,
  8934. .items = {
  8935. { "Mic", 0x1 },
  8936. { "Line", 0x2 },
  8937. },
  8938. };
  8939. #define alc662_mux_enum_info alc_mux_enum_info
  8940. #define alc662_mux_enum_get alc_mux_enum_get
  8941. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  8942. struct snd_ctl_elem_value *ucontrol)
  8943. {
  8944. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8945. struct alc_spec *spec = codec->spec;
  8946. const struct hda_input_mux *imux = spec->input_mux;
  8947. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8948. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  8949. hda_nid_t nid = capture_mixers[adc_idx];
  8950. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8951. unsigned int i, idx;
  8952. idx = ucontrol->value.enumerated.item[0];
  8953. if (idx >= imux->num_items)
  8954. idx = imux->num_items - 1;
  8955. if (*cur_val == idx && !codec->in_resume)
  8956. return 0;
  8957. for (i = 0; i < imux->num_items; i++) {
  8958. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8959. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8960. v | (imux->items[i].index << 8));
  8961. }
  8962. *cur_val = idx;
  8963. return 1;
  8964. }
  8965. /*
  8966. * 2ch mode
  8967. */
  8968. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  8969. { 2, NULL }
  8970. };
  8971. /*
  8972. * 2ch mode
  8973. */
  8974. static struct hda_verb alc662_3ST_ch2_init[] = {
  8975. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  8976. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8977. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  8978. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8979. { } /* end */
  8980. };
  8981. /*
  8982. * 6ch mode
  8983. */
  8984. static struct hda_verb alc662_3ST_ch6_init[] = {
  8985. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8986. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8987. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  8988. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8989. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8990. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8991. { } /* end */
  8992. };
  8993. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  8994. { 2, alc662_3ST_ch2_init },
  8995. { 6, alc662_3ST_ch6_init },
  8996. };
  8997. /*
  8998. * 2ch mode
  8999. */
  9000. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9001. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9002. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9003. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9004. { } /* end */
  9005. };
  9006. /*
  9007. * 6ch mode
  9008. */
  9009. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9010. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9011. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9012. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9013. { } /* end */
  9014. };
  9015. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9016. { 2, alc662_sixstack_ch6_init },
  9017. { 6, alc662_sixstack_ch8_init },
  9018. };
  9019. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9020. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9021. */
  9022. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9023. /* output mixer control */
  9024. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9025. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9026. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9027. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9028. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9029. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9030. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9031. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9032. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9033. /*Input mixer control */
  9034. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9035. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9036. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9037. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9038. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9039. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9040. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9041. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9042. /* Capture mixer control */
  9043. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9044. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9045. {
  9046. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9047. .name = "Capture Source",
  9048. .count = 1,
  9049. .info = alc_mux_enum_info,
  9050. .get = alc_mux_enum_get,
  9051. .put = alc_mux_enum_put,
  9052. },
  9053. { } /* end */
  9054. };
  9055. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9056. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9057. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9058. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9059. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9060. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9061. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9062. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9063. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9064. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9065. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9066. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9067. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9068. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9069. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9070. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9071. {
  9072. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9073. /* .name = "Capture Source", */
  9074. .name = "Input Source",
  9075. .count = 1,
  9076. .info = alc662_mux_enum_info,
  9077. .get = alc662_mux_enum_get,
  9078. .put = alc662_mux_enum_put,
  9079. },
  9080. { } /* end */
  9081. };
  9082. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9083. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9084. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9085. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9086. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9087. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9088. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9089. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9090. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9091. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9092. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9093. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9094. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9095. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9096. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9097. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9098. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9099. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9100. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9101. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9102. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9103. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9104. {
  9105. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9106. /* .name = "Capture Source", */
  9107. .name = "Input Source",
  9108. .count = 1,
  9109. .info = alc662_mux_enum_info,
  9110. .get = alc662_mux_enum_get,
  9111. .put = alc662_mux_enum_put,
  9112. },
  9113. { } /* end */
  9114. };
  9115. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9116. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9117. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9118. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9119. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9120. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9121. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9122. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9123. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9124. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9125. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9126. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9127. {
  9128. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9129. /* .name = "Capture Source", */
  9130. .name = "Input Source",
  9131. .count = 1,
  9132. .info = alc662_mux_enum_info,
  9133. .get = alc662_mux_enum_get,
  9134. .put = alc662_mux_enum_put,
  9135. },
  9136. { } /* end */
  9137. };
  9138. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9139. {
  9140. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9141. .name = "Channel Mode",
  9142. .info = alc_ch_mode_info,
  9143. .get = alc_ch_mode_get,
  9144. .put = alc_ch_mode_put,
  9145. },
  9146. { } /* end */
  9147. };
  9148. static struct hda_verb alc662_init_verbs[] = {
  9149. /* ADC: mute amp left and right */
  9150. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9151. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9152. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9153. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9154. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9155. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9156. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9157. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9158. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9159. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9160. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9161. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9162. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9163. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9164. /* Front Pin: output 0 (0x0c) */
  9165. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9166. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9167. /* Rear Pin: output 1 (0x0d) */
  9168. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9169. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9170. /* CLFE Pin: output 2 (0x0e) */
  9171. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9172. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9173. /* Mic (rear) pin: input vref at 80% */
  9174. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9175. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9176. /* Front Mic pin: input vref at 80% */
  9177. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9178. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9179. /* Line In pin: input */
  9180. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9181. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9182. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9183. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9184. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9185. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9186. /* CD pin widget for input */
  9187. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9188. /* FIXME: use matrix-type input source selection */
  9189. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9190. /* Input mixer */
  9191. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9192. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9193. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9194. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9195. { }
  9196. };
  9197. static struct hda_verb alc662_sue_init_verbs[] = {
  9198. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9199. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9200. {}
  9201. };
  9202. /*
  9203. * generic initialization of ADC, input mixers and output mixers
  9204. */
  9205. static struct hda_verb alc662_auto_init_verbs[] = {
  9206. /*
  9207. * Unmute ADC and set the default input to mic-in
  9208. */
  9209. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9210. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9211. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9212. * mixer widget
  9213. * Note: PASD motherboards uses the Line In 2 as the input for front
  9214. * panel mic (mic 2)
  9215. */
  9216. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9217. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9218. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9219. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9220. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9221. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9222. /*
  9223. * Set up output mixers (0x0c - 0x0f)
  9224. */
  9225. /* set vol=0 to output mixers */
  9226. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9227. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9228. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9229. /* set up input amps for analog loopback */
  9230. /* Amp Indices: DAC = 0, mixer = 1 */
  9231. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9232. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9233. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9234. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9235. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9236. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9237. /* FIXME: use matrix-type input source selection */
  9238. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9239. /* Input mixer */
  9240. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9241. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9242. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9243. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9244. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9245. { }
  9246. };
  9247. /* capture mixer elements */
  9248. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9249. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9250. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9251. {
  9252. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9253. /* The multiple "Capture Source" controls confuse alsamixer
  9254. * So call somewhat different..
  9255. * FIXME: the controls appear in the "playback" view!
  9256. */
  9257. /* .name = "Capture Source", */
  9258. .name = "Input Source",
  9259. .count = 1,
  9260. .info = alc882_mux_enum_info,
  9261. .get = alc882_mux_enum_get,
  9262. .put = alc882_mux_enum_put,
  9263. },
  9264. { } /* end */
  9265. };
  9266. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9267. {
  9268. unsigned int present;
  9269. unsigned char bits;
  9270. present = snd_hda_codec_read(codec, 0x14, 0,
  9271. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9272. bits = present ? 0x80 : 0;
  9273. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9274. 0x80, bits);
  9275. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9276. 0x80, bits);
  9277. }
  9278. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9279. {
  9280. unsigned int present;
  9281. unsigned char bits;
  9282. present = snd_hda_codec_read(codec, 0x1b, 0,
  9283. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9284. bits = present ? 0x80 : 0;
  9285. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9286. 0x80, bits);
  9287. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9288. 0x80, bits);
  9289. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9290. 0x80, bits);
  9291. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9292. 0x80, bits);
  9293. }
  9294. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9295. unsigned int res)
  9296. {
  9297. if ((res >> 26) == ALC880_HP_EVENT)
  9298. alc662_lenovo_101e_all_automute(codec);
  9299. if ((res >> 26) == ALC880_FRONT_EVENT)
  9300. alc662_lenovo_101e_ispeaker_automute(codec);
  9301. }
  9302. /* pcm configuration: identiacal with ALC880 */
  9303. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9304. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9305. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9306. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9307. /*
  9308. * configuration and preset
  9309. */
  9310. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9311. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9312. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9313. [ALC662_3ST_6ch] = "3stack-6ch",
  9314. [ALC662_5ST_DIG] = "6stack-dig",
  9315. [ALC662_LENOVO_101E] = "lenovo-101e",
  9316. [ALC662_AUTO] = "auto",
  9317. };
  9318. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9319. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9320. {}
  9321. };
  9322. static struct alc_config_preset alc662_presets[] = {
  9323. [ALC662_3ST_2ch_DIG] = {
  9324. .mixers = { alc662_3ST_2ch_mixer },
  9325. .init_verbs = { alc662_init_verbs },
  9326. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9327. .dac_nids = alc662_dac_nids,
  9328. .dig_out_nid = ALC662_DIGOUT_NID,
  9329. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9330. .adc_nids = alc662_adc_nids,
  9331. .dig_in_nid = ALC662_DIGIN_NID,
  9332. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9333. .channel_mode = alc662_3ST_2ch_modes,
  9334. .input_mux = &alc662_capture_source,
  9335. },
  9336. [ALC662_3ST_6ch_DIG] = {
  9337. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9338. .init_verbs = { alc662_init_verbs },
  9339. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9340. .dac_nids = alc662_dac_nids,
  9341. .dig_out_nid = ALC662_DIGOUT_NID,
  9342. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9343. .adc_nids = alc662_adc_nids,
  9344. .dig_in_nid = ALC662_DIGIN_NID,
  9345. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9346. .channel_mode = alc662_3ST_6ch_modes,
  9347. .need_dac_fix = 1,
  9348. .input_mux = &alc662_capture_source,
  9349. },
  9350. [ALC662_3ST_6ch] = {
  9351. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9352. .init_verbs = { alc662_init_verbs },
  9353. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9354. .dac_nids = alc662_dac_nids,
  9355. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9356. .adc_nids = alc662_adc_nids,
  9357. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9358. .channel_mode = alc662_3ST_6ch_modes,
  9359. .need_dac_fix = 1,
  9360. .input_mux = &alc662_capture_source,
  9361. },
  9362. [ALC662_5ST_DIG] = {
  9363. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9364. .init_verbs = { alc662_init_verbs },
  9365. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9366. .dac_nids = alc662_dac_nids,
  9367. .dig_out_nid = ALC662_DIGOUT_NID,
  9368. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9369. .adc_nids = alc662_adc_nids,
  9370. .dig_in_nid = ALC662_DIGIN_NID,
  9371. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9372. .channel_mode = alc662_5stack_modes,
  9373. .input_mux = &alc662_capture_source,
  9374. },
  9375. [ALC662_LENOVO_101E] = {
  9376. .mixers = { alc662_lenovo_101e_mixer },
  9377. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9378. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9379. .dac_nids = alc662_dac_nids,
  9380. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9381. .adc_nids = alc662_adc_nids,
  9382. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9383. .channel_mode = alc662_3ST_2ch_modes,
  9384. .input_mux = &alc662_lenovo_101e_capture_source,
  9385. .unsol_event = alc662_lenovo_101e_unsol_event,
  9386. .init_hook = alc662_lenovo_101e_all_automute,
  9387. },
  9388. };
  9389. /*
  9390. * BIOS auto configuration
  9391. */
  9392. /* add playback controls from the parsed DAC table */
  9393. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9394. const struct auto_pin_cfg *cfg)
  9395. {
  9396. char name[32];
  9397. static const char *chname[4] = {
  9398. "Front", "Surround", NULL /*CLFE*/, "Side"
  9399. };
  9400. hda_nid_t nid;
  9401. int i, err;
  9402. for (i = 0; i < cfg->line_outs; i++) {
  9403. if (!spec->multiout.dac_nids[i])
  9404. continue;
  9405. nid = alc880_idx_to_dac(i);
  9406. if (i == 2) {
  9407. /* Center/LFE */
  9408. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9409. "Center Playback Volume",
  9410. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9411. HDA_OUTPUT));
  9412. if (err < 0)
  9413. return err;
  9414. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9415. "LFE Playback Volume",
  9416. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9417. HDA_OUTPUT));
  9418. if (err < 0)
  9419. return err;
  9420. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9421. "Center Playback Switch",
  9422. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9423. HDA_INPUT));
  9424. if (err < 0)
  9425. return err;
  9426. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9427. "LFE Playback Switch",
  9428. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9429. HDA_INPUT));
  9430. if (err < 0)
  9431. return err;
  9432. } else {
  9433. sprintf(name, "%s Playback Volume", chname[i]);
  9434. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9435. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9436. HDA_OUTPUT));
  9437. if (err < 0)
  9438. return err;
  9439. sprintf(name, "%s Playback Switch", chname[i]);
  9440. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9441. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9442. HDA_INPUT));
  9443. if (err < 0)
  9444. return err;
  9445. }
  9446. }
  9447. return 0;
  9448. }
  9449. /* add playback controls for speaker and HP outputs */
  9450. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9451. const char *pfx)
  9452. {
  9453. hda_nid_t nid;
  9454. int err;
  9455. char name[32];
  9456. if (!pin)
  9457. return 0;
  9458. if (alc880_is_fixed_pin(pin)) {
  9459. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9460. /* printk("DAC nid=%x\n",nid); */
  9461. /* specify the DAC as the extra output */
  9462. if (!spec->multiout.hp_nid)
  9463. spec->multiout.hp_nid = nid;
  9464. else
  9465. spec->multiout.extra_out_nid[0] = nid;
  9466. /* control HP volume/switch on the output mixer amp */
  9467. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9468. sprintf(name, "%s Playback Volume", pfx);
  9469. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9470. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9471. if (err < 0)
  9472. return err;
  9473. sprintf(name, "%s Playback Switch", pfx);
  9474. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9475. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9476. if (err < 0)
  9477. return err;
  9478. } else if (alc880_is_multi_pin(pin)) {
  9479. /* set manual connection */
  9480. /* we have only a switch on HP-out PIN */
  9481. sprintf(name, "%s Playback Switch", pfx);
  9482. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9483. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9484. if (err < 0)
  9485. return err;
  9486. }
  9487. return 0;
  9488. }
  9489. /* create playback/capture controls for input pins */
  9490. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9491. const struct auto_pin_cfg *cfg)
  9492. {
  9493. struct hda_input_mux *imux = &spec->private_imux;
  9494. int i, err, idx;
  9495. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9496. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9497. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9498. err = new_analog_input(spec, cfg->input_pins[i],
  9499. auto_pin_cfg_labels[i],
  9500. idx, 0x0b);
  9501. if (err < 0)
  9502. return err;
  9503. imux->items[imux->num_items].label =
  9504. auto_pin_cfg_labels[i];
  9505. imux->items[imux->num_items].index =
  9506. alc880_input_pin_idx(cfg->input_pins[i]);
  9507. imux->num_items++;
  9508. }
  9509. }
  9510. return 0;
  9511. }
  9512. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9513. hda_nid_t nid, int pin_type,
  9514. int dac_idx)
  9515. {
  9516. /* set as output */
  9517. snd_hda_codec_write(codec, nid, 0,
  9518. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9519. snd_hda_codec_write(codec, nid, 0,
  9520. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9521. /* need the manual connection? */
  9522. if (alc880_is_multi_pin(nid)) {
  9523. struct alc_spec *spec = codec->spec;
  9524. int idx = alc880_multi_pin_idx(nid);
  9525. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  9526. AC_VERB_SET_CONNECT_SEL,
  9527. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  9528. }
  9529. }
  9530. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  9531. {
  9532. struct alc_spec *spec = codec->spec;
  9533. int i;
  9534. for (i = 0; i <= HDA_SIDE; i++) {
  9535. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9536. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9537. if (nid)
  9538. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  9539. i);
  9540. }
  9541. }
  9542. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  9543. {
  9544. struct alc_spec *spec = codec->spec;
  9545. hda_nid_t pin;
  9546. pin = spec->autocfg.hp_pins[0];
  9547. if (pin) /* connect to front */
  9548. /* use dac 0 */
  9549. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9550. }
  9551. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  9552. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  9553. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  9554. {
  9555. struct alc_spec *spec = codec->spec;
  9556. int i;
  9557. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9558. hda_nid_t nid = spec->autocfg.input_pins[i];
  9559. if (alc662_is_input_pin(nid)) {
  9560. snd_hda_codec_write(codec, nid, 0,
  9561. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9562. (i <= AUTO_PIN_FRONT_MIC ?
  9563. PIN_VREF80 : PIN_IN));
  9564. if (nid != ALC662_PIN_CD_NID)
  9565. snd_hda_codec_write(codec, nid, 0,
  9566. AC_VERB_SET_AMP_GAIN_MUTE,
  9567. AMP_OUT_MUTE);
  9568. }
  9569. }
  9570. }
  9571. static int alc662_parse_auto_config(struct hda_codec *codec)
  9572. {
  9573. struct alc_spec *spec = codec->spec;
  9574. int err;
  9575. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  9576. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9577. alc662_ignore);
  9578. if (err < 0)
  9579. return err;
  9580. if (!spec->autocfg.line_outs)
  9581. return 0; /* can't find valid BIOS pin config */
  9582. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9583. if (err < 0)
  9584. return err;
  9585. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9586. if (err < 0)
  9587. return err;
  9588. err = alc662_auto_create_extra_out(spec,
  9589. spec->autocfg.speaker_pins[0],
  9590. "Speaker");
  9591. if (err < 0)
  9592. return err;
  9593. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  9594. "Headphone");
  9595. if (err < 0)
  9596. return err;
  9597. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9598. if (err < 0)
  9599. return err;
  9600. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9601. if (spec->autocfg.dig_out_pin)
  9602. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  9603. if (spec->kctl_alloc)
  9604. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9605. spec->num_mux_defs = 1;
  9606. spec->input_mux = &spec->private_imux;
  9607. if (err < 0)
  9608. return err;
  9609. else if (err > 0)
  9610. /* hack - override the init verbs */
  9611. spec->init_verbs[0] = alc662_auto_init_verbs;
  9612. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  9613. spec->num_mixers++;
  9614. return err;
  9615. }
  9616. /* additional initialization for auto-configuration model */
  9617. static void alc662_auto_init(struct hda_codec *codec)
  9618. {
  9619. alc662_auto_init_multi_out(codec);
  9620. alc662_auto_init_hp_out(codec);
  9621. alc662_auto_init_analog_input(codec);
  9622. }
  9623. static int patch_alc662(struct hda_codec *codec)
  9624. {
  9625. struct alc_spec *spec;
  9626. int err, board_config;
  9627. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9628. if (!spec)
  9629. return -ENOMEM;
  9630. codec->spec = spec;
  9631. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  9632. alc662_models,
  9633. alc662_cfg_tbl);
  9634. if (board_config < 0) {
  9635. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  9636. "trying auto-probe from BIOS...\n");
  9637. board_config = ALC662_AUTO;
  9638. }
  9639. if (board_config == ALC662_AUTO) {
  9640. /* automatic parse from the BIOS config */
  9641. err = alc662_parse_auto_config(codec);
  9642. if (err < 0) {
  9643. alc_free(codec);
  9644. return err;
  9645. } else if (err) {
  9646. printk(KERN_INFO
  9647. "hda_codec: Cannot set up configuration "
  9648. "from BIOS. Using base mode...\n");
  9649. board_config = ALC662_3ST_2ch_DIG;
  9650. }
  9651. }
  9652. if (board_config != ALC662_AUTO)
  9653. setup_preset(spec, &alc662_presets[board_config]);
  9654. spec->stream_name_analog = "ALC662 Analog";
  9655. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  9656. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  9657. spec->stream_name_digital = "ALC662 Digital";
  9658. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  9659. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  9660. if (!spec->adc_nids && spec->input_mux) {
  9661. spec->adc_nids = alc662_adc_nids;
  9662. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  9663. }
  9664. codec->patch_ops = alc_patch_ops;
  9665. if (board_config == ALC662_AUTO)
  9666. spec->init_hook = alc662_auto_init;
  9667. return 0;
  9668. }
  9669. /*
  9670. * patch entries
  9671. */
  9672. struct hda_codec_preset snd_hda_preset_realtek[] = {
  9673. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  9674. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  9675. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  9676. .patch = patch_alc861 },
  9677. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  9678. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  9679. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  9680. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  9681. .patch = patch_alc883 },
  9682. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  9683. .patch = patch_alc662 },
  9684. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  9685. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  9686. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  9687. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  9688. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  9689. {} /* terminator */
  9690. };