patch_realtek.c 387 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC885_IMAC24,
  147. ALC882_AUTO,
  148. ALC882_MODEL_LAST,
  149. };
  150. /* ALC883 models */
  151. enum {
  152. ALC883_3ST_2ch_DIG,
  153. ALC883_3ST_6ch_DIG,
  154. ALC883_3ST_6ch,
  155. ALC883_6ST_DIG,
  156. ALC883_TARGA_DIG,
  157. ALC883_TARGA_2ch_DIG,
  158. ALC883_ACER,
  159. ALC883_ACER_ASPIRE,
  160. ALC883_MEDION,
  161. ALC883_MEDION_MD2,
  162. ALC883_LAPTOP_EAPD,
  163. ALC883_LENOVO_101E_2ch,
  164. ALC883_LENOVO_NB0763,
  165. ALC888_LENOVO_MS7195_DIG,
  166. ALC888_6ST_HP,
  167. ALC888_3ST_HP,
  168. ALC883_AUTO,
  169. ALC883_MODEL_LAST,
  170. };
  171. /* for GPIO Poll */
  172. #define GPIO_MASK 0x03
  173. struct alc_spec {
  174. /* codec parameterization */
  175. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  176. unsigned int num_mixers;
  177. const struct hda_verb *init_verbs[5]; /* initialization verbs
  178. * don't forget NULL
  179. * termination!
  180. */
  181. unsigned int num_init_verbs;
  182. char *stream_name_analog; /* analog PCM stream */
  183. struct hda_pcm_stream *stream_analog_playback;
  184. struct hda_pcm_stream *stream_analog_capture;
  185. char *stream_name_digital; /* digital PCM stream */
  186. struct hda_pcm_stream *stream_digital_playback;
  187. struct hda_pcm_stream *stream_digital_capture;
  188. /* playback */
  189. struct hda_multi_out multiout; /* playback set-up
  190. * max_channels, dacs must be set
  191. * dig_out_nid and hp_nid are optional
  192. */
  193. /* capture */
  194. unsigned int num_adc_nids;
  195. hda_nid_t *adc_nids;
  196. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  197. /* capture source */
  198. unsigned int num_mux_defs;
  199. const struct hda_input_mux *input_mux;
  200. unsigned int cur_mux[3];
  201. /* channel model */
  202. const struct hda_channel_mode *channel_mode;
  203. int num_channel_mode;
  204. int need_dac_fix;
  205. /* PCM information */
  206. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  207. /* dynamic controls, init_verbs and input_mux */
  208. struct auto_pin_cfg autocfg;
  209. unsigned int num_kctl_alloc, num_kctl_used;
  210. struct snd_kcontrol_new *kctl_alloc;
  211. struct hda_input_mux private_imux;
  212. hda_nid_t private_dac_nids[5];
  213. /* hooks */
  214. void (*init_hook)(struct hda_codec *codec);
  215. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  216. /* for pin sensing */
  217. unsigned int sense_updated: 1;
  218. unsigned int jack_present: 1;
  219. };
  220. /*
  221. * configuration template - to be copied to the spec instance
  222. */
  223. struct alc_config_preset {
  224. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  225. * with spec
  226. */
  227. const struct hda_verb *init_verbs[5];
  228. unsigned int num_dacs;
  229. hda_nid_t *dac_nids;
  230. hda_nid_t dig_out_nid; /* optional */
  231. hda_nid_t hp_nid; /* optional */
  232. unsigned int num_adc_nids;
  233. hda_nid_t *adc_nids;
  234. hda_nid_t dig_in_nid;
  235. unsigned int num_channel_mode;
  236. const struct hda_channel_mode *channel_mode;
  237. int need_dac_fix;
  238. unsigned int num_mux_defs;
  239. const struct hda_input_mux *input_mux;
  240. void (*unsol_event)(struct hda_codec *, unsigned int);
  241. void (*init_hook)(struct hda_codec *);
  242. };
  243. /*
  244. * input MUX handling
  245. */
  246. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  247. struct snd_ctl_elem_info *uinfo)
  248. {
  249. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  250. struct alc_spec *spec = codec->spec;
  251. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  252. if (mux_idx >= spec->num_mux_defs)
  253. mux_idx = 0;
  254. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  255. }
  256. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  257. struct snd_ctl_elem_value *ucontrol)
  258. {
  259. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  260. struct alc_spec *spec = codec->spec;
  261. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  262. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  263. return 0;
  264. }
  265. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  266. struct snd_ctl_elem_value *ucontrol)
  267. {
  268. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  269. struct alc_spec *spec = codec->spec;
  270. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  271. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  272. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  273. spec->adc_nids[adc_idx],
  274. &spec->cur_mux[adc_idx]);
  275. }
  276. /*
  277. * channel mode setting
  278. */
  279. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  280. struct snd_ctl_elem_info *uinfo)
  281. {
  282. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  283. struct alc_spec *spec = codec->spec;
  284. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  285. spec->num_channel_mode);
  286. }
  287. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  288. struct snd_ctl_elem_value *ucontrol)
  289. {
  290. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  291. struct alc_spec *spec = codec->spec;
  292. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  293. spec->num_channel_mode,
  294. spec->multiout.max_channels);
  295. }
  296. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  297. struct snd_ctl_elem_value *ucontrol)
  298. {
  299. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  300. struct alc_spec *spec = codec->spec;
  301. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  302. spec->num_channel_mode,
  303. &spec->multiout.max_channels);
  304. if (err >= 0 && spec->need_dac_fix)
  305. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  306. return err;
  307. }
  308. /*
  309. * Control the mode of pin widget settings via the mixer. "pc" is used
  310. * instead of "%" to avoid consequences of accidently treating the % as
  311. * being part of a format specifier. Maximum allowed length of a value is
  312. * 63 characters plus NULL terminator.
  313. *
  314. * Note: some retasking pin complexes seem to ignore requests for input
  315. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  316. * are requested. Therefore order this list so that this behaviour will not
  317. * cause problems when mixer clients move through the enum sequentially.
  318. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  319. * March 2006.
  320. */
  321. static char *alc_pin_mode_names[] = {
  322. "Mic 50pc bias", "Mic 80pc bias",
  323. "Line in", "Line out", "Headphone out",
  324. };
  325. static unsigned char alc_pin_mode_values[] = {
  326. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  327. };
  328. /* The control can present all 5 options, or it can limit the options based
  329. * in the pin being assumed to be exclusively an input or an output pin. In
  330. * addition, "input" pins may or may not process the mic bias option
  331. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  332. * accept requests for bias as of chip versions up to March 2006) and/or
  333. * wiring in the computer.
  334. */
  335. #define ALC_PIN_DIR_IN 0x00
  336. #define ALC_PIN_DIR_OUT 0x01
  337. #define ALC_PIN_DIR_INOUT 0x02
  338. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  339. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  340. /* Info about the pin modes supported by the different pin direction modes.
  341. * For each direction the minimum and maximum values are given.
  342. */
  343. static signed char alc_pin_mode_dir_info[5][2] = {
  344. { 0, 2 }, /* ALC_PIN_DIR_IN */
  345. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  346. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  347. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  348. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  349. };
  350. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  351. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  352. #define alc_pin_mode_n_items(_dir) \
  353. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  354. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  355. struct snd_ctl_elem_info *uinfo)
  356. {
  357. unsigned int item_num = uinfo->value.enumerated.item;
  358. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  359. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  360. uinfo->count = 1;
  361. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  362. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  363. item_num = alc_pin_mode_min(dir);
  364. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  365. return 0;
  366. }
  367. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  368. struct snd_ctl_elem_value *ucontrol)
  369. {
  370. unsigned int i;
  371. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  372. hda_nid_t nid = kcontrol->private_value & 0xffff;
  373. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  374. long *valp = ucontrol->value.integer.value;
  375. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  376. AC_VERB_GET_PIN_WIDGET_CONTROL,
  377. 0x00);
  378. /* Find enumerated value for current pinctl setting */
  379. i = alc_pin_mode_min(dir);
  380. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  381. i++;
  382. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  383. return 0;
  384. }
  385. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  386. struct snd_ctl_elem_value *ucontrol)
  387. {
  388. signed int change;
  389. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  390. hda_nid_t nid = kcontrol->private_value & 0xffff;
  391. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  392. long val = *ucontrol->value.integer.value;
  393. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  394. AC_VERB_GET_PIN_WIDGET_CONTROL,
  395. 0x00);
  396. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  397. val = alc_pin_mode_min(dir);
  398. change = pinctl != alc_pin_mode_values[val];
  399. if (change) {
  400. /* Set pin mode to that requested */
  401. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  402. alc_pin_mode_values[val]);
  403. /* Also enable the retasking pin's input/output as required
  404. * for the requested pin mode. Enum values of 2 or less are
  405. * input modes.
  406. *
  407. * Dynamically switching the input/output buffers probably
  408. * reduces noise slightly (particularly on input) so we'll
  409. * do it. However, having both input and output buffers
  410. * enabled simultaneously doesn't seem to be problematic if
  411. * this turns out to be necessary in the future.
  412. */
  413. if (val <= 2) {
  414. snd_hda_codec_write(codec, nid, 0,
  415. AC_VERB_SET_AMP_GAIN_MUTE,
  416. AMP_OUT_MUTE);
  417. snd_hda_codec_write(codec, nid, 0,
  418. AC_VERB_SET_AMP_GAIN_MUTE,
  419. AMP_IN_UNMUTE(0));
  420. } else {
  421. snd_hda_codec_write(codec, nid, 0,
  422. AC_VERB_SET_AMP_GAIN_MUTE,
  423. AMP_IN_MUTE(0));
  424. snd_hda_codec_write(codec, nid, 0,
  425. AC_VERB_SET_AMP_GAIN_MUTE,
  426. AMP_OUT_UNMUTE);
  427. }
  428. }
  429. return change;
  430. }
  431. #define ALC_PIN_MODE(xname, nid, dir) \
  432. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  433. .info = alc_pin_mode_info, \
  434. .get = alc_pin_mode_get, \
  435. .put = alc_pin_mode_put, \
  436. .private_value = nid | (dir<<16) }
  437. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  438. * together using a mask with more than one bit set. This control is
  439. * currently used only by the ALC260 test model. At this stage they are not
  440. * needed for any "production" models.
  441. */
  442. #ifdef CONFIG_SND_DEBUG
  443. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  444. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  445. struct snd_ctl_elem_value *ucontrol)
  446. {
  447. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  448. hda_nid_t nid = kcontrol->private_value & 0xffff;
  449. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  450. long *valp = ucontrol->value.integer.value;
  451. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  452. AC_VERB_GET_GPIO_DATA, 0x00);
  453. *valp = (val & mask) != 0;
  454. return 0;
  455. }
  456. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  457. struct snd_ctl_elem_value *ucontrol)
  458. {
  459. signed int change;
  460. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  461. hda_nid_t nid = kcontrol->private_value & 0xffff;
  462. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  463. long val = *ucontrol->value.integer.value;
  464. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  465. AC_VERB_GET_GPIO_DATA,
  466. 0x00);
  467. /* Set/unset the masked GPIO bit(s) as needed */
  468. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  469. if (val == 0)
  470. gpio_data &= ~mask;
  471. else
  472. gpio_data |= mask;
  473. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  474. return change;
  475. }
  476. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  477. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  478. .info = alc_gpio_data_info, \
  479. .get = alc_gpio_data_get, \
  480. .put = alc_gpio_data_put, \
  481. .private_value = nid | (mask<<16) }
  482. #endif /* CONFIG_SND_DEBUG */
  483. /* A switch control to allow the enabling of the digital IO pins on the
  484. * ALC260. This is incredibly simplistic; the intention of this control is
  485. * to provide something in the test model allowing digital outputs to be
  486. * identified if present. If models are found which can utilise these
  487. * outputs a more complete mixer control can be devised for those models if
  488. * necessary.
  489. */
  490. #ifdef CONFIG_SND_DEBUG
  491. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  492. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  493. struct snd_ctl_elem_value *ucontrol)
  494. {
  495. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  496. hda_nid_t nid = kcontrol->private_value & 0xffff;
  497. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  498. long *valp = ucontrol->value.integer.value;
  499. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  500. AC_VERB_GET_DIGI_CONVERT, 0x00);
  501. *valp = (val & mask) != 0;
  502. return 0;
  503. }
  504. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  505. struct snd_ctl_elem_value *ucontrol)
  506. {
  507. signed int change;
  508. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  509. hda_nid_t nid = kcontrol->private_value & 0xffff;
  510. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  511. long val = *ucontrol->value.integer.value;
  512. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  513. AC_VERB_GET_DIGI_CONVERT,
  514. 0x00);
  515. /* Set/unset the masked control bit(s) as needed */
  516. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  517. if (val==0)
  518. ctrl_data &= ~mask;
  519. else
  520. ctrl_data |= mask;
  521. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  522. ctrl_data);
  523. return change;
  524. }
  525. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  526. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  527. .info = alc_spdif_ctrl_info, \
  528. .get = alc_spdif_ctrl_get, \
  529. .put = alc_spdif_ctrl_put, \
  530. .private_value = nid | (mask<<16) }
  531. #endif /* CONFIG_SND_DEBUG */
  532. /*
  533. * set up from the preset table
  534. */
  535. static void setup_preset(struct alc_spec *spec,
  536. const struct alc_config_preset *preset)
  537. {
  538. int i;
  539. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  540. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  541. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  542. i++)
  543. spec->init_verbs[spec->num_init_verbs++] =
  544. preset->init_verbs[i];
  545. spec->channel_mode = preset->channel_mode;
  546. spec->num_channel_mode = preset->num_channel_mode;
  547. spec->need_dac_fix = preset->need_dac_fix;
  548. spec->multiout.max_channels = spec->channel_mode[0].channels;
  549. spec->multiout.num_dacs = preset->num_dacs;
  550. spec->multiout.dac_nids = preset->dac_nids;
  551. spec->multiout.dig_out_nid = preset->dig_out_nid;
  552. spec->multiout.hp_nid = preset->hp_nid;
  553. spec->num_mux_defs = preset->num_mux_defs;
  554. if (!spec->num_mux_defs)
  555. spec->num_mux_defs = 1;
  556. spec->input_mux = preset->input_mux;
  557. spec->num_adc_nids = preset->num_adc_nids;
  558. spec->adc_nids = preset->adc_nids;
  559. spec->dig_in_nid = preset->dig_in_nid;
  560. spec->unsol_event = preset->unsol_event;
  561. spec->init_hook = preset->init_hook;
  562. }
  563. /* Enable GPIO mask and set output */
  564. static struct hda_verb alc_gpio1_init_verbs[] = {
  565. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  566. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  567. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  568. { }
  569. };
  570. static struct hda_verb alc_gpio2_init_verbs[] = {
  571. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  572. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  573. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  574. { }
  575. };
  576. static struct hda_verb alc_gpio3_init_verbs[] = {
  577. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  578. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  579. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  580. { }
  581. };
  582. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  583. * 31 ~ 16 : Manufacture ID
  584. * 15 ~ 8 : SKU ID
  585. * 7 ~ 0 : Assembly ID
  586. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  587. */
  588. static void alc_subsystem_id(struct hda_codec *codec,
  589. unsigned int porta, unsigned int porte,
  590. unsigned int portd)
  591. {
  592. unsigned int ass, tmp;
  593. ass = codec->subsystem_id;
  594. if (!(ass & 1))
  595. return;
  596. /* Override */
  597. tmp = (ass & 0x38) >> 3; /* external Amp control */
  598. switch (tmp) {
  599. case 1:
  600. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  601. break;
  602. case 3:
  603. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  604. break;
  605. case 7:
  606. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  607. break;
  608. case 5:
  609. switch (codec->vendor_id) {
  610. case 0x10ec0862:
  611. case 0x10ec0660:
  612. case 0x10ec0662:
  613. case 0x10ec0267:
  614. case 0x10ec0268:
  615. snd_hda_codec_write(codec, 0x14, 0,
  616. AC_VERB_SET_EAPD_BTLENABLE, 2);
  617. snd_hda_codec_write(codec, 0x15, 0,
  618. AC_VERB_SET_EAPD_BTLENABLE, 2);
  619. return;
  620. }
  621. case 6:
  622. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  623. hda_nid_t port = 0;
  624. tmp = (ass & 0x1800) >> 11;
  625. switch (tmp) {
  626. case 0: port = porta; break;
  627. case 1: port = porte; break;
  628. case 2: port = portd; break;
  629. }
  630. if (port)
  631. snd_hda_codec_write(codec, port, 0,
  632. AC_VERB_SET_EAPD_BTLENABLE,
  633. 2);
  634. }
  635. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  636. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  637. (tmp == 5 ? 0x3040 : 0x3050));
  638. break;
  639. }
  640. }
  641. /*
  642. * Fix-up pin default configurations
  643. */
  644. struct alc_pincfg {
  645. hda_nid_t nid;
  646. u32 val;
  647. };
  648. static void alc_fix_pincfg(struct hda_codec *codec,
  649. const struct snd_pci_quirk *quirk,
  650. const struct alc_pincfg **pinfix)
  651. {
  652. const struct alc_pincfg *cfg;
  653. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  654. if (!quirk)
  655. return;
  656. cfg = pinfix[quirk->value];
  657. for (; cfg->nid; cfg++) {
  658. int i;
  659. u32 val = cfg->val;
  660. for (i = 0; i < 4; i++) {
  661. snd_hda_codec_write(codec, cfg->nid, 0,
  662. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  663. val & 0xff);
  664. val >>= 8;
  665. }
  666. }
  667. }
  668. /*
  669. * ALC880 3-stack model
  670. *
  671. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  672. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  673. * F-Mic = 0x1b, HP = 0x19
  674. */
  675. static hda_nid_t alc880_dac_nids[4] = {
  676. /* front, rear, clfe, rear_surr */
  677. 0x02, 0x05, 0x04, 0x03
  678. };
  679. static hda_nid_t alc880_adc_nids[3] = {
  680. /* ADC0-2 */
  681. 0x07, 0x08, 0x09,
  682. };
  683. /* The datasheet says the node 0x07 is connected from inputs,
  684. * but it shows zero connection in the real implementation on some devices.
  685. * Note: this is a 915GAV bug, fixed on 915GLV
  686. */
  687. static hda_nid_t alc880_adc_nids_alt[2] = {
  688. /* ADC1-2 */
  689. 0x08, 0x09,
  690. };
  691. #define ALC880_DIGOUT_NID 0x06
  692. #define ALC880_DIGIN_NID 0x0a
  693. static struct hda_input_mux alc880_capture_source = {
  694. .num_items = 4,
  695. .items = {
  696. { "Mic", 0x0 },
  697. { "Front Mic", 0x3 },
  698. { "Line", 0x2 },
  699. { "CD", 0x4 },
  700. },
  701. };
  702. /* channel source setting (2/6 channel selection for 3-stack) */
  703. /* 2ch mode */
  704. static struct hda_verb alc880_threestack_ch2_init[] = {
  705. /* set line-in to input, mute it */
  706. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  707. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  708. /* set mic-in to input vref 80%, mute it */
  709. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  710. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  711. { } /* end */
  712. };
  713. /* 6ch mode */
  714. static struct hda_verb alc880_threestack_ch6_init[] = {
  715. /* set line-in to output, unmute it */
  716. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  717. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  718. /* set mic-in to output, unmute it */
  719. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  720. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  721. { } /* end */
  722. };
  723. static struct hda_channel_mode alc880_threestack_modes[2] = {
  724. { 2, alc880_threestack_ch2_init },
  725. { 6, alc880_threestack_ch6_init },
  726. };
  727. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  728. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  729. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  730. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  731. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  732. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  733. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  734. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  735. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  736. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  737. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  738. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  739. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  740. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  741. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  742. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  743. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  744. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  745. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  746. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  747. {
  748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  749. .name = "Channel Mode",
  750. .info = alc_ch_mode_info,
  751. .get = alc_ch_mode_get,
  752. .put = alc_ch_mode_put,
  753. },
  754. { } /* end */
  755. };
  756. /* capture mixer elements */
  757. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  758. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  759. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  760. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  761. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  762. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  763. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  764. {
  765. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  766. /* The multiple "Capture Source" controls confuse alsamixer
  767. * So call somewhat different..
  768. * FIXME: the controls appear in the "playback" view!
  769. */
  770. /* .name = "Capture Source", */
  771. .name = "Input Source",
  772. .count = 3,
  773. .info = alc_mux_enum_info,
  774. .get = alc_mux_enum_get,
  775. .put = alc_mux_enum_put,
  776. },
  777. { } /* end */
  778. };
  779. /* capture mixer elements (in case NID 0x07 not available) */
  780. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  781. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  782. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  783. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  784. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  785. {
  786. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  787. /* The multiple "Capture Source" controls confuse alsamixer
  788. * So call somewhat different..
  789. * FIXME: the controls appear in the "playback" view!
  790. */
  791. /* .name = "Capture Source", */
  792. .name = "Input Source",
  793. .count = 2,
  794. .info = alc_mux_enum_info,
  795. .get = alc_mux_enum_get,
  796. .put = alc_mux_enum_put,
  797. },
  798. { } /* end */
  799. };
  800. /*
  801. * ALC880 5-stack model
  802. *
  803. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  804. * Side = 0x02 (0xd)
  805. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  806. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  807. */
  808. /* additional mixers to alc880_three_stack_mixer */
  809. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  810. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  811. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  812. { } /* end */
  813. };
  814. /* channel source setting (6/8 channel selection for 5-stack) */
  815. /* 6ch mode */
  816. static struct hda_verb alc880_fivestack_ch6_init[] = {
  817. /* set line-in to input, mute it */
  818. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  819. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  820. { } /* end */
  821. };
  822. /* 8ch mode */
  823. static struct hda_verb alc880_fivestack_ch8_init[] = {
  824. /* set line-in to output, unmute it */
  825. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  826. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  827. { } /* end */
  828. };
  829. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  830. { 6, alc880_fivestack_ch6_init },
  831. { 8, alc880_fivestack_ch8_init },
  832. };
  833. /*
  834. * ALC880 6-stack model
  835. *
  836. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  837. * Side = 0x05 (0x0f)
  838. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  839. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  840. */
  841. static hda_nid_t alc880_6st_dac_nids[4] = {
  842. /* front, rear, clfe, rear_surr */
  843. 0x02, 0x03, 0x04, 0x05
  844. };
  845. static struct hda_input_mux alc880_6stack_capture_source = {
  846. .num_items = 4,
  847. .items = {
  848. { "Mic", 0x0 },
  849. { "Front Mic", 0x1 },
  850. { "Line", 0x2 },
  851. { "CD", 0x4 },
  852. },
  853. };
  854. /* fixed 8-channels */
  855. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  856. { 8, NULL },
  857. };
  858. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  859. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  860. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  861. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  862. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  863. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  864. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  865. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  866. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  867. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  868. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  869. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  870. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  871. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  872. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  873. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  874. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  875. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  876. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  877. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  878. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  879. {
  880. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  881. .name = "Channel Mode",
  882. .info = alc_ch_mode_info,
  883. .get = alc_ch_mode_get,
  884. .put = alc_ch_mode_put,
  885. },
  886. { } /* end */
  887. };
  888. /*
  889. * ALC880 W810 model
  890. *
  891. * W810 has rear IO for:
  892. * Front (DAC 02)
  893. * Surround (DAC 03)
  894. * Center/LFE (DAC 04)
  895. * Digital out (06)
  896. *
  897. * The system also has a pair of internal speakers, and a headphone jack.
  898. * These are both connected to Line2 on the codec, hence to DAC 02.
  899. *
  900. * There is a variable resistor to control the speaker or headphone
  901. * volume. This is a hardware-only device without a software API.
  902. *
  903. * Plugging headphones in will disable the internal speakers. This is
  904. * implemented in hardware, not via the driver using jack sense. In
  905. * a similar fashion, plugging into the rear socket marked "front" will
  906. * disable both the speakers and headphones.
  907. *
  908. * For input, there's a microphone jack, and an "audio in" jack.
  909. * These may not do anything useful with this driver yet, because I
  910. * haven't setup any initialization verbs for these yet...
  911. */
  912. static hda_nid_t alc880_w810_dac_nids[3] = {
  913. /* front, rear/surround, clfe */
  914. 0x02, 0x03, 0x04
  915. };
  916. /* fixed 6 channels */
  917. static struct hda_channel_mode alc880_w810_modes[1] = {
  918. { 6, NULL }
  919. };
  920. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  921. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  922. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  923. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  924. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  925. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  926. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  927. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  928. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  929. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  930. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  931. { } /* end */
  932. };
  933. /*
  934. * Z710V model
  935. *
  936. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  937. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  938. * Line = 0x1a
  939. */
  940. static hda_nid_t alc880_z71v_dac_nids[1] = {
  941. 0x02
  942. };
  943. #define ALC880_Z71V_HP_DAC 0x03
  944. /* fixed 2 channels */
  945. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  946. { 2, NULL }
  947. };
  948. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  949. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  950. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  951. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  952. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  953. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  954. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  955. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  956. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  957. { } /* end */
  958. };
  959. /* FIXME! */
  960. /*
  961. * ALC880 F1734 model
  962. *
  963. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  964. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  965. */
  966. static hda_nid_t alc880_f1734_dac_nids[1] = {
  967. 0x03
  968. };
  969. #define ALC880_F1734_HP_DAC 0x02
  970. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  971. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  972. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  973. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  974. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  975. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  976. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  977. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  978. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  979. { } /* end */
  980. };
  981. /* FIXME! */
  982. /*
  983. * ALC880 ASUS model
  984. *
  985. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  986. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  987. * Mic = 0x18, Line = 0x1a
  988. */
  989. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  990. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  991. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  992. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  993. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  994. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  995. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  996. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  997. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  998. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  999. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1000. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1001. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1002. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1003. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1004. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1005. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1006. {
  1007. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1008. .name = "Channel Mode",
  1009. .info = alc_ch_mode_info,
  1010. .get = alc_ch_mode_get,
  1011. .put = alc_ch_mode_put,
  1012. },
  1013. { } /* end */
  1014. };
  1015. /* FIXME! */
  1016. /*
  1017. * ALC880 ASUS W1V model
  1018. *
  1019. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1020. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1021. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1022. */
  1023. /* additional mixers to alc880_asus_mixer */
  1024. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1025. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1027. { } /* end */
  1028. };
  1029. /* additional mixers to alc880_asus_mixer */
  1030. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1031. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1032. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1033. { } /* end */
  1034. };
  1035. /* TCL S700 */
  1036. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1037. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1038. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1039. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1040. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1041. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1042. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1043. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1044. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1045. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1046. {
  1047. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1048. /* The multiple "Capture Source" controls confuse alsamixer
  1049. * So call somewhat different..
  1050. * FIXME: the controls appear in the "playback" view!
  1051. */
  1052. /* .name = "Capture Source", */
  1053. .name = "Input Source",
  1054. .count = 1,
  1055. .info = alc_mux_enum_info,
  1056. .get = alc_mux_enum_get,
  1057. .put = alc_mux_enum_put,
  1058. },
  1059. { } /* end */
  1060. };
  1061. /* Uniwill */
  1062. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1063. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1064. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1065. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1066. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1067. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1068. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1069. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1070. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1071. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1072. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1073. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1074. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1075. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1076. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1078. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1080. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1081. {
  1082. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1083. .name = "Channel Mode",
  1084. .info = alc_ch_mode_info,
  1085. .get = alc_ch_mode_get,
  1086. .put = alc_ch_mode_put,
  1087. },
  1088. { } /* end */
  1089. };
  1090. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1091. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1092. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1093. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1094. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1095. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1096. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1097. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1098. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1099. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1100. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1101. { } /* end */
  1102. };
  1103. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1104. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1105. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1107. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1109. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1110. { } /* end */
  1111. };
  1112. /*
  1113. * build control elements
  1114. */
  1115. static int alc_build_controls(struct hda_codec *codec)
  1116. {
  1117. struct alc_spec *spec = codec->spec;
  1118. int err;
  1119. int i;
  1120. for (i = 0; i < spec->num_mixers; i++) {
  1121. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1122. if (err < 0)
  1123. return err;
  1124. }
  1125. if (spec->multiout.dig_out_nid) {
  1126. err = snd_hda_create_spdif_out_ctls(codec,
  1127. spec->multiout.dig_out_nid);
  1128. if (err < 0)
  1129. return err;
  1130. }
  1131. if (spec->dig_in_nid) {
  1132. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1133. if (err < 0)
  1134. return err;
  1135. }
  1136. return 0;
  1137. }
  1138. /*
  1139. * initialize the codec volumes, etc
  1140. */
  1141. /*
  1142. * generic initialization of ADC, input mixers and output mixers
  1143. */
  1144. static struct hda_verb alc880_volume_init_verbs[] = {
  1145. /*
  1146. * Unmute ADC0-2 and set the default input to mic-in
  1147. */
  1148. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1149. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1150. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1151. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1152. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1153. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1154. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1155. * mixer widget
  1156. * Note: PASD motherboards uses the Line In 2 as the input for front
  1157. * panel mic (mic 2)
  1158. */
  1159. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1160. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1161. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1162. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1163. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1164. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1165. /*
  1166. * Set up output mixers (0x0c - 0x0f)
  1167. */
  1168. /* set vol=0 to output mixers */
  1169. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1170. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1171. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1172. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1173. /* set up input amps for analog loopback */
  1174. /* Amp Indices: DAC = 0, mixer = 1 */
  1175. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1176. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1177. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1178. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1179. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1180. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1181. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1182. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1183. { }
  1184. };
  1185. /*
  1186. * 3-stack pin configuration:
  1187. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1188. */
  1189. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1190. /*
  1191. * preset connection lists of input pins
  1192. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1193. */
  1194. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1195. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1196. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1197. /*
  1198. * Set pin mode and muting
  1199. */
  1200. /* set front pin widgets 0x14 for output */
  1201. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1202. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1203. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1204. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1205. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1206. /* Mic2 (as headphone out) for HP output */
  1207. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1208. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1209. /* Line In pin widget for input */
  1210. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1211. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1212. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1213. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1214. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1215. /* CD pin widget for input */
  1216. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1217. { }
  1218. };
  1219. /*
  1220. * 5-stack pin configuration:
  1221. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1222. * line-in/side = 0x1a, f-mic = 0x1b
  1223. */
  1224. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1225. /*
  1226. * preset connection lists of input pins
  1227. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1228. */
  1229. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1230. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1231. /*
  1232. * Set pin mode and muting
  1233. */
  1234. /* set pin widgets 0x14-0x17 for output */
  1235. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1236. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1237. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1238. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1239. /* unmute pins for output (no gain on this amp) */
  1240. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1241. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1242. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1243. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1244. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1245. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1246. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1247. /* Mic2 (as headphone out) for HP output */
  1248. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1249. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1250. /* Line In pin widget for input */
  1251. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1252. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1253. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1254. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1255. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1256. /* CD pin widget for input */
  1257. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1258. { }
  1259. };
  1260. /*
  1261. * W810 pin configuration:
  1262. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1263. */
  1264. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1265. /* hphone/speaker input selector: front DAC */
  1266. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1267. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1268. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1269. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1270. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1271. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1272. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1273. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1274. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1275. { }
  1276. };
  1277. /*
  1278. * Z71V pin configuration:
  1279. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1280. */
  1281. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1282. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1287. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1288. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1289. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1290. { }
  1291. };
  1292. /*
  1293. * 6-stack pin configuration:
  1294. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1295. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1296. */
  1297. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1298. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1299. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1300. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1301. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1302. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1303. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1304. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1305. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1306. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1307. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1308. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1309. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1310. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1311. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1312. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1313. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1314. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1316. { }
  1317. };
  1318. /*
  1319. * Uniwill pin configuration:
  1320. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1321. * line = 0x1a
  1322. */
  1323. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1324. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1325. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1326. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1327. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1330. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1331. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1332. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1333. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1334. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1335. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1336. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1337. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1338. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1339. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1340. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1341. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1342. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1343. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1344. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1345. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1346. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1347. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1348. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1349. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1350. { }
  1351. };
  1352. /*
  1353. * Uniwill P53
  1354. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1355. */
  1356. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1357. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1358. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1359. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1360. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1361. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1362. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1363. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1364. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1365. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1366. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1367. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1368. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1369. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1370. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1371. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1372. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1373. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1374. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1375. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1376. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1377. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1378. { }
  1379. };
  1380. static struct hda_verb alc880_beep_init_verbs[] = {
  1381. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1382. { }
  1383. };
  1384. /* toggle speaker-output according to the hp-jack state */
  1385. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1386. {
  1387. unsigned int present;
  1388. unsigned char bits;
  1389. present = snd_hda_codec_read(codec, 0x14, 0,
  1390. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1391. bits = present ? 0x80 : 0;
  1392. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1393. 0x80, bits);
  1394. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1395. 0x80, bits);
  1396. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1397. 0x80, bits);
  1398. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1399. 0x80, bits);
  1400. }
  1401. /* auto-toggle front mic */
  1402. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1403. {
  1404. unsigned int present;
  1405. unsigned char bits;
  1406. present = snd_hda_codec_read(codec, 0x18, 0,
  1407. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1408. bits = present ? 0x80 : 0;
  1409. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1410. 0x80, bits);
  1411. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1412. 0x80, bits);
  1413. }
  1414. static void alc880_uniwill_automute(struct hda_codec *codec)
  1415. {
  1416. alc880_uniwill_hp_automute(codec);
  1417. alc880_uniwill_mic_automute(codec);
  1418. }
  1419. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1420. unsigned int res)
  1421. {
  1422. /* Looks like the unsol event is incompatible with the standard
  1423. * definition. 4bit tag is placed at 28 bit!
  1424. */
  1425. switch (res >> 28) {
  1426. case ALC880_HP_EVENT:
  1427. alc880_uniwill_hp_automute(codec);
  1428. break;
  1429. case ALC880_MIC_EVENT:
  1430. alc880_uniwill_mic_automute(codec);
  1431. break;
  1432. }
  1433. }
  1434. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1435. {
  1436. unsigned int present;
  1437. unsigned char bits;
  1438. present = snd_hda_codec_read(codec, 0x14, 0,
  1439. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1440. bits = present ? 0x80 : 0;
  1441. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1442. 0x80, bits);
  1443. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1444. 0x80, bits);
  1445. }
  1446. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1447. {
  1448. unsigned int present;
  1449. present = snd_hda_codec_read(codec, 0x21, 0,
  1450. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1451. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1452. 0x7f, present);
  1453. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1454. 0x7f, present);
  1455. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1456. 0x7f, present);
  1457. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1458. 0x7f, present);
  1459. }
  1460. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1461. unsigned int res)
  1462. {
  1463. /* Looks like the unsol event is incompatible with the standard
  1464. * definition. 4bit tag is placed at 28 bit!
  1465. */
  1466. if ((res >> 28) == ALC880_HP_EVENT)
  1467. alc880_uniwill_p53_hp_automute(codec);
  1468. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1469. alc880_uniwill_p53_dcvol_automute(codec);
  1470. }
  1471. /* FIXME! */
  1472. /*
  1473. * F1734 pin configuration:
  1474. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1475. */
  1476. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1477. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1478. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1479. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1480. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1482. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1483. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1486. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1487. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1488. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1489. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1490. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1494. { }
  1495. };
  1496. /* FIXME! */
  1497. /*
  1498. * ASUS pin configuration:
  1499. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1500. */
  1501. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1502. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1503. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1504. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1505. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1506. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1507. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1508. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1510. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1513. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1514. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1515. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1516. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1518. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1519. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1520. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1523. { }
  1524. };
  1525. /* Enable GPIO mask and set output */
  1526. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1527. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1528. /* Clevo m520g init */
  1529. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1530. /* headphone output */
  1531. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1532. /* line-out */
  1533. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1534. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1535. /* Line-in */
  1536. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1537. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1538. /* CD */
  1539. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1540. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1541. /* Mic1 (rear panel) */
  1542. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1543. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1544. /* Mic2 (front panel) */
  1545. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1546. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1547. /* headphone */
  1548. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1549. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1550. /* change to EAPD mode */
  1551. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1552. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1553. { }
  1554. };
  1555. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1556. /* change to EAPD mode */
  1557. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1558. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1559. /* Headphone output */
  1560. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1561. /* Front output*/
  1562. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1563. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1564. /* Line In pin widget for input */
  1565. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1566. /* CD pin widget for input */
  1567. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1568. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1569. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1570. /* change to EAPD mode */
  1571. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1572. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1573. { }
  1574. };
  1575. /*
  1576. * LG m1 express dual
  1577. *
  1578. * Pin assignment:
  1579. * Rear Line-In/Out (blue): 0x14
  1580. * Build-in Mic-In: 0x15
  1581. * Speaker-out: 0x17
  1582. * HP-Out (green): 0x1b
  1583. * Mic-In/Out (red): 0x19
  1584. * SPDIF-Out: 0x1e
  1585. */
  1586. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1587. static hda_nid_t alc880_lg_dac_nids[3] = {
  1588. 0x05, 0x02, 0x03
  1589. };
  1590. /* seems analog CD is not working */
  1591. static struct hda_input_mux alc880_lg_capture_source = {
  1592. .num_items = 3,
  1593. .items = {
  1594. { "Mic", 0x1 },
  1595. { "Line", 0x5 },
  1596. { "Internal Mic", 0x6 },
  1597. },
  1598. };
  1599. /* 2,4,6 channel modes */
  1600. static struct hda_verb alc880_lg_ch2_init[] = {
  1601. /* set line-in and mic-in to input */
  1602. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1603. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1604. { }
  1605. };
  1606. static struct hda_verb alc880_lg_ch4_init[] = {
  1607. /* set line-in to out and mic-in to input */
  1608. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1609. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1610. { }
  1611. };
  1612. static struct hda_verb alc880_lg_ch6_init[] = {
  1613. /* set line-in and mic-in to output */
  1614. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1615. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1616. { }
  1617. };
  1618. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1619. { 2, alc880_lg_ch2_init },
  1620. { 4, alc880_lg_ch4_init },
  1621. { 6, alc880_lg_ch6_init },
  1622. };
  1623. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1624. /* FIXME: it's not really "master" but front channels */
  1625. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1626. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1627. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1628. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1629. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1630. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1631. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1632. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1633. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1634. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1635. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1636. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1637. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1638. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1639. {
  1640. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1641. .name = "Channel Mode",
  1642. .info = alc_ch_mode_info,
  1643. .get = alc_ch_mode_get,
  1644. .put = alc_ch_mode_put,
  1645. },
  1646. { } /* end */
  1647. };
  1648. static struct hda_verb alc880_lg_init_verbs[] = {
  1649. /* set capture source to mic-in */
  1650. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1651. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. /* mute all amp mixer inputs */
  1654. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1657. /* line-in to input */
  1658. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1660. /* built-in mic */
  1661. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1662. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1663. /* speaker-out */
  1664. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1665. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1666. /* mic-in to input */
  1667. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1668. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1669. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1670. /* HP-out */
  1671. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1672. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1673. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* jack sense */
  1675. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1676. { }
  1677. };
  1678. /* toggle speaker-output according to the hp-jack state */
  1679. static void alc880_lg_automute(struct hda_codec *codec)
  1680. {
  1681. unsigned int present;
  1682. unsigned char bits;
  1683. present = snd_hda_codec_read(codec, 0x1b, 0,
  1684. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1685. bits = present ? 0x80 : 0;
  1686. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1687. 0x80, bits);
  1688. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1689. 0x80, bits);
  1690. }
  1691. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1692. {
  1693. /* Looks like the unsol event is incompatible with the standard
  1694. * definition. 4bit tag is placed at 28 bit!
  1695. */
  1696. if ((res >> 28) == 0x01)
  1697. alc880_lg_automute(codec);
  1698. }
  1699. /*
  1700. * LG LW20
  1701. *
  1702. * Pin assignment:
  1703. * Speaker-out: 0x14
  1704. * Mic-In: 0x18
  1705. * Built-in Mic-In: 0x19
  1706. * Line-In: 0x1b
  1707. * HP-Out: 0x1a
  1708. * SPDIF-Out: 0x1e
  1709. */
  1710. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1711. .num_items = 3,
  1712. .items = {
  1713. { "Mic", 0x0 },
  1714. { "Internal Mic", 0x1 },
  1715. { "Line In", 0x2 },
  1716. },
  1717. };
  1718. #define alc880_lg_lw_modes alc880_threestack_modes
  1719. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1720. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1721. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1722. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1723. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1724. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1725. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1726. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1727. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1728. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1732. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1733. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1734. {
  1735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1736. .name = "Channel Mode",
  1737. .info = alc_ch_mode_info,
  1738. .get = alc_ch_mode_get,
  1739. .put = alc_ch_mode_put,
  1740. },
  1741. { } /* end */
  1742. };
  1743. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1744. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1745. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1746. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1747. /* set capture source to mic-in */
  1748. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1752. /* speaker-out */
  1753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1754. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1755. /* HP-out */
  1756. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1757. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1758. /* mic-in to input */
  1759. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1760. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1761. /* built-in mic */
  1762. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1763. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1764. /* jack sense */
  1765. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1766. { }
  1767. };
  1768. /* toggle speaker-output according to the hp-jack state */
  1769. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1770. {
  1771. unsigned int present;
  1772. unsigned char bits;
  1773. present = snd_hda_codec_read(codec, 0x1b, 0,
  1774. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1775. bits = present ? 0x80 : 0;
  1776. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1777. 0x80, bits);
  1778. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1779. 0x80, bits);
  1780. }
  1781. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1782. {
  1783. /* Looks like the unsol event is incompatible with the standard
  1784. * definition. 4bit tag is placed at 28 bit!
  1785. */
  1786. if ((res >> 28) == 0x01)
  1787. alc880_lg_lw_automute(codec);
  1788. }
  1789. /*
  1790. * Common callbacks
  1791. */
  1792. static int alc_init(struct hda_codec *codec)
  1793. {
  1794. struct alc_spec *spec = codec->spec;
  1795. unsigned int i;
  1796. for (i = 0; i < spec->num_init_verbs; i++)
  1797. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1798. if (spec->init_hook)
  1799. spec->init_hook(codec);
  1800. return 0;
  1801. }
  1802. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1803. {
  1804. struct alc_spec *spec = codec->spec;
  1805. if (spec->unsol_event)
  1806. spec->unsol_event(codec, res);
  1807. }
  1808. #ifdef CONFIG_PM
  1809. /*
  1810. * resume
  1811. */
  1812. static int alc_resume(struct hda_codec *codec)
  1813. {
  1814. struct alc_spec *spec = codec->spec;
  1815. int i;
  1816. alc_init(codec);
  1817. for (i = 0; i < spec->num_mixers; i++)
  1818. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1819. if (spec->multiout.dig_out_nid)
  1820. snd_hda_resume_spdif_out(codec);
  1821. if (spec->dig_in_nid)
  1822. snd_hda_resume_spdif_in(codec);
  1823. return 0;
  1824. }
  1825. #endif
  1826. /*
  1827. * Analog playback callbacks
  1828. */
  1829. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1830. struct hda_codec *codec,
  1831. struct snd_pcm_substream *substream)
  1832. {
  1833. struct alc_spec *spec = codec->spec;
  1834. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1835. }
  1836. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1837. struct hda_codec *codec,
  1838. unsigned int stream_tag,
  1839. unsigned int format,
  1840. struct snd_pcm_substream *substream)
  1841. {
  1842. struct alc_spec *spec = codec->spec;
  1843. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1844. stream_tag, format, substream);
  1845. }
  1846. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1847. struct hda_codec *codec,
  1848. struct snd_pcm_substream *substream)
  1849. {
  1850. struct alc_spec *spec = codec->spec;
  1851. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1852. }
  1853. /*
  1854. * Digital out
  1855. */
  1856. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1857. struct hda_codec *codec,
  1858. struct snd_pcm_substream *substream)
  1859. {
  1860. struct alc_spec *spec = codec->spec;
  1861. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1862. }
  1863. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1864. struct hda_codec *codec,
  1865. unsigned int stream_tag,
  1866. unsigned int format,
  1867. struct snd_pcm_substream *substream)
  1868. {
  1869. struct alc_spec *spec = codec->spec;
  1870. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1871. stream_tag, format, substream);
  1872. }
  1873. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1874. struct hda_codec *codec,
  1875. struct snd_pcm_substream *substream)
  1876. {
  1877. struct alc_spec *spec = codec->spec;
  1878. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1879. }
  1880. /*
  1881. * Analog capture
  1882. */
  1883. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1884. struct hda_codec *codec,
  1885. unsigned int stream_tag,
  1886. unsigned int format,
  1887. struct snd_pcm_substream *substream)
  1888. {
  1889. struct alc_spec *spec = codec->spec;
  1890. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1891. stream_tag, 0, format);
  1892. return 0;
  1893. }
  1894. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1895. struct hda_codec *codec,
  1896. struct snd_pcm_substream *substream)
  1897. {
  1898. struct alc_spec *spec = codec->spec;
  1899. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1900. 0, 0, 0);
  1901. return 0;
  1902. }
  1903. /*
  1904. */
  1905. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1906. .substreams = 1,
  1907. .channels_min = 2,
  1908. .channels_max = 8,
  1909. /* NID is set in alc_build_pcms */
  1910. .ops = {
  1911. .open = alc880_playback_pcm_open,
  1912. .prepare = alc880_playback_pcm_prepare,
  1913. .cleanup = alc880_playback_pcm_cleanup
  1914. },
  1915. };
  1916. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1917. .substreams = 2,
  1918. .channels_min = 2,
  1919. .channels_max = 2,
  1920. /* NID is set in alc_build_pcms */
  1921. .ops = {
  1922. .prepare = alc880_capture_pcm_prepare,
  1923. .cleanup = alc880_capture_pcm_cleanup
  1924. },
  1925. };
  1926. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1927. .substreams = 1,
  1928. .channels_min = 2,
  1929. .channels_max = 2,
  1930. /* NID is set in alc_build_pcms */
  1931. .ops = {
  1932. .open = alc880_dig_playback_pcm_open,
  1933. .close = alc880_dig_playback_pcm_close,
  1934. .prepare = alc880_dig_playback_pcm_prepare
  1935. },
  1936. };
  1937. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1938. .substreams = 1,
  1939. .channels_min = 2,
  1940. .channels_max = 2,
  1941. /* NID is set in alc_build_pcms */
  1942. };
  1943. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1944. static struct hda_pcm_stream alc_pcm_null_playback = {
  1945. .substreams = 0,
  1946. .channels_min = 0,
  1947. .channels_max = 0,
  1948. };
  1949. static int alc_build_pcms(struct hda_codec *codec)
  1950. {
  1951. struct alc_spec *spec = codec->spec;
  1952. struct hda_pcm *info = spec->pcm_rec;
  1953. int i;
  1954. codec->num_pcms = 1;
  1955. codec->pcm_info = info;
  1956. info->name = spec->stream_name_analog;
  1957. if (spec->stream_analog_playback) {
  1958. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1959. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1960. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1961. }
  1962. if (spec->stream_analog_capture) {
  1963. snd_assert(spec->adc_nids, return -EINVAL);
  1964. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1965. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1966. }
  1967. if (spec->channel_mode) {
  1968. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1969. for (i = 0; i < spec->num_channel_mode; i++) {
  1970. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1971. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1972. }
  1973. }
  1974. }
  1975. /* SPDIF for stream index #1 */
  1976. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1977. codec->num_pcms = 2;
  1978. info = spec->pcm_rec + 1;
  1979. info->name = spec->stream_name_digital;
  1980. if (spec->multiout.dig_out_nid &&
  1981. spec->stream_digital_playback) {
  1982. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1983. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1984. }
  1985. if (spec->dig_in_nid &&
  1986. spec->stream_digital_capture) {
  1987. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1988. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1989. }
  1990. }
  1991. /* If the use of more than one ADC is requested for the current
  1992. * model, configure a second analog capture-only PCM.
  1993. */
  1994. /* Additional Analaog capture for index #2 */
  1995. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1996. spec->adc_nids) {
  1997. codec->num_pcms = 3;
  1998. info = spec->pcm_rec + 2;
  1999. info->name = spec->stream_name_analog;
  2000. /* No playback stream for second PCM */
  2001. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2002. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2003. if (spec->stream_analog_capture) {
  2004. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2005. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2006. }
  2007. }
  2008. return 0;
  2009. }
  2010. static void alc_free(struct hda_codec *codec)
  2011. {
  2012. struct alc_spec *spec = codec->spec;
  2013. unsigned int i;
  2014. if (!spec)
  2015. return;
  2016. if (spec->kctl_alloc) {
  2017. for (i = 0; i < spec->num_kctl_used; i++)
  2018. kfree(spec->kctl_alloc[i].name);
  2019. kfree(spec->kctl_alloc);
  2020. }
  2021. kfree(spec);
  2022. }
  2023. /*
  2024. */
  2025. static struct hda_codec_ops alc_patch_ops = {
  2026. .build_controls = alc_build_controls,
  2027. .build_pcms = alc_build_pcms,
  2028. .init = alc_init,
  2029. .free = alc_free,
  2030. .unsol_event = alc_unsol_event,
  2031. #ifdef CONFIG_PM
  2032. .resume = alc_resume,
  2033. #endif
  2034. };
  2035. /*
  2036. * Test configuration for debugging
  2037. *
  2038. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2039. * enum controls.
  2040. */
  2041. #ifdef CONFIG_SND_DEBUG
  2042. static hda_nid_t alc880_test_dac_nids[4] = {
  2043. 0x02, 0x03, 0x04, 0x05
  2044. };
  2045. static struct hda_input_mux alc880_test_capture_source = {
  2046. .num_items = 7,
  2047. .items = {
  2048. { "In-1", 0x0 },
  2049. { "In-2", 0x1 },
  2050. { "In-3", 0x2 },
  2051. { "In-4", 0x3 },
  2052. { "CD", 0x4 },
  2053. { "Front", 0x5 },
  2054. { "Surround", 0x6 },
  2055. },
  2056. };
  2057. static struct hda_channel_mode alc880_test_modes[4] = {
  2058. { 2, NULL },
  2059. { 4, NULL },
  2060. { 6, NULL },
  2061. { 8, NULL },
  2062. };
  2063. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2064. struct snd_ctl_elem_info *uinfo)
  2065. {
  2066. static char *texts[] = {
  2067. "N/A", "Line Out", "HP Out",
  2068. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2069. };
  2070. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2071. uinfo->count = 1;
  2072. uinfo->value.enumerated.items = 8;
  2073. if (uinfo->value.enumerated.item >= 8)
  2074. uinfo->value.enumerated.item = 7;
  2075. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2076. return 0;
  2077. }
  2078. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2079. struct snd_ctl_elem_value *ucontrol)
  2080. {
  2081. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2082. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2083. unsigned int pin_ctl, item = 0;
  2084. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2085. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2086. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2087. if (pin_ctl & AC_PINCTL_HP_EN)
  2088. item = 2;
  2089. else
  2090. item = 1;
  2091. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2092. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2093. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2094. case AC_PINCTL_VREF_50: item = 4; break;
  2095. case AC_PINCTL_VREF_GRD: item = 5; break;
  2096. case AC_PINCTL_VREF_80: item = 6; break;
  2097. case AC_PINCTL_VREF_100: item = 7; break;
  2098. }
  2099. }
  2100. ucontrol->value.enumerated.item[0] = item;
  2101. return 0;
  2102. }
  2103. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2104. struct snd_ctl_elem_value *ucontrol)
  2105. {
  2106. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2107. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2108. static unsigned int ctls[] = {
  2109. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2110. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2111. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2115. };
  2116. unsigned int old_ctl, new_ctl;
  2117. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2118. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2119. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2120. if (old_ctl != new_ctl) {
  2121. snd_hda_codec_write(codec, nid, 0,
  2122. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2123. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2124. (ucontrol->value.enumerated.item[0] >= 3 ?
  2125. 0xb080 : 0xb000));
  2126. return 1;
  2127. }
  2128. return 0;
  2129. }
  2130. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2131. struct snd_ctl_elem_info *uinfo)
  2132. {
  2133. static char *texts[] = {
  2134. "Front", "Surround", "CLFE", "Side"
  2135. };
  2136. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2137. uinfo->count = 1;
  2138. uinfo->value.enumerated.items = 4;
  2139. if (uinfo->value.enumerated.item >= 4)
  2140. uinfo->value.enumerated.item = 3;
  2141. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2142. return 0;
  2143. }
  2144. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2145. struct snd_ctl_elem_value *ucontrol)
  2146. {
  2147. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2148. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2149. unsigned int sel;
  2150. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2151. ucontrol->value.enumerated.item[0] = sel & 3;
  2152. return 0;
  2153. }
  2154. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2155. struct snd_ctl_elem_value *ucontrol)
  2156. {
  2157. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2158. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2159. unsigned int sel;
  2160. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2161. if (ucontrol->value.enumerated.item[0] != sel) {
  2162. sel = ucontrol->value.enumerated.item[0] & 3;
  2163. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2164. return 1;
  2165. }
  2166. return 0;
  2167. }
  2168. #define PIN_CTL_TEST(xname,nid) { \
  2169. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2170. .name = xname, \
  2171. .info = alc_test_pin_ctl_info, \
  2172. .get = alc_test_pin_ctl_get, \
  2173. .put = alc_test_pin_ctl_put, \
  2174. .private_value = nid \
  2175. }
  2176. #define PIN_SRC_TEST(xname,nid) { \
  2177. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2178. .name = xname, \
  2179. .info = alc_test_pin_src_info, \
  2180. .get = alc_test_pin_src_get, \
  2181. .put = alc_test_pin_src_put, \
  2182. .private_value = nid \
  2183. }
  2184. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2185. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2186. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2187. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2188. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2189. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2190. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2191. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2192. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2193. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2194. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2195. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2196. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2197. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2198. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2199. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2200. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2201. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2202. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2203. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2204. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2205. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2206. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2207. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2208. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2209. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2210. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2211. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2212. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2213. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2214. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2215. {
  2216. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2217. .name = "Channel Mode",
  2218. .info = alc_ch_mode_info,
  2219. .get = alc_ch_mode_get,
  2220. .put = alc_ch_mode_put,
  2221. },
  2222. { } /* end */
  2223. };
  2224. static struct hda_verb alc880_test_init_verbs[] = {
  2225. /* Unmute inputs of 0x0c - 0x0f */
  2226. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2227. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2228. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2229. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2230. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2231. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2232. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2233. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2234. /* Vol output for 0x0c-0x0f */
  2235. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2239. /* Set output pins 0x14-0x17 */
  2240. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2241. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2242. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2243. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2244. /* Unmute output pins 0x14-0x17 */
  2245. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2246. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2247. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2248. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2249. /* Set input pins 0x18-0x1c */
  2250. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2251. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2252. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2253. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2254. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2255. /* Mute input pins 0x18-0x1b */
  2256. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2257. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2258. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2259. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2260. /* ADC set up */
  2261. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2262. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2263. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2264. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2265. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2266. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2267. /* Analog input/passthru */
  2268. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2271. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2272. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2273. { }
  2274. };
  2275. #endif
  2276. /*
  2277. */
  2278. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2279. [ALC880_3ST] = "3stack",
  2280. [ALC880_TCL_S700] = "tcl",
  2281. [ALC880_3ST_DIG] = "3stack-digout",
  2282. [ALC880_CLEVO] = "clevo",
  2283. [ALC880_5ST] = "5stack",
  2284. [ALC880_5ST_DIG] = "5stack-digout",
  2285. [ALC880_W810] = "w810",
  2286. [ALC880_Z71V] = "z71v",
  2287. [ALC880_6ST] = "6stack",
  2288. [ALC880_6ST_DIG] = "6stack-digout",
  2289. [ALC880_ASUS] = "asus",
  2290. [ALC880_ASUS_W1V] = "asus-w1v",
  2291. [ALC880_ASUS_DIG] = "asus-dig",
  2292. [ALC880_ASUS_DIG2] = "asus-dig2",
  2293. [ALC880_UNIWILL_DIG] = "uniwill",
  2294. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2295. [ALC880_FUJITSU] = "fujitsu",
  2296. [ALC880_F1734] = "F1734",
  2297. [ALC880_LG] = "lg",
  2298. [ALC880_LG_LW] = "lg-lw",
  2299. #ifdef CONFIG_SND_DEBUG
  2300. [ALC880_TEST] = "test",
  2301. #endif
  2302. [ALC880_AUTO] = "auto",
  2303. };
  2304. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2305. /* Broken BIOS configuration */
  2306. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2307. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2308. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2309. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2310. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2311. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2312. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2316. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2317. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2318. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2319. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2320. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2321. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2322. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2323. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2324. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2325. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2326. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2327. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2330. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2332. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2333. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2334. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2335. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2336. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2337. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2338. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2339. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2340. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2341. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2342. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2343. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2344. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2345. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2346. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2347. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2348. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2349. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2350. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2351. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2352. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2353. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2354. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2355. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2356. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2357. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2358. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2359. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2360. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2361. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2362. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2363. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2364. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2365. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2366. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2367. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2368. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2369. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2370. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2375. {}
  2376. };
  2377. /*
  2378. * ALC880 codec presets
  2379. */
  2380. static struct alc_config_preset alc880_presets[] = {
  2381. [ALC880_3ST] = {
  2382. .mixers = { alc880_three_stack_mixer },
  2383. .init_verbs = { alc880_volume_init_verbs,
  2384. alc880_pin_3stack_init_verbs },
  2385. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2386. .dac_nids = alc880_dac_nids,
  2387. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2388. .channel_mode = alc880_threestack_modes,
  2389. .need_dac_fix = 1,
  2390. .input_mux = &alc880_capture_source,
  2391. },
  2392. [ALC880_3ST_DIG] = {
  2393. .mixers = { alc880_three_stack_mixer },
  2394. .init_verbs = { alc880_volume_init_verbs,
  2395. alc880_pin_3stack_init_verbs },
  2396. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2397. .dac_nids = alc880_dac_nids,
  2398. .dig_out_nid = ALC880_DIGOUT_NID,
  2399. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2400. .channel_mode = alc880_threestack_modes,
  2401. .need_dac_fix = 1,
  2402. .input_mux = &alc880_capture_source,
  2403. },
  2404. [ALC880_TCL_S700] = {
  2405. .mixers = { alc880_tcl_s700_mixer },
  2406. .init_verbs = { alc880_volume_init_verbs,
  2407. alc880_pin_tcl_S700_init_verbs,
  2408. alc880_gpio2_init_verbs },
  2409. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2410. .dac_nids = alc880_dac_nids,
  2411. .hp_nid = 0x03,
  2412. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2413. .channel_mode = alc880_2_jack_modes,
  2414. .input_mux = &alc880_capture_source,
  2415. },
  2416. [ALC880_5ST] = {
  2417. .mixers = { alc880_three_stack_mixer,
  2418. alc880_five_stack_mixer},
  2419. .init_verbs = { alc880_volume_init_verbs,
  2420. alc880_pin_5stack_init_verbs },
  2421. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2422. .dac_nids = alc880_dac_nids,
  2423. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2424. .channel_mode = alc880_fivestack_modes,
  2425. .input_mux = &alc880_capture_source,
  2426. },
  2427. [ALC880_5ST_DIG] = {
  2428. .mixers = { alc880_three_stack_mixer,
  2429. alc880_five_stack_mixer },
  2430. .init_verbs = { alc880_volume_init_verbs,
  2431. alc880_pin_5stack_init_verbs },
  2432. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2433. .dac_nids = alc880_dac_nids,
  2434. .dig_out_nid = ALC880_DIGOUT_NID,
  2435. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2436. .channel_mode = alc880_fivestack_modes,
  2437. .input_mux = &alc880_capture_source,
  2438. },
  2439. [ALC880_6ST] = {
  2440. .mixers = { alc880_six_stack_mixer },
  2441. .init_verbs = { alc880_volume_init_verbs,
  2442. alc880_pin_6stack_init_verbs },
  2443. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2444. .dac_nids = alc880_6st_dac_nids,
  2445. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2446. .channel_mode = alc880_sixstack_modes,
  2447. .input_mux = &alc880_6stack_capture_source,
  2448. },
  2449. [ALC880_6ST_DIG] = {
  2450. .mixers = { alc880_six_stack_mixer },
  2451. .init_verbs = { alc880_volume_init_verbs,
  2452. alc880_pin_6stack_init_verbs },
  2453. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2454. .dac_nids = alc880_6st_dac_nids,
  2455. .dig_out_nid = ALC880_DIGOUT_NID,
  2456. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2457. .channel_mode = alc880_sixstack_modes,
  2458. .input_mux = &alc880_6stack_capture_source,
  2459. },
  2460. [ALC880_W810] = {
  2461. .mixers = { alc880_w810_base_mixer },
  2462. .init_verbs = { alc880_volume_init_verbs,
  2463. alc880_pin_w810_init_verbs,
  2464. alc880_gpio2_init_verbs },
  2465. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2466. .dac_nids = alc880_w810_dac_nids,
  2467. .dig_out_nid = ALC880_DIGOUT_NID,
  2468. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2469. .channel_mode = alc880_w810_modes,
  2470. .input_mux = &alc880_capture_source,
  2471. },
  2472. [ALC880_Z71V] = {
  2473. .mixers = { alc880_z71v_mixer },
  2474. .init_verbs = { alc880_volume_init_verbs,
  2475. alc880_pin_z71v_init_verbs },
  2476. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2477. .dac_nids = alc880_z71v_dac_nids,
  2478. .dig_out_nid = ALC880_DIGOUT_NID,
  2479. .hp_nid = 0x03,
  2480. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2481. .channel_mode = alc880_2_jack_modes,
  2482. .input_mux = &alc880_capture_source,
  2483. },
  2484. [ALC880_F1734] = {
  2485. .mixers = { alc880_f1734_mixer },
  2486. .init_verbs = { alc880_volume_init_verbs,
  2487. alc880_pin_f1734_init_verbs },
  2488. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2489. .dac_nids = alc880_f1734_dac_nids,
  2490. .hp_nid = 0x02,
  2491. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2492. .channel_mode = alc880_2_jack_modes,
  2493. .input_mux = &alc880_capture_source,
  2494. },
  2495. [ALC880_ASUS] = {
  2496. .mixers = { alc880_asus_mixer },
  2497. .init_verbs = { alc880_volume_init_verbs,
  2498. alc880_pin_asus_init_verbs,
  2499. alc880_gpio1_init_verbs },
  2500. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2501. .dac_nids = alc880_asus_dac_nids,
  2502. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2503. .channel_mode = alc880_asus_modes,
  2504. .need_dac_fix = 1,
  2505. .input_mux = &alc880_capture_source,
  2506. },
  2507. [ALC880_ASUS_DIG] = {
  2508. .mixers = { alc880_asus_mixer },
  2509. .init_verbs = { alc880_volume_init_verbs,
  2510. alc880_pin_asus_init_verbs,
  2511. alc880_gpio1_init_verbs },
  2512. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2513. .dac_nids = alc880_asus_dac_nids,
  2514. .dig_out_nid = ALC880_DIGOUT_NID,
  2515. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2516. .channel_mode = alc880_asus_modes,
  2517. .need_dac_fix = 1,
  2518. .input_mux = &alc880_capture_source,
  2519. },
  2520. [ALC880_ASUS_DIG2] = {
  2521. .mixers = { alc880_asus_mixer },
  2522. .init_verbs = { alc880_volume_init_verbs,
  2523. alc880_pin_asus_init_verbs,
  2524. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2525. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2526. .dac_nids = alc880_asus_dac_nids,
  2527. .dig_out_nid = ALC880_DIGOUT_NID,
  2528. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2529. .channel_mode = alc880_asus_modes,
  2530. .need_dac_fix = 1,
  2531. .input_mux = &alc880_capture_source,
  2532. },
  2533. [ALC880_ASUS_W1V] = {
  2534. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2535. .init_verbs = { alc880_volume_init_verbs,
  2536. alc880_pin_asus_init_verbs,
  2537. alc880_gpio1_init_verbs },
  2538. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2539. .dac_nids = alc880_asus_dac_nids,
  2540. .dig_out_nid = ALC880_DIGOUT_NID,
  2541. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2542. .channel_mode = alc880_asus_modes,
  2543. .need_dac_fix = 1,
  2544. .input_mux = &alc880_capture_source,
  2545. },
  2546. [ALC880_UNIWILL_DIG] = {
  2547. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2548. .init_verbs = { alc880_volume_init_verbs,
  2549. alc880_pin_asus_init_verbs },
  2550. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2551. .dac_nids = alc880_asus_dac_nids,
  2552. .dig_out_nid = ALC880_DIGOUT_NID,
  2553. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2554. .channel_mode = alc880_asus_modes,
  2555. .need_dac_fix = 1,
  2556. .input_mux = &alc880_capture_source,
  2557. },
  2558. [ALC880_UNIWILL] = {
  2559. .mixers = { alc880_uniwill_mixer },
  2560. .init_verbs = { alc880_volume_init_verbs,
  2561. alc880_uniwill_init_verbs },
  2562. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2563. .dac_nids = alc880_asus_dac_nids,
  2564. .dig_out_nid = ALC880_DIGOUT_NID,
  2565. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2566. .channel_mode = alc880_threestack_modes,
  2567. .need_dac_fix = 1,
  2568. .input_mux = &alc880_capture_source,
  2569. .unsol_event = alc880_uniwill_unsol_event,
  2570. .init_hook = alc880_uniwill_automute,
  2571. },
  2572. [ALC880_UNIWILL_P53] = {
  2573. .mixers = { alc880_uniwill_p53_mixer },
  2574. .init_verbs = { alc880_volume_init_verbs,
  2575. alc880_uniwill_p53_init_verbs },
  2576. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2577. .dac_nids = alc880_asus_dac_nids,
  2578. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2579. .channel_mode = alc880_threestack_modes,
  2580. .input_mux = &alc880_capture_source,
  2581. .unsol_event = alc880_uniwill_p53_unsol_event,
  2582. .init_hook = alc880_uniwill_p53_hp_automute,
  2583. },
  2584. [ALC880_FUJITSU] = {
  2585. .mixers = { alc880_fujitsu_mixer,
  2586. alc880_pcbeep_mixer, },
  2587. .init_verbs = { alc880_volume_init_verbs,
  2588. alc880_uniwill_p53_init_verbs,
  2589. alc880_beep_init_verbs },
  2590. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2591. .dac_nids = alc880_dac_nids,
  2592. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2593. .channel_mode = alc880_2_jack_modes,
  2594. .input_mux = &alc880_capture_source,
  2595. .unsol_event = alc880_uniwill_p53_unsol_event,
  2596. .init_hook = alc880_uniwill_p53_hp_automute,
  2597. },
  2598. [ALC880_CLEVO] = {
  2599. .mixers = { alc880_three_stack_mixer },
  2600. .init_verbs = { alc880_volume_init_verbs,
  2601. alc880_pin_clevo_init_verbs },
  2602. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2603. .dac_nids = alc880_dac_nids,
  2604. .hp_nid = 0x03,
  2605. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2606. .channel_mode = alc880_threestack_modes,
  2607. .need_dac_fix = 1,
  2608. .input_mux = &alc880_capture_source,
  2609. },
  2610. [ALC880_LG] = {
  2611. .mixers = { alc880_lg_mixer },
  2612. .init_verbs = { alc880_volume_init_verbs,
  2613. alc880_lg_init_verbs },
  2614. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2615. .dac_nids = alc880_lg_dac_nids,
  2616. .dig_out_nid = ALC880_DIGOUT_NID,
  2617. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2618. .channel_mode = alc880_lg_ch_modes,
  2619. .need_dac_fix = 1,
  2620. .input_mux = &alc880_lg_capture_source,
  2621. .unsol_event = alc880_lg_unsol_event,
  2622. .init_hook = alc880_lg_automute,
  2623. },
  2624. [ALC880_LG_LW] = {
  2625. .mixers = { alc880_lg_lw_mixer },
  2626. .init_verbs = { alc880_volume_init_verbs,
  2627. alc880_lg_lw_init_verbs },
  2628. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2629. .dac_nids = alc880_dac_nids,
  2630. .dig_out_nid = ALC880_DIGOUT_NID,
  2631. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2632. .channel_mode = alc880_lg_lw_modes,
  2633. .input_mux = &alc880_lg_lw_capture_source,
  2634. .unsol_event = alc880_lg_lw_unsol_event,
  2635. .init_hook = alc880_lg_lw_automute,
  2636. },
  2637. #ifdef CONFIG_SND_DEBUG
  2638. [ALC880_TEST] = {
  2639. .mixers = { alc880_test_mixer },
  2640. .init_verbs = { alc880_test_init_verbs },
  2641. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2642. .dac_nids = alc880_test_dac_nids,
  2643. .dig_out_nid = ALC880_DIGOUT_NID,
  2644. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2645. .channel_mode = alc880_test_modes,
  2646. .input_mux = &alc880_test_capture_source,
  2647. },
  2648. #endif
  2649. };
  2650. /*
  2651. * Automatic parse of I/O pins from the BIOS configuration
  2652. */
  2653. #define NUM_CONTROL_ALLOC 32
  2654. #define NUM_VERB_ALLOC 32
  2655. enum {
  2656. ALC_CTL_WIDGET_VOL,
  2657. ALC_CTL_WIDGET_MUTE,
  2658. ALC_CTL_BIND_MUTE,
  2659. };
  2660. static struct snd_kcontrol_new alc880_control_templates[] = {
  2661. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2662. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2663. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2664. };
  2665. /* add dynamic controls */
  2666. static int add_control(struct alc_spec *spec, int type, const char *name,
  2667. unsigned long val)
  2668. {
  2669. struct snd_kcontrol_new *knew;
  2670. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2671. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2672. /* array + terminator */
  2673. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2674. if (!knew)
  2675. return -ENOMEM;
  2676. if (spec->kctl_alloc) {
  2677. memcpy(knew, spec->kctl_alloc,
  2678. sizeof(*knew) * spec->num_kctl_alloc);
  2679. kfree(spec->kctl_alloc);
  2680. }
  2681. spec->kctl_alloc = knew;
  2682. spec->num_kctl_alloc = num;
  2683. }
  2684. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2685. *knew = alc880_control_templates[type];
  2686. knew->name = kstrdup(name, GFP_KERNEL);
  2687. if (!knew->name)
  2688. return -ENOMEM;
  2689. knew->private_value = val;
  2690. spec->num_kctl_used++;
  2691. return 0;
  2692. }
  2693. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2694. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2695. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2696. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2697. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2698. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2699. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2700. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2701. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2702. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2703. #define ALC880_PIN_CD_NID 0x1c
  2704. /* fill in the dac_nids table from the parsed pin configuration */
  2705. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2706. const struct auto_pin_cfg *cfg)
  2707. {
  2708. hda_nid_t nid;
  2709. int assigned[4];
  2710. int i, j;
  2711. memset(assigned, 0, sizeof(assigned));
  2712. spec->multiout.dac_nids = spec->private_dac_nids;
  2713. /* check the pins hardwired to audio widget */
  2714. for (i = 0; i < cfg->line_outs; i++) {
  2715. nid = cfg->line_out_pins[i];
  2716. if (alc880_is_fixed_pin(nid)) {
  2717. int idx = alc880_fixed_pin_idx(nid);
  2718. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2719. assigned[idx] = 1;
  2720. }
  2721. }
  2722. /* left pins can be connect to any audio widget */
  2723. for (i = 0; i < cfg->line_outs; i++) {
  2724. nid = cfg->line_out_pins[i];
  2725. if (alc880_is_fixed_pin(nid))
  2726. continue;
  2727. /* search for an empty channel */
  2728. for (j = 0; j < cfg->line_outs; j++) {
  2729. if (!assigned[j]) {
  2730. spec->multiout.dac_nids[i] =
  2731. alc880_idx_to_dac(j);
  2732. assigned[j] = 1;
  2733. break;
  2734. }
  2735. }
  2736. }
  2737. spec->multiout.num_dacs = cfg->line_outs;
  2738. return 0;
  2739. }
  2740. /* add playback controls from the parsed DAC table */
  2741. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2742. const struct auto_pin_cfg *cfg)
  2743. {
  2744. char name[32];
  2745. static const char *chname[4] = {
  2746. "Front", "Surround", NULL /*CLFE*/, "Side"
  2747. };
  2748. hda_nid_t nid;
  2749. int i, err;
  2750. for (i = 0; i < cfg->line_outs; i++) {
  2751. if (!spec->multiout.dac_nids[i])
  2752. continue;
  2753. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2754. if (i == 2) {
  2755. /* Center/LFE */
  2756. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2757. "Center Playback Volume",
  2758. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2759. HDA_OUTPUT));
  2760. if (err < 0)
  2761. return err;
  2762. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2763. "LFE Playback Volume",
  2764. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2765. HDA_OUTPUT));
  2766. if (err < 0)
  2767. return err;
  2768. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2769. "Center Playback Switch",
  2770. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2771. HDA_INPUT));
  2772. if (err < 0)
  2773. return err;
  2774. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2775. "LFE Playback Switch",
  2776. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2777. HDA_INPUT));
  2778. if (err < 0)
  2779. return err;
  2780. } else {
  2781. sprintf(name, "%s Playback Volume", chname[i]);
  2782. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2783. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2784. HDA_OUTPUT));
  2785. if (err < 0)
  2786. return err;
  2787. sprintf(name, "%s Playback Switch", chname[i]);
  2788. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2789. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2790. HDA_INPUT));
  2791. if (err < 0)
  2792. return err;
  2793. }
  2794. }
  2795. return 0;
  2796. }
  2797. /* add playback controls for speaker and HP outputs */
  2798. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2799. const char *pfx)
  2800. {
  2801. hda_nid_t nid;
  2802. int err;
  2803. char name[32];
  2804. if (!pin)
  2805. return 0;
  2806. if (alc880_is_fixed_pin(pin)) {
  2807. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2808. /* specify the DAC as the extra output */
  2809. if (!spec->multiout.hp_nid)
  2810. spec->multiout.hp_nid = nid;
  2811. else
  2812. spec->multiout.extra_out_nid[0] = nid;
  2813. /* control HP volume/switch on the output mixer amp */
  2814. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2815. sprintf(name, "%s Playback Volume", pfx);
  2816. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2817. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2818. if (err < 0)
  2819. return err;
  2820. sprintf(name, "%s Playback Switch", pfx);
  2821. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2822. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2823. if (err < 0)
  2824. return err;
  2825. } else if (alc880_is_multi_pin(pin)) {
  2826. /* set manual connection */
  2827. /* we have only a switch on HP-out PIN */
  2828. sprintf(name, "%s Playback Switch", pfx);
  2829. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2830. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2831. if (err < 0)
  2832. return err;
  2833. }
  2834. return 0;
  2835. }
  2836. /* create input playback/capture controls for the given pin */
  2837. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2838. const char *ctlname,
  2839. int idx, hda_nid_t mix_nid)
  2840. {
  2841. char name[32];
  2842. int err;
  2843. sprintf(name, "%s Playback Volume", ctlname);
  2844. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2845. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2846. if (err < 0)
  2847. return err;
  2848. sprintf(name, "%s Playback Switch", ctlname);
  2849. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2850. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2851. if (err < 0)
  2852. return err;
  2853. return 0;
  2854. }
  2855. /* create playback/capture controls for input pins */
  2856. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2857. const struct auto_pin_cfg *cfg)
  2858. {
  2859. struct hda_input_mux *imux = &spec->private_imux;
  2860. int i, err, idx;
  2861. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2862. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2863. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2864. err = new_analog_input(spec, cfg->input_pins[i],
  2865. auto_pin_cfg_labels[i],
  2866. idx, 0x0b);
  2867. if (err < 0)
  2868. return err;
  2869. imux->items[imux->num_items].label =
  2870. auto_pin_cfg_labels[i];
  2871. imux->items[imux->num_items].index =
  2872. alc880_input_pin_idx(cfg->input_pins[i]);
  2873. imux->num_items++;
  2874. }
  2875. }
  2876. return 0;
  2877. }
  2878. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2879. hda_nid_t nid, int pin_type,
  2880. int dac_idx)
  2881. {
  2882. /* set as output */
  2883. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2884. pin_type);
  2885. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2886. AMP_OUT_UNMUTE);
  2887. /* need the manual connection? */
  2888. if (alc880_is_multi_pin(nid)) {
  2889. struct alc_spec *spec = codec->spec;
  2890. int idx = alc880_multi_pin_idx(nid);
  2891. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2892. AC_VERB_SET_CONNECT_SEL,
  2893. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2894. }
  2895. }
  2896. static int get_pin_type(int line_out_type)
  2897. {
  2898. if (line_out_type == AUTO_PIN_HP_OUT)
  2899. return PIN_HP;
  2900. else
  2901. return PIN_OUT;
  2902. }
  2903. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2904. {
  2905. struct alc_spec *spec = codec->spec;
  2906. int i;
  2907. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2908. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2909. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2910. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2911. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2912. }
  2913. }
  2914. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2915. {
  2916. struct alc_spec *spec = codec->spec;
  2917. hda_nid_t pin;
  2918. pin = spec->autocfg.speaker_pins[0];
  2919. if (pin) /* connect to front */
  2920. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2921. pin = spec->autocfg.hp_pins[0];
  2922. if (pin) /* connect to front */
  2923. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2924. }
  2925. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2926. {
  2927. struct alc_spec *spec = codec->spec;
  2928. int i;
  2929. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2930. hda_nid_t nid = spec->autocfg.input_pins[i];
  2931. if (alc880_is_input_pin(nid)) {
  2932. snd_hda_codec_write(codec, nid, 0,
  2933. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2934. i <= AUTO_PIN_FRONT_MIC ?
  2935. PIN_VREF80 : PIN_IN);
  2936. if (nid != ALC880_PIN_CD_NID)
  2937. snd_hda_codec_write(codec, nid, 0,
  2938. AC_VERB_SET_AMP_GAIN_MUTE,
  2939. AMP_OUT_MUTE);
  2940. }
  2941. }
  2942. }
  2943. /* parse the BIOS configuration and set up the alc_spec */
  2944. /* return 1 if successful, 0 if the proper config is not found,
  2945. * or a negative error code
  2946. */
  2947. static int alc880_parse_auto_config(struct hda_codec *codec)
  2948. {
  2949. struct alc_spec *spec = codec->spec;
  2950. int err;
  2951. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2952. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2953. alc880_ignore);
  2954. if (err < 0)
  2955. return err;
  2956. if (!spec->autocfg.line_outs)
  2957. return 0; /* can't find valid BIOS pin config */
  2958. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2959. if (err < 0)
  2960. return err;
  2961. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2962. if (err < 0)
  2963. return err;
  2964. err = alc880_auto_create_extra_out(spec,
  2965. spec->autocfg.speaker_pins[0],
  2966. "Speaker");
  2967. if (err < 0)
  2968. return err;
  2969. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2970. "Headphone");
  2971. if (err < 0)
  2972. return err;
  2973. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2974. if (err < 0)
  2975. return err;
  2976. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2977. if (spec->autocfg.dig_out_pin)
  2978. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2979. if (spec->autocfg.dig_in_pin)
  2980. spec->dig_in_nid = ALC880_DIGIN_NID;
  2981. if (spec->kctl_alloc)
  2982. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2983. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2984. spec->num_mux_defs = 1;
  2985. spec->input_mux = &spec->private_imux;
  2986. return 1;
  2987. }
  2988. /* additional initialization for auto-configuration model */
  2989. static void alc880_auto_init(struct hda_codec *codec)
  2990. {
  2991. alc880_auto_init_multi_out(codec);
  2992. alc880_auto_init_extra_out(codec);
  2993. alc880_auto_init_analog_input(codec);
  2994. }
  2995. /*
  2996. * OK, here we have finally the patch for ALC880
  2997. */
  2998. static int patch_alc880(struct hda_codec *codec)
  2999. {
  3000. struct alc_spec *spec;
  3001. int board_config;
  3002. int err;
  3003. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3004. if (spec == NULL)
  3005. return -ENOMEM;
  3006. codec->spec = spec;
  3007. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3008. alc880_models,
  3009. alc880_cfg_tbl);
  3010. if (board_config < 0) {
  3011. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3012. "trying auto-probe from BIOS...\n");
  3013. board_config = ALC880_AUTO;
  3014. }
  3015. if (board_config == ALC880_AUTO) {
  3016. /* automatic parse from the BIOS config */
  3017. err = alc880_parse_auto_config(codec);
  3018. if (err < 0) {
  3019. alc_free(codec);
  3020. return err;
  3021. } else if (!err) {
  3022. printk(KERN_INFO
  3023. "hda_codec: Cannot set up configuration "
  3024. "from BIOS. Using 3-stack mode...\n");
  3025. board_config = ALC880_3ST;
  3026. }
  3027. }
  3028. if (board_config != ALC880_AUTO)
  3029. setup_preset(spec, &alc880_presets[board_config]);
  3030. spec->stream_name_analog = "ALC880 Analog";
  3031. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3032. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3033. spec->stream_name_digital = "ALC880 Digital";
  3034. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3035. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3036. if (!spec->adc_nids && spec->input_mux) {
  3037. /* check whether NID 0x07 is valid */
  3038. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3039. /* get type */
  3040. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3041. if (wcap != AC_WID_AUD_IN) {
  3042. spec->adc_nids = alc880_adc_nids_alt;
  3043. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3044. spec->mixers[spec->num_mixers] =
  3045. alc880_capture_alt_mixer;
  3046. spec->num_mixers++;
  3047. } else {
  3048. spec->adc_nids = alc880_adc_nids;
  3049. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3050. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3051. spec->num_mixers++;
  3052. }
  3053. }
  3054. codec->patch_ops = alc_patch_ops;
  3055. if (board_config == ALC880_AUTO)
  3056. spec->init_hook = alc880_auto_init;
  3057. return 0;
  3058. }
  3059. /*
  3060. * ALC260 support
  3061. */
  3062. static hda_nid_t alc260_dac_nids[1] = {
  3063. /* front */
  3064. 0x02,
  3065. };
  3066. static hda_nid_t alc260_adc_nids[1] = {
  3067. /* ADC0 */
  3068. 0x04,
  3069. };
  3070. static hda_nid_t alc260_adc_nids_alt[1] = {
  3071. /* ADC1 */
  3072. 0x05,
  3073. };
  3074. static hda_nid_t alc260_hp_adc_nids[2] = {
  3075. /* ADC1, 0 */
  3076. 0x05, 0x04
  3077. };
  3078. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3079. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3080. */
  3081. static hda_nid_t alc260_dual_adc_nids[2] = {
  3082. /* ADC0, ADC1 */
  3083. 0x04, 0x05
  3084. };
  3085. #define ALC260_DIGOUT_NID 0x03
  3086. #define ALC260_DIGIN_NID 0x06
  3087. static struct hda_input_mux alc260_capture_source = {
  3088. .num_items = 4,
  3089. .items = {
  3090. { "Mic", 0x0 },
  3091. { "Front Mic", 0x1 },
  3092. { "Line", 0x2 },
  3093. { "CD", 0x4 },
  3094. },
  3095. };
  3096. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3097. * headphone jack and the internal CD lines since these are the only pins at
  3098. * which audio can appear. For flexibility, also allow the option of
  3099. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3100. * connection to the mixer output).
  3101. */
  3102. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3103. {
  3104. .num_items = 3,
  3105. .items = {
  3106. { "Mic/Line", 0x0 },
  3107. { "CD", 0x4 },
  3108. { "Headphone", 0x2 },
  3109. },
  3110. },
  3111. {
  3112. .num_items = 4,
  3113. .items = {
  3114. { "Mic/Line", 0x0 },
  3115. { "CD", 0x4 },
  3116. { "Headphone", 0x2 },
  3117. { "Mixer", 0x5 },
  3118. },
  3119. },
  3120. };
  3121. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3122. * the Fujitsu S702x, but jacks are marked differently.
  3123. */
  3124. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic", 0x0 },
  3129. { "Line", 0x2 },
  3130. { "CD", 0x4 },
  3131. { "Headphone", 0x5 },
  3132. },
  3133. },
  3134. {
  3135. .num_items = 5,
  3136. .items = {
  3137. { "Mic", 0x0 },
  3138. { "Line", 0x2 },
  3139. { "CD", 0x4 },
  3140. { "Headphone", 0x6 },
  3141. { "Mixer", 0x5 },
  3142. },
  3143. },
  3144. };
  3145. /*
  3146. * This is just place-holder, so there's something for alc_build_pcms to look
  3147. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3148. * element which allows changing the channel mode, so the verb list is
  3149. * never used.
  3150. */
  3151. static struct hda_channel_mode alc260_modes[1] = {
  3152. { 2, NULL },
  3153. };
  3154. /* Mixer combinations
  3155. *
  3156. * basic: base_output + input + pc_beep + capture
  3157. * HP: base_output + input + capture_alt
  3158. * HP_3013: hp_3013 + input + capture
  3159. * fujitsu: fujitsu + capture
  3160. * acer: acer + capture
  3161. */
  3162. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3163. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3164. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3165. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3166. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3167. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3168. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3169. { } /* end */
  3170. };
  3171. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3172. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3173. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3174. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3175. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3176. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3177. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3178. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3179. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3180. { } /* end */
  3181. };
  3182. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3183. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3184. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3185. { } /* end */
  3186. };
  3187. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3188. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3189. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3190. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3193. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3194. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3195. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3196. { } /* end */
  3197. };
  3198. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3199. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3200. */
  3201. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3202. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3203. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3204. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  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/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3208. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3209. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3210. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3211. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3212. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3213. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3214. { } /* end */
  3215. };
  3216. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3217. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3218. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3219. * datasheet doesn't mention this restriction. At this stage it's not clear
  3220. * whether this behaviour is intentional or is a hardware bug in chip
  3221. * revisions available in early 2006. Therefore for now allow the
  3222. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3223. * that the lack of mic bias for this NID is intentional we could change the
  3224. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3225. *
  3226. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3227. * don't appear to make the mic bias available from the "line" jack, even
  3228. * though the NID used for this jack (0x14) can supply it. The theory is
  3229. * that perhaps Acer have included blocking capacitors between the ALC260
  3230. * and the output jack. If this turns out to be the case for all such
  3231. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3232. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3233. *
  3234. * The C20x Tablet series have a mono internal speaker which is controlled
  3235. * via the chip's Mono sum widget and pin complex, so include the necessary
  3236. * controls for such models. On models without a "mono speaker" the control
  3237. * won't do anything.
  3238. */
  3239. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3240. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3241. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3242. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3243. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3244. HDA_OUTPUT),
  3245. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3246. HDA_INPUT),
  3247. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3248. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3249. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3250. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3251. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3252. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3253. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3254. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3255. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3256. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3257. { } /* end */
  3258. };
  3259. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3260. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3261. */
  3262. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3263. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3264. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3266. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3267. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3268. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3269. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3270. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3271. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3272. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3273. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3274. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3275. { } /* end */
  3276. };
  3277. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3278. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3279. */
  3280. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3281. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3282. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3283. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3284. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3285. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3286. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3287. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3288. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3289. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3290. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3291. { } /* end */
  3292. };
  3293. /* capture mixer elements */
  3294. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3295. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3296. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3297. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3299. {
  3300. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3301. /* The multiple "Capture Source" controls confuse alsamixer
  3302. * So call somewhat different..
  3303. * FIXME: the controls appear in the "playback" view!
  3304. */
  3305. /* .name = "Capture Source", */
  3306. .name = "Input Source",
  3307. .count = 2,
  3308. .info = alc_mux_enum_info,
  3309. .get = alc_mux_enum_get,
  3310. .put = alc_mux_enum_put,
  3311. },
  3312. { } /* end */
  3313. };
  3314. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3315. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3316. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3317. {
  3318. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3319. /* The multiple "Capture Source" controls confuse alsamixer
  3320. * So call somewhat different..
  3321. * FIXME: the controls appear in the "playback" view!
  3322. */
  3323. /* .name = "Capture Source", */
  3324. .name = "Input Source",
  3325. .count = 1,
  3326. .info = alc_mux_enum_info,
  3327. .get = alc_mux_enum_get,
  3328. .put = alc_mux_enum_put,
  3329. },
  3330. { } /* end */
  3331. };
  3332. /*
  3333. * initialization verbs
  3334. */
  3335. static struct hda_verb alc260_init_verbs[] = {
  3336. /* Line In pin widget for input */
  3337. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3338. /* CD pin widget for input */
  3339. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3340. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3341. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3342. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3343. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3344. /* LINE-2 is used for line-out in rear */
  3345. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3346. /* select line-out */
  3347. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3348. /* LINE-OUT pin */
  3349. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3350. /* enable HP */
  3351. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3352. /* enable Mono */
  3353. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3354. /* mute capture amp left and right */
  3355. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3356. /* set connection select to line in (default select for this ADC) */
  3357. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3358. /* mute capture amp left and right */
  3359. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3360. /* set connection select to line in (default select for this ADC) */
  3361. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3362. /* set vol=0 Line-Out mixer amp left and right */
  3363. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3364. /* unmute pin widget amp left and right (no gain on this amp) */
  3365. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3366. /* set vol=0 HP mixer amp left and right */
  3367. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3368. /* unmute pin widget amp left and right (no gain on this amp) */
  3369. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3370. /* set vol=0 Mono mixer amp left and right */
  3371. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3372. /* unmute pin widget amp left and right (no gain on this amp) */
  3373. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3374. /* unmute LINE-2 out pin */
  3375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3376. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3377. * Line In 2 = 0x03
  3378. */
  3379. /* mute CD */
  3380. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3381. /* mute Line In */
  3382. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3383. /* mute Mic */
  3384. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3385. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3386. /* mute Front out path */
  3387. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3388. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3389. /* mute Headphone out path */
  3390. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3391. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3392. /* mute Mono out path */
  3393. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3394. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3395. { }
  3396. };
  3397. #if 0 /* should be identical with alc260_init_verbs? */
  3398. static struct hda_verb alc260_hp_init_verbs[] = {
  3399. /* Headphone and output */
  3400. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3401. /* mono output */
  3402. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3403. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3404. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3405. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3406. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3407. /* Line In pin widget for input */
  3408. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3409. /* Line-2 pin widget for output */
  3410. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3411. /* CD pin widget for input */
  3412. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3413. /* unmute amp left and right */
  3414. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3415. /* set connection select to line in (default select for this ADC) */
  3416. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3417. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3418. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3419. /* mute pin widget amp left and right (no gain on this amp) */
  3420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3421. /* unmute HP mixer amp left and right (volume = 0) */
  3422. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3423. /* mute pin widget amp left and right (no gain on this amp) */
  3424. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3425. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3426. * Line In 2 = 0x03
  3427. */
  3428. /* unmute CD */
  3429. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3430. /* unmute Line In */
  3431. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3432. /* unmute Mic */
  3433. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3434. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3435. /* Unmute Front out path */
  3436. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3437. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3438. /* Unmute Headphone out path */
  3439. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3440. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3441. /* Unmute Mono out path */
  3442. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3443. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3444. { }
  3445. };
  3446. #endif
  3447. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3448. /* Line out and output */
  3449. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3450. /* mono output */
  3451. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3452. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3453. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3454. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3455. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3456. /* Line In pin widget for input */
  3457. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3458. /* Headphone pin widget for output */
  3459. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3460. /* CD pin widget for input */
  3461. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3462. /* unmute amp left and right */
  3463. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3464. /* set connection select to line in (default select for this ADC) */
  3465. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3466. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3467. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3468. /* mute pin widget amp left and right (no gain on this amp) */
  3469. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3470. /* unmute HP mixer amp left and right (volume = 0) */
  3471. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3472. /* mute pin widget amp left and right (no gain on this amp) */
  3473. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3474. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3475. * Line In 2 = 0x03
  3476. */
  3477. /* unmute CD */
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3479. /* unmute Line In */
  3480. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3481. /* unmute Mic */
  3482. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3483. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3484. /* Unmute Front out path */
  3485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3486. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3487. /* Unmute Headphone out path */
  3488. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3489. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3490. /* Unmute Mono out path */
  3491. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3492. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3493. { }
  3494. };
  3495. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3496. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3497. * audio = 0x16, internal speaker = 0x10.
  3498. */
  3499. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3500. /* Disable all GPIOs */
  3501. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3502. /* Internal speaker is connected to headphone pin */
  3503. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3504. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3505. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3506. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3507. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3508. /* Ensure all other unused pins are disabled and muted. */
  3509. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3510. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3511. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3512. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3514. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3516. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3517. /* Disable digital (SPDIF) pins */
  3518. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3519. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3520. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3521. * when acting as an output.
  3522. */
  3523. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3524. /* Start with output sum widgets muted and their output gains at min */
  3525. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3527. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3528. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3530. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3531. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3533. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3534. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3535. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3536. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3537. * If the pin mode is changed by the user the pin mode control will
  3538. * take care of enabling the pin's input/output buffers as needed.
  3539. * Therefore there's no need to enable the input buffer at this
  3540. * stage.
  3541. */
  3542. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3543. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3544. * mixer ctrl)
  3545. */
  3546. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3547. /* Mute capture amp left and right */
  3548. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3549. /* Set ADC connection select to match default mixer setting - line
  3550. * in (on mic1 pin)
  3551. */
  3552. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3553. /* Do the same for the second ADC: mute capture input amp and
  3554. * set ADC connection to line in (on mic1 pin)
  3555. */
  3556. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3557. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3558. /* Mute all inputs to mixer widget (even unconnected ones) */
  3559. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3560. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3561. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3562. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3563. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3564. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3565. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3566. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3567. { }
  3568. };
  3569. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3570. * similar laptops (adapted from Fujitsu init verbs).
  3571. */
  3572. static struct hda_verb alc260_acer_init_verbs[] = {
  3573. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3574. * the headphone jack. Turn this on and rely on the standard mute
  3575. * methods whenever the user wants to turn these outputs off.
  3576. */
  3577. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3578. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3579. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3580. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3581. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3582. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3583. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3584. /* Line In jack is connected to Line1 pin */
  3585. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3586. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3587. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3588. /* Ensure all other unused pins are disabled and muted. */
  3589. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3590. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3591. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3592. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3593. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3594. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3595. /* Disable digital (SPDIF) pins */
  3596. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3597. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3598. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3599. * bus when acting as outputs.
  3600. */
  3601. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3602. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3603. /* Start with output sum widgets muted and their output gains at min */
  3604. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3606. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3607. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3609. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3610. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3611. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3612. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3613. /* Unmute Line-out pin widget amp left and right
  3614. * (no equiv mixer ctrl)
  3615. */
  3616. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3617. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3618. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3619. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3620. * inputs. If the pin mode is changed by the user the pin mode control
  3621. * will take care of enabling the pin's input/output buffers as needed.
  3622. * Therefore there's no need to enable the input buffer at this
  3623. * stage.
  3624. */
  3625. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3626. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3627. /* Mute capture amp left and right */
  3628. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3629. /* Set ADC connection select to match default mixer setting - mic
  3630. * (on mic1 pin)
  3631. */
  3632. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3633. /* Do similar with the second ADC: mute capture input amp and
  3634. * set ADC connection to mic to match ALSA's default state.
  3635. */
  3636. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3637. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3638. /* Mute all inputs to mixer widget (even unconnected ones) */
  3639. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3640. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3641. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3642. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3643. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3644. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3645. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3646. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3647. { }
  3648. };
  3649. static struct hda_verb alc260_will_verbs[] = {
  3650. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3651. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3653. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3654. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3655. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3656. {}
  3657. };
  3658. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3659. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3660. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3661. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3662. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3663. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3664. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3665. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3666. {}
  3667. };
  3668. /* toggle speaker-output according to the hp-jack state */
  3669. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3670. {
  3671. unsigned int present;
  3672. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3673. present = snd_hda_codec_read(codec, 0x0f, 0,
  3674. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3675. if (present) {
  3676. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3677. snd_hda_codec_write(codec, 0x0f, 0,
  3678. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3679. } else {
  3680. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3681. snd_hda_codec_write(codec, 0x0f, 0,
  3682. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3683. }
  3684. }
  3685. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3686. unsigned int res)
  3687. {
  3688. if ((res >> 26) == ALC880_HP_EVENT)
  3689. alc260_replacer_672v_automute(codec);
  3690. }
  3691. /* Test configuration for debugging, modelled after the ALC880 test
  3692. * configuration.
  3693. */
  3694. #ifdef CONFIG_SND_DEBUG
  3695. static hda_nid_t alc260_test_dac_nids[1] = {
  3696. 0x02,
  3697. };
  3698. static hda_nid_t alc260_test_adc_nids[2] = {
  3699. 0x04, 0x05,
  3700. };
  3701. /* For testing the ALC260, each input MUX needs its own definition since
  3702. * the signal assignments are different. This assumes that the first ADC
  3703. * is NID 0x04.
  3704. */
  3705. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3706. {
  3707. .num_items = 7,
  3708. .items = {
  3709. { "MIC1 pin", 0x0 },
  3710. { "MIC2 pin", 0x1 },
  3711. { "LINE1 pin", 0x2 },
  3712. { "LINE2 pin", 0x3 },
  3713. { "CD pin", 0x4 },
  3714. { "LINE-OUT pin", 0x5 },
  3715. { "HP-OUT pin", 0x6 },
  3716. },
  3717. },
  3718. {
  3719. .num_items = 8,
  3720. .items = {
  3721. { "MIC1 pin", 0x0 },
  3722. { "MIC2 pin", 0x1 },
  3723. { "LINE1 pin", 0x2 },
  3724. { "LINE2 pin", 0x3 },
  3725. { "CD pin", 0x4 },
  3726. { "Mixer", 0x5 },
  3727. { "LINE-OUT pin", 0x6 },
  3728. { "HP-OUT pin", 0x7 },
  3729. },
  3730. },
  3731. };
  3732. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3733. /* Output driver widgets */
  3734. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3735. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3736. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3737. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3738. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3739. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3740. /* Modes for retasking pin widgets
  3741. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3742. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3743. * mention this restriction. At this stage it's not clear whether
  3744. * this behaviour is intentional or is a hardware bug in chip
  3745. * revisions available at least up until early 2006. Therefore for
  3746. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3747. * choices, but if it turns out that the lack of mic bias for these
  3748. * NIDs is intentional we could change their modes from
  3749. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3750. */
  3751. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3752. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3753. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3754. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3755. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3756. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3757. /* Loopback mixer controls */
  3758. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3759. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3760. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3761. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3762. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3763. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3764. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3765. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3766. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3767. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3768. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3769. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3770. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3771. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3772. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3773. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3774. /* Controls for GPIO pins, assuming they are configured as outputs */
  3775. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3776. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3777. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3778. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3779. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3780. * is ambigious as to which NID is which; testing on laptops which
  3781. * make this output available should provide clarification.
  3782. */
  3783. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3784. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3785. { } /* end */
  3786. };
  3787. static struct hda_verb alc260_test_init_verbs[] = {
  3788. /* Enable all GPIOs as outputs with an initial value of 0 */
  3789. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3790. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3791. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3792. /* Enable retasking pins as output, initially without power amp */
  3793. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3794. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3795. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3796. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3797. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3798. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3799. /* Disable digital (SPDIF) pins initially, but users can enable
  3800. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3801. * payload also sets the generation to 0, output to be in "consumer"
  3802. * PCM format, copyright asserted, no pre-emphasis and no validity
  3803. * control.
  3804. */
  3805. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3806. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3807. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3808. * OUT1 sum bus when acting as an output.
  3809. */
  3810. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3811. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3812. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3813. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3814. /* Start with output sum widgets muted and their output gains at min */
  3815. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3816. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3817. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3818. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3819. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3820. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3821. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3822. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3823. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3824. /* Unmute retasking pin widget output buffers since the default
  3825. * state appears to be output. As the pin mode is changed by the
  3826. * user the pin mode control will take care of enabling the pin's
  3827. * input/output buffers as needed.
  3828. */
  3829. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3830. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3831. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3832. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3833. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3834. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3835. /* Also unmute the mono-out pin widget */
  3836. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3837. /* Mute capture amp left and right */
  3838. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3839. /* Set ADC connection select to match default mixer setting (mic1
  3840. * pin)
  3841. */
  3842. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3843. /* Do the same for the second ADC: mute capture input amp and
  3844. * set ADC connection to mic1 pin
  3845. */
  3846. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3847. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3848. /* Mute all inputs to mixer widget (even unconnected ones) */
  3849. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3850. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3851. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3852. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3853. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3854. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3855. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3856. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3857. { }
  3858. };
  3859. #endif
  3860. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3861. .substreams = 1,
  3862. .channels_min = 2,
  3863. .channels_max = 2,
  3864. };
  3865. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3866. .substreams = 1,
  3867. .channels_min = 2,
  3868. .channels_max = 2,
  3869. };
  3870. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3871. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3872. /*
  3873. * for BIOS auto-configuration
  3874. */
  3875. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3876. const char *pfx)
  3877. {
  3878. hda_nid_t nid_vol;
  3879. unsigned long vol_val, sw_val;
  3880. char name[32];
  3881. int err;
  3882. if (nid >= 0x0f && nid < 0x11) {
  3883. nid_vol = nid - 0x7;
  3884. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3885. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3886. } else if (nid == 0x11) {
  3887. nid_vol = nid - 0x7;
  3888. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3889. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3890. } else if (nid >= 0x12 && nid <= 0x15) {
  3891. nid_vol = 0x08;
  3892. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3893. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3894. } else
  3895. return 0; /* N/A */
  3896. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3897. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3898. if (err < 0)
  3899. return err;
  3900. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3901. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3902. if (err < 0)
  3903. return err;
  3904. return 1;
  3905. }
  3906. /* add playback controls from the parsed DAC table */
  3907. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3908. const struct auto_pin_cfg *cfg)
  3909. {
  3910. hda_nid_t nid;
  3911. int err;
  3912. spec->multiout.num_dacs = 1;
  3913. spec->multiout.dac_nids = spec->private_dac_nids;
  3914. spec->multiout.dac_nids[0] = 0x02;
  3915. nid = cfg->line_out_pins[0];
  3916. if (nid) {
  3917. err = alc260_add_playback_controls(spec, nid, "Front");
  3918. if (err < 0)
  3919. return err;
  3920. }
  3921. nid = cfg->speaker_pins[0];
  3922. if (nid) {
  3923. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3924. if (err < 0)
  3925. return err;
  3926. }
  3927. nid = cfg->hp_pins[0];
  3928. if (nid) {
  3929. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3930. if (err < 0)
  3931. return err;
  3932. }
  3933. return 0;
  3934. }
  3935. /* create playback/capture controls for input pins */
  3936. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3937. const struct auto_pin_cfg *cfg)
  3938. {
  3939. struct hda_input_mux *imux = &spec->private_imux;
  3940. int i, err, idx;
  3941. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3942. if (cfg->input_pins[i] >= 0x12) {
  3943. idx = cfg->input_pins[i] - 0x12;
  3944. err = new_analog_input(spec, cfg->input_pins[i],
  3945. auto_pin_cfg_labels[i], idx,
  3946. 0x07);
  3947. if (err < 0)
  3948. return err;
  3949. imux->items[imux->num_items].label =
  3950. auto_pin_cfg_labels[i];
  3951. imux->items[imux->num_items].index = idx;
  3952. imux->num_items++;
  3953. }
  3954. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3955. idx = cfg->input_pins[i] - 0x09;
  3956. err = new_analog_input(spec, cfg->input_pins[i],
  3957. auto_pin_cfg_labels[i], idx,
  3958. 0x07);
  3959. if (err < 0)
  3960. return err;
  3961. imux->items[imux->num_items].label =
  3962. auto_pin_cfg_labels[i];
  3963. imux->items[imux->num_items].index = idx;
  3964. imux->num_items++;
  3965. }
  3966. }
  3967. return 0;
  3968. }
  3969. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3970. hda_nid_t nid, int pin_type,
  3971. int sel_idx)
  3972. {
  3973. /* set as output */
  3974. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3975. pin_type);
  3976. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3977. AMP_OUT_UNMUTE);
  3978. /* need the manual connection? */
  3979. if (nid >= 0x12) {
  3980. int idx = nid - 0x12;
  3981. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3982. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3983. }
  3984. }
  3985. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3986. {
  3987. struct alc_spec *spec = codec->spec;
  3988. hda_nid_t nid;
  3989. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3990. nid = spec->autocfg.line_out_pins[0];
  3991. if (nid) {
  3992. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3993. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3994. }
  3995. nid = spec->autocfg.speaker_pins[0];
  3996. if (nid)
  3997. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3998. nid = spec->autocfg.hp_pins[0];
  3999. if (nid)
  4000. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4001. }
  4002. #define ALC260_PIN_CD_NID 0x16
  4003. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4004. {
  4005. struct alc_spec *spec = codec->spec;
  4006. int i;
  4007. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4008. hda_nid_t nid = spec->autocfg.input_pins[i];
  4009. if (nid >= 0x12) {
  4010. snd_hda_codec_write(codec, nid, 0,
  4011. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4012. i <= AUTO_PIN_FRONT_MIC ?
  4013. PIN_VREF80 : PIN_IN);
  4014. if (nid != ALC260_PIN_CD_NID)
  4015. snd_hda_codec_write(codec, nid, 0,
  4016. AC_VERB_SET_AMP_GAIN_MUTE,
  4017. AMP_OUT_MUTE);
  4018. }
  4019. }
  4020. }
  4021. /*
  4022. * generic initialization of ADC, input mixers and output mixers
  4023. */
  4024. static struct hda_verb alc260_volume_init_verbs[] = {
  4025. /*
  4026. * Unmute ADC0-1 and set the default input to mic-in
  4027. */
  4028. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4029. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4030. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4031. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4032. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4033. * mixer widget
  4034. * Note: PASD motherboards uses the Line In 2 as the input for
  4035. * front panel mic (mic 2)
  4036. */
  4037. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4038. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4039. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4040. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4041. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4042. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4043. /*
  4044. * Set up output mixers (0x08 - 0x0a)
  4045. */
  4046. /* set vol=0 to output mixers */
  4047. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4048. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4049. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4050. /* set up input amps for analog loopback */
  4051. /* Amp Indices: DAC = 0, mixer = 1 */
  4052. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4053. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4054. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4055. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4056. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4057. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4058. { }
  4059. };
  4060. static int alc260_parse_auto_config(struct hda_codec *codec)
  4061. {
  4062. struct alc_spec *spec = codec->spec;
  4063. unsigned int wcap;
  4064. int err;
  4065. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4066. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4067. alc260_ignore);
  4068. if (err < 0)
  4069. return err;
  4070. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4071. if (err < 0)
  4072. return err;
  4073. if (!spec->kctl_alloc)
  4074. return 0; /* can't find valid BIOS pin config */
  4075. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4076. if (err < 0)
  4077. return err;
  4078. spec->multiout.max_channels = 2;
  4079. if (spec->autocfg.dig_out_pin)
  4080. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4081. if (spec->kctl_alloc)
  4082. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4083. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4084. spec->num_mux_defs = 1;
  4085. spec->input_mux = &spec->private_imux;
  4086. /* check whether NID 0x04 is valid */
  4087. wcap = get_wcaps(codec, 0x04);
  4088. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4089. if (wcap != AC_WID_AUD_IN) {
  4090. spec->adc_nids = alc260_adc_nids_alt;
  4091. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4092. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4093. } else {
  4094. spec->adc_nids = alc260_adc_nids;
  4095. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4096. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4097. }
  4098. spec->num_mixers++;
  4099. return 1;
  4100. }
  4101. /* additional initialization for auto-configuration model */
  4102. static void alc260_auto_init(struct hda_codec *codec)
  4103. {
  4104. alc260_auto_init_multi_out(codec);
  4105. alc260_auto_init_analog_input(codec);
  4106. }
  4107. /*
  4108. * ALC260 configurations
  4109. */
  4110. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4111. [ALC260_BASIC] = "basic",
  4112. [ALC260_HP] = "hp",
  4113. [ALC260_HP_3013] = "hp-3013",
  4114. [ALC260_FUJITSU_S702X] = "fujitsu",
  4115. [ALC260_ACER] = "acer",
  4116. [ALC260_WILL] = "will",
  4117. [ALC260_REPLACER_672V] = "replacer",
  4118. #ifdef CONFIG_SND_DEBUG
  4119. [ALC260_TEST] = "test",
  4120. #endif
  4121. [ALC260_AUTO] = "auto",
  4122. };
  4123. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4124. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4125. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4126. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4127. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4128. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4129. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4130. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4131. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4132. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4133. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4134. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4135. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4136. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4137. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4138. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4139. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4140. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4141. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4142. {}
  4143. };
  4144. static struct alc_config_preset alc260_presets[] = {
  4145. [ALC260_BASIC] = {
  4146. .mixers = { alc260_base_output_mixer,
  4147. alc260_input_mixer,
  4148. alc260_pc_beep_mixer,
  4149. alc260_capture_mixer },
  4150. .init_verbs = { alc260_init_verbs },
  4151. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4152. .dac_nids = alc260_dac_nids,
  4153. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4154. .adc_nids = alc260_adc_nids,
  4155. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4156. .channel_mode = alc260_modes,
  4157. .input_mux = &alc260_capture_source,
  4158. },
  4159. [ALC260_HP] = {
  4160. .mixers = { alc260_base_output_mixer,
  4161. alc260_input_mixer,
  4162. alc260_capture_alt_mixer },
  4163. .init_verbs = { alc260_init_verbs },
  4164. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4165. .dac_nids = alc260_dac_nids,
  4166. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4167. .adc_nids = alc260_hp_adc_nids,
  4168. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4169. .channel_mode = alc260_modes,
  4170. .input_mux = &alc260_capture_source,
  4171. },
  4172. [ALC260_HP_3013] = {
  4173. .mixers = { alc260_hp_3013_mixer,
  4174. alc260_input_mixer,
  4175. alc260_capture_alt_mixer },
  4176. .init_verbs = { alc260_hp_3013_init_verbs },
  4177. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4178. .dac_nids = alc260_dac_nids,
  4179. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4180. .adc_nids = alc260_hp_adc_nids,
  4181. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4182. .channel_mode = alc260_modes,
  4183. .input_mux = &alc260_capture_source,
  4184. },
  4185. [ALC260_FUJITSU_S702X] = {
  4186. .mixers = { alc260_fujitsu_mixer,
  4187. alc260_capture_mixer },
  4188. .init_verbs = { alc260_fujitsu_init_verbs },
  4189. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4190. .dac_nids = alc260_dac_nids,
  4191. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4192. .adc_nids = alc260_dual_adc_nids,
  4193. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4194. .channel_mode = alc260_modes,
  4195. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4196. .input_mux = alc260_fujitsu_capture_sources,
  4197. },
  4198. [ALC260_ACER] = {
  4199. .mixers = { alc260_acer_mixer,
  4200. alc260_capture_mixer },
  4201. .init_verbs = { alc260_acer_init_verbs },
  4202. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4203. .dac_nids = alc260_dac_nids,
  4204. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4205. .adc_nids = alc260_dual_adc_nids,
  4206. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4207. .channel_mode = alc260_modes,
  4208. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4209. .input_mux = alc260_acer_capture_sources,
  4210. },
  4211. [ALC260_WILL] = {
  4212. .mixers = { alc260_will_mixer,
  4213. alc260_capture_mixer },
  4214. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4215. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4216. .dac_nids = alc260_dac_nids,
  4217. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4218. .adc_nids = alc260_adc_nids,
  4219. .dig_out_nid = ALC260_DIGOUT_NID,
  4220. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4221. .channel_mode = alc260_modes,
  4222. .input_mux = &alc260_capture_source,
  4223. },
  4224. [ALC260_REPLACER_672V] = {
  4225. .mixers = { alc260_replacer_672v_mixer,
  4226. alc260_capture_mixer },
  4227. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4228. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4229. .dac_nids = alc260_dac_nids,
  4230. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4231. .adc_nids = alc260_adc_nids,
  4232. .dig_out_nid = ALC260_DIGOUT_NID,
  4233. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4234. .channel_mode = alc260_modes,
  4235. .input_mux = &alc260_capture_source,
  4236. .unsol_event = alc260_replacer_672v_unsol_event,
  4237. .init_hook = alc260_replacer_672v_automute,
  4238. },
  4239. #ifdef CONFIG_SND_DEBUG
  4240. [ALC260_TEST] = {
  4241. .mixers = { alc260_test_mixer,
  4242. alc260_capture_mixer },
  4243. .init_verbs = { alc260_test_init_verbs },
  4244. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4245. .dac_nids = alc260_test_dac_nids,
  4246. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4247. .adc_nids = alc260_test_adc_nids,
  4248. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4249. .channel_mode = alc260_modes,
  4250. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4251. .input_mux = alc260_test_capture_sources,
  4252. },
  4253. #endif
  4254. };
  4255. static int patch_alc260(struct hda_codec *codec)
  4256. {
  4257. struct alc_spec *spec;
  4258. int err, board_config;
  4259. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4260. if (spec == NULL)
  4261. return -ENOMEM;
  4262. codec->spec = spec;
  4263. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4264. alc260_models,
  4265. alc260_cfg_tbl);
  4266. if (board_config < 0) {
  4267. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4268. "trying auto-probe from BIOS...\n");
  4269. board_config = ALC260_AUTO;
  4270. }
  4271. if (board_config == ALC260_AUTO) {
  4272. /* automatic parse from the BIOS config */
  4273. err = alc260_parse_auto_config(codec);
  4274. if (err < 0) {
  4275. alc_free(codec);
  4276. return err;
  4277. } else if (!err) {
  4278. printk(KERN_INFO
  4279. "hda_codec: Cannot set up configuration "
  4280. "from BIOS. Using base mode...\n");
  4281. board_config = ALC260_BASIC;
  4282. }
  4283. }
  4284. if (board_config != ALC260_AUTO)
  4285. setup_preset(spec, &alc260_presets[board_config]);
  4286. spec->stream_name_analog = "ALC260 Analog";
  4287. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4288. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4289. spec->stream_name_digital = "ALC260 Digital";
  4290. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4291. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4292. codec->patch_ops = alc_patch_ops;
  4293. if (board_config == ALC260_AUTO)
  4294. spec->init_hook = alc260_auto_init;
  4295. return 0;
  4296. }
  4297. /*
  4298. * ALC882 support
  4299. *
  4300. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4301. * configuration. Each pin widget can choose any input DACs and a mixer.
  4302. * Each ADC is connected from a mixer of all inputs. This makes possible
  4303. * 6-channel independent captures.
  4304. *
  4305. * In addition, an independent DAC for the multi-playback (not used in this
  4306. * driver yet).
  4307. */
  4308. #define ALC882_DIGOUT_NID 0x06
  4309. #define ALC882_DIGIN_NID 0x0a
  4310. static struct hda_channel_mode alc882_ch_modes[1] = {
  4311. { 8, NULL }
  4312. };
  4313. static hda_nid_t alc882_dac_nids[4] = {
  4314. /* front, rear, clfe, rear_surr */
  4315. 0x02, 0x03, 0x04, 0x05
  4316. };
  4317. /* identical with ALC880 */
  4318. #define alc882_adc_nids alc880_adc_nids
  4319. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4320. /* input MUX */
  4321. /* FIXME: should be a matrix-type input source selection */
  4322. static struct hda_input_mux alc882_capture_source = {
  4323. .num_items = 4,
  4324. .items = {
  4325. { "Mic", 0x0 },
  4326. { "Front Mic", 0x1 },
  4327. { "Line", 0x2 },
  4328. { "CD", 0x4 },
  4329. },
  4330. };
  4331. #define alc882_mux_enum_info alc_mux_enum_info
  4332. #define alc882_mux_enum_get alc_mux_enum_get
  4333. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4334. struct snd_ctl_elem_value *ucontrol)
  4335. {
  4336. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4337. struct alc_spec *spec = codec->spec;
  4338. const struct hda_input_mux *imux = spec->input_mux;
  4339. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4340. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4341. hda_nid_t nid = capture_mixers[adc_idx];
  4342. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4343. unsigned int i, idx;
  4344. idx = ucontrol->value.enumerated.item[0];
  4345. if (idx >= imux->num_items)
  4346. idx = imux->num_items - 1;
  4347. if (*cur_val == idx && !codec->in_resume)
  4348. return 0;
  4349. for (i = 0; i < imux->num_items; i++) {
  4350. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4351. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4352. v | (imux->items[i].index << 8));
  4353. }
  4354. *cur_val = idx;
  4355. return 1;
  4356. }
  4357. /*
  4358. * 2ch mode
  4359. */
  4360. static struct hda_verb alc882_3ST_ch2_init[] = {
  4361. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4362. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4363. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4364. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4365. { } /* end */
  4366. };
  4367. /*
  4368. * 6ch mode
  4369. */
  4370. static struct hda_verb alc882_3ST_ch6_init[] = {
  4371. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4372. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4373. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4374. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4375. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4376. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4377. { } /* end */
  4378. };
  4379. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4380. { 2, alc882_3ST_ch2_init },
  4381. { 6, alc882_3ST_ch6_init },
  4382. };
  4383. /*
  4384. * 6ch mode
  4385. */
  4386. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4387. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4388. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4389. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4390. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4391. { } /* end */
  4392. };
  4393. /*
  4394. * 8ch mode
  4395. */
  4396. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4397. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4398. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4399. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4400. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4401. { } /* end */
  4402. };
  4403. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4404. { 6, alc882_sixstack_ch6_init },
  4405. { 8, alc882_sixstack_ch8_init },
  4406. };
  4407. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4408. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4409. */
  4410. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4411. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4412. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4413. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4414. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4415. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4416. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4417. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4418. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4419. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4420. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4421. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4422. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4423. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4424. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4425. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4426. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4427. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4428. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4429. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4430. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4431. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4432. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4433. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4434. { } /* end */
  4435. };
  4436. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4437. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4438. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4440. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4445. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4446. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4447. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4448. { } /* end */
  4449. };
  4450. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4451. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4452. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4454. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4456. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4459. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4461. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4462. { } /* end */
  4463. };
  4464. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4465. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4466. */
  4467. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4468. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4469. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4470. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4471. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4472. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4473. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4475. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4476. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4477. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4478. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4479. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4480. { } /* end */
  4481. };
  4482. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4483. {
  4484. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4485. .name = "Channel Mode",
  4486. .info = alc_ch_mode_info,
  4487. .get = alc_ch_mode_get,
  4488. .put = alc_ch_mode_put,
  4489. },
  4490. { } /* end */
  4491. };
  4492. static struct hda_verb alc882_init_verbs[] = {
  4493. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4494. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4495. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4496. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4497. /* Rear mixer */
  4498. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4499. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4500. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4501. /* CLFE mixer */
  4502. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4503. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4504. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4505. /* Side mixer */
  4506. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4507. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4508. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4509. /* Front Pin: output 0 (0x0c) */
  4510. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4512. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4513. /* Rear Pin: output 1 (0x0d) */
  4514. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4515. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4516. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4517. /* CLFE Pin: output 2 (0x0e) */
  4518. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4519. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4520. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4521. /* Side Pin: output 3 (0x0f) */
  4522. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4523. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4524. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4525. /* Mic (rear) pin: input vref at 80% */
  4526. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4527. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4528. /* Front Mic pin: input vref at 80% */
  4529. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4530. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4531. /* Line In pin: input */
  4532. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4533. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4534. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4535. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4536. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4537. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4538. /* CD pin widget for input */
  4539. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4540. /* FIXME: use matrix-type input source selection */
  4541. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4542. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4543. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4544. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4545. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4546. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4547. /* Input mixer2 */
  4548. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4549. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4550. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4551. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4552. /* Input mixer3 */
  4553. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4554. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4555. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4556. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4557. /* ADC1: mute amp left and right */
  4558. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4559. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4560. /* ADC2: mute amp left and right */
  4561. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4562. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4563. /* ADC3: mute amp left and right */
  4564. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4565. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4566. { }
  4567. };
  4568. static struct hda_verb alc882_eapd_verbs[] = {
  4569. /* change to EAPD mode */
  4570. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4571. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4572. { }
  4573. };
  4574. /* Mac Pro test */
  4575. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4576. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4577. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4578. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4579. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4580. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4581. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4582. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4583. { } /* end */
  4584. };
  4585. static struct hda_verb alc882_macpro_init_verbs[] = {
  4586. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4587. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4588. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4590. /* Front Pin: output 0 (0x0c) */
  4591. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4592. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4593. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4594. /* Front Mic pin: input vref at 80% */
  4595. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4596. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4597. /* Speaker: output */
  4598. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4599. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4600. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4601. /* Headphone output (output 0 - 0x0c) */
  4602. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4603. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4604. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4605. /* FIXME: use matrix-type input source selection */
  4606. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4607. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4608. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4609. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4610. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4611. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4612. /* Input mixer2 */
  4613. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4614. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4615. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4616. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4617. /* Input mixer3 */
  4618. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4619. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4620. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4621. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4622. /* ADC1: mute amp left and right */
  4623. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4624. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4625. /* ADC2: mute amp left and right */
  4626. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4627. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4628. /* ADC3: mute amp left and right */
  4629. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4630. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4631. { }
  4632. };
  4633. /* iMac 24 mixer. */
  4634. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4635. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4636. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4637. { } /* end */
  4638. };
  4639. /* iMac 24 init verbs. */
  4640. static struct hda_verb alc885_imac24_init_verbs[] = {
  4641. /* Internal speakers: output 0 (0x0c) */
  4642. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4643. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4644. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4645. /* Internal speakers: output 0 (0x0c) */
  4646. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4647. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4648. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4649. /* Headphone: output 0 (0x0c) */
  4650. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4651. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4652. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4653. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4654. /* Front Mic: input vref at 80% */
  4655. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4656. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4657. { }
  4658. };
  4659. /* Toggle speaker-output according to the hp-jack state */
  4660. static void alc885_imac24_automute(struct hda_codec *codec)
  4661. {
  4662. unsigned int present;
  4663. present = snd_hda_codec_read(codec, 0x14, 0,
  4664. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4665. snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
  4666. 0x80, present ? 0x80 : 0);
  4667. snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
  4668. 0x80, present ? 0x80 : 0);
  4669. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
  4670. 0x80, present ? 0x80 : 0);
  4671. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
  4672. 0x80, present ? 0x80 : 0);
  4673. }
  4674. /* Processes unsolicited events. */
  4675. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4676. unsigned int res)
  4677. {
  4678. /* Headphone insertion or removal. */
  4679. if ((res >> 26) == ALC880_HP_EVENT)
  4680. alc885_imac24_automute(codec);
  4681. }
  4682. static struct hda_verb alc882_targa_verbs[] = {
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4684. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4685. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4686. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4687. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4688. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4689. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4690. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4691. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4692. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4693. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4694. { } /* end */
  4695. };
  4696. /* toggle speaker-output according to the hp-jack state */
  4697. static void alc882_targa_automute(struct hda_codec *codec)
  4698. {
  4699. unsigned int present;
  4700. present = snd_hda_codec_read(codec, 0x14, 0,
  4701. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4702. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4703. 0x80, present ? 0x80 : 0);
  4704. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4705. 0x80, present ? 0x80 : 0);
  4706. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4707. }
  4708. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4709. {
  4710. /* Looks like the unsol event is incompatible with the standard
  4711. * definition. 4bit tag is placed at 26 bit!
  4712. */
  4713. if (((res >> 26) == ALC880_HP_EVENT)) {
  4714. alc882_targa_automute(codec);
  4715. }
  4716. }
  4717. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4720. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4721. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4722. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4723. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4724. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4725. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4726. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4727. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4728. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4729. { } /* end */
  4730. };
  4731. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4732. {
  4733. unsigned int gpiostate, gpiomask, gpiodir;
  4734. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4735. AC_VERB_GET_GPIO_DATA, 0);
  4736. if (!muted)
  4737. gpiostate |= (1 << pin);
  4738. else
  4739. gpiostate &= ~(1 << pin);
  4740. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4741. AC_VERB_GET_GPIO_MASK, 0);
  4742. gpiomask |= (1 << pin);
  4743. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4744. AC_VERB_GET_GPIO_DIRECTION, 0);
  4745. gpiodir |= (1 << pin);
  4746. snd_hda_codec_write(codec, codec->afg, 0,
  4747. AC_VERB_SET_GPIO_MASK, gpiomask);
  4748. snd_hda_codec_write(codec, codec->afg, 0,
  4749. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4750. msleep(1);
  4751. snd_hda_codec_write(codec, codec->afg, 0,
  4752. AC_VERB_SET_GPIO_DATA, gpiostate);
  4753. }
  4754. /*
  4755. * generic initialization of ADC, input mixers and output mixers
  4756. */
  4757. static struct hda_verb alc882_auto_init_verbs[] = {
  4758. /*
  4759. * Unmute ADC0-2 and set the default input to mic-in
  4760. */
  4761. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4762. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4763. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4764. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4765. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4766. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4767. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4768. * mixer widget
  4769. * Note: PASD motherboards uses the Line In 2 as the input for
  4770. * front panel mic (mic 2)
  4771. */
  4772. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4773. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4774. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4775. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4776. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4777. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4778. /*
  4779. * Set up output mixers (0x0c - 0x0f)
  4780. */
  4781. /* set vol=0 to output mixers */
  4782. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4783. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4784. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4785. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4786. /* set up input amps for analog loopback */
  4787. /* Amp Indices: DAC = 0, mixer = 1 */
  4788. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4789. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4790. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4791. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4792. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4793. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4794. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4795. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4796. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4797. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4798. /* FIXME: use matrix-type input source selection */
  4799. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4800. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4801. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4804. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4805. /* Input mixer2 */
  4806. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4810. /* Input mixer3 */
  4811. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4814. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4815. { }
  4816. };
  4817. /* capture mixer elements */
  4818. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4819. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4820. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4821. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4822. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4823. {
  4824. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4825. /* The multiple "Capture Source" controls confuse alsamixer
  4826. * So call somewhat different..
  4827. * FIXME: the controls appear in the "playback" view!
  4828. */
  4829. /* .name = "Capture Source", */
  4830. .name = "Input Source",
  4831. .count = 2,
  4832. .info = alc882_mux_enum_info,
  4833. .get = alc882_mux_enum_get,
  4834. .put = alc882_mux_enum_put,
  4835. },
  4836. { } /* end */
  4837. };
  4838. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4839. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4840. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4841. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4842. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4843. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4844. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4845. {
  4846. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4847. /* The multiple "Capture Source" controls confuse alsamixer
  4848. * So call somewhat different..
  4849. * FIXME: the controls appear in the "playback" view!
  4850. */
  4851. /* .name = "Capture Source", */
  4852. .name = "Input Source",
  4853. .count = 3,
  4854. .info = alc882_mux_enum_info,
  4855. .get = alc882_mux_enum_get,
  4856. .put = alc882_mux_enum_put,
  4857. },
  4858. { } /* end */
  4859. };
  4860. /* pcm configuration: identiacal with ALC880 */
  4861. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4862. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4863. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4864. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4865. /*
  4866. * configuration and preset
  4867. */
  4868. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4869. [ALC882_3ST_DIG] = "3stack-dig",
  4870. [ALC882_6ST_DIG] = "6stack-dig",
  4871. [ALC882_ARIMA] = "arima",
  4872. [ALC882_W2JC] = "w2jc",
  4873. [ALC885_MACPRO] = "macpro",
  4874. [ALC885_IMAC24] = "imac24",
  4875. [ALC882_AUTO] = "auto",
  4876. };
  4877. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4878. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4879. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4880. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4881. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4882. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4883. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4884. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  4885. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4886. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4887. {}
  4888. };
  4889. static struct alc_config_preset alc882_presets[] = {
  4890. [ALC882_3ST_DIG] = {
  4891. .mixers = { alc882_base_mixer },
  4892. .init_verbs = { alc882_init_verbs },
  4893. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4894. .dac_nids = alc882_dac_nids,
  4895. .dig_out_nid = ALC882_DIGOUT_NID,
  4896. .dig_in_nid = ALC882_DIGIN_NID,
  4897. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4898. .channel_mode = alc882_ch_modes,
  4899. .need_dac_fix = 1,
  4900. .input_mux = &alc882_capture_source,
  4901. },
  4902. [ALC882_6ST_DIG] = {
  4903. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4904. .init_verbs = { alc882_init_verbs },
  4905. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4906. .dac_nids = alc882_dac_nids,
  4907. .dig_out_nid = ALC882_DIGOUT_NID,
  4908. .dig_in_nid = ALC882_DIGIN_NID,
  4909. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4910. .channel_mode = alc882_sixstack_modes,
  4911. .input_mux = &alc882_capture_source,
  4912. },
  4913. [ALC882_ARIMA] = {
  4914. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4915. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4916. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4917. .dac_nids = alc882_dac_nids,
  4918. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4919. .channel_mode = alc882_sixstack_modes,
  4920. .input_mux = &alc882_capture_source,
  4921. },
  4922. [ALC882_W2JC] = {
  4923. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4924. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4925. alc880_gpio1_init_verbs },
  4926. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4927. .dac_nids = alc882_dac_nids,
  4928. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4929. .channel_mode = alc880_threestack_modes,
  4930. .need_dac_fix = 1,
  4931. .input_mux = &alc882_capture_source,
  4932. .dig_out_nid = ALC882_DIGOUT_NID,
  4933. },
  4934. [ALC885_MACPRO] = {
  4935. .mixers = { alc882_macpro_mixer },
  4936. .init_verbs = { alc882_macpro_init_verbs },
  4937. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4938. .dac_nids = alc882_dac_nids,
  4939. .dig_out_nid = ALC882_DIGOUT_NID,
  4940. .dig_in_nid = ALC882_DIGIN_NID,
  4941. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4942. .channel_mode = alc882_ch_modes,
  4943. .input_mux = &alc882_capture_source,
  4944. },
  4945. [ALC885_IMAC24] = {
  4946. .mixers = { alc885_imac24_mixer },
  4947. .init_verbs = { alc885_imac24_init_verbs },
  4948. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4949. .dac_nids = alc882_dac_nids,
  4950. .dig_out_nid = ALC882_DIGOUT_NID,
  4951. .dig_in_nid = ALC882_DIGIN_NID,
  4952. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4953. .channel_mode = alc882_ch_modes,
  4954. .input_mux = &alc882_capture_source,
  4955. .unsol_event = alc885_imac24_unsol_event,
  4956. .init_hook = alc885_imac24_automute,
  4957. },
  4958. [ALC882_TARGA] = {
  4959. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4960. alc882_capture_mixer },
  4961. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4962. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4963. .dac_nids = alc882_dac_nids,
  4964. .dig_out_nid = ALC882_DIGOUT_NID,
  4965. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4966. .adc_nids = alc882_adc_nids,
  4967. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4968. .channel_mode = alc882_3ST_6ch_modes,
  4969. .need_dac_fix = 1,
  4970. .input_mux = &alc882_capture_source,
  4971. .unsol_event = alc882_targa_unsol_event,
  4972. .init_hook = alc882_targa_automute,
  4973. },
  4974. [ALC882_ASUS_A7J] = {
  4975. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4976. alc882_capture_mixer },
  4977. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4978. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4979. .dac_nids = alc882_dac_nids,
  4980. .dig_out_nid = ALC882_DIGOUT_NID,
  4981. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4982. .adc_nids = alc882_adc_nids,
  4983. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4984. .channel_mode = alc882_3ST_6ch_modes,
  4985. .need_dac_fix = 1,
  4986. .input_mux = &alc882_capture_source,
  4987. },
  4988. };
  4989. /*
  4990. * Pin config fixes
  4991. */
  4992. enum {
  4993. PINFIX_ABIT_AW9D_MAX
  4994. };
  4995. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  4996. { 0x15, 0x01080104 }, /* side */
  4997. { 0x16, 0x01011012 }, /* rear */
  4998. { 0x17, 0x01016011 }, /* clfe */
  4999. { }
  5000. };
  5001. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5002. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5003. };
  5004. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5005. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5006. {}
  5007. };
  5008. /*
  5009. * BIOS auto configuration
  5010. */
  5011. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5012. hda_nid_t nid, int pin_type,
  5013. int dac_idx)
  5014. {
  5015. /* set as output */
  5016. struct alc_spec *spec = codec->spec;
  5017. int idx;
  5018. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5019. idx = 4;
  5020. else
  5021. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5022. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5023. pin_type);
  5024. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5025. AMP_OUT_UNMUTE);
  5026. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5027. }
  5028. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5029. {
  5030. struct alc_spec *spec = codec->spec;
  5031. int i;
  5032. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5033. for (i = 0; i <= HDA_SIDE; i++) {
  5034. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5035. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5036. if (nid)
  5037. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5038. i);
  5039. }
  5040. }
  5041. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5042. {
  5043. struct alc_spec *spec = codec->spec;
  5044. hda_nid_t pin;
  5045. pin = spec->autocfg.hp_pins[0];
  5046. if (pin) /* connect to front */
  5047. /* use dac 0 */
  5048. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5049. }
  5050. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5051. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5052. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5053. {
  5054. struct alc_spec *spec = codec->spec;
  5055. int i;
  5056. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5057. hda_nid_t nid = spec->autocfg.input_pins[i];
  5058. if (alc882_is_input_pin(nid)) {
  5059. snd_hda_codec_write(codec, nid, 0,
  5060. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5061. i <= AUTO_PIN_FRONT_MIC ?
  5062. PIN_VREF80 : PIN_IN);
  5063. if (nid != ALC882_PIN_CD_NID)
  5064. snd_hda_codec_write(codec, nid, 0,
  5065. AC_VERB_SET_AMP_GAIN_MUTE,
  5066. AMP_OUT_MUTE);
  5067. }
  5068. }
  5069. }
  5070. /* almost identical with ALC880 parser... */
  5071. static int alc882_parse_auto_config(struct hda_codec *codec)
  5072. {
  5073. struct alc_spec *spec = codec->spec;
  5074. int err = alc880_parse_auto_config(codec);
  5075. if (err < 0)
  5076. return err;
  5077. else if (err > 0)
  5078. /* hack - override the init verbs */
  5079. spec->init_verbs[0] = alc882_auto_init_verbs;
  5080. return err;
  5081. }
  5082. /* additional initialization for auto-configuration model */
  5083. static void alc882_auto_init(struct hda_codec *codec)
  5084. {
  5085. alc882_auto_init_multi_out(codec);
  5086. alc882_auto_init_hp_out(codec);
  5087. alc882_auto_init_analog_input(codec);
  5088. }
  5089. static int patch_alc882(struct hda_codec *codec)
  5090. {
  5091. struct alc_spec *spec;
  5092. int err, board_config;
  5093. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5094. if (spec == NULL)
  5095. return -ENOMEM;
  5096. codec->spec = spec;
  5097. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5098. alc882_models,
  5099. alc882_cfg_tbl);
  5100. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5101. /* Pick up systems that don't supply PCI SSID */
  5102. switch (codec->subsystem_id) {
  5103. case 0x106b0c00: /* Mac Pro */
  5104. board_config = ALC885_MACPRO;
  5105. break;
  5106. case 0x106b1000: /* iMac 24 */
  5107. board_config = ALC885_IMAC24;
  5108. break;
  5109. default:
  5110. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5111. "trying auto-probe from BIOS...\n");
  5112. board_config = ALC882_AUTO;
  5113. }
  5114. }
  5115. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5116. if (board_config == ALC882_AUTO) {
  5117. /* automatic parse from the BIOS config */
  5118. err = alc882_parse_auto_config(codec);
  5119. if (err < 0) {
  5120. alc_free(codec);
  5121. return err;
  5122. } else if (!err) {
  5123. printk(KERN_INFO
  5124. "hda_codec: Cannot set up configuration "
  5125. "from BIOS. Using base mode...\n");
  5126. board_config = ALC882_3ST_DIG;
  5127. }
  5128. }
  5129. if (board_config != ALC882_AUTO)
  5130. setup_preset(spec, &alc882_presets[board_config]);
  5131. if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
  5132. alc882_gpio_mute(codec, 0, 0);
  5133. alc882_gpio_mute(codec, 1, 0);
  5134. }
  5135. spec->stream_name_analog = "ALC882 Analog";
  5136. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5137. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5138. spec->stream_name_digital = "ALC882 Digital";
  5139. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5140. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5141. if (!spec->adc_nids && spec->input_mux) {
  5142. /* check whether NID 0x07 is valid */
  5143. unsigned int wcap = get_wcaps(codec, 0x07);
  5144. /* get type */
  5145. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5146. if (wcap != AC_WID_AUD_IN) {
  5147. spec->adc_nids = alc882_adc_nids_alt;
  5148. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5149. spec->mixers[spec->num_mixers] =
  5150. alc882_capture_alt_mixer;
  5151. spec->num_mixers++;
  5152. } else {
  5153. spec->adc_nids = alc882_adc_nids;
  5154. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5155. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5156. spec->num_mixers++;
  5157. }
  5158. }
  5159. codec->patch_ops = alc_patch_ops;
  5160. if (board_config == ALC882_AUTO)
  5161. spec->init_hook = alc882_auto_init;
  5162. return 0;
  5163. }
  5164. /*
  5165. * ALC883 support
  5166. *
  5167. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5168. * configuration. Each pin widget can choose any input DACs and a mixer.
  5169. * Each ADC is connected from a mixer of all inputs. This makes possible
  5170. * 6-channel independent captures.
  5171. *
  5172. * In addition, an independent DAC for the multi-playback (not used in this
  5173. * driver yet).
  5174. */
  5175. #define ALC883_DIGOUT_NID 0x06
  5176. #define ALC883_DIGIN_NID 0x0a
  5177. static hda_nid_t alc883_dac_nids[4] = {
  5178. /* front, rear, clfe, rear_surr */
  5179. 0x02, 0x04, 0x03, 0x05
  5180. };
  5181. static hda_nid_t alc883_adc_nids[2] = {
  5182. /* ADC1-2 */
  5183. 0x08, 0x09,
  5184. };
  5185. /* input MUX */
  5186. /* FIXME: should be a matrix-type input source selection */
  5187. static struct hda_input_mux alc883_capture_source = {
  5188. .num_items = 4,
  5189. .items = {
  5190. { "Mic", 0x0 },
  5191. { "Front Mic", 0x1 },
  5192. { "Line", 0x2 },
  5193. { "CD", 0x4 },
  5194. },
  5195. };
  5196. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5197. .num_items = 2,
  5198. .items = {
  5199. { "Mic", 0x1 },
  5200. { "Line", 0x2 },
  5201. },
  5202. };
  5203. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5204. .num_items = 4,
  5205. .items = {
  5206. { "Mic", 0x0 },
  5207. { "iMic", 0x1 },
  5208. { "Line", 0x2 },
  5209. { "CD", 0x4 },
  5210. },
  5211. };
  5212. #define alc883_mux_enum_info alc_mux_enum_info
  5213. #define alc883_mux_enum_get alc_mux_enum_get
  5214. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5215. struct snd_ctl_elem_value *ucontrol)
  5216. {
  5217. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5218. struct alc_spec *spec = codec->spec;
  5219. const struct hda_input_mux *imux = spec->input_mux;
  5220. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5221. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5222. hda_nid_t nid = capture_mixers[adc_idx];
  5223. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5224. unsigned int i, idx;
  5225. idx = ucontrol->value.enumerated.item[0];
  5226. if (idx >= imux->num_items)
  5227. idx = imux->num_items - 1;
  5228. if (*cur_val == idx && !codec->in_resume)
  5229. return 0;
  5230. for (i = 0; i < imux->num_items; i++) {
  5231. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5232. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5233. v | (imux->items[i].index << 8));
  5234. }
  5235. *cur_val = idx;
  5236. return 1;
  5237. }
  5238. /*
  5239. * 2ch mode
  5240. */
  5241. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5242. { 2, NULL }
  5243. };
  5244. /*
  5245. * 2ch mode
  5246. */
  5247. static struct hda_verb alc883_3ST_ch2_init[] = {
  5248. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5249. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5250. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5251. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5252. { } /* end */
  5253. };
  5254. /*
  5255. * 6ch mode
  5256. */
  5257. static struct hda_verb alc883_3ST_ch6_init[] = {
  5258. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5259. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5260. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5261. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5262. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5263. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5264. { } /* end */
  5265. };
  5266. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5267. { 2, alc883_3ST_ch2_init },
  5268. { 6, alc883_3ST_ch6_init },
  5269. };
  5270. /*
  5271. * 6ch mode
  5272. */
  5273. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5274. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5275. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5276. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5277. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5278. { } /* end */
  5279. };
  5280. /*
  5281. * 8ch mode
  5282. */
  5283. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5284. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5285. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5286. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5287. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5288. { } /* end */
  5289. };
  5290. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5291. { 6, alc883_sixstack_ch6_init },
  5292. { 8, alc883_sixstack_ch8_init },
  5293. };
  5294. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5295. /* eanable EAPD on medion laptop */
  5296. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5297. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5298. { }
  5299. };
  5300. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5301. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5302. */
  5303. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5304. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5305. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5306. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5307. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5308. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5309. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5310. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5311. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5312. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5313. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5314. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5315. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5316. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5317. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5318. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5319. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5320. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5321. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5322. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5323. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5324. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5325. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5326. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5327. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5328. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5329. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5330. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5331. {
  5332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5333. /* .name = "Capture Source", */
  5334. .name = "Input Source",
  5335. .count = 2,
  5336. .info = alc883_mux_enum_info,
  5337. .get = alc883_mux_enum_get,
  5338. .put = alc883_mux_enum_put,
  5339. },
  5340. { } /* end */
  5341. };
  5342. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5343. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5344. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5345. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5346. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5347. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5348. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5349. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5350. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5351. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5352. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5353. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5355. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5356. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5357. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5358. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5359. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5360. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5361. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5362. {
  5363. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5364. /* .name = "Capture Source", */
  5365. .name = "Input Source",
  5366. .count = 2,
  5367. .info = alc883_mux_enum_info,
  5368. .get = alc883_mux_enum_get,
  5369. .put = alc883_mux_enum_put,
  5370. },
  5371. { } /* end */
  5372. };
  5373. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5374. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5375. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5376. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5377. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5378. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5379. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5380. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5381. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5382. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5383. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5384. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5386. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5387. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5388. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5389. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5390. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5391. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5392. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5393. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5394. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5395. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5396. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5397. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5398. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5399. {
  5400. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5401. /* .name = "Capture Source", */
  5402. .name = "Input Source",
  5403. .count = 2,
  5404. .info = alc883_mux_enum_info,
  5405. .get = alc883_mux_enum_get,
  5406. .put = alc883_mux_enum_put,
  5407. },
  5408. { } /* end */
  5409. };
  5410. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5411. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5412. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5413. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5414. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5415. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5416. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5417. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5418. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5419. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5420. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5421. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5422. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5423. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5424. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5425. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5426. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5428. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5429. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5431. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5432. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5433. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5434. {
  5435. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5436. /* .name = "Capture Source", */
  5437. .name = "Input Source",
  5438. .count = 1,
  5439. .info = alc883_mux_enum_info,
  5440. .get = alc883_mux_enum_get,
  5441. .put = alc883_mux_enum_put,
  5442. },
  5443. { } /* end */
  5444. };
  5445. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5446. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5447. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5448. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5449. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5450. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5451. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5452. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5453. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5454. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5455. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5456. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5457. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5458. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5459. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5460. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5461. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5462. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5463. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5464. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5465. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5466. {
  5467. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5468. /* .name = "Capture Source", */
  5469. .name = "Input Source",
  5470. .count = 2,
  5471. .info = alc883_mux_enum_info,
  5472. .get = alc883_mux_enum_get,
  5473. .put = alc883_mux_enum_put,
  5474. },
  5475. { } /* end */
  5476. };
  5477. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5478. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5479. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5480. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5481. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5482. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5483. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5484. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5485. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5486. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5487. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5488. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5489. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5490. {
  5491. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5492. /* .name = "Capture Source", */
  5493. .name = "Input Source",
  5494. .count = 2,
  5495. .info = alc883_mux_enum_info,
  5496. .get = alc883_mux_enum_get,
  5497. .put = alc883_mux_enum_put,
  5498. },
  5499. { } /* end */
  5500. };
  5501. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5502. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5503. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5504. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5505. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5506. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5507. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5508. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5509. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5510. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5511. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5512. {
  5513. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5514. /* .name = "Capture Source", */
  5515. .name = "Input Source",
  5516. .count = 1,
  5517. .info = alc883_mux_enum_info,
  5518. .get = alc883_mux_enum_get,
  5519. .put = alc883_mux_enum_put,
  5520. },
  5521. { } /* end */
  5522. };
  5523. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5524. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5525. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5526. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5527. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5528. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5531. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5532. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5533. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5534. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5535. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5536. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5537. {
  5538. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5539. /* .name = "Capture Source", */
  5540. .name = "Input Source",
  5541. .count = 2,
  5542. .info = alc883_mux_enum_info,
  5543. .get = alc883_mux_enum_get,
  5544. .put = alc883_mux_enum_put,
  5545. },
  5546. { } /* end */
  5547. };
  5548. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5549. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5550. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5551. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5552. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5553. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5554. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5555. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5556. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5557. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5558. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5559. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5560. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5561. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5562. {
  5563. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5564. /* .name = "Capture Source", */
  5565. .name = "Input Source",
  5566. .count = 2,
  5567. .info = alc883_mux_enum_info,
  5568. .get = alc883_mux_enum_get,
  5569. .put = alc883_mux_enum_put,
  5570. },
  5571. { } /* end */
  5572. };
  5573. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5574. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5575. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5577. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5578. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5579. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5580. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5581. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5582. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5583. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5584. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5585. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5586. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5587. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5588. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5589. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5590. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5591. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5592. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5594. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5598. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5599. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5600. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5601. {
  5602. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5603. /* .name = "Capture Source", */
  5604. .name = "Input Source",
  5605. .count = 2,
  5606. .info = alc883_mux_enum_info,
  5607. .get = alc883_mux_enum_get,
  5608. .put = alc883_mux_enum_put,
  5609. },
  5610. { } /* end */
  5611. };
  5612. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5613. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5614. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5615. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5616. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5617. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5618. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5619. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5620. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5621. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5622. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5623. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5624. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5625. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5627. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5628. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5629. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5630. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5631. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5632. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5633. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5634. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5635. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5636. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5637. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5638. {
  5639. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5640. /* .name = "Capture Source", */
  5641. .name = "Input Source",
  5642. .count = 2,
  5643. .info = alc883_mux_enum_info,
  5644. .get = alc883_mux_enum_get,
  5645. .put = alc883_mux_enum_put,
  5646. },
  5647. { } /* end */
  5648. };
  5649. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5650. HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5651. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5652. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5653. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5654. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5655. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5656. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5657. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5659. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5660. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5661. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5662. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5663. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5664. {
  5665. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5666. /* .name = "Capture Source", */
  5667. .name = "Input Source",
  5668. .count = 2,
  5669. .info = alc883_mux_enum_info,
  5670. .get = alc883_mux_enum_get,
  5671. .put = alc883_mux_enum_put,
  5672. },
  5673. { } /* end */
  5674. };
  5675. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5676. {
  5677. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5678. .name = "Channel Mode",
  5679. .info = alc_ch_mode_info,
  5680. .get = alc_ch_mode_get,
  5681. .put = alc_ch_mode_put,
  5682. },
  5683. { } /* end */
  5684. };
  5685. static struct hda_verb alc883_init_verbs[] = {
  5686. /* ADC1: mute amp left and right */
  5687. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5688. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5689. /* ADC2: mute amp left and right */
  5690. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5691. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5692. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5693. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5694. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5695. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5696. /* Rear mixer */
  5697. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5698. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5700. /* CLFE mixer */
  5701. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5703. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5704. /* Side mixer */
  5705. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5706. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5707. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5709. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5710. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5711. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5712. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5713. /* Front Pin: output 0 (0x0c) */
  5714. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5715. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5716. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5717. /* Rear Pin: output 1 (0x0d) */
  5718. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5719. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5720. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5721. /* CLFE Pin: output 2 (0x0e) */
  5722. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5723. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5724. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5725. /* Side Pin: output 3 (0x0f) */
  5726. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5727. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5728. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5729. /* Mic (rear) pin: input vref at 80% */
  5730. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5731. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5732. /* Front Mic pin: input vref at 80% */
  5733. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5734. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5735. /* Line In pin: input */
  5736. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5737. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5738. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5739. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5740. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5741. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5742. /* CD pin widget for input */
  5743. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5744. /* FIXME: use matrix-type input source selection */
  5745. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5746. /* Input mixer2 */
  5747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5748. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5749. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5750. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5751. /* Input mixer3 */
  5752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5753. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5754. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5755. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5756. { }
  5757. };
  5758. static struct hda_verb alc883_tagra_verbs[] = {
  5759. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5760. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5761. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5762. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5763. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5764. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5765. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5766. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5767. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5768. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5769. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5770. { } /* end */
  5771. };
  5772. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5773. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5774. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5775. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5776. { } /* end */
  5777. };
  5778. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5779. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5780. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5781. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5782. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5783. { } /* end */
  5784. };
  5785. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5786. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5787. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5788. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5789. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5790. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5791. { } /* end */
  5792. };
  5793. static struct hda_verb alc888_6st_hp_verbs[] = {
  5794. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5795. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5796. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5797. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5798. { }
  5799. };
  5800. static struct hda_verb alc888_3st_hp_verbs[] = {
  5801. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5802. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5803. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5804. { }
  5805. };
  5806. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5807. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5808. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5809. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5810. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5811. { }
  5812. };
  5813. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5814. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5815. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5816. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5817. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5818. { }
  5819. };
  5820. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5821. { 2, alc888_3st_hp_2ch_init },
  5822. { 6, alc888_3st_hp_6ch_init },
  5823. };
  5824. /* toggle front-jack and RCA according to the hp-jack state */
  5825. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5826. {
  5827. unsigned int present;
  5828. present = snd_hda_codec_read(codec, 0x1b, 0,
  5829. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5830. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5831. 0x80, present ? 0x80 : 0);
  5832. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5833. 0x80, present ? 0x80 : 0);
  5834. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5835. 0x80, present ? 0x80 : 0);
  5836. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5837. 0x80, present ? 0x80 : 0);
  5838. }
  5839. /* toggle RCA according to the front-jack state */
  5840. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5841. {
  5842. unsigned int present;
  5843. present = snd_hda_codec_read(codec, 0x14, 0,
  5844. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5845. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5846. 0x80, present ? 0x80 : 0);
  5847. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5848. 0x80, present ? 0x80 : 0);
  5849. }
  5850. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5851. unsigned int res)
  5852. {
  5853. if ((res >> 26) == ALC880_HP_EVENT)
  5854. alc888_lenovo_ms7195_front_automute(codec);
  5855. if ((res >> 26) == ALC880_FRONT_EVENT)
  5856. alc888_lenovo_ms7195_rca_automute(codec);
  5857. }
  5858. static struct hda_verb alc883_medion_md2_verbs[] = {
  5859. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5860. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5861. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5862. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5863. { } /* end */
  5864. };
  5865. static struct hda_verb alc883_acer_aspire_verbs[] = {
  5866. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5868. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5869. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5870. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5871. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5872. { } /* end */
  5873. };
  5874. /* toggle speaker-output according to the hp-jack state */
  5875. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5876. {
  5877. unsigned int present;
  5878. present = snd_hda_codec_read(codec, 0x14, 0,
  5879. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5880. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5881. 0x80, present ? 0x80 : 0);
  5882. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5883. 0x80, present ? 0x80 : 0);
  5884. }
  5885. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5886. unsigned int res)
  5887. {
  5888. if ((res >> 26) == ALC880_HP_EVENT)
  5889. alc883_medion_md2_automute(codec);
  5890. }
  5891. /* toggle speaker-output according to the hp-jack state */
  5892. static void alc883_tagra_automute(struct hda_codec *codec)
  5893. {
  5894. unsigned int present;
  5895. unsigned char bits;
  5896. present = snd_hda_codec_read(codec, 0x14, 0,
  5897. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5898. bits = present ? 0x80 : 0;
  5899. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5900. 0x80, bits);
  5901. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5902. 0x80, bits);
  5903. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5904. present ? 1 : 3);
  5905. }
  5906. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5907. {
  5908. if ((res >> 26) == ALC880_HP_EVENT)
  5909. alc883_tagra_automute(codec);
  5910. }
  5911. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5912. {
  5913. unsigned int present;
  5914. unsigned char bits;
  5915. present = snd_hda_codec_read(codec, 0x14, 0,
  5916. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5917. bits = present ? 0x80 : 0;
  5918. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5919. 0x80, bits);
  5920. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5921. 0x80, bits);
  5922. }
  5923. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5924. {
  5925. unsigned int present;
  5926. unsigned char bits;
  5927. present = snd_hda_codec_read(codec, 0x1b, 0,
  5928. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5929. bits = present ? 0x80 : 0;
  5930. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5931. 0x80, bits);
  5932. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5933. 0x80, bits);
  5934. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5935. 0x80, bits);
  5936. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5937. 0x80, bits);
  5938. }
  5939. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5940. unsigned int res)
  5941. {
  5942. if ((res >> 26) == ALC880_HP_EVENT)
  5943. alc883_lenovo_101e_all_automute(codec);
  5944. if ((res >> 26) == ALC880_FRONT_EVENT)
  5945. alc883_lenovo_101e_ispeaker_automute(codec);
  5946. }
  5947. /*
  5948. * generic initialization of ADC, input mixers and output mixers
  5949. */
  5950. static struct hda_verb alc883_auto_init_verbs[] = {
  5951. /*
  5952. * Unmute ADC0-2 and set the default input to mic-in
  5953. */
  5954. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5955. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5956. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5957. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5958. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5959. * mixer widget
  5960. * Note: PASD motherboards uses the Line In 2 as the input for
  5961. * front panel mic (mic 2)
  5962. */
  5963. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5965. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5966. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5967. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5968. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5969. /*
  5970. * Set up output mixers (0x0c - 0x0f)
  5971. */
  5972. /* set vol=0 to output mixers */
  5973. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5974. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5975. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5976. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5977. /* set up input amps for analog loopback */
  5978. /* Amp Indices: DAC = 0, mixer = 1 */
  5979. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5980. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5981. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5982. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5983. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5984. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5985. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5986. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5987. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5988. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5989. /* FIXME: use matrix-type input source selection */
  5990. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5991. /* Input mixer1 */
  5992. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5993. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5994. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5995. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5996. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5997. /* Input mixer2 */
  5998. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5999. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6000. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6001. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6002. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6003. { }
  6004. };
  6005. /* capture mixer elements */
  6006. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6007. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6008. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6009. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6010. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6011. {
  6012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6013. /* The multiple "Capture Source" controls confuse alsamixer
  6014. * So call somewhat different..
  6015. * FIXME: the controls appear in the "playback" view!
  6016. */
  6017. /* .name = "Capture Source", */
  6018. .name = "Input Source",
  6019. .count = 2,
  6020. .info = alc882_mux_enum_info,
  6021. .get = alc882_mux_enum_get,
  6022. .put = alc882_mux_enum_put,
  6023. },
  6024. { } /* end */
  6025. };
  6026. /* pcm configuration: identiacal with ALC880 */
  6027. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6028. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6029. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6030. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6031. /*
  6032. * configuration and preset
  6033. */
  6034. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6035. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6036. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6037. [ALC883_3ST_6ch] = "3stack-6ch",
  6038. [ALC883_6ST_DIG] = "6stack-dig",
  6039. [ALC883_TARGA_DIG] = "targa-dig",
  6040. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6041. [ALC883_ACER] = "acer",
  6042. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6043. [ALC883_MEDION] = "medion",
  6044. [ALC883_MEDION_MD2] = "medion-md2",
  6045. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6046. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6047. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6048. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6049. [ALC888_6ST_HP] = "6stack-hp",
  6050. [ALC888_3ST_HP] = "3stack-hp",
  6051. [ALC883_AUTO] = "auto",
  6052. };
  6053. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6054. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6055. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6056. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6057. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6058. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6059. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6060. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6061. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6062. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6063. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6064. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6065. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6066. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6067. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6068. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6069. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6070. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6071. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6072. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6073. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6074. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6075. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6076. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6077. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6078. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6079. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6080. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6081. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6082. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6083. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6084. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6085. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6086. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6087. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6088. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6089. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6090. {}
  6091. };
  6092. static struct alc_config_preset alc883_presets[] = {
  6093. [ALC883_3ST_2ch_DIG] = {
  6094. .mixers = { alc883_3ST_2ch_mixer },
  6095. .init_verbs = { alc883_init_verbs },
  6096. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6097. .dac_nids = alc883_dac_nids,
  6098. .dig_out_nid = ALC883_DIGOUT_NID,
  6099. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6100. .adc_nids = alc883_adc_nids,
  6101. .dig_in_nid = ALC883_DIGIN_NID,
  6102. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6103. .channel_mode = alc883_3ST_2ch_modes,
  6104. .input_mux = &alc883_capture_source,
  6105. },
  6106. [ALC883_3ST_6ch_DIG] = {
  6107. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6108. .init_verbs = { alc883_init_verbs },
  6109. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6110. .dac_nids = alc883_dac_nids,
  6111. .dig_out_nid = ALC883_DIGOUT_NID,
  6112. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6113. .adc_nids = alc883_adc_nids,
  6114. .dig_in_nid = ALC883_DIGIN_NID,
  6115. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6116. .channel_mode = alc883_3ST_6ch_modes,
  6117. .need_dac_fix = 1,
  6118. .input_mux = &alc883_capture_source,
  6119. },
  6120. [ALC883_3ST_6ch] = {
  6121. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6122. .init_verbs = { alc883_init_verbs },
  6123. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6124. .dac_nids = alc883_dac_nids,
  6125. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6126. .adc_nids = alc883_adc_nids,
  6127. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6128. .channel_mode = alc883_3ST_6ch_modes,
  6129. .need_dac_fix = 1,
  6130. .input_mux = &alc883_capture_source,
  6131. },
  6132. [ALC883_6ST_DIG] = {
  6133. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6134. .init_verbs = { alc883_init_verbs },
  6135. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6136. .dac_nids = alc883_dac_nids,
  6137. .dig_out_nid = ALC883_DIGOUT_NID,
  6138. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6139. .adc_nids = alc883_adc_nids,
  6140. .dig_in_nid = ALC883_DIGIN_NID,
  6141. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6142. .channel_mode = alc883_sixstack_modes,
  6143. .input_mux = &alc883_capture_source,
  6144. },
  6145. [ALC883_TARGA_DIG] = {
  6146. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6147. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6148. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6149. .dac_nids = alc883_dac_nids,
  6150. .dig_out_nid = ALC883_DIGOUT_NID,
  6151. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6152. .adc_nids = alc883_adc_nids,
  6153. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6154. .channel_mode = alc883_3ST_6ch_modes,
  6155. .need_dac_fix = 1,
  6156. .input_mux = &alc883_capture_source,
  6157. .unsol_event = alc883_tagra_unsol_event,
  6158. .init_hook = alc883_tagra_automute,
  6159. },
  6160. [ALC883_TARGA_2ch_DIG] = {
  6161. .mixers = { alc883_tagra_2ch_mixer},
  6162. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6163. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6164. .dac_nids = alc883_dac_nids,
  6165. .dig_out_nid = ALC883_DIGOUT_NID,
  6166. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6167. .adc_nids = alc883_adc_nids,
  6168. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6169. .channel_mode = alc883_3ST_2ch_modes,
  6170. .input_mux = &alc883_capture_source,
  6171. .unsol_event = alc883_tagra_unsol_event,
  6172. .init_hook = alc883_tagra_automute,
  6173. },
  6174. [ALC883_ACER] = {
  6175. .mixers = { alc883_base_mixer,
  6176. alc883_chmode_mixer },
  6177. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6178. * and the headphone jack. Turn this on and rely on the
  6179. * standard mute methods whenever the user wants to turn
  6180. * these outputs off.
  6181. */
  6182. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6183. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6184. .dac_nids = alc883_dac_nids,
  6185. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6186. .adc_nids = alc883_adc_nids,
  6187. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6188. .channel_mode = alc883_3ST_2ch_modes,
  6189. .input_mux = &alc883_capture_source,
  6190. },
  6191. [ALC883_ACER_ASPIRE] = {
  6192. .mixers = { alc883_acer_aspire_mixer},
  6193. .init_verbs = { alc883_init_verbs, alc883_acer_aspire_verbs},
  6194. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6195. .dac_nids = alc883_dac_nids,
  6196. .dig_out_nid = ALC883_DIGOUT_NID,
  6197. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6198. .adc_nids = alc883_adc_nids,
  6199. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6200. .channel_mode = alc883_3ST_2ch_modes,
  6201. .input_mux = &alc883_capture_source,
  6202. .unsol_event = alc883_medion_md2_unsol_event,
  6203. .init_hook = alc883_medion_md2_automute,
  6204. },
  6205. [ALC883_MEDION] = {
  6206. .mixers = { alc883_fivestack_mixer,
  6207. alc883_chmode_mixer },
  6208. .init_verbs = { alc883_init_verbs,
  6209. alc883_medion_eapd_verbs },
  6210. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6211. .dac_nids = alc883_dac_nids,
  6212. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6213. .adc_nids = alc883_adc_nids,
  6214. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6215. .channel_mode = alc883_sixstack_modes,
  6216. .input_mux = &alc883_capture_source,
  6217. },
  6218. [ALC883_MEDION_MD2] = {
  6219. .mixers = { alc883_medion_md2_mixer},
  6220. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6221. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6222. .dac_nids = alc883_dac_nids,
  6223. .dig_out_nid = ALC883_DIGOUT_NID,
  6224. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6225. .adc_nids = alc883_adc_nids,
  6226. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6227. .channel_mode = alc883_3ST_2ch_modes,
  6228. .input_mux = &alc883_capture_source,
  6229. .unsol_event = alc883_medion_md2_unsol_event,
  6230. .init_hook = alc883_medion_md2_automute,
  6231. },
  6232. [ALC883_LAPTOP_EAPD] = {
  6233. .mixers = { alc883_base_mixer,
  6234. alc883_chmode_mixer },
  6235. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6236. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6237. .dac_nids = alc883_dac_nids,
  6238. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6239. .adc_nids = alc883_adc_nids,
  6240. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6241. .channel_mode = alc883_3ST_2ch_modes,
  6242. .input_mux = &alc883_capture_source,
  6243. },
  6244. [ALC883_LENOVO_101E_2ch] = {
  6245. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6246. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6247. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6248. .dac_nids = alc883_dac_nids,
  6249. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6250. .adc_nids = alc883_adc_nids,
  6251. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6252. .channel_mode = alc883_3ST_2ch_modes,
  6253. .input_mux = &alc883_lenovo_101e_capture_source,
  6254. .unsol_event = alc883_lenovo_101e_unsol_event,
  6255. .init_hook = alc883_lenovo_101e_all_automute,
  6256. },
  6257. [ALC883_LENOVO_NB0763] = {
  6258. .mixers = { alc883_lenovo_nb0763_mixer },
  6259. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6260. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6261. .dac_nids = alc883_dac_nids,
  6262. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6263. .adc_nids = alc883_adc_nids,
  6264. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6265. .channel_mode = alc883_3ST_2ch_modes,
  6266. .need_dac_fix = 1,
  6267. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6268. .unsol_event = alc883_medion_md2_unsol_event,
  6269. .init_hook = alc883_medion_md2_automute,
  6270. },
  6271. [ALC888_LENOVO_MS7195_DIG] = {
  6272. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6273. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6274. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6275. .dac_nids = alc883_dac_nids,
  6276. .dig_out_nid = ALC883_DIGOUT_NID,
  6277. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6278. .adc_nids = alc883_adc_nids,
  6279. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6280. .channel_mode = alc883_3ST_6ch_modes,
  6281. .need_dac_fix = 1,
  6282. .input_mux = &alc883_capture_source,
  6283. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6284. .init_hook = alc888_lenovo_ms7195_front_automute,
  6285. },
  6286. [ALC888_6ST_HP] = {
  6287. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6288. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6289. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6290. .dac_nids = alc883_dac_nids,
  6291. .dig_out_nid = ALC883_DIGOUT_NID,
  6292. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6293. .adc_nids = alc883_adc_nids,
  6294. .dig_in_nid = ALC883_DIGIN_NID,
  6295. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6296. .channel_mode = alc883_sixstack_modes,
  6297. .input_mux = &alc883_capture_source,
  6298. },
  6299. [ALC888_3ST_HP] = {
  6300. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6301. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6302. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6303. .dac_nids = alc883_dac_nids,
  6304. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6305. .adc_nids = alc883_adc_nids,
  6306. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6307. .channel_mode = alc888_3st_hp_modes,
  6308. .need_dac_fix = 1,
  6309. .input_mux = &alc883_capture_source,
  6310. },
  6311. };
  6312. /*
  6313. * BIOS auto configuration
  6314. */
  6315. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6316. hda_nid_t nid, int pin_type,
  6317. int dac_idx)
  6318. {
  6319. /* set as output */
  6320. struct alc_spec *spec = codec->spec;
  6321. int idx;
  6322. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6323. idx = 4;
  6324. else
  6325. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6326. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6327. pin_type);
  6328. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6329. AMP_OUT_UNMUTE);
  6330. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6331. }
  6332. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6333. {
  6334. struct alc_spec *spec = codec->spec;
  6335. int i;
  6336. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6337. for (i = 0; i <= HDA_SIDE; i++) {
  6338. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6339. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6340. if (nid)
  6341. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6342. i);
  6343. }
  6344. }
  6345. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6346. {
  6347. struct alc_spec *spec = codec->spec;
  6348. hda_nid_t pin;
  6349. pin = spec->autocfg.hp_pins[0];
  6350. if (pin) /* connect to front */
  6351. /* use dac 0 */
  6352. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6353. }
  6354. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6355. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6356. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6357. {
  6358. struct alc_spec *spec = codec->spec;
  6359. int i;
  6360. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6361. hda_nid_t nid = spec->autocfg.input_pins[i];
  6362. if (alc883_is_input_pin(nid)) {
  6363. snd_hda_codec_write(codec, nid, 0,
  6364. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6365. (i <= AUTO_PIN_FRONT_MIC ?
  6366. PIN_VREF80 : PIN_IN));
  6367. if (nid != ALC883_PIN_CD_NID)
  6368. snd_hda_codec_write(codec, nid, 0,
  6369. AC_VERB_SET_AMP_GAIN_MUTE,
  6370. AMP_OUT_MUTE);
  6371. }
  6372. }
  6373. }
  6374. /* almost identical with ALC880 parser... */
  6375. static int alc883_parse_auto_config(struct hda_codec *codec)
  6376. {
  6377. struct alc_spec *spec = codec->spec;
  6378. int err = alc880_parse_auto_config(codec);
  6379. if (err < 0)
  6380. return err;
  6381. else if (err > 0)
  6382. /* hack - override the init verbs */
  6383. spec->init_verbs[0] = alc883_auto_init_verbs;
  6384. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6385. spec->num_mixers++;
  6386. return err;
  6387. }
  6388. /* additional initialization for auto-configuration model */
  6389. static void alc883_auto_init(struct hda_codec *codec)
  6390. {
  6391. alc883_auto_init_multi_out(codec);
  6392. alc883_auto_init_hp_out(codec);
  6393. alc883_auto_init_analog_input(codec);
  6394. }
  6395. static int patch_alc883(struct hda_codec *codec)
  6396. {
  6397. struct alc_spec *spec;
  6398. int err, board_config;
  6399. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6400. if (spec == NULL)
  6401. return -ENOMEM;
  6402. codec->spec = spec;
  6403. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6404. alc883_models,
  6405. alc883_cfg_tbl);
  6406. if (board_config < 0) {
  6407. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6408. "trying auto-probe from BIOS...\n");
  6409. board_config = ALC883_AUTO;
  6410. }
  6411. if (board_config == ALC883_AUTO) {
  6412. /* automatic parse from the BIOS config */
  6413. err = alc883_parse_auto_config(codec);
  6414. if (err < 0) {
  6415. alc_free(codec);
  6416. return err;
  6417. } else if (!err) {
  6418. printk(KERN_INFO
  6419. "hda_codec: Cannot set up configuration "
  6420. "from BIOS. Using base mode...\n");
  6421. board_config = ALC883_3ST_2ch_DIG;
  6422. }
  6423. }
  6424. if (board_config != ALC883_AUTO)
  6425. setup_preset(spec, &alc883_presets[board_config]);
  6426. spec->stream_name_analog = "ALC883 Analog";
  6427. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6428. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6429. spec->stream_name_digital = "ALC883 Digital";
  6430. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6431. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6432. if (!spec->adc_nids && spec->input_mux) {
  6433. spec->adc_nids = alc883_adc_nids;
  6434. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6435. }
  6436. codec->patch_ops = alc_patch_ops;
  6437. if (board_config == ALC883_AUTO)
  6438. spec->init_hook = alc883_auto_init;
  6439. return 0;
  6440. }
  6441. /*
  6442. * ALC262 support
  6443. */
  6444. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6445. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6446. #define alc262_dac_nids alc260_dac_nids
  6447. #define alc262_adc_nids alc882_adc_nids
  6448. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6449. #define alc262_modes alc260_modes
  6450. #define alc262_capture_source alc882_capture_source
  6451. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6452. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6453. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6454. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6455. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6456. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6457. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6458. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6459. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6460. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6461. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6462. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6463. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6464. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6465. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6466. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6467. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6468. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6469. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6470. { } /* end */
  6471. };
  6472. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6473. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6474. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6475. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6476. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6477. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6478. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6479. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6480. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6481. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6482. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6483. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6484. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6485. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6486. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6487. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6488. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6489. { } /* end */
  6490. };
  6491. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6492. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6493. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6494. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6495. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6496. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6497. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6498. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6499. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6500. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6501. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6502. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6503. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6504. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6505. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6506. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6507. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6508. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6509. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6510. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6511. { } /* end */
  6512. };
  6513. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6514. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6515. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6516. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6517. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6518. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6519. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6520. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6521. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6522. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6523. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6524. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6525. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6526. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6527. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6528. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6529. { } /* end */
  6530. };
  6531. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6532. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6533. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6534. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6535. { } /* end */
  6536. };
  6537. static struct hda_bind_ctls alc262_sony_bind_sw = {
  6538. .ops = &snd_hda_bind_sw,
  6539. .values = {
  6540. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6541. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6542. 0,
  6543. },
  6544. };
  6545. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6546. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6547. HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
  6548. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6549. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6550. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6551. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6552. { } /* end */
  6553. };
  6554. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6555. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6556. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6557. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6558. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6559. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6560. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6561. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6562. { } /* end */
  6563. };
  6564. #define alc262_capture_mixer alc882_capture_mixer
  6565. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6566. /*
  6567. * generic initialization of ADC, input mixers and output mixers
  6568. */
  6569. static struct hda_verb alc262_init_verbs[] = {
  6570. /*
  6571. * Unmute ADC0-2 and set the default input to mic-in
  6572. */
  6573. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6575. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6576. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6577. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6578. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6579. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6580. * mixer widget
  6581. * Note: PASD motherboards uses the Line In 2 as the input for
  6582. * front panel mic (mic 2)
  6583. */
  6584. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6586. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6587. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6588. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6589. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6590. /*
  6591. * Set up output mixers (0x0c - 0x0e)
  6592. */
  6593. /* set vol=0 to output mixers */
  6594. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6595. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6596. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6597. /* set up input amps for analog loopback */
  6598. /* Amp Indices: DAC = 0, mixer = 1 */
  6599. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6600. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6601. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6602. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6603. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6604. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6605. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6606. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6607. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6608. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6609. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6610. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6611. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6612. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6613. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6614. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6615. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6616. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6617. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6618. /* FIXME: use matrix-type input source selection */
  6619. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6620. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6621. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6622. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6623. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6624. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6625. /* Input mixer2 */
  6626. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6627. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6628. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6629. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6630. /* Input mixer3 */
  6631. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6632. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6635. { }
  6636. };
  6637. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6638. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6639. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6640. {}
  6641. };
  6642. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6643. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6644. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6645. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6646. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6647. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6648. {}
  6649. };
  6650. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6651. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6652. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6653. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6654. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6655. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6656. };
  6657. /* mute/unmute internal speaker according to the hp jack and mute state */
  6658. static void alc262_hippo_automute(struct hda_codec *codec)
  6659. {
  6660. struct alc_spec *spec = codec->spec;
  6661. unsigned int mute;
  6662. unsigned int present;
  6663. /* need to execute and sync at first */
  6664. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6665. present = snd_hda_codec_read(codec, 0x15, 0,
  6666. AC_VERB_GET_PIN_SENSE, 0);
  6667. spec->jack_present = (present & 0x80000000) != 0;
  6668. if (spec->jack_present) {
  6669. /* mute internal speaker */
  6670. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6671. 0x80, 0x80);
  6672. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6673. 0x80, 0x80);
  6674. } else {
  6675. /* unmute internal speaker if necessary */
  6676. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6677. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6678. 0x80, mute & 0x80);
  6679. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6680. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6681. 0x80, mute & 0x80);
  6682. }
  6683. }
  6684. /* unsolicited event for HP jack sensing */
  6685. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6686. unsigned int res)
  6687. {
  6688. if ((res >> 26) != ALC880_HP_EVENT)
  6689. return;
  6690. alc262_hippo_automute(codec);
  6691. }
  6692. static void alc262_hippo1_automute(struct hda_codec *codec)
  6693. {
  6694. unsigned int mute;
  6695. unsigned int present;
  6696. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6697. present = snd_hda_codec_read(codec, 0x1b, 0,
  6698. AC_VERB_GET_PIN_SENSE, 0);
  6699. present = (present & 0x80000000) != 0;
  6700. if (present) {
  6701. /* mute internal speaker */
  6702. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6703. 0x80, 0x80);
  6704. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6705. 0x80, 0x80);
  6706. } else {
  6707. /* unmute internal speaker if necessary */
  6708. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6709. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6710. 0x80, mute & 0x80);
  6711. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6712. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6713. 0x80, mute & 0x80);
  6714. }
  6715. }
  6716. /* unsolicited event for HP jack sensing */
  6717. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6718. unsigned int res)
  6719. {
  6720. if ((res >> 26) != ALC880_HP_EVENT)
  6721. return;
  6722. alc262_hippo1_automute(codec);
  6723. }
  6724. /*
  6725. * fujitsu model
  6726. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6727. */
  6728. #define ALC_HP_EVENT 0x37
  6729. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6730. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6731. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6732. {}
  6733. };
  6734. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6735. .num_items = 2,
  6736. .items = {
  6737. { "Mic", 0x0 },
  6738. { "CD", 0x4 },
  6739. },
  6740. };
  6741. static struct hda_input_mux alc262_HP_capture_source = {
  6742. .num_items = 5,
  6743. .items = {
  6744. { "Mic", 0x0 },
  6745. { "Front Mic", 0x3 },
  6746. { "Line", 0x2 },
  6747. { "CD", 0x4 },
  6748. { "AUX IN", 0x6 },
  6749. },
  6750. };
  6751. /* mute/unmute internal speaker according to the hp jack and mute state */
  6752. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6753. {
  6754. struct alc_spec *spec = codec->spec;
  6755. unsigned int mute;
  6756. if (force || !spec->sense_updated) {
  6757. unsigned int present;
  6758. /* need to execute and sync at first */
  6759. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6760. present = snd_hda_codec_read(codec, 0x14, 0,
  6761. AC_VERB_GET_PIN_SENSE, 0);
  6762. spec->jack_present = (present & 0x80000000) != 0;
  6763. spec->sense_updated = 1;
  6764. }
  6765. if (spec->jack_present) {
  6766. /* mute internal speaker */
  6767. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6768. 0x80, 0x80);
  6769. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6770. 0x80, 0x80);
  6771. } else {
  6772. /* unmute internal speaker if necessary */
  6773. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6774. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6775. 0x80, mute & 0x80);
  6776. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6777. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6778. 0x80, mute & 0x80);
  6779. }
  6780. }
  6781. /* unsolicited event for HP jack sensing */
  6782. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6783. unsigned int res)
  6784. {
  6785. if ((res >> 26) != ALC_HP_EVENT)
  6786. return;
  6787. alc262_fujitsu_automute(codec, 1);
  6788. }
  6789. /* bind volumes of both NID 0x0c and 0x0d */
  6790. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6791. struct snd_ctl_elem_value *ucontrol)
  6792. {
  6793. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6794. long *valp = ucontrol->value.integer.value;
  6795. int change;
  6796. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6797. 0x7f, valp[0] & 0x7f);
  6798. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6799. 0x7f, valp[1] & 0x7f);
  6800. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6801. 0x7f, valp[0] & 0x7f);
  6802. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6803. 0x7f, valp[1] & 0x7f);
  6804. return change;
  6805. }
  6806. /* bind hp and internal speaker mute (with plug check) */
  6807. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6808. struct snd_ctl_elem_value *ucontrol)
  6809. {
  6810. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6811. long *valp = ucontrol->value.integer.value;
  6812. int change;
  6813. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6814. 0x80, valp[0] ? 0 : 0x80);
  6815. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6816. 0x80, valp[1] ? 0 : 0x80);
  6817. if (change || codec->in_resume)
  6818. alc262_fujitsu_automute(codec, codec->in_resume);
  6819. return change;
  6820. }
  6821. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6822. {
  6823. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6824. .name = "Master Playback Volume",
  6825. .info = snd_hda_mixer_amp_volume_info,
  6826. .get = snd_hda_mixer_amp_volume_get,
  6827. .put = alc262_fujitsu_master_vol_put,
  6828. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6829. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6830. },
  6831. {
  6832. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6833. .name = "Master Playback Switch",
  6834. .info = snd_hda_mixer_amp_switch_info,
  6835. .get = snd_hda_mixer_amp_switch_get,
  6836. .put = alc262_fujitsu_master_sw_put,
  6837. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6838. },
  6839. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6840. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6841. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6842. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6843. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6844. { } /* end */
  6845. };
  6846. /* additional init verbs for Benq laptops */
  6847. static struct hda_verb alc262_EAPD_verbs[] = {
  6848. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6849. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6850. {}
  6851. };
  6852. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6853. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6854. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6855. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6856. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6857. {}
  6858. };
  6859. /* add playback controls from the parsed DAC table */
  6860. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6861. const struct auto_pin_cfg *cfg)
  6862. {
  6863. hda_nid_t nid;
  6864. int err;
  6865. spec->multiout.num_dacs = 1; /* only use one dac */
  6866. spec->multiout.dac_nids = spec->private_dac_nids;
  6867. spec->multiout.dac_nids[0] = 2;
  6868. nid = cfg->line_out_pins[0];
  6869. if (nid) {
  6870. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6871. "Front Playback Volume",
  6872. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6873. if (err < 0)
  6874. return err;
  6875. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6876. "Front Playback Switch",
  6877. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6878. if (err < 0)
  6879. return err;
  6880. }
  6881. nid = cfg->speaker_pins[0];
  6882. if (nid) {
  6883. if (nid == 0x16) {
  6884. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6885. "Speaker Playback Volume",
  6886. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6887. HDA_OUTPUT));
  6888. if (err < 0)
  6889. return err;
  6890. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6891. "Speaker Playback Switch",
  6892. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6893. HDA_OUTPUT));
  6894. if (err < 0)
  6895. return err;
  6896. } else {
  6897. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6898. "Speaker Playback Switch",
  6899. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6900. HDA_OUTPUT));
  6901. if (err < 0)
  6902. return err;
  6903. }
  6904. }
  6905. nid = cfg->hp_pins[0];
  6906. if (nid) {
  6907. /* spec->multiout.hp_nid = 2; */
  6908. if (nid == 0x16) {
  6909. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6910. "Headphone Playback Volume",
  6911. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6912. HDA_OUTPUT));
  6913. if (err < 0)
  6914. return err;
  6915. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6916. "Headphone Playback Switch",
  6917. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6918. HDA_OUTPUT));
  6919. if (err < 0)
  6920. return err;
  6921. } else {
  6922. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6923. "Headphone Playback Switch",
  6924. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6925. HDA_OUTPUT));
  6926. if (err < 0)
  6927. return err;
  6928. }
  6929. }
  6930. return 0;
  6931. }
  6932. /* identical with ALC880 */
  6933. #define alc262_auto_create_analog_input_ctls \
  6934. alc880_auto_create_analog_input_ctls
  6935. /*
  6936. * generic initialization of ADC, input mixers and output mixers
  6937. */
  6938. static struct hda_verb alc262_volume_init_verbs[] = {
  6939. /*
  6940. * Unmute ADC0-2 and set the default input to mic-in
  6941. */
  6942. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6943. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6944. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6945. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6946. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6947. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6948. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6949. * mixer widget
  6950. * Note: PASD motherboards uses the Line In 2 as the input for
  6951. * front panel mic (mic 2)
  6952. */
  6953. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6954. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6955. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6956. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6957. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6958. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6959. /*
  6960. * Set up output mixers (0x0c - 0x0f)
  6961. */
  6962. /* set vol=0 to output mixers */
  6963. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6964. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6965. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6966. /* set up input amps for analog loopback */
  6967. /* Amp Indices: DAC = 0, mixer = 1 */
  6968. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6969. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6970. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6971. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6973. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6974. /* FIXME: use matrix-type input source selection */
  6975. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6976. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6977. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6978. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6979. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6980. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6981. /* Input mixer2 */
  6982. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6983. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6984. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6985. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6986. /* Input mixer3 */
  6987. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6988. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6989. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6991. { }
  6992. };
  6993. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6994. /*
  6995. * Unmute ADC0-2 and set the default input to mic-in
  6996. */
  6997. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6998. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6999. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7000. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7001. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7002. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7003. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7004. * mixer widget
  7005. * Note: PASD motherboards uses the Line In 2 as the input for
  7006. * front panel mic (mic 2)
  7007. */
  7008. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7009. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7010. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7011. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7012. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7013. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7014. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7015. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7016. /*
  7017. * Set up output mixers (0x0c - 0x0e)
  7018. */
  7019. /* set vol=0 to output mixers */
  7020. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7021. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7022. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7023. /* set up input amps for analog loopback */
  7024. /* Amp Indices: DAC = 0, mixer = 1 */
  7025. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7027. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7028. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7029. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7030. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7031. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7032. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7033. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7034. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7035. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7036. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7037. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7038. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7039. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7040. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7041. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7042. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7043. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7044. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7045. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7046. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7047. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7048. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7049. /* FIXME: use matrix-type input source selection */
  7050. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7051. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7052. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7053. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7054. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7055. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7056. /* Input mixer2 */
  7057. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7058. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7059. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7060. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7061. /* Input mixer3 */
  7062. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7063. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7064. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7065. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7066. { }
  7067. };
  7068. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7069. /*
  7070. * Unmute ADC0-2 and set the default input to mic-in
  7071. */
  7072. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7073. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7074. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7075. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7076. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7077. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7078. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7079. * mixer widget
  7080. * Note: PASD motherboards uses the Line In 2 as the input for front
  7081. * panel mic (mic 2)
  7082. */
  7083. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7084. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7085. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7086. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7087. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7088. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7089. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7090. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7091. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  7092. /*
  7093. * Set up output mixers (0x0c - 0x0e)
  7094. */
  7095. /* set vol=0 to output mixers */
  7096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7097. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7098. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7099. /* set up input amps for analog loopback */
  7100. /* Amp Indices: DAC = 0, mixer = 1 */
  7101. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7102. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7103. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7104. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7105. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7106. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7107. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7108. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7109. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7110. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7111. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7112. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7113. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7114. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7115. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7116. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7117. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7118. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7119. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7120. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7121. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7122. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7123. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7124. /* FIXME: use matrix-type input source selection */
  7125. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7126. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7128. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7129. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7130. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7131. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7132. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7133. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7134. /* Input mixer2 */
  7135. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7136. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7137. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7138. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7139. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7140. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7141. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7142. /* Input mixer3 */
  7143. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7144. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7145. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7146. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7147. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7148. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7149. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7150. { }
  7151. };
  7152. /* pcm configuration: identiacal with ALC880 */
  7153. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7154. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7155. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7156. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7157. /*
  7158. * BIOS auto configuration
  7159. */
  7160. static int alc262_parse_auto_config(struct hda_codec *codec)
  7161. {
  7162. struct alc_spec *spec = codec->spec;
  7163. int err;
  7164. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7165. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7166. alc262_ignore);
  7167. if (err < 0)
  7168. return err;
  7169. if (!spec->autocfg.line_outs)
  7170. return 0; /* can't find valid BIOS pin config */
  7171. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7172. if (err < 0)
  7173. return err;
  7174. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7175. if (err < 0)
  7176. return err;
  7177. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7178. if (spec->autocfg.dig_out_pin)
  7179. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7180. if (spec->autocfg.dig_in_pin)
  7181. spec->dig_in_nid = ALC262_DIGIN_NID;
  7182. if (spec->kctl_alloc)
  7183. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7184. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7185. spec->num_mux_defs = 1;
  7186. spec->input_mux = &spec->private_imux;
  7187. return 1;
  7188. }
  7189. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7190. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7191. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7192. /* init callback for auto-configuration model -- overriding the default init */
  7193. static void alc262_auto_init(struct hda_codec *codec)
  7194. {
  7195. alc262_auto_init_multi_out(codec);
  7196. alc262_auto_init_hp_out(codec);
  7197. alc262_auto_init_analog_input(codec);
  7198. }
  7199. /*
  7200. * configuration and preset
  7201. */
  7202. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7203. [ALC262_BASIC] = "basic",
  7204. [ALC262_HIPPO] = "hippo",
  7205. [ALC262_HIPPO_1] = "hippo_1",
  7206. [ALC262_FUJITSU] = "fujitsu",
  7207. [ALC262_HP_BPC] = "hp-bpc",
  7208. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7209. [ALC262_BENQ_ED8] = "benq",
  7210. [ALC262_BENQ_T31] = "benq-t31",
  7211. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7212. [ALC262_AUTO] = "auto",
  7213. };
  7214. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7215. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7216. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7217. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7218. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7219. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7220. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7221. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7222. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7223. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7224. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7225. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7226. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7227. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7228. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7229. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7230. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7231. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7232. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7233. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7234. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7235. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7236. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7237. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7238. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7239. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7240. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7241. {}
  7242. };
  7243. static struct alc_config_preset alc262_presets[] = {
  7244. [ALC262_BASIC] = {
  7245. .mixers = { alc262_base_mixer },
  7246. .init_verbs = { alc262_init_verbs },
  7247. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7248. .dac_nids = alc262_dac_nids,
  7249. .hp_nid = 0x03,
  7250. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7251. .channel_mode = alc262_modes,
  7252. .input_mux = &alc262_capture_source,
  7253. },
  7254. [ALC262_HIPPO] = {
  7255. .mixers = { alc262_base_mixer },
  7256. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7257. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7258. .dac_nids = alc262_dac_nids,
  7259. .hp_nid = 0x03,
  7260. .dig_out_nid = ALC262_DIGOUT_NID,
  7261. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7262. .channel_mode = alc262_modes,
  7263. .input_mux = &alc262_capture_source,
  7264. .unsol_event = alc262_hippo_unsol_event,
  7265. .init_hook = alc262_hippo_automute,
  7266. },
  7267. [ALC262_HIPPO_1] = {
  7268. .mixers = { alc262_hippo1_mixer },
  7269. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7270. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7271. .dac_nids = alc262_dac_nids,
  7272. .hp_nid = 0x02,
  7273. .dig_out_nid = ALC262_DIGOUT_NID,
  7274. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7275. .channel_mode = alc262_modes,
  7276. .input_mux = &alc262_capture_source,
  7277. .unsol_event = alc262_hippo1_unsol_event,
  7278. .init_hook = alc262_hippo1_automute,
  7279. },
  7280. [ALC262_FUJITSU] = {
  7281. .mixers = { alc262_fujitsu_mixer },
  7282. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7283. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7284. .dac_nids = alc262_dac_nids,
  7285. .hp_nid = 0x03,
  7286. .dig_out_nid = ALC262_DIGOUT_NID,
  7287. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7288. .channel_mode = alc262_modes,
  7289. .input_mux = &alc262_fujitsu_capture_source,
  7290. .unsol_event = alc262_fujitsu_unsol_event,
  7291. },
  7292. [ALC262_HP_BPC] = {
  7293. .mixers = { alc262_HP_BPC_mixer },
  7294. .init_verbs = { alc262_HP_BPC_init_verbs },
  7295. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7296. .dac_nids = alc262_dac_nids,
  7297. .hp_nid = 0x03,
  7298. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7299. .channel_mode = alc262_modes,
  7300. .input_mux = &alc262_HP_capture_source,
  7301. },
  7302. [ALC262_HP_BPC_D7000_WF] = {
  7303. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7304. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7305. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7306. .dac_nids = alc262_dac_nids,
  7307. .hp_nid = 0x03,
  7308. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7309. .channel_mode = alc262_modes,
  7310. .input_mux = &alc262_HP_capture_source,
  7311. },
  7312. [ALC262_HP_BPC_D7000_WL] = {
  7313. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7314. alc262_HP_BPC_WildWest_option_mixer },
  7315. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7316. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7317. .dac_nids = alc262_dac_nids,
  7318. .hp_nid = 0x03,
  7319. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7320. .channel_mode = alc262_modes,
  7321. .input_mux = &alc262_HP_capture_source,
  7322. },
  7323. [ALC262_BENQ_ED8] = {
  7324. .mixers = { alc262_base_mixer },
  7325. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7326. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7327. .dac_nids = alc262_dac_nids,
  7328. .hp_nid = 0x03,
  7329. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7330. .channel_mode = alc262_modes,
  7331. .input_mux = &alc262_capture_source,
  7332. },
  7333. [ALC262_SONY_ASSAMD] = {
  7334. .mixers = { alc262_sony_mixer },
  7335. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7336. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7337. .dac_nids = alc262_dac_nids,
  7338. .hp_nid = 0x02,
  7339. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7340. .channel_mode = alc262_modes,
  7341. .input_mux = &alc262_capture_source,
  7342. .unsol_event = alc262_hippo_unsol_event,
  7343. .init_hook = alc262_hippo_automute,
  7344. },
  7345. [ALC262_BENQ_T31] = {
  7346. .mixers = { alc262_benq_t31_mixer },
  7347. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7348. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7349. .dac_nids = alc262_dac_nids,
  7350. .hp_nid = 0x03,
  7351. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7352. .channel_mode = alc262_modes,
  7353. .input_mux = &alc262_capture_source,
  7354. .unsol_event = alc262_hippo_unsol_event,
  7355. .init_hook = alc262_hippo_automute,
  7356. },
  7357. };
  7358. static int patch_alc262(struct hda_codec *codec)
  7359. {
  7360. struct alc_spec *spec;
  7361. int board_config;
  7362. int err;
  7363. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7364. if (spec == NULL)
  7365. return -ENOMEM;
  7366. codec->spec = spec;
  7367. #if 0
  7368. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7369. * under-run
  7370. */
  7371. {
  7372. int tmp;
  7373. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7374. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7375. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7376. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7377. }
  7378. #endif
  7379. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7380. alc262_models,
  7381. alc262_cfg_tbl);
  7382. if (board_config < 0) {
  7383. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7384. "trying auto-probe from BIOS...\n");
  7385. board_config = ALC262_AUTO;
  7386. }
  7387. if (board_config == ALC262_AUTO) {
  7388. /* automatic parse from the BIOS config */
  7389. err = alc262_parse_auto_config(codec);
  7390. if (err < 0) {
  7391. alc_free(codec);
  7392. return err;
  7393. } else if (!err) {
  7394. printk(KERN_INFO
  7395. "hda_codec: Cannot set up configuration "
  7396. "from BIOS. Using base mode...\n");
  7397. board_config = ALC262_BASIC;
  7398. }
  7399. }
  7400. if (board_config != ALC262_AUTO)
  7401. setup_preset(spec, &alc262_presets[board_config]);
  7402. spec->stream_name_analog = "ALC262 Analog";
  7403. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7404. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7405. spec->stream_name_digital = "ALC262 Digital";
  7406. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7407. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7408. if (!spec->adc_nids && spec->input_mux) {
  7409. /* check whether NID 0x07 is valid */
  7410. unsigned int wcap = get_wcaps(codec, 0x07);
  7411. /* get type */
  7412. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7413. if (wcap != AC_WID_AUD_IN) {
  7414. spec->adc_nids = alc262_adc_nids_alt;
  7415. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7416. spec->mixers[spec->num_mixers] =
  7417. alc262_capture_alt_mixer;
  7418. spec->num_mixers++;
  7419. } else {
  7420. spec->adc_nids = alc262_adc_nids;
  7421. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7422. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7423. spec->num_mixers++;
  7424. }
  7425. }
  7426. codec->patch_ops = alc_patch_ops;
  7427. if (board_config == ALC262_AUTO)
  7428. spec->init_hook = alc262_auto_init;
  7429. return 0;
  7430. }
  7431. /*
  7432. * ALC268 channel source setting (2 channel)
  7433. */
  7434. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7435. #define alc268_modes alc260_modes
  7436. static hda_nid_t alc268_dac_nids[2] = {
  7437. /* front, hp */
  7438. 0x02, 0x03
  7439. };
  7440. static hda_nid_t alc268_adc_nids[2] = {
  7441. /* ADC0-1 */
  7442. 0x08, 0x07
  7443. };
  7444. static hda_nid_t alc268_adc_nids_alt[1] = {
  7445. /* ADC0 */
  7446. 0x08
  7447. };
  7448. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7449. /* output mixer control */
  7450. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7451. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7452. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7454. { }
  7455. };
  7456. /*
  7457. * generic initialization of ADC, input mixers and output mixers
  7458. */
  7459. static struct hda_verb alc268_base_init_verbs[] = {
  7460. /* Unmute DAC0-1 and set vol = 0 */
  7461. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7462. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7463. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7464. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7465. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7466. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7467. /*
  7468. * Set up output mixers (0x0c - 0x0e)
  7469. */
  7470. /* set vol=0 to output mixers */
  7471. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7472. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7473. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7474. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7475. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7476. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7477. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7478. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7479. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7480. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7481. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7482. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7483. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7484. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7485. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7486. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7487. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7488. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7489. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7490. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7491. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7492. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7493. /* FIXME: use matrix-type input source selection */
  7494. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7495. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7496. /* Input mixer2 */
  7497. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7498. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7499. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7500. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7501. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7502. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7503. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7504. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7505. { }
  7506. };
  7507. /*
  7508. * generic initialization of ADC, input mixers and output mixers
  7509. */
  7510. static struct hda_verb alc268_volume_init_verbs[] = {
  7511. /* set output DAC */
  7512. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7513. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7514. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7515. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7516. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7517. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7518. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7519. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7520. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7521. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7522. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7523. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7525. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7526. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7527. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7528. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7529. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7530. /* set PCBEEP vol = 0 */
  7531. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7532. { }
  7533. };
  7534. #define alc268_mux_enum_info alc_mux_enum_info
  7535. #define alc268_mux_enum_get alc_mux_enum_get
  7536. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7537. struct snd_ctl_elem_value *ucontrol)
  7538. {
  7539. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7540. struct alc_spec *spec = codec->spec;
  7541. const struct hda_input_mux *imux = spec->input_mux;
  7542. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7543. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7544. hda_nid_t nid = capture_mixers[adc_idx];
  7545. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7546. unsigned int i, idx;
  7547. idx = ucontrol->value.enumerated.item[0];
  7548. if (idx >= imux->num_items)
  7549. idx = imux->num_items - 1;
  7550. if (*cur_val == idx && !codec->in_resume)
  7551. return 0;
  7552. for (i = 0; i < imux->num_items; i++) {
  7553. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7554. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7555. v | (imux->items[i].index << 8));
  7556. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7557. idx );
  7558. }
  7559. *cur_val = idx;
  7560. return 1;
  7561. }
  7562. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7563. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7564. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7565. {
  7566. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7567. /* The multiple "Capture Source" controls confuse alsamixer
  7568. * So call somewhat different..
  7569. * FIXME: the controls appear in the "playback" view!
  7570. */
  7571. /* .name = "Capture Source", */
  7572. .name = "Input Source",
  7573. .count = 1,
  7574. .info = alc268_mux_enum_info,
  7575. .get = alc268_mux_enum_get,
  7576. .put = alc268_mux_enum_put,
  7577. },
  7578. { } /* end */
  7579. };
  7580. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7581. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7582. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7583. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7584. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7585. {
  7586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7587. /* The multiple "Capture Source" controls confuse alsamixer
  7588. * So call somewhat different..
  7589. * FIXME: the controls appear in the "playback" view!
  7590. */
  7591. /* .name = "Capture Source", */
  7592. .name = "Input Source",
  7593. .count = 2,
  7594. .info = alc268_mux_enum_info,
  7595. .get = alc268_mux_enum_get,
  7596. .put = alc268_mux_enum_put,
  7597. },
  7598. { } /* end */
  7599. };
  7600. static struct hda_input_mux alc268_capture_source = {
  7601. .num_items = 4,
  7602. .items = {
  7603. { "Mic", 0x0 },
  7604. { "Front Mic", 0x1 },
  7605. { "Line", 0x2 },
  7606. { "CD", 0x3 },
  7607. },
  7608. };
  7609. /* create input playback/capture controls for the given pin */
  7610. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7611. const char *ctlname, int idx)
  7612. {
  7613. char name[32];
  7614. int err;
  7615. sprintf(name, "%s Playback Volume", ctlname);
  7616. if (nid == 0x14) {
  7617. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7618. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7619. HDA_OUTPUT));
  7620. if (err < 0)
  7621. return err;
  7622. } else if (nid == 0x15) {
  7623. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7624. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7625. HDA_OUTPUT));
  7626. if (err < 0)
  7627. return err;
  7628. } else
  7629. return -1;
  7630. sprintf(name, "%s Playback Switch", ctlname);
  7631. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7632. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7633. if (err < 0)
  7634. return err;
  7635. return 0;
  7636. }
  7637. /* add playback controls from the parsed DAC table */
  7638. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7639. const struct auto_pin_cfg *cfg)
  7640. {
  7641. hda_nid_t nid;
  7642. int err;
  7643. spec->multiout.num_dacs = 2; /* only use one dac */
  7644. spec->multiout.dac_nids = spec->private_dac_nids;
  7645. spec->multiout.dac_nids[0] = 2;
  7646. spec->multiout.dac_nids[1] = 3;
  7647. nid = cfg->line_out_pins[0];
  7648. if (nid)
  7649. alc268_new_analog_output(spec, nid, "Front", 0);
  7650. nid = cfg->speaker_pins[0];
  7651. if (nid == 0x1d) {
  7652. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7653. "Speaker Playback Volume",
  7654. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7655. if (err < 0)
  7656. return err;
  7657. }
  7658. nid = cfg->hp_pins[0];
  7659. if (nid)
  7660. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7661. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7662. if (nid == 0x16) {
  7663. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7664. "Mono Playback Switch",
  7665. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7666. if (err < 0)
  7667. return err;
  7668. }
  7669. return 0;
  7670. }
  7671. /* create playback/capture controls for input pins */
  7672. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7673. const struct auto_pin_cfg *cfg)
  7674. {
  7675. struct hda_input_mux *imux = &spec->private_imux;
  7676. int i, idx1;
  7677. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7678. switch(cfg->input_pins[i]) {
  7679. case 0x18:
  7680. idx1 = 0; /* Mic 1 */
  7681. break;
  7682. case 0x19:
  7683. idx1 = 1; /* Mic 2 */
  7684. break;
  7685. case 0x1a:
  7686. idx1 = 2; /* Line In */
  7687. break;
  7688. case 0x1c:
  7689. idx1 = 3; /* CD */
  7690. break;
  7691. default:
  7692. continue;
  7693. }
  7694. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7695. imux->items[imux->num_items].index = idx1;
  7696. imux->num_items++;
  7697. }
  7698. return 0;
  7699. }
  7700. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7701. {
  7702. struct alc_spec *spec = codec->spec;
  7703. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7704. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7705. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7706. unsigned int dac_vol1, dac_vol2;
  7707. if (speaker_nid) {
  7708. snd_hda_codec_write(codec, speaker_nid, 0,
  7709. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7710. snd_hda_codec_write(codec, 0x0f, 0,
  7711. AC_VERB_SET_AMP_GAIN_MUTE,
  7712. AMP_IN_UNMUTE(1));
  7713. snd_hda_codec_write(codec, 0x10, 0,
  7714. AC_VERB_SET_AMP_GAIN_MUTE,
  7715. AMP_IN_UNMUTE(1));
  7716. } else {
  7717. snd_hda_codec_write(codec, 0x0f, 0,
  7718. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7719. snd_hda_codec_write(codec, 0x10, 0,
  7720. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7721. }
  7722. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7723. if (line_nid == 0x14)
  7724. dac_vol2 = AMP_OUT_ZERO;
  7725. else if (line_nid == 0x15)
  7726. dac_vol1 = AMP_OUT_ZERO;
  7727. if (hp_nid == 0x14)
  7728. dac_vol2 = AMP_OUT_ZERO;
  7729. else if (hp_nid == 0x15)
  7730. dac_vol1 = AMP_OUT_ZERO;
  7731. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7732. spec->autocfg.line_out_pins[1] != 0x16 ||
  7733. spec->autocfg.line_out_pins[2] != 0x16)
  7734. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7735. snd_hda_codec_write(codec, 0x02, 0,
  7736. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7737. snd_hda_codec_write(codec, 0x03, 0,
  7738. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7739. }
  7740. /* pcm configuration: identiacal with ALC880 */
  7741. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7742. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7743. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7744. /*
  7745. * BIOS auto configuration
  7746. */
  7747. static int alc268_parse_auto_config(struct hda_codec *codec)
  7748. {
  7749. struct alc_spec *spec = codec->spec;
  7750. int err;
  7751. static hda_nid_t alc268_ignore[] = { 0 };
  7752. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7753. alc268_ignore);
  7754. if (err < 0)
  7755. return err;
  7756. if (!spec->autocfg.line_outs)
  7757. return 0; /* can't find valid BIOS pin config */
  7758. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7759. if (err < 0)
  7760. return err;
  7761. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7762. if (err < 0)
  7763. return err;
  7764. spec->multiout.max_channels = 2;
  7765. /* digital only support output */
  7766. if (spec->autocfg.dig_out_pin)
  7767. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7768. if (spec->kctl_alloc)
  7769. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7770. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7771. spec->num_mux_defs = 1;
  7772. spec->input_mux = &spec->private_imux;
  7773. return 1;
  7774. }
  7775. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7776. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7777. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7778. /* init callback for auto-configuration model -- overriding the default init */
  7779. static void alc268_auto_init(struct hda_codec *codec)
  7780. {
  7781. alc268_auto_init_multi_out(codec);
  7782. alc268_auto_init_hp_out(codec);
  7783. alc268_auto_init_mono_speaker_out(codec);
  7784. alc268_auto_init_analog_input(codec);
  7785. }
  7786. /*
  7787. * configuration and preset
  7788. */
  7789. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7790. [ALC268_3ST] = "3stack",
  7791. [ALC268_AUTO] = "auto",
  7792. };
  7793. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7794. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7795. {}
  7796. };
  7797. static struct alc_config_preset alc268_presets[] = {
  7798. [ALC268_3ST] = {
  7799. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7800. .init_verbs = { alc268_base_init_verbs },
  7801. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7802. .dac_nids = alc268_dac_nids,
  7803. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7804. .adc_nids = alc268_adc_nids_alt,
  7805. .hp_nid = 0x03,
  7806. .dig_out_nid = ALC268_DIGOUT_NID,
  7807. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7808. .channel_mode = alc268_modes,
  7809. .input_mux = &alc268_capture_source,
  7810. },
  7811. };
  7812. static int patch_alc268(struct hda_codec *codec)
  7813. {
  7814. struct alc_spec *spec;
  7815. int board_config;
  7816. int err;
  7817. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7818. if (spec == NULL)
  7819. return -ENOMEM;
  7820. codec->spec = spec;
  7821. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7822. alc268_models,
  7823. alc268_cfg_tbl);
  7824. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7825. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7826. "trying auto-probe from BIOS...\n");
  7827. board_config = ALC268_AUTO;
  7828. }
  7829. if (board_config == ALC268_AUTO) {
  7830. /* automatic parse from the BIOS config */
  7831. err = alc268_parse_auto_config(codec);
  7832. if (err < 0) {
  7833. alc_free(codec);
  7834. return err;
  7835. } else if (!err) {
  7836. printk(KERN_INFO
  7837. "hda_codec: Cannot set up configuration "
  7838. "from BIOS. Using base mode...\n");
  7839. board_config = ALC268_3ST;
  7840. }
  7841. }
  7842. if (board_config != ALC268_AUTO)
  7843. setup_preset(spec, &alc268_presets[board_config]);
  7844. spec->stream_name_analog = "ALC268 Analog";
  7845. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7846. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7847. spec->stream_name_digital = "ALC268 Digital";
  7848. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7849. if (board_config == ALC268_AUTO) {
  7850. if (!spec->adc_nids && spec->input_mux) {
  7851. /* check whether NID 0x07 is valid */
  7852. unsigned int wcap = get_wcaps(codec, 0x07);
  7853. /* get type */
  7854. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7855. if (wcap != AC_WID_AUD_IN) {
  7856. spec->adc_nids = alc268_adc_nids_alt;
  7857. spec->num_adc_nids =
  7858. ARRAY_SIZE(alc268_adc_nids_alt);
  7859. spec->mixers[spec->num_mixers] =
  7860. alc268_capture_alt_mixer;
  7861. spec->num_mixers++;
  7862. } else {
  7863. spec->adc_nids = alc268_adc_nids;
  7864. spec->num_adc_nids =
  7865. ARRAY_SIZE(alc268_adc_nids);
  7866. spec->mixers[spec->num_mixers] =
  7867. alc268_capture_mixer;
  7868. spec->num_mixers++;
  7869. }
  7870. }
  7871. }
  7872. codec->patch_ops = alc_patch_ops;
  7873. if (board_config == ALC268_AUTO)
  7874. spec->init_hook = alc268_auto_init;
  7875. return 0;
  7876. }
  7877. /*
  7878. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7879. */
  7880. /*
  7881. * set the path ways for 2 channel output
  7882. * need to set the codec line out and mic 1 pin widgets to inputs
  7883. */
  7884. static struct hda_verb alc861_threestack_ch2_init[] = {
  7885. /* set pin widget 1Ah (line in) for input */
  7886. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7887. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7888. * the vref
  7889. */
  7890. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7891. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7892. #if 0
  7893. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7894. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7895. #endif
  7896. { } /* end */
  7897. };
  7898. /*
  7899. * 6ch mode
  7900. * need to set the codec line out and mic 1 pin widgets to outputs
  7901. */
  7902. static struct hda_verb alc861_threestack_ch6_init[] = {
  7903. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7904. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7905. /* set pin widget 18h (mic1) for output (CLFE)*/
  7906. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7907. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7908. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7909. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7910. #if 0
  7911. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7912. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7913. #endif
  7914. { } /* end */
  7915. };
  7916. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7917. { 2, alc861_threestack_ch2_init },
  7918. { 6, alc861_threestack_ch6_init },
  7919. };
  7920. /* Set mic1 as input and unmute the mixer */
  7921. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7922. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7923. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7924. { } /* end */
  7925. };
  7926. /* Set mic1 as output and mute mixer */
  7927. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7928. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7929. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7930. { } /* end */
  7931. };
  7932. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7933. { 2, alc861_uniwill_m31_ch2_init },
  7934. { 4, alc861_uniwill_m31_ch4_init },
  7935. };
  7936. /* Set mic1 and line-in as input and unmute the mixer */
  7937. static struct hda_verb alc861_asus_ch2_init[] = {
  7938. /* set pin widget 1Ah (line in) for input */
  7939. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7940. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7941. * the vref
  7942. */
  7943. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7944. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7945. #if 0
  7946. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7947. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7948. #endif
  7949. { } /* end */
  7950. };
  7951. /* Set mic1 nad line-in as output and mute mixer */
  7952. static struct hda_verb alc861_asus_ch6_init[] = {
  7953. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7954. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7955. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7956. /* set pin widget 18h (mic1) for output (CLFE)*/
  7957. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7958. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7959. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7960. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7961. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7962. #if 0
  7963. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7964. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7965. #endif
  7966. { } /* end */
  7967. };
  7968. static struct hda_channel_mode alc861_asus_modes[2] = {
  7969. { 2, alc861_asus_ch2_init },
  7970. { 6, alc861_asus_ch6_init },
  7971. };
  7972. /* patch-ALC861 */
  7973. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7974. /* output mixer control */
  7975. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7976. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7977. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7978. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7979. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7980. /*Input mixer control */
  7981. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7982. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7983. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7984. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7985. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7986. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7987. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7988. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7989. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7990. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7991. /* Capture mixer control */
  7992. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7993. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7994. {
  7995. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7996. .name = "Capture Source",
  7997. .count = 1,
  7998. .info = alc_mux_enum_info,
  7999. .get = alc_mux_enum_get,
  8000. .put = alc_mux_enum_put,
  8001. },
  8002. { } /* end */
  8003. };
  8004. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8005. /* output mixer control */
  8006. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8007. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8008. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8009. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8010. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8011. /* Input mixer control */
  8012. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8013. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8014. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8015. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8016. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8017. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8018. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8019. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8020. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8021. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8022. /* Capture mixer control */
  8023. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8024. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8025. {
  8026. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8027. .name = "Capture Source",
  8028. .count = 1,
  8029. .info = alc_mux_enum_info,
  8030. .get = alc_mux_enum_get,
  8031. .put = alc_mux_enum_put,
  8032. },
  8033. {
  8034. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8035. .name = "Channel Mode",
  8036. .info = alc_ch_mode_info,
  8037. .get = alc_ch_mode_get,
  8038. .put = alc_ch_mode_put,
  8039. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8040. },
  8041. { } /* end */
  8042. };
  8043. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8044. /* output mixer control */
  8045. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8046. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8047. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8048. /*Capture mixer control */
  8049. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8050. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8051. {
  8052. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8053. .name = "Capture Source",
  8054. .count = 1,
  8055. .info = alc_mux_enum_info,
  8056. .get = alc_mux_enum_get,
  8057. .put = alc_mux_enum_put,
  8058. },
  8059. { } /* end */
  8060. };
  8061. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8062. /* output mixer control */
  8063. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8064. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8065. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8066. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8067. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8068. /* Input mixer control */
  8069. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8070. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8071. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8072. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8073. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8074. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8075. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8076. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8077. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8078. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8079. /* Capture mixer control */
  8080. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8081. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8082. {
  8083. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8084. .name = "Capture Source",
  8085. .count = 1,
  8086. .info = alc_mux_enum_info,
  8087. .get = alc_mux_enum_get,
  8088. .put = alc_mux_enum_put,
  8089. },
  8090. {
  8091. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8092. .name = "Channel Mode",
  8093. .info = alc_ch_mode_info,
  8094. .get = alc_ch_mode_get,
  8095. .put = alc_ch_mode_put,
  8096. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8097. },
  8098. { } /* end */
  8099. };
  8100. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8101. /* output mixer control */
  8102. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8103. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8104. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8105. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8106. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8107. /* Input mixer control */
  8108. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8109. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8110. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8111. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8112. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8113. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8114. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8115. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8116. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8117. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8118. /* Capture mixer control */
  8119. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8120. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8121. {
  8122. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8123. .name = "Capture Source",
  8124. .count = 1,
  8125. .info = alc_mux_enum_info,
  8126. .get = alc_mux_enum_get,
  8127. .put = alc_mux_enum_put,
  8128. },
  8129. {
  8130. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8131. .name = "Channel Mode",
  8132. .info = alc_ch_mode_info,
  8133. .get = alc_ch_mode_get,
  8134. .put = alc_ch_mode_put,
  8135. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8136. },
  8137. { }
  8138. };
  8139. /* additional mixer */
  8140. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8141. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8142. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8143. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8144. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8145. { }
  8146. };
  8147. /*
  8148. * generic initialization of ADC, input mixers and output mixers
  8149. */
  8150. static struct hda_verb alc861_base_init_verbs[] = {
  8151. /*
  8152. * Unmute ADC0 and set the default input to mic-in
  8153. */
  8154. /* port-A for surround (rear panel) */
  8155. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8156. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8157. /* port-B for mic-in (rear panel) with vref */
  8158. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8159. /* port-C for line-in (rear panel) */
  8160. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8161. /* port-D for Front */
  8162. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8163. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8164. /* port-E for HP out (front panel) */
  8165. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8166. /* route front PCM to HP */
  8167. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8168. /* port-F for mic-in (front panel) with vref */
  8169. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8170. /* port-G for CLFE (rear panel) */
  8171. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8172. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8173. /* port-H for side (rear panel) */
  8174. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8175. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8176. /* CD-in */
  8177. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8178. /* route front mic to ADC1*/
  8179. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8180. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8181. /* Unmute DAC0~3 & spdif out*/
  8182. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8183. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8184. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8185. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8186. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8187. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8188. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8189. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8190. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8191. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8192. /* Unmute Stereo Mixer 15 */
  8193. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8194. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8195. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8196. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8197. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8198. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8199. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8200. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8201. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8202. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8203. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8204. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8205. /* hp used DAC 3 (Front) */
  8206. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8207. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8208. { }
  8209. };
  8210. static struct hda_verb alc861_threestack_init_verbs[] = {
  8211. /*
  8212. * Unmute ADC0 and set the default input to mic-in
  8213. */
  8214. /* port-A for surround (rear panel) */
  8215. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8216. /* port-B for mic-in (rear panel) with vref */
  8217. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8218. /* port-C for line-in (rear panel) */
  8219. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8220. /* port-D for Front */
  8221. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8222. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8223. /* port-E for HP out (front panel) */
  8224. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8225. /* route front PCM to HP */
  8226. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8227. /* port-F for mic-in (front panel) with vref */
  8228. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8229. /* port-G for CLFE (rear panel) */
  8230. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8231. /* port-H for side (rear panel) */
  8232. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8233. /* CD-in */
  8234. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8235. /* route front mic to ADC1*/
  8236. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8237. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8238. /* Unmute DAC0~3 & spdif out*/
  8239. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8240. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8241. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8242. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8243. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8244. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8245. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8246. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8247. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8248. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8249. /* Unmute Stereo Mixer 15 */
  8250. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8251. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8252. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8254. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8256. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8258. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8259. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8260. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8261. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8262. /* hp used DAC 3 (Front) */
  8263. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8265. { }
  8266. };
  8267. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8268. /*
  8269. * Unmute ADC0 and set the default input to mic-in
  8270. */
  8271. /* port-A for surround (rear panel) */
  8272. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8273. /* port-B for mic-in (rear panel) with vref */
  8274. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8275. /* port-C for line-in (rear panel) */
  8276. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8277. /* port-D for Front */
  8278. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8279. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8280. /* port-E for HP out (front panel) */
  8281. /* this has to be set to VREF80 */
  8282. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8283. /* route front PCM to HP */
  8284. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8285. /* port-F for mic-in (front panel) with vref */
  8286. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8287. /* port-G for CLFE (rear panel) */
  8288. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8289. /* port-H for side (rear panel) */
  8290. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8291. /* CD-in */
  8292. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8293. /* route front mic to ADC1*/
  8294. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8295. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8296. /* Unmute DAC0~3 & spdif out*/
  8297. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8298. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8299. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8300. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8301. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8302. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8303. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8304. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8305. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8306. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8307. /* Unmute Stereo Mixer 15 */
  8308. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8309. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8310. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8311. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8312. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8313. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8314. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8315. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8316. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8317. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8318. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8319. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8320. /* hp used DAC 3 (Front) */
  8321. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8322. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8323. { }
  8324. };
  8325. static struct hda_verb alc861_asus_init_verbs[] = {
  8326. /*
  8327. * Unmute ADC0 and set the default input to mic-in
  8328. */
  8329. /* port-A for surround (rear panel)
  8330. * according to codec#0 this is the HP jack
  8331. */
  8332. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8333. /* route front PCM to HP */
  8334. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8335. /* port-B for mic-in (rear panel) with vref */
  8336. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8337. /* port-C for line-in (rear panel) */
  8338. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8339. /* port-D for Front */
  8340. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8341. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8342. /* port-E for HP out (front panel) */
  8343. /* this has to be set to VREF80 */
  8344. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8345. /* route front PCM to HP */
  8346. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8347. /* port-F for mic-in (front panel) with vref */
  8348. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8349. /* port-G for CLFE (rear panel) */
  8350. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8351. /* port-H for side (rear panel) */
  8352. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8353. /* CD-in */
  8354. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8355. /* route front mic to ADC1*/
  8356. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8357. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8358. /* Unmute DAC0~3 & spdif out*/
  8359. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8360. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8361. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8362. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8363. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8364. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8365. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8366. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8367. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8368. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8369. /* Unmute Stereo Mixer 15 */
  8370. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8371. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8372. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8374. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8375. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8376. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8377. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8378. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8379. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8380. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8381. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8382. /* hp used DAC 3 (Front) */
  8383. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8384. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8385. { }
  8386. };
  8387. /* additional init verbs for ASUS laptops */
  8388. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8389. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8390. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8391. { }
  8392. };
  8393. /*
  8394. * generic initialization of ADC, input mixers and output mixers
  8395. */
  8396. static struct hda_verb alc861_auto_init_verbs[] = {
  8397. /*
  8398. * Unmute ADC0 and set the default input to mic-in
  8399. */
  8400. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8402. /* Unmute DAC0~3 & spdif out*/
  8403. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8404. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8405. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8406. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8407. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8408. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8409. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8410. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8411. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8412. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8413. /* Unmute Stereo Mixer 15 */
  8414. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8415. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8416. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8417. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8418. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8419. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8420. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8421. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8422. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8423. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8424. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8425. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8426. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8427. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8428. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8429. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8430. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8431. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8432. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8433. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8434. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8435. { }
  8436. };
  8437. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8438. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8439. { }
  8440. };
  8441. /* toggle speaker-output according to the hp-jack state */
  8442. static void alc861_toshiba_automute(struct hda_codec *codec)
  8443. {
  8444. unsigned int present;
  8445. present = snd_hda_codec_read(codec, 0x0f, 0,
  8446. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8447. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8448. 0x80, present ? 0x80 : 0);
  8449. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8450. 0x80, present ? 0x80 : 0);
  8451. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8452. 0x80, present ? 0 : 0x80);
  8453. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8454. 0x80, present ? 0 : 0x80);
  8455. }
  8456. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8457. unsigned int res)
  8458. {
  8459. if ((res >> 26) == ALC880_HP_EVENT)
  8460. alc861_toshiba_automute(codec);
  8461. }
  8462. /* pcm configuration: identiacal with ALC880 */
  8463. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8464. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8465. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8466. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8467. #define ALC861_DIGOUT_NID 0x07
  8468. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8469. { 8, NULL }
  8470. };
  8471. static hda_nid_t alc861_dac_nids[4] = {
  8472. /* front, surround, clfe, side */
  8473. 0x03, 0x06, 0x05, 0x04
  8474. };
  8475. static hda_nid_t alc660_dac_nids[3] = {
  8476. /* front, clfe, surround */
  8477. 0x03, 0x05, 0x06
  8478. };
  8479. static hda_nid_t alc861_adc_nids[1] = {
  8480. /* ADC0-2 */
  8481. 0x08,
  8482. };
  8483. static struct hda_input_mux alc861_capture_source = {
  8484. .num_items = 5,
  8485. .items = {
  8486. { "Mic", 0x0 },
  8487. { "Front Mic", 0x3 },
  8488. { "Line", 0x1 },
  8489. { "CD", 0x4 },
  8490. { "Mixer", 0x5 },
  8491. },
  8492. };
  8493. /* fill in the dac_nids table from the parsed pin configuration */
  8494. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8495. const struct auto_pin_cfg *cfg)
  8496. {
  8497. int i;
  8498. hda_nid_t nid;
  8499. spec->multiout.dac_nids = spec->private_dac_nids;
  8500. for (i = 0; i < cfg->line_outs; i++) {
  8501. nid = cfg->line_out_pins[i];
  8502. if (nid) {
  8503. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8504. continue;
  8505. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8506. }
  8507. }
  8508. spec->multiout.num_dacs = cfg->line_outs;
  8509. return 0;
  8510. }
  8511. /* add playback controls from the parsed DAC table */
  8512. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8513. const struct auto_pin_cfg *cfg)
  8514. {
  8515. char name[32];
  8516. static const char *chname[4] = {
  8517. "Front", "Surround", NULL /*CLFE*/, "Side"
  8518. };
  8519. hda_nid_t nid;
  8520. int i, idx, err;
  8521. for (i = 0; i < cfg->line_outs; i++) {
  8522. nid = spec->multiout.dac_nids[i];
  8523. if (!nid)
  8524. continue;
  8525. if (nid == 0x05) {
  8526. /* Center/LFE */
  8527. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8528. "Center Playback Switch",
  8529. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8530. HDA_OUTPUT));
  8531. if (err < 0)
  8532. return err;
  8533. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8534. "LFE Playback Switch",
  8535. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8536. HDA_OUTPUT));
  8537. if (err < 0)
  8538. return err;
  8539. } else {
  8540. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8541. idx++)
  8542. if (nid == alc861_dac_nids[idx])
  8543. break;
  8544. sprintf(name, "%s Playback Switch", chname[idx]);
  8545. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8546. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8547. HDA_OUTPUT));
  8548. if (err < 0)
  8549. return err;
  8550. }
  8551. }
  8552. return 0;
  8553. }
  8554. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8555. {
  8556. int err;
  8557. hda_nid_t nid;
  8558. if (!pin)
  8559. return 0;
  8560. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8561. nid = 0x03;
  8562. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8563. "Headphone Playback Switch",
  8564. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8565. if (err < 0)
  8566. return err;
  8567. spec->multiout.hp_nid = nid;
  8568. }
  8569. return 0;
  8570. }
  8571. /* create playback/capture controls for input pins */
  8572. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8573. const struct auto_pin_cfg *cfg)
  8574. {
  8575. struct hda_input_mux *imux = &spec->private_imux;
  8576. int i, err, idx, idx1;
  8577. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8578. switch (cfg->input_pins[i]) {
  8579. case 0x0c:
  8580. idx1 = 1;
  8581. idx = 2; /* Line In */
  8582. break;
  8583. case 0x0f:
  8584. idx1 = 2;
  8585. idx = 2; /* Line In */
  8586. break;
  8587. case 0x0d:
  8588. idx1 = 0;
  8589. idx = 1; /* Mic In */
  8590. break;
  8591. case 0x10:
  8592. idx1 = 3;
  8593. idx = 1; /* Mic In */
  8594. break;
  8595. case 0x11:
  8596. idx1 = 4;
  8597. idx = 0; /* CD */
  8598. break;
  8599. default:
  8600. continue;
  8601. }
  8602. err = new_analog_input(spec, cfg->input_pins[i],
  8603. auto_pin_cfg_labels[i], idx, 0x15);
  8604. if (err < 0)
  8605. return err;
  8606. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8607. imux->items[imux->num_items].index = idx1;
  8608. imux->num_items++;
  8609. }
  8610. return 0;
  8611. }
  8612. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8613. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8614. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8615. {
  8616. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8617. /* The multiple "Capture Source" controls confuse alsamixer
  8618. * So call somewhat different..
  8619. *FIXME: the controls appear in the "playback" view!
  8620. */
  8621. /* .name = "Capture Source", */
  8622. .name = "Input Source",
  8623. .count = 1,
  8624. .info = alc_mux_enum_info,
  8625. .get = alc_mux_enum_get,
  8626. .put = alc_mux_enum_put,
  8627. },
  8628. { } /* end */
  8629. };
  8630. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8631. hda_nid_t nid,
  8632. int pin_type, int dac_idx)
  8633. {
  8634. /* set as output */
  8635. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8636. pin_type);
  8637. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8638. AMP_OUT_UNMUTE);
  8639. }
  8640. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8641. {
  8642. struct alc_spec *spec = codec->spec;
  8643. int i;
  8644. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8645. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8646. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8647. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8648. if (nid)
  8649. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8650. spec->multiout.dac_nids[i]);
  8651. }
  8652. }
  8653. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8654. {
  8655. struct alc_spec *spec = codec->spec;
  8656. hda_nid_t pin;
  8657. pin = spec->autocfg.hp_pins[0];
  8658. if (pin) /* connect to front */
  8659. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8660. spec->multiout.dac_nids[0]);
  8661. }
  8662. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8663. {
  8664. struct alc_spec *spec = codec->spec;
  8665. int i;
  8666. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8667. hda_nid_t nid = spec->autocfg.input_pins[i];
  8668. if (nid >= 0x0c && nid <= 0x11) {
  8669. snd_hda_codec_write(codec, nid, 0,
  8670. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8671. i <= AUTO_PIN_FRONT_MIC ?
  8672. PIN_VREF80 : PIN_IN);
  8673. }
  8674. }
  8675. }
  8676. /* parse the BIOS configuration and set up the alc_spec */
  8677. /* return 1 if successful, 0 if the proper config is not found,
  8678. * or a negative error code
  8679. */
  8680. static int alc861_parse_auto_config(struct hda_codec *codec)
  8681. {
  8682. struct alc_spec *spec = codec->spec;
  8683. int err;
  8684. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8685. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8686. alc861_ignore);
  8687. if (err < 0)
  8688. return err;
  8689. if (!spec->autocfg.line_outs)
  8690. return 0; /* can't find valid BIOS pin config */
  8691. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8692. if (err < 0)
  8693. return err;
  8694. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8695. if (err < 0)
  8696. return err;
  8697. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8698. if (err < 0)
  8699. return err;
  8700. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8701. if (err < 0)
  8702. return err;
  8703. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8704. if (spec->autocfg.dig_out_pin)
  8705. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8706. if (spec->kctl_alloc)
  8707. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8708. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8709. spec->num_mux_defs = 1;
  8710. spec->input_mux = &spec->private_imux;
  8711. spec->adc_nids = alc861_adc_nids;
  8712. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8713. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8714. spec->num_mixers++;
  8715. return 1;
  8716. }
  8717. /* additional initialization for auto-configuration model */
  8718. static void alc861_auto_init(struct hda_codec *codec)
  8719. {
  8720. alc861_auto_init_multi_out(codec);
  8721. alc861_auto_init_hp_out(codec);
  8722. alc861_auto_init_analog_input(codec);
  8723. }
  8724. /*
  8725. * configuration and preset
  8726. */
  8727. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8728. [ALC861_3ST] = "3stack",
  8729. [ALC660_3ST] = "3stack-660",
  8730. [ALC861_3ST_DIG] = "3stack-dig",
  8731. [ALC861_6ST_DIG] = "6stack-dig",
  8732. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8733. [ALC861_TOSHIBA] = "toshiba",
  8734. [ALC861_ASUS] = "asus",
  8735. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8736. [ALC861_AUTO] = "auto",
  8737. };
  8738. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8739. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8740. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8741. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8742. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8743. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8744. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8745. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8746. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8747. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8748. * Any other models that need this preset?
  8749. */
  8750. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8751. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8752. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8753. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8754. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8755. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8756. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  8757. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  8758. {}
  8759. };
  8760. static struct alc_config_preset alc861_presets[] = {
  8761. [ALC861_3ST] = {
  8762. .mixers = { alc861_3ST_mixer },
  8763. .init_verbs = { alc861_threestack_init_verbs },
  8764. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8765. .dac_nids = alc861_dac_nids,
  8766. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8767. .channel_mode = alc861_threestack_modes,
  8768. .need_dac_fix = 1,
  8769. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8770. .adc_nids = alc861_adc_nids,
  8771. .input_mux = &alc861_capture_source,
  8772. },
  8773. [ALC861_3ST_DIG] = {
  8774. .mixers = { alc861_base_mixer },
  8775. .init_verbs = { alc861_threestack_init_verbs },
  8776. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8777. .dac_nids = alc861_dac_nids,
  8778. .dig_out_nid = ALC861_DIGOUT_NID,
  8779. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8780. .channel_mode = alc861_threestack_modes,
  8781. .need_dac_fix = 1,
  8782. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8783. .adc_nids = alc861_adc_nids,
  8784. .input_mux = &alc861_capture_source,
  8785. },
  8786. [ALC861_6ST_DIG] = {
  8787. .mixers = { alc861_base_mixer },
  8788. .init_verbs = { alc861_base_init_verbs },
  8789. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8790. .dac_nids = alc861_dac_nids,
  8791. .dig_out_nid = ALC861_DIGOUT_NID,
  8792. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8793. .channel_mode = alc861_8ch_modes,
  8794. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8795. .adc_nids = alc861_adc_nids,
  8796. .input_mux = &alc861_capture_source,
  8797. },
  8798. [ALC660_3ST] = {
  8799. .mixers = { alc861_3ST_mixer },
  8800. .init_verbs = { alc861_threestack_init_verbs },
  8801. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8802. .dac_nids = alc660_dac_nids,
  8803. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8804. .channel_mode = alc861_threestack_modes,
  8805. .need_dac_fix = 1,
  8806. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8807. .adc_nids = alc861_adc_nids,
  8808. .input_mux = &alc861_capture_source,
  8809. },
  8810. [ALC861_UNIWILL_M31] = {
  8811. .mixers = { alc861_uniwill_m31_mixer },
  8812. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8813. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8814. .dac_nids = alc861_dac_nids,
  8815. .dig_out_nid = ALC861_DIGOUT_NID,
  8816. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8817. .channel_mode = alc861_uniwill_m31_modes,
  8818. .need_dac_fix = 1,
  8819. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8820. .adc_nids = alc861_adc_nids,
  8821. .input_mux = &alc861_capture_source,
  8822. },
  8823. [ALC861_TOSHIBA] = {
  8824. .mixers = { alc861_toshiba_mixer },
  8825. .init_verbs = { alc861_base_init_verbs,
  8826. alc861_toshiba_init_verbs },
  8827. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8828. .dac_nids = alc861_dac_nids,
  8829. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8830. .channel_mode = alc883_3ST_2ch_modes,
  8831. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8832. .adc_nids = alc861_adc_nids,
  8833. .input_mux = &alc861_capture_source,
  8834. .unsol_event = alc861_toshiba_unsol_event,
  8835. .init_hook = alc861_toshiba_automute,
  8836. },
  8837. [ALC861_ASUS] = {
  8838. .mixers = { alc861_asus_mixer },
  8839. .init_verbs = { alc861_asus_init_verbs },
  8840. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8841. .dac_nids = alc861_dac_nids,
  8842. .dig_out_nid = ALC861_DIGOUT_NID,
  8843. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8844. .channel_mode = alc861_asus_modes,
  8845. .need_dac_fix = 1,
  8846. .hp_nid = 0x06,
  8847. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8848. .adc_nids = alc861_adc_nids,
  8849. .input_mux = &alc861_capture_source,
  8850. },
  8851. [ALC861_ASUS_LAPTOP] = {
  8852. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8853. .init_verbs = { alc861_asus_init_verbs,
  8854. alc861_asus_laptop_init_verbs },
  8855. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8856. .dac_nids = alc861_dac_nids,
  8857. .dig_out_nid = ALC861_DIGOUT_NID,
  8858. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8859. .channel_mode = alc883_3ST_2ch_modes,
  8860. .need_dac_fix = 1,
  8861. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8862. .adc_nids = alc861_adc_nids,
  8863. .input_mux = &alc861_capture_source,
  8864. },
  8865. };
  8866. static int patch_alc861(struct hda_codec *codec)
  8867. {
  8868. struct alc_spec *spec;
  8869. int board_config;
  8870. int err;
  8871. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8872. if (spec == NULL)
  8873. return -ENOMEM;
  8874. codec->spec = spec;
  8875. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8876. alc861_models,
  8877. alc861_cfg_tbl);
  8878. if (board_config < 0) {
  8879. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8880. "trying auto-probe from BIOS...\n");
  8881. board_config = ALC861_AUTO;
  8882. }
  8883. if (board_config == ALC861_AUTO) {
  8884. /* automatic parse from the BIOS config */
  8885. err = alc861_parse_auto_config(codec);
  8886. if (err < 0) {
  8887. alc_free(codec);
  8888. return err;
  8889. } else if (!err) {
  8890. printk(KERN_INFO
  8891. "hda_codec: Cannot set up configuration "
  8892. "from BIOS. Using base mode...\n");
  8893. board_config = ALC861_3ST_DIG;
  8894. }
  8895. }
  8896. if (board_config != ALC861_AUTO)
  8897. setup_preset(spec, &alc861_presets[board_config]);
  8898. spec->stream_name_analog = "ALC861 Analog";
  8899. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8900. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8901. spec->stream_name_digital = "ALC861 Digital";
  8902. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8903. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8904. codec->patch_ops = alc_patch_ops;
  8905. if (board_config == ALC861_AUTO)
  8906. spec->init_hook = alc861_auto_init;
  8907. return 0;
  8908. }
  8909. /*
  8910. * ALC861-VD support
  8911. *
  8912. * Based on ALC882
  8913. *
  8914. * In addition, an independent DAC
  8915. */
  8916. #define ALC861VD_DIGOUT_NID 0x06
  8917. static hda_nid_t alc861vd_dac_nids[4] = {
  8918. /* front, surr, clfe, side surr */
  8919. 0x02, 0x03, 0x04, 0x05
  8920. };
  8921. /* dac_nids for ALC660vd are in a different order - according to
  8922. * Realtek's driver.
  8923. * This should probably tesult in a different mixer for 6stack models
  8924. * of ALC660vd codecs, but for now there is only 3stack mixer
  8925. * - and it is the same as in 861vd.
  8926. * adc_nids in ALC660vd are (is) the same as in 861vd
  8927. */
  8928. static hda_nid_t alc660vd_dac_nids[3] = {
  8929. /* front, rear, clfe, rear_surr */
  8930. 0x02, 0x04, 0x03
  8931. };
  8932. static hda_nid_t alc861vd_adc_nids[1] = {
  8933. /* ADC0 */
  8934. 0x09,
  8935. };
  8936. /* input MUX */
  8937. /* FIXME: should be a matrix-type input source selection */
  8938. static struct hda_input_mux alc861vd_capture_source = {
  8939. .num_items = 4,
  8940. .items = {
  8941. { "Mic", 0x0 },
  8942. { "Front Mic", 0x1 },
  8943. { "Line", 0x2 },
  8944. { "CD", 0x4 },
  8945. },
  8946. };
  8947. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8948. .num_items = 3,
  8949. .items = {
  8950. { "Front Mic", 0x0 },
  8951. { "ATAPI Mic", 0x1 },
  8952. { "Line In", 0x5 },
  8953. },
  8954. };
  8955. #define alc861vd_mux_enum_info alc_mux_enum_info
  8956. #define alc861vd_mux_enum_get alc_mux_enum_get
  8957. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8958. struct snd_ctl_elem_value *ucontrol)
  8959. {
  8960. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8961. struct alc_spec *spec = codec->spec;
  8962. const struct hda_input_mux *imux = spec->input_mux;
  8963. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8964. static hda_nid_t capture_mixers[1] = { 0x22 };
  8965. hda_nid_t nid = capture_mixers[adc_idx];
  8966. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8967. unsigned int i, idx;
  8968. idx = ucontrol->value.enumerated.item[0];
  8969. if (idx >= imux->num_items)
  8970. idx = imux->num_items - 1;
  8971. if (*cur_val == idx && !codec->in_resume)
  8972. return 0;
  8973. for (i = 0; i < imux->num_items; i++) {
  8974. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8975. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8976. v | (imux->items[i].index << 8));
  8977. }
  8978. *cur_val = idx;
  8979. return 1;
  8980. }
  8981. /*
  8982. * 2ch mode
  8983. */
  8984. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8985. { 2, NULL }
  8986. };
  8987. /*
  8988. * 6ch mode
  8989. */
  8990. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8991. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8992. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8993. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8994. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8995. { } /* end */
  8996. };
  8997. /*
  8998. * 8ch mode
  8999. */
  9000. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9001. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9002. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9003. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9004. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9005. { } /* end */
  9006. };
  9007. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9008. { 6, alc861vd_6stack_ch6_init },
  9009. { 8, alc861vd_6stack_ch8_init },
  9010. };
  9011. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9012. {
  9013. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9014. .name = "Channel Mode",
  9015. .info = alc_ch_mode_info,
  9016. .get = alc_ch_mode_get,
  9017. .put = alc_ch_mode_put,
  9018. },
  9019. { } /* end */
  9020. };
  9021. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9022. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9023. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9024. {
  9025. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9026. /* The multiple "Capture Source" controls confuse alsamixer
  9027. * So call somewhat different..
  9028. *FIXME: the controls appear in the "playback" view!
  9029. */
  9030. /* .name = "Capture Source", */
  9031. .name = "Input Source",
  9032. .count = 1,
  9033. .info = alc861vd_mux_enum_info,
  9034. .get = alc861vd_mux_enum_get,
  9035. .put = alc861vd_mux_enum_put,
  9036. },
  9037. { } /* end */
  9038. };
  9039. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9040. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9041. */
  9042. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9043. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9044. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9045. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9046. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9047. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9048. HDA_OUTPUT),
  9049. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9050. HDA_OUTPUT),
  9051. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9052. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9053. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9054. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9055. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9056. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9057. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9058. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9059. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9060. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9061. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9062. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9063. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9064. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9065. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9066. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9067. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9068. { } /* end */
  9069. };
  9070. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9071. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9072. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9073. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9074. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9075. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9076. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9077. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9078. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9079. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9080. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9081. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9082. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9083. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9084. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9085. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9086. { } /* end */
  9087. };
  9088. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9089. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9090. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9091. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9092. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9093. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9094. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9095. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9096. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9097. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9098. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9099. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9100. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9101. { } /* end */
  9102. };
  9103. /* Pin assignment: Front=0x14, HP = 0x15,
  9104. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9105. */
  9106. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9107. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9108. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9109. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9110. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9111. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9112. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9113. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9114. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9115. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9116. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9117. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9118. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9119. {
  9120. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9121. /* .name = "Capture Source", */
  9122. .name = "Input Source",
  9123. .count = 1,
  9124. .info = alc882_mux_enum_info,
  9125. .get = alc882_mux_enum_get,
  9126. .put = alc882_mux_enum_put,
  9127. },
  9128. { } /* end */
  9129. };
  9130. /*
  9131. * generic initialization of ADC, input mixers and output mixers
  9132. */
  9133. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9134. /*
  9135. * Unmute ADC0 and set the default input to mic-in
  9136. */
  9137. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9138. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9139. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9140. * the analog-loopback mixer widget
  9141. */
  9142. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9143. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9148. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9149. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9150. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9151. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9152. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9153. /*
  9154. * Set up output mixers (0x02 - 0x05)
  9155. */
  9156. /* set vol=0 to output mixers */
  9157. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9158. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9159. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9160. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9161. /* set up input amps for analog loopback */
  9162. /* Amp Indices: DAC = 0, mixer = 1 */
  9163. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9165. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9166. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9167. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9168. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9169. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9170. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9171. { }
  9172. };
  9173. /*
  9174. * 3-stack pin configuration:
  9175. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9176. */
  9177. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9178. /*
  9179. * Set pin mode and muting
  9180. */
  9181. /* set front pin widgets 0x14 for output */
  9182. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9183. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9184. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9185. /* Mic (rear) pin: input vref at 80% */
  9186. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9187. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9188. /* Front Mic pin: input vref at 80% */
  9189. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9190. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9191. /* Line In pin: input */
  9192. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9193. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9194. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9195. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9196. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9197. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9198. /* CD pin widget for input */
  9199. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9200. { }
  9201. };
  9202. /*
  9203. * 6-stack pin configuration:
  9204. */
  9205. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9206. /*
  9207. * Set pin mode and muting
  9208. */
  9209. /* set front pin widgets 0x14 for output */
  9210. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9211. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9212. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9213. /* Rear Pin: output 1 (0x0d) */
  9214. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9215. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9216. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9217. /* CLFE Pin: output 2 (0x0e) */
  9218. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9219. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9220. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9221. /* Side Pin: output 3 (0x0f) */
  9222. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9223. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9224. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9225. /* Mic (rear) pin: input vref at 80% */
  9226. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9227. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9228. /* Front Mic pin: input vref at 80% */
  9229. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9230. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9231. /* Line In pin: input */
  9232. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9233. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9234. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9235. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9236. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9237. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9238. /* CD pin widget for input */
  9239. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9240. { }
  9241. };
  9242. static struct hda_verb alc861vd_eapd_verbs[] = {
  9243. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9244. { }
  9245. };
  9246. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9247. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9248. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9249. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9250. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9251. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9252. {}
  9253. };
  9254. /* toggle speaker-output according to the hp-jack state */
  9255. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9256. {
  9257. unsigned int present;
  9258. unsigned char bits;
  9259. present = snd_hda_codec_read(codec, 0x1b, 0,
  9260. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9261. bits = present ? 0x80 : 0;
  9262. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9263. 0x80, bits);
  9264. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9265. 0x80, bits);
  9266. }
  9267. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9268. {
  9269. unsigned int present;
  9270. unsigned char bits;
  9271. present = snd_hda_codec_read(codec, 0x18, 0,
  9272. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9273. bits = present ? 0x80 : 0;
  9274. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9275. 0x80, bits);
  9276. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9277. 0x80, bits);
  9278. }
  9279. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9280. {
  9281. alc861vd_lenovo_hp_automute(codec);
  9282. alc861vd_lenovo_mic_automute(codec);
  9283. }
  9284. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9285. unsigned int res)
  9286. {
  9287. switch (res >> 26) {
  9288. case ALC880_HP_EVENT:
  9289. alc861vd_lenovo_hp_automute(codec);
  9290. break;
  9291. case ALC880_MIC_EVENT:
  9292. alc861vd_lenovo_mic_automute(codec);
  9293. break;
  9294. }
  9295. }
  9296. static struct hda_verb alc861vd_dallas_verbs[] = {
  9297. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9298. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9299. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9300. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9301. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9302. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9303. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9304. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9305. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9306. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9307. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9308. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9309. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9310. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9313. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9314. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9315. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9316. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9317. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9318. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9319. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9320. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9321. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9322. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9323. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9324. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9325. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9326. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9327. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9328. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9329. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9330. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9331. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9332. { } /* end */
  9333. };
  9334. /* toggle speaker-output according to the hp-jack state */
  9335. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9336. {
  9337. unsigned int present;
  9338. present = snd_hda_codec_read(codec, 0x15, 0,
  9339. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9340. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9341. 0x80, present ? 0x80 : 0);
  9342. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9343. 0x80, present ? 0x80 : 0);
  9344. }
  9345. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9346. {
  9347. if ((res >> 26) == ALC880_HP_EVENT)
  9348. alc861vd_dallas_automute(codec);
  9349. }
  9350. /* pcm configuration: identiacal with ALC880 */
  9351. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9352. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9353. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9354. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9355. /*
  9356. * configuration and preset
  9357. */
  9358. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9359. [ALC660VD_3ST] = "3stack-660",
  9360. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9361. [ALC861VD_3ST] = "3stack",
  9362. [ALC861VD_3ST_DIG] = "3stack-digout",
  9363. [ALC861VD_6ST_DIG] = "6stack-digout",
  9364. [ALC861VD_LENOVO] = "lenovo",
  9365. [ALC861VD_DALLAS] = "dallas",
  9366. [ALC861VD_AUTO] = "auto",
  9367. };
  9368. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9369. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9370. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9371. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9372. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9373. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9374. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9375. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9376. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9377. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9378. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9379. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9380. {}
  9381. };
  9382. static struct alc_config_preset alc861vd_presets[] = {
  9383. [ALC660VD_3ST] = {
  9384. .mixers = { alc861vd_3st_mixer },
  9385. .init_verbs = { alc861vd_volume_init_verbs,
  9386. alc861vd_3stack_init_verbs },
  9387. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9388. .dac_nids = alc660vd_dac_nids,
  9389. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9390. .adc_nids = alc861vd_adc_nids,
  9391. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9392. .channel_mode = alc861vd_3stack_2ch_modes,
  9393. .input_mux = &alc861vd_capture_source,
  9394. },
  9395. [ALC660VD_3ST_DIG] = {
  9396. .mixers = { alc861vd_3st_mixer },
  9397. .init_verbs = { alc861vd_volume_init_verbs,
  9398. alc861vd_3stack_init_verbs },
  9399. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9400. .dac_nids = alc660vd_dac_nids,
  9401. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9402. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9403. .adc_nids = alc861vd_adc_nids,
  9404. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9405. .channel_mode = alc861vd_3stack_2ch_modes,
  9406. .input_mux = &alc861vd_capture_source,
  9407. },
  9408. [ALC861VD_3ST] = {
  9409. .mixers = { alc861vd_3st_mixer },
  9410. .init_verbs = { alc861vd_volume_init_verbs,
  9411. alc861vd_3stack_init_verbs },
  9412. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9413. .dac_nids = alc861vd_dac_nids,
  9414. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9415. .channel_mode = alc861vd_3stack_2ch_modes,
  9416. .input_mux = &alc861vd_capture_source,
  9417. },
  9418. [ALC861VD_3ST_DIG] = {
  9419. .mixers = { alc861vd_3st_mixer },
  9420. .init_verbs = { alc861vd_volume_init_verbs,
  9421. alc861vd_3stack_init_verbs },
  9422. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9423. .dac_nids = alc861vd_dac_nids,
  9424. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9425. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9426. .channel_mode = alc861vd_3stack_2ch_modes,
  9427. .input_mux = &alc861vd_capture_source,
  9428. },
  9429. [ALC861VD_6ST_DIG] = {
  9430. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9431. .init_verbs = { alc861vd_volume_init_verbs,
  9432. alc861vd_6stack_init_verbs },
  9433. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9434. .dac_nids = alc861vd_dac_nids,
  9435. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9436. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9437. .channel_mode = alc861vd_6stack_modes,
  9438. .input_mux = &alc861vd_capture_source,
  9439. },
  9440. [ALC861VD_LENOVO] = {
  9441. .mixers = { alc861vd_lenovo_mixer },
  9442. .init_verbs = { alc861vd_volume_init_verbs,
  9443. alc861vd_3stack_init_verbs,
  9444. alc861vd_eapd_verbs,
  9445. alc861vd_lenovo_unsol_verbs },
  9446. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9447. .dac_nids = alc660vd_dac_nids,
  9448. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9449. .adc_nids = alc861vd_adc_nids,
  9450. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9451. .channel_mode = alc861vd_3stack_2ch_modes,
  9452. .input_mux = &alc861vd_capture_source,
  9453. .unsol_event = alc861vd_lenovo_unsol_event,
  9454. .init_hook = alc861vd_lenovo_automute,
  9455. },
  9456. [ALC861VD_DALLAS] = {
  9457. .mixers = { alc861vd_dallas_mixer },
  9458. .init_verbs = { alc861vd_dallas_verbs },
  9459. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9460. .dac_nids = alc861vd_dac_nids,
  9461. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9462. .adc_nids = alc861vd_adc_nids,
  9463. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9464. .channel_mode = alc861vd_3stack_2ch_modes,
  9465. .input_mux = &alc861vd_dallas_capture_source,
  9466. .unsol_event = alc861vd_dallas_unsol_event,
  9467. .init_hook = alc861vd_dallas_automute,
  9468. },
  9469. };
  9470. /*
  9471. * BIOS auto configuration
  9472. */
  9473. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9474. hda_nid_t nid, int pin_type, int dac_idx)
  9475. {
  9476. /* set as output */
  9477. snd_hda_codec_write(codec, nid, 0,
  9478. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9479. snd_hda_codec_write(codec, nid, 0,
  9480. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9481. }
  9482. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9483. {
  9484. struct alc_spec *spec = codec->spec;
  9485. int i;
  9486. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9487. for (i = 0; i <= HDA_SIDE; i++) {
  9488. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9489. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9490. if (nid)
  9491. alc861vd_auto_set_output_and_unmute(codec, nid,
  9492. pin_type, i);
  9493. }
  9494. }
  9495. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9496. {
  9497. struct alc_spec *spec = codec->spec;
  9498. hda_nid_t pin;
  9499. pin = spec->autocfg.hp_pins[0];
  9500. if (pin) /* connect to front and use dac 0 */
  9501. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9502. }
  9503. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9504. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9505. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9506. {
  9507. struct alc_spec *spec = codec->spec;
  9508. int i;
  9509. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9510. hda_nid_t nid = spec->autocfg.input_pins[i];
  9511. if (alc861vd_is_input_pin(nid)) {
  9512. snd_hda_codec_write(codec, nid, 0,
  9513. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9514. i <= AUTO_PIN_FRONT_MIC ?
  9515. PIN_VREF80 : PIN_IN);
  9516. if (nid != ALC861VD_PIN_CD_NID)
  9517. snd_hda_codec_write(codec, nid, 0,
  9518. AC_VERB_SET_AMP_GAIN_MUTE,
  9519. AMP_OUT_MUTE);
  9520. }
  9521. }
  9522. }
  9523. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9524. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9525. /* add playback controls from the parsed DAC table */
  9526. /* Based on ALC880 version. But ALC861VD has separate,
  9527. * different NIDs for mute/unmute switch and volume control */
  9528. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9529. const struct auto_pin_cfg *cfg)
  9530. {
  9531. char name[32];
  9532. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9533. hda_nid_t nid_v, nid_s;
  9534. int i, err;
  9535. for (i = 0; i < cfg->line_outs; i++) {
  9536. if (!spec->multiout.dac_nids[i])
  9537. continue;
  9538. nid_v = alc861vd_idx_to_mixer_vol(
  9539. alc880_dac_to_idx(
  9540. spec->multiout.dac_nids[i]));
  9541. nid_s = alc861vd_idx_to_mixer_switch(
  9542. alc880_dac_to_idx(
  9543. spec->multiout.dac_nids[i]));
  9544. if (i == 2) {
  9545. /* Center/LFE */
  9546. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9547. "Center Playback Volume",
  9548. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9549. HDA_OUTPUT));
  9550. if (err < 0)
  9551. return err;
  9552. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9553. "LFE Playback Volume",
  9554. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9555. HDA_OUTPUT));
  9556. if (err < 0)
  9557. return err;
  9558. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9559. "Center Playback Switch",
  9560. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9561. HDA_INPUT));
  9562. if (err < 0)
  9563. return err;
  9564. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9565. "LFE Playback Switch",
  9566. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9567. HDA_INPUT));
  9568. if (err < 0)
  9569. return err;
  9570. } else {
  9571. sprintf(name, "%s Playback Volume", chname[i]);
  9572. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9573. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9574. HDA_OUTPUT));
  9575. if (err < 0)
  9576. return err;
  9577. sprintf(name, "%s Playback Switch", chname[i]);
  9578. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9579. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9580. HDA_INPUT));
  9581. if (err < 0)
  9582. return err;
  9583. }
  9584. }
  9585. return 0;
  9586. }
  9587. /* add playback controls for speaker and HP outputs */
  9588. /* Based on ALC880 version. But ALC861VD has separate,
  9589. * different NIDs for mute/unmute switch and volume control */
  9590. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9591. hda_nid_t pin, const char *pfx)
  9592. {
  9593. hda_nid_t nid_v, nid_s;
  9594. int err;
  9595. char name[32];
  9596. if (!pin)
  9597. return 0;
  9598. if (alc880_is_fixed_pin(pin)) {
  9599. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9600. /* specify the DAC as the extra output */
  9601. if (!spec->multiout.hp_nid)
  9602. spec->multiout.hp_nid = nid_v;
  9603. else
  9604. spec->multiout.extra_out_nid[0] = nid_v;
  9605. /* control HP volume/switch on the output mixer amp */
  9606. nid_v = alc861vd_idx_to_mixer_vol(
  9607. alc880_fixed_pin_idx(pin));
  9608. nid_s = alc861vd_idx_to_mixer_switch(
  9609. alc880_fixed_pin_idx(pin));
  9610. sprintf(name, "%s Playback Volume", pfx);
  9611. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9612. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9613. if (err < 0)
  9614. return err;
  9615. sprintf(name, "%s Playback Switch", pfx);
  9616. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9617. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9618. if (err < 0)
  9619. return err;
  9620. } else if (alc880_is_multi_pin(pin)) {
  9621. /* set manual connection */
  9622. /* we have only a switch on HP-out PIN */
  9623. sprintf(name, "%s Playback Switch", pfx);
  9624. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9625. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9626. if (err < 0)
  9627. return err;
  9628. }
  9629. return 0;
  9630. }
  9631. /* parse the BIOS configuration and set up the alc_spec
  9632. * return 1 if successful, 0 if the proper config is not found,
  9633. * or a negative error code
  9634. * Based on ALC880 version - had to change it to override
  9635. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9636. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9637. {
  9638. struct alc_spec *spec = codec->spec;
  9639. int err;
  9640. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9641. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9642. alc861vd_ignore);
  9643. if (err < 0)
  9644. return err;
  9645. if (!spec->autocfg.line_outs)
  9646. return 0; /* can't find valid BIOS pin config */
  9647. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9648. if (err < 0)
  9649. return err;
  9650. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9651. if (err < 0)
  9652. return err;
  9653. err = alc861vd_auto_create_extra_out(spec,
  9654. spec->autocfg.speaker_pins[0],
  9655. "Speaker");
  9656. if (err < 0)
  9657. return err;
  9658. err = alc861vd_auto_create_extra_out(spec,
  9659. spec->autocfg.hp_pins[0],
  9660. "Headphone");
  9661. if (err < 0)
  9662. return err;
  9663. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9664. if (err < 0)
  9665. return err;
  9666. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9667. if (spec->autocfg.dig_out_pin)
  9668. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9669. if (spec->kctl_alloc)
  9670. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9671. spec->init_verbs[spec->num_init_verbs++]
  9672. = alc861vd_volume_init_verbs;
  9673. spec->num_mux_defs = 1;
  9674. spec->input_mux = &spec->private_imux;
  9675. return 1;
  9676. }
  9677. /* additional initialization for auto-configuration model */
  9678. static void alc861vd_auto_init(struct hda_codec *codec)
  9679. {
  9680. alc861vd_auto_init_multi_out(codec);
  9681. alc861vd_auto_init_hp_out(codec);
  9682. alc861vd_auto_init_analog_input(codec);
  9683. }
  9684. static int patch_alc861vd(struct hda_codec *codec)
  9685. {
  9686. struct alc_spec *spec;
  9687. int err, board_config;
  9688. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9689. if (spec == NULL)
  9690. return -ENOMEM;
  9691. codec->spec = spec;
  9692. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9693. alc861vd_models,
  9694. alc861vd_cfg_tbl);
  9695. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9696. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9697. "ALC861VD, trying auto-probe from BIOS...\n");
  9698. board_config = ALC861VD_AUTO;
  9699. }
  9700. if (board_config == ALC861VD_AUTO) {
  9701. /* automatic parse from the BIOS config */
  9702. err = alc861vd_parse_auto_config(codec);
  9703. if (err < 0) {
  9704. alc_free(codec);
  9705. return err;
  9706. } else if (!err) {
  9707. printk(KERN_INFO
  9708. "hda_codec: Cannot set up configuration "
  9709. "from BIOS. Using base mode...\n");
  9710. board_config = ALC861VD_3ST;
  9711. }
  9712. }
  9713. if (board_config != ALC861VD_AUTO)
  9714. setup_preset(spec, &alc861vd_presets[board_config]);
  9715. spec->stream_name_analog = "ALC861VD Analog";
  9716. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9717. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9718. spec->stream_name_digital = "ALC861VD Digital";
  9719. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9720. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9721. spec->adc_nids = alc861vd_adc_nids;
  9722. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9723. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9724. spec->num_mixers++;
  9725. codec->patch_ops = alc_patch_ops;
  9726. if (board_config == ALC861VD_AUTO)
  9727. spec->init_hook = alc861vd_auto_init;
  9728. return 0;
  9729. }
  9730. /*
  9731. * ALC662 support
  9732. *
  9733. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9734. * configuration. Each pin widget can choose any input DACs and a mixer.
  9735. * Each ADC is connected from a mixer of all inputs. This makes possible
  9736. * 6-channel independent captures.
  9737. *
  9738. * In addition, an independent DAC for the multi-playback (not used in this
  9739. * driver yet).
  9740. */
  9741. #define ALC662_DIGOUT_NID 0x06
  9742. #define ALC662_DIGIN_NID 0x0a
  9743. static hda_nid_t alc662_dac_nids[4] = {
  9744. /* front, rear, clfe, rear_surr */
  9745. 0x02, 0x03, 0x04
  9746. };
  9747. static hda_nid_t alc662_adc_nids[1] = {
  9748. /* ADC1-2 */
  9749. 0x09,
  9750. };
  9751. /* input MUX */
  9752. /* FIXME: should be a matrix-type input source selection */
  9753. static struct hda_input_mux alc662_capture_source = {
  9754. .num_items = 4,
  9755. .items = {
  9756. { "Mic", 0x0 },
  9757. { "Front Mic", 0x1 },
  9758. { "Line", 0x2 },
  9759. { "CD", 0x4 },
  9760. },
  9761. };
  9762. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9763. .num_items = 2,
  9764. .items = {
  9765. { "Mic", 0x1 },
  9766. { "Line", 0x2 },
  9767. },
  9768. };
  9769. #define alc662_mux_enum_info alc_mux_enum_info
  9770. #define alc662_mux_enum_get alc_mux_enum_get
  9771. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9772. struct snd_ctl_elem_value *ucontrol)
  9773. {
  9774. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9775. struct alc_spec *spec = codec->spec;
  9776. const struct hda_input_mux *imux = spec->input_mux;
  9777. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9778. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9779. hda_nid_t nid = capture_mixers[adc_idx];
  9780. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9781. unsigned int i, idx;
  9782. idx = ucontrol->value.enumerated.item[0];
  9783. if (idx >= imux->num_items)
  9784. idx = imux->num_items - 1;
  9785. if (*cur_val == idx && !codec->in_resume)
  9786. return 0;
  9787. for (i = 0; i < imux->num_items; i++) {
  9788. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9789. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9790. v | (imux->items[i].index << 8));
  9791. }
  9792. *cur_val = idx;
  9793. return 1;
  9794. }
  9795. /*
  9796. * 2ch mode
  9797. */
  9798. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9799. { 2, NULL }
  9800. };
  9801. /*
  9802. * 2ch mode
  9803. */
  9804. static struct hda_verb alc662_3ST_ch2_init[] = {
  9805. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9806. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9807. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9808. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9809. { } /* end */
  9810. };
  9811. /*
  9812. * 6ch mode
  9813. */
  9814. static struct hda_verb alc662_3ST_ch6_init[] = {
  9815. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9816. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9817. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9818. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9819. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9820. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9821. { } /* end */
  9822. };
  9823. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9824. { 2, alc662_3ST_ch2_init },
  9825. { 6, alc662_3ST_ch6_init },
  9826. };
  9827. /*
  9828. * 2ch mode
  9829. */
  9830. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9831. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9832. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9833. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9834. { } /* end */
  9835. };
  9836. /*
  9837. * 6ch mode
  9838. */
  9839. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9840. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9841. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9842. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9843. { } /* end */
  9844. };
  9845. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9846. { 2, alc662_sixstack_ch6_init },
  9847. { 6, alc662_sixstack_ch8_init },
  9848. };
  9849. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9850. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9851. */
  9852. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9853. /* output mixer control */
  9854. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9855. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9856. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9857. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9858. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9859. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9860. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9861. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9862. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9863. /*Input mixer control */
  9864. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9865. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9866. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9867. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9868. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9869. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9870. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9871. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9872. /* Capture mixer control */
  9873. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9874. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9875. {
  9876. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9877. .name = "Capture Source",
  9878. .count = 1,
  9879. .info = alc_mux_enum_info,
  9880. .get = alc_mux_enum_get,
  9881. .put = alc_mux_enum_put,
  9882. },
  9883. { } /* end */
  9884. };
  9885. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9886. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9887. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9888. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9889. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9890. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9891. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9892. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9893. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9894. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9895. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9896. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9897. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9898. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9899. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9900. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9901. {
  9902. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9903. /* .name = "Capture Source", */
  9904. .name = "Input Source",
  9905. .count = 1,
  9906. .info = alc662_mux_enum_info,
  9907. .get = alc662_mux_enum_get,
  9908. .put = alc662_mux_enum_put,
  9909. },
  9910. { } /* end */
  9911. };
  9912. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9913. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9914. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9915. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9916. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9917. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9918. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9919. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9920. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9921. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9922. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9923. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9924. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9925. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9926. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9927. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9928. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9929. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9930. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9931. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9932. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9933. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9934. {
  9935. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9936. /* .name = "Capture Source", */
  9937. .name = "Input Source",
  9938. .count = 1,
  9939. .info = alc662_mux_enum_info,
  9940. .get = alc662_mux_enum_get,
  9941. .put = alc662_mux_enum_put,
  9942. },
  9943. { } /* end */
  9944. };
  9945. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9946. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9947. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9948. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9949. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9950. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9951. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9952. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9953. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9954. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9955. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9956. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9957. {
  9958. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9959. /* .name = "Capture Source", */
  9960. .name = "Input Source",
  9961. .count = 1,
  9962. .info = alc662_mux_enum_info,
  9963. .get = alc662_mux_enum_get,
  9964. .put = alc662_mux_enum_put,
  9965. },
  9966. { } /* end */
  9967. };
  9968. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9969. {
  9970. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9971. .name = "Channel Mode",
  9972. .info = alc_ch_mode_info,
  9973. .get = alc_ch_mode_get,
  9974. .put = alc_ch_mode_put,
  9975. },
  9976. { } /* end */
  9977. };
  9978. static struct hda_verb alc662_init_verbs[] = {
  9979. /* ADC: mute amp left and right */
  9980. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9981. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9982. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9985. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9986. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9987. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9988. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9989. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9990. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9991. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9992. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9993. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9994. /* Front Pin: output 0 (0x0c) */
  9995. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9996. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9997. /* Rear Pin: output 1 (0x0d) */
  9998. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9999. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10000. /* CLFE Pin: output 2 (0x0e) */
  10001. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10002. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10003. /* Mic (rear) pin: input vref at 80% */
  10004. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10005. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10006. /* Front Mic pin: input vref at 80% */
  10007. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10008. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10009. /* Line In pin: input */
  10010. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10011. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10012. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10013. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10014. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10015. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10016. /* CD pin widget for input */
  10017. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10018. /* FIXME: use matrix-type input source selection */
  10019. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10020. /* Input mixer */
  10021. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10022. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10023. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10024. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10025. { }
  10026. };
  10027. static struct hda_verb alc662_sue_init_verbs[] = {
  10028. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10029. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10030. {}
  10031. };
  10032. /*
  10033. * generic initialization of ADC, input mixers and output mixers
  10034. */
  10035. static struct hda_verb alc662_auto_init_verbs[] = {
  10036. /*
  10037. * Unmute ADC and set the default input to mic-in
  10038. */
  10039. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10040. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10041. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10042. * mixer widget
  10043. * Note: PASD motherboards uses the Line In 2 as the input for front
  10044. * panel mic (mic 2)
  10045. */
  10046. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10047. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10048. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10049. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10050. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  10051. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10052. /*
  10053. * Set up output mixers (0x0c - 0x0f)
  10054. */
  10055. /* set vol=0 to output mixers */
  10056. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10057. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10058. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10059. /* set up input amps for analog loopback */
  10060. /* Amp Indices: DAC = 0, mixer = 1 */
  10061. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10062. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10063. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10064. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10065. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10066. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10067. /* FIXME: use matrix-type input source selection */
  10068. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10069. /* Input mixer */
  10070. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10071. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10072. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10073. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  10074. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10075. { }
  10076. };
  10077. /* capture mixer elements */
  10078. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10079. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10080. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10081. {
  10082. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10083. /* The multiple "Capture Source" controls confuse alsamixer
  10084. * So call somewhat different..
  10085. * FIXME: the controls appear in the "playback" view!
  10086. */
  10087. /* .name = "Capture Source", */
  10088. .name = "Input Source",
  10089. .count = 1,
  10090. .info = alc882_mux_enum_info,
  10091. .get = alc882_mux_enum_get,
  10092. .put = alc882_mux_enum_put,
  10093. },
  10094. { } /* end */
  10095. };
  10096. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10097. {
  10098. unsigned int present;
  10099. unsigned char bits;
  10100. present = snd_hda_codec_read(codec, 0x14, 0,
  10101. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10102. bits = present ? 0x80 : 0;
  10103. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10104. 0x80, bits);
  10105. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10106. 0x80, bits);
  10107. }
  10108. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10109. {
  10110. unsigned int present;
  10111. unsigned char bits;
  10112. present = snd_hda_codec_read(codec, 0x1b, 0,
  10113. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10114. bits = present ? 0x80 : 0;
  10115. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10116. 0x80, bits);
  10117. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10118. 0x80, bits);
  10119. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10120. 0x80, bits);
  10121. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10122. 0x80, bits);
  10123. }
  10124. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10125. unsigned int res)
  10126. {
  10127. if ((res >> 26) == ALC880_HP_EVENT)
  10128. alc662_lenovo_101e_all_automute(codec);
  10129. if ((res >> 26) == ALC880_FRONT_EVENT)
  10130. alc662_lenovo_101e_ispeaker_automute(codec);
  10131. }
  10132. /* pcm configuration: identiacal with ALC880 */
  10133. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10134. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10135. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10136. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10137. /*
  10138. * configuration and preset
  10139. */
  10140. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10141. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10142. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10143. [ALC662_3ST_6ch] = "3stack-6ch",
  10144. [ALC662_5ST_DIG] = "6stack-dig",
  10145. [ALC662_LENOVO_101E] = "lenovo-101e",
  10146. [ALC662_AUTO] = "auto",
  10147. };
  10148. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10149. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10150. {}
  10151. };
  10152. static struct alc_config_preset alc662_presets[] = {
  10153. [ALC662_3ST_2ch_DIG] = {
  10154. .mixers = { alc662_3ST_2ch_mixer },
  10155. .init_verbs = { alc662_init_verbs },
  10156. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10157. .dac_nids = alc662_dac_nids,
  10158. .dig_out_nid = ALC662_DIGOUT_NID,
  10159. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10160. .adc_nids = alc662_adc_nids,
  10161. .dig_in_nid = ALC662_DIGIN_NID,
  10162. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10163. .channel_mode = alc662_3ST_2ch_modes,
  10164. .input_mux = &alc662_capture_source,
  10165. },
  10166. [ALC662_3ST_6ch_DIG] = {
  10167. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10168. .init_verbs = { alc662_init_verbs },
  10169. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10170. .dac_nids = alc662_dac_nids,
  10171. .dig_out_nid = ALC662_DIGOUT_NID,
  10172. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10173. .adc_nids = alc662_adc_nids,
  10174. .dig_in_nid = ALC662_DIGIN_NID,
  10175. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10176. .channel_mode = alc662_3ST_6ch_modes,
  10177. .need_dac_fix = 1,
  10178. .input_mux = &alc662_capture_source,
  10179. },
  10180. [ALC662_3ST_6ch] = {
  10181. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10182. .init_verbs = { alc662_init_verbs },
  10183. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10184. .dac_nids = alc662_dac_nids,
  10185. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10186. .adc_nids = alc662_adc_nids,
  10187. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10188. .channel_mode = alc662_3ST_6ch_modes,
  10189. .need_dac_fix = 1,
  10190. .input_mux = &alc662_capture_source,
  10191. },
  10192. [ALC662_5ST_DIG] = {
  10193. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10194. .init_verbs = { alc662_init_verbs },
  10195. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10196. .dac_nids = alc662_dac_nids,
  10197. .dig_out_nid = ALC662_DIGOUT_NID,
  10198. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10199. .adc_nids = alc662_adc_nids,
  10200. .dig_in_nid = ALC662_DIGIN_NID,
  10201. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10202. .channel_mode = alc662_5stack_modes,
  10203. .input_mux = &alc662_capture_source,
  10204. },
  10205. [ALC662_LENOVO_101E] = {
  10206. .mixers = { alc662_lenovo_101e_mixer },
  10207. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10208. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10209. .dac_nids = alc662_dac_nids,
  10210. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10211. .adc_nids = alc662_adc_nids,
  10212. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10213. .channel_mode = alc662_3ST_2ch_modes,
  10214. .input_mux = &alc662_lenovo_101e_capture_source,
  10215. .unsol_event = alc662_lenovo_101e_unsol_event,
  10216. .init_hook = alc662_lenovo_101e_all_automute,
  10217. },
  10218. };
  10219. /*
  10220. * BIOS auto configuration
  10221. */
  10222. /* add playback controls from the parsed DAC table */
  10223. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10224. const struct auto_pin_cfg *cfg)
  10225. {
  10226. char name[32];
  10227. static const char *chname[4] = {
  10228. "Front", "Surround", NULL /*CLFE*/, "Side"
  10229. };
  10230. hda_nid_t nid;
  10231. int i, err;
  10232. for (i = 0; i < cfg->line_outs; i++) {
  10233. if (!spec->multiout.dac_nids[i])
  10234. continue;
  10235. nid = alc880_idx_to_mixer(i);
  10236. if (i == 2) {
  10237. /* Center/LFE */
  10238. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10239. "Center Playback Volume",
  10240. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10241. HDA_OUTPUT));
  10242. if (err < 0)
  10243. return err;
  10244. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10245. "LFE Playback Volume",
  10246. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10247. HDA_OUTPUT));
  10248. if (err < 0)
  10249. return err;
  10250. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10251. "Center Playback Switch",
  10252. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10253. HDA_INPUT));
  10254. if (err < 0)
  10255. return err;
  10256. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10257. "LFE Playback Switch",
  10258. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10259. HDA_INPUT));
  10260. if (err < 0)
  10261. return err;
  10262. } else {
  10263. sprintf(name, "%s Playback Volume", chname[i]);
  10264. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10265. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10266. HDA_OUTPUT));
  10267. if (err < 0)
  10268. return err;
  10269. sprintf(name, "%s Playback Switch", chname[i]);
  10270. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10271. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10272. HDA_INPUT));
  10273. if (err < 0)
  10274. return err;
  10275. }
  10276. }
  10277. return 0;
  10278. }
  10279. /* add playback controls for speaker and HP outputs */
  10280. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10281. const char *pfx)
  10282. {
  10283. hda_nid_t nid;
  10284. int err;
  10285. char name[32];
  10286. if (!pin)
  10287. return 0;
  10288. if (alc880_is_fixed_pin(pin)) {
  10289. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10290. /* printk("DAC nid=%x\n",nid); */
  10291. /* specify the DAC as the extra output */
  10292. if (!spec->multiout.hp_nid)
  10293. spec->multiout.hp_nid = nid;
  10294. else
  10295. spec->multiout.extra_out_nid[0] = nid;
  10296. /* control HP volume/switch on the output mixer amp */
  10297. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10298. sprintf(name, "%s Playback Volume", pfx);
  10299. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10300. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10301. if (err < 0)
  10302. return err;
  10303. sprintf(name, "%s Playback Switch", pfx);
  10304. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10305. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10306. if (err < 0)
  10307. return err;
  10308. } else if (alc880_is_multi_pin(pin)) {
  10309. /* set manual connection */
  10310. /* we have only a switch on HP-out PIN */
  10311. sprintf(name, "%s Playback Switch", pfx);
  10312. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10313. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10314. if (err < 0)
  10315. return err;
  10316. }
  10317. return 0;
  10318. }
  10319. /* create playback/capture controls for input pins */
  10320. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10321. const struct auto_pin_cfg *cfg)
  10322. {
  10323. struct hda_input_mux *imux = &spec->private_imux;
  10324. int i, err, idx;
  10325. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10326. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10327. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10328. err = new_analog_input(spec, cfg->input_pins[i],
  10329. auto_pin_cfg_labels[i],
  10330. idx, 0x0b);
  10331. if (err < 0)
  10332. return err;
  10333. imux->items[imux->num_items].label =
  10334. auto_pin_cfg_labels[i];
  10335. imux->items[imux->num_items].index =
  10336. alc880_input_pin_idx(cfg->input_pins[i]);
  10337. imux->num_items++;
  10338. }
  10339. }
  10340. return 0;
  10341. }
  10342. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10343. hda_nid_t nid, int pin_type,
  10344. int dac_idx)
  10345. {
  10346. /* set as output */
  10347. snd_hda_codec_write(codec, nid, 0,
  10348. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10349. snd_hda_codec_write(codec, nid, 0,
  10350. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10351. /* need the manual connection? */
  10352. if (alc880_is_multi_pin(nid)) {
  10353. struct alc_spec *spec = codec->spec;
  10354. int idx = alc880_multi_pin_idx(nid);
  10355. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10356. AC_VERB_SET_CONNECT_SEL,
  10357. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10358. }
  10359. }
  10360. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10361. {
  10362. struct alc_spec *spec = codec->spec;
  10363. int i;
  10364. for (i = 0; i <= HDA_SIDE; i++) {
  10365. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10366. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10367. if (nid)
  10368. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10369. i);
  10370. }
  10371. }
  10372. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10373. {
  10374. struct alc_spec *spec = codec->spec;
  10375. hda_nid_t pin;
  10376. pin = spec->autocfg.hp_pins[0];
  10377. if (pin) /* connect to front */
  10378. /* use dac 0 */
  10379. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10380. }
  10381. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10382. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10383. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10384. {
  10385. struct alc_spec *spec = codec->spec;
  10386. int i;
  10387. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10388. hda_nid_t nid = spec->autocfg.input_pins[i];
  10389. if (alc662_is_input_pin(nid)) {
  10390. snd_hda_codec_write(codec, nid, 0,
  10391. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10392. (i <= AUTO_PIN_FRONT_MIC ?
  10393. PIN_VREF80 : PIN_IN));
  10394. if (nid != ALC662_PIN_CD_NID)
  10395. snd_hda_codec_write(codec, nid, 0,
  10396. AC_VERB_SET_AMP_GAIN_MUTE,
  10397. AMP_OUT_MUTE);
  10398. }
  10399. }
  10400. }
  10401. static int alc662_parse_auto_config(struct hda_codec *codec)
  10402. {
  10403. struct alc_spec *spec = codec->spec;
  10404. int err;
  10405. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10406. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10407. alc662_ignore);
  10408. if (err < 0)
  10409. return err;
  10410. if (!spec->autocfg.line_outs)
  10411. return 0; /* can't find valid BIOS pin config */
  10412. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10413. if (err < 0)
  10414. return err;
  10415. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10416. if (err < 0)
  10417. return err;
  10418. err = alc662_auto_create_extra_out(spec,
  10419. spec->autocfg.speaker_pins[0],
  10420. "Speaker");
  10421. if (err < 0)
  10422. return err;
  10423. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10424. "Headphone");
  10425. if (err < 0)
  10426. return err;
  10427. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10428. if (err < 0)
  10429. return err;
  10430. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10431. if (spec->autocfg.dig_out_pin)
  10432. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10433. if (spec->kctl_alloc)
  10434. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10435. spec->num_mux_defs = 1;
  10436. spec->input_mux = &spec->private_imux;
  10437. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10438. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10439. spec->num_mixers++;
  10440. return 1;
  10441. }
  10442. /* additional initialization for auto-configuration model */
  10443. static void alc662_auto_init(struct hda_codec *codec)
  10444. {
  10445. alc662_auto_init_multi_out(codec);
  10446. alc662_auto_init_hp_out(codec);
  10447. alc662_auto_init_analog_input(codec);
  10448. }
  10449. static int patch_alc662(struct hda_codec *codec)
  10450. {
  10451. struct alc_spec *spec;
  10452. int err, board_config;
  10453. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10454. if (!spec)
  10455. return -ENOMEM;
  10456. codec->spec = spec;
  10457. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10458. alc662_models,
  10459. alc662_cfg_tbl);
  10460. if (board_config < 0) {
  10461. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10462. "trying auto-probe from BIOS...\n");
  10463. board_config = ALC662_AUTO;
  10464. }
  10465. if (board_config == ALC662_AUTO) {
  10466. /* automatic parse from the BIOS config */
  10467. err = alc662_parse_auto_config(codec);
  10468. if (err < 0) {
  10469. alc_free(codec);
  10470. return err;
  10471. } else if (!err) {
  10472. printk(KERN_INFO
  10473. "hda_codec: Cannot set up configuration "
  10474. "from BIOS. Using base mode...\n");
  10475. board_config = ALC662_3ST_2ch_DIG;
  10476. }
  10477. }
  10478. if (board_config != ALC662_AUTO)
  10479. setup_preset(spec, &alc662_presets[board_config]);
  10480. spec->stream_name_analog = "ALC662 Analog";
  10481. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10482. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10483. spec->stream_name_digital = "ALC662 Digital";
  10484. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10485. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10486. if (!spec->adc_nids && spec->input_mux) {
  10487. spec->adc_nids = alc662_adc_nids;
  10488. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10489. }
  10490. codec->patch_ops = alc_patch_ops;
  10491. if (board_config == ALC662_AUTO)
  10492. spec->init_hook = alc662_auto_init;
  10493. return 0;
  10494. }
  10495. /*
  10496. * patch entries
  10497. */
  10498. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10499. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10500. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10501. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10502. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10503. .patch = patch_alc861 },
  10504. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10505. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10506. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10507. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10508. .patch = patch_alc883 },
  10509. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10510. .patch = patch_alc662 },
  10511. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10512. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10513. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10514. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10515. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10516. {} /* terminator */
  10517. };