patch_realtek.c 373 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_AUTO,
  93. ALC262_MODEL_LAST /* last tag */
  94. };
  95. /* ALC268 models */
  96. enum {
  97. ALC268_3ST,
  98. ALC268_AUTO,
  99. ALC268_MODEL_LAST /* last tag */
  100. };
  101. /* ALC861 models */
  102. enum {
  103. ALC861_3ST,
  104. ALC660_3ST,
  105. ALC861_3ST_DIG,
  106. ALC861_6ST_DIG,
  107. ALC861_UNIWILL_M31,
  108. ALC861_TOSHIBA,
  109. ALC861_ASUS,
  110. ALC861_ASUS_LAPTOP,
  111. ALC861_AUTO,
  112. ALC861_MODEL_LAST,
  113. };
  114. /* ALC861-VD models */
  115. enum {
  116. ALC660VD_3ST,
  117. ALC660VD_3ST_DIG,
  118. ALC861VD_3ST,
  119. ALC861VD_3ST_DIG,
  120. ALC861VD_6ST_DIG,
  121. ALC861VD_LENOVO,
  122. ALC861VD_DALLAS,
  123. ALC861VD_AUTO,
  124. ALC861VD_MODEL_LAST,
  125. };
  126. /* ALC662 models */
  127. enum {
  128. ALC662_3ST_2ch_DIG,
  129. ALC662_3ST_6ch_DIG,
  130. ALC662_3ST_6ch,
  131. ALC662_5ST_DIG,
  132. ALC662_LENOVO_101E,
  133. ALC662_AUTO,
  134. ALC662_MODEL_LAST,
  135. };
  136. /* ALC882 models */
  137. enum {
  138. ALC882_3ST_DIG,
  139. ALC882_6ST_DIG,
  140. ALC882_ARIMA,
  141. ALC882_W2JC,
  142. ALC882_TARGA,
  143. ALC882_ASUS_A7J,
  144. ALC885_MACPRO,
  145. ALC882_AUTO,
  146. ALC882_MODEL_LAST,
  147. };
  148. /* ALC883 models */
  149. enum {
  150. ALC883_3ST_2ch_DIG,
  151. ALC883_3ST_6ch_DIG,
  152. ALC883_3ST_6ch,
  153. ALC883_6ST_DIG,
  154. ALC883_TARGA_DIG,
  155. ALC883_TARGA_2ch_DIG,
  156. ALC883_ACER,
  157. ALC883_MEDION,
  158. ALC883_MEDION_MD2,
  159. ALC883_LAPTOP_EAPD,
  160. ALC883_LENOVO_101E_2ch,
  161. ALC883_LENOVO_NB0763,
  162. ALC888_LENOVO_MS7195_DIG,
  163. ALC883_AUTO,
  164. ALC883_MODEL_LAST,
  165. };
  166. /* for GPIO Poll */
  167. #define GPIO_MASK 0x03
  168. struct alc_spec {
  169. /* codec parameterization */
  170. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  171. unsigned int num_mixers;
  172. const struct hda_verb *init_verbs[5]; /* initialization verbs
  173. * don't forget NULL
  174. * termination!
  175. */
  176. unsigned int num_init_verbs;
  177. char *stream_name_analog; /* analog PCM stream */
  178. struct hda_pcm_stream *stream_analog_playback;
  179. struct hda_pcm_stream *stream_analog_capture;
  180. char *stream_name_digital; /* digital PCM stream */
  181. struct hda_pcm_stream *stream_digital_playback;
  182. struct hda_pcm_stream *stream_digital_capture;
  183. /* playback */
  184. struct hda_multi_out multiout; /* playback set-up
  185. * max_channels, dacs must be set
  186. * dig_out_nid and hp_nid are optional
  187. */
  188. /* capture */
  189. unsigned int num_adc_nids;
  190. hda_nid_t *adc_nids;
  191. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  192. /* capture source */
  193. unsigned int num_mux_defs;
  194. const struct hda_input_mux *input_mux;
  195. unsigned int cur_mux[3];
  196. /* channel model */
  197. const struct hda_channel_mode *channel_mode;
  198. int num_channel_mode;
  199. int need_dac_fix;
  200. /* PCM information */
  201. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  202. /* dynamic controls, init_verbs and input_mux */
  203. struct auto_pin_cfg autocfg;
  204. unsigned int num_kctl_alloc, num_kctl_used;
  205. struct snd_kcontrol_new *kctl_alloc;
  206. struct hda_input_mux private_imux;
  207. hda_nid_t private_dac_nids[5];
  208. /* hooks */
  209. void (*init_hook)(struct hda_codec *codec);
  210. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  211. /* for pin sensing */
  212. unsigned int sense_updated: 1;
  213. unsigned int jack_present: 1;
  214. };
  215. /*
  216. * configuration template - to be copied to the spec instance
  217. */
  218. struct alc_config_preset {
  219. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  220. * with spec
  221. */
  222. const struct hda_verb *init_verbs[5];
  223. unsigned int num_dacs;
  224. hda_nid_t *dac_nids;
  225. hda_nid_t dig_out_nid; /* optional */
  226. hda_nid_t hp_nid; /* optional */
  227. unsigned int num_adc_nids;
  228. hda_nid_t *adc_nids;
  229. hda_nid_t dig_in_nid;
  230. unsigned int num_channel_mode;
  231. const struct hda_channel_mode *channel_mode;
  232. int need_dac_fix;
  233. unsigned int num_mux_defs;
  234. const struct hda_input_mux *input_mux;
  235. void (*unsol_event)(struct hda_codec *, unsigned int);
  236. void (*init_hook)(struct hda_codec *);
  237. };
  238. /*
  239. * input MUX handling
  240. */
  241. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  242. struct snd_ctl_elem_info *uinfo)
  243. {
  244. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  245. struct alc_spec *spec = codec->spec;
  246. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  247. if (mux_idx >= spec->num_mux_defs)
  248. mux_idx = 0;
  249. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  250. }
  251. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  252. struct snd_ctl_elem_value *ucontrol)
  253. {
  254. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  255. struct alc_spec *spec = codec->spec;
  256. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  257. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  258. return 0;
  259. }
  260. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol)
  262. {
  263. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  264. struct alc_spec *spec = codec->spec;
  265. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  266. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  267. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  268. spec->adc_nids[adc_idx],
  269. &spec->cur_mux[adc_idx]);
  270. }
  271. /*
  272. * channel mode setting
  273. */
  274. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  275. struct snd_ctl_elem_info *uinfo)
  276. {
  277. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  278. struct alc_spec *spec = codec->spec;
  279. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  280. spec->num_channel_mode);
  281. }
  282. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  283. struct snd_ctl_elem_value *ucontrol)
  284. {
  285. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  286. struct alc_spec *spec = codec->spec;
  287. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  288. spec->num_channel_mode,
  289. spec->multiout.max_channels);
  290. }
  291. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_value *ucontrol)
  293. {
  294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  295. struct alc_spec *spec = codec->spec;
  296. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  297. spec->num_channel_mode,
  298. &spec->multiout.max_channels);
  299. if (err >= 0 && spec->need_dac_fix)
  300. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  301. return err;
  302. }
  303. /*
  304. * Control the mode of pin widget settings via the mixer. "pc" is used
  305. * instead of "%" to avoid consequences of accidently treating the % as
  306. * being part of a format specifier. Maximum allowed length of a value is
  307. * 63 characters plus NULL terminator.
  308. *
  309. * Note: some retasking pin complexes seem to ignore requests for input
  310. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  311. * are requested. Therefore order this list so that this behaviour will not
  312. * cause problems when mixer clients move through the enum sequentially.
  313. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  314. * March 2006.
  315. */
  316. static char *alc_pin_mode_names[] = {
  317. "Mic 50pc bias", "Mic 80pc bias",
  318. "Line in", "Line out", "Headphone out",
  319. };
  320. static unsigned char alc_pin_mode_values[] = {
  321. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  322. };
  323. /* The control can present all 5 options, or it can limit the options based
  324. * in the pin being assumed to be exclusively an input or an output pin. In
  325. * addition, "input" pins may or may not process the mic bias option
  326. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  327. * accept requests for bias as of chip versions up to March 2006) and/or
  328. * wiring in the computer.
  329. */
  330. #define ALC_PIN_DIR_IN 0x00
  331. #define ALC_PIN_DIR_OUT 0x01
  332. #define ALC_PIN_DIR_INOUT 0x02
  333. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  334. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  335. /* Info about the pin modes supported by the different pin direction modes.
  336. * For each direction the minimum and maximum values are given.
  337. */
  338. static signed char alc_pin_mode_dir_info[5][2] = {
  339. { 0, 2 }, /* ALC_PIN_DIR_IN */
  340. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  341. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  342. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  343. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  344. };
  345. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  346. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  347. #define alc_pin_mode_n_items(_dir) \
  348. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  349. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  350. struct snd_ctl_elem_info *uinfo)
  351. {
  352. unsigned int item_num = uinfo->value.enumerated.item;
  353. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  354. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  355. uinfo->count = 1;
  356. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  357. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  358. item_num = alc_pin_mode_min(dir);
  359. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  360. return 0;
  361. }
  362. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  363. struct snd_ctl_elem_value *ucontrol)
  364. {
  365. unsigned int i;
  366. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  367. hda_nid_t nid = kcontrol->private_value & 0xffff;
  368. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  369. long *valp = ucontrol->value.integer.value;
  370. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  371. AC_VERB_GET_PIN_WIDGET_CONTROL,
  372. 0x00);
  373. /* Find enumerated value for current pinctl setting */
  374. i = alc_pin_mode_min(dir);
  375. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  376. i++;
  377. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  378. return 0;
  379. }
  380. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. signed int change;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long val = *ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  392. val = alc_pin_mode_min(dir);
  393. change = pinctl != alc_pin_mode_values[val];
  394. if (change) {
  395. /* Set pin mode to that requested */
  396. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  397. alc_pin_mode_values[val]);
  398. /* Also enable the retasking pin's input/output as required
  399. * for the requested pin mode. Enum values of 2 or less are
  400. * input modes.
  401. *
  402. * Dynamically switching the input/output buffers probably
  403. * reduces noise slightly (particularly on input) so we'll
  404. * do it. However, having both input and output buffers
  405. * enabled simultaneously doesn't seem to be problematic if
  406. * this turns out to be necessary in the future.
  407. */
  408. if (val <= 2) {
  409. snd_hda_codec_write(codec, nid, 0,
  410. AC_VERB_SET_AMP_GAIN_MUTE,
  411. AMP_OUT_MUTE);
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_IN_UNMUTE(0));
  415. } else {
  416. snd_hda_codec_write(codec, nid, 0,
  417. AC_VERB_SET_AMP_GAIN_MUTE,
  418. AMP_IN_MUTE(0));
  419. snd_hda_codec_write(codec, nid, 0,
  420. AC_VERB_SET_AMP_GAIN_MUTE,
  421. AMP_OUT_UNMUTE);
  422. }
  423. }
  424. return change;
  425. }
  426. #define ALC_PIN_MODE(xname, nid, dir) \
  427. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  428. .info = alc_pin_mode_info, \
  429. .get = alc_pin_mode_get, \
  430. .put = alc_pin_mode_put, \
  431. .private_value = nid | (dir<<16) }
  432. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  433. * together using a mask with more than one bit set. This control is
  434. * currently used only by the ALC260 test model. At this stage they are not
  435. * needed for any "production" models.
  436. */
  437. #ifdef CONFIG_SND_DEBUG
  438. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  439. struct snd_ctl_elem_info *uinfo)
  440. {
  441. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  442. uinfo->count = 1;
  443. uinfo->value.integer.min = 0;
  444. uinfo->value.integer.max = 1;
  445. return 0;
  446. }
  447. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  448. struct snd_ctl_elem_value *ucontrol)
  449. {
  450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  451. hda_nid_t nid = kcontrol->private_value & 0xffff;
  452. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  453. long *valp = ucontrol->value.integer.value;
  454. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_GPIO_DATA, 0x00);
  456. *valp = (val & mask) != 0;
  457. return 0;
  458. }
  459. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  460. struct snd_ctl_elem_value *ucontrol)
  461. {
  462. signed int change;
  463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  464. hda_nid_t nid = kcontrol->private_value & 0xffff;
  465. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  466. long val = *ucontrol->value.integer.value;
  467. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_GPIO_DATA,
  469. 0x00);
  470. /* Set/unset the masked GPIO bit(s) as needed */
  471. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  472. if (val == 0)
  473. gpio_data &= ~mask;
  474. else
  475. gpio_data |= mask;
  476. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  477. return change;
  478. }
  479. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  480. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  481. .info = alc_gpio_data_info, \
  482. .get = alc_gpio_data_get, \
  483. .put = alc_gpio_data_put, \
  484. .private_value = nid | (mask<<16) }
  485. #endif /* CONFIG_SND_DEBUG */
  486. /* A switch control to allow the enabling of the digital IO pins on the
  487. * ALC260. This is incredibly simplistic; the intention of this control is
  488. * to provide something in the test model allowing digital outputs to be
  489. * identified if present. If models are found which can utilise these
  490. * outputs a more complete mixer control can be devised for those models if
  491. * necessary.
  492. */
  493. #ifdef CONFIG_SND_DEBUG
  494. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  495. struct snd_ctl_elem_info *uinfo)
  496. {
  497. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  498. uinfo->count = 1;
  499. uinfo->value.integer.min = 0;
  500. uinfo->value.integer.max = 1;
  501. return 0;
  502. }
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. }
  574. /* Enable GPIO mask and set output */
  575. static struct hda_verb alc_gpio1_init_verbs[] = {
  576. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  579. { }
  580. };
  581. static struct hda_verb alc_gpio2_init_verbs[] = {
  582. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  585. { }
  586. };
  587. static struct hda_verb alc_gpio3_init_verbs[] = {
  588. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  591. { }
  592. };
  593. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  594. * 31 ~ 16 : Manufacture ID
  595. * 15 ~ 8 : SKU ID
  596. * 7 ~ 0 : Assembly ID
  597. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  598. */
  599. static void alc_subsystem_id(struct hda_codec *codec,
  600. unsigned int porta, unsigned int porte,
  601. unsigned int portd)
  602. {
  603. unsigned int ass, tmp;
  604. ass = codec->subsystem_id;
  605. if (!(ass & 1))
  606. return;
  607. /* Override */
  608. tmp = (ass & 0x38) >> 3; /* external Amp control */
  609. switch (tmp) {
  610. case 1:
  611. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  612. break;
  613. case 3:
  614. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  615. break;
  616. case 7:
  617. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  618. break;
  619. case 5:
  620. switch (codec->vendor_id) {
  621. case 0x10ec0862:
  622. case 0x10ec0660:
  623. case 0x10ec0662:
  624. case 0x10ec0267:
  625. case 0x10ec0268:
  626. snd_hda_codec_write(codec, 0x14, 0,
  627. AC_VERB_SET_EAPD_BTLENABLE, 2);
  628. snd_hda_codec_write(codec, 0x15, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. return;
  631. }
  632. case 6:
  633. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  634. hda_nid_t port = 0;
  635. tmp = (ass & 0x1800) >> 11;
  636. switch (tmp) {
  637. case 0: port = porta; break;
  638. case 1: port = porte; break;
  639. case 2: port = portd; break;
  640. }
  641. if (port)
  642. snd_hda_codec_write(codec, port, 0,
  643. AC_VERB_SET_EAPD_BTLENABLE,
  644. 2);
  645. }
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  648. (tmp == 5 ? 0x3040 : 0x3050));
  649. break;
  650. }
  651. }
  652. /*
  653. * ALC880 3-stack model
  654. *
  655. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  656. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  657. * F-Mic = 0x1b, HP = 0x19
  658. */
  659. static hda_nid_t alc880_dac_nids[4] = {
  660. /* front, rear, clfe, rear_surr */
  661. 0x02, 0x05, 0x04, 0x03
  662. };
  663. static hda_nid_t alc880_adc_nids[3] = {
  664. /* ADC0-2 */
  665. 0x07, 0x08, 0x09,
  666. };
  667. /* The datasheet says the node 0x07 is connected from inputs,
  668. * but it shows zero connection in the real implementation on some devices.
  669. * Note: this is a 915GAV bug, fixed on 915GLV
  670. */
  671. static hda_nid_t alc880_adc_nids_alt[2] = {
  672. /* ADC1-2 */
  673. 0x08, 0x09,
  674. };
  675. #define ALC880_DIGOUT_NID 0x06
  676. #define ALC880_DIGIN_NID 0x0a
  677. static struct hda_input_mux alc880_capture_source = {
  678. .num_items = 4,
  679. .items = {
  680. { "Mic", 0x0 },
  681. { "Front Mic", 0x3 },
  682. { "Line", 0x2 },
  683. { "CD", 0x4 },
  684. },
  685. };
  686. /* channel source setting (2/6 channel selection for 3-stack) */
  687. /* 2ch mode */
  688. static struct hda_verb alc880_threestack_ch2_init[] = {
  689. /* set line-in to input, mute it */
  690. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  691. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  692. /* set mic-in to input vref 80%, mute it */
  693. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  694. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  695. { } /* end */
  696. };
  697. /* 6ch mode */
  698. static struct hda_verb alc880_threestack_ch6_init[] = {
  699. /* set line-in to output, unmute it */
  700. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  701. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  702. /* set mic-in to output, unmute it */
  703. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. { } /* end */
  706. };
  707. static struct hda_channel_mode alc880_threestack_modes[2] = {
  708. { 2, alc880_threestack_ch2_init },
  709. { 6, alc880_threestack_ch6_init },
  710. };
  711. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  712. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  713. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  714. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  715. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  716. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  717. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  719. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  728. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  730. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  731. {
  732. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  733. .name = "Channel Mode",
  734. .info = alc_ch_mode_info,
  735. .get = alc_ch_mode_get,
  736. .put = alc_ch_mode_put,
  737. },
  738. { } /* end */
  739. };
  740. /* capture mixer elements */
  741. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  742. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  743. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  744. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  745. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  746. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  747. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  748. {
  749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  750. /* The multiple "Capture Source" controls confuse alsamixer
  751. * So call somewhat different..
  752. * FIXME: the controls appear in the "playback" view!
  753. */
  754. /* .name = "Capture Source", */
  755. .name = "Input Source",
  756. .count = 3,
  757. .info = alc_mux_enum_info,
  758. .get = alc_mux_enum_get,
  759. .put = alc_mux_enum_put,
  760. },
  761. { } /* end */
  762. };
  763. /* capture mixer elements (in case NID 0x07 not available) */
  764. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  765. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  766. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  767. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  768. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  769. {
  770. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  771. /* The multiple "Capture Source" controls confuse alsamixer
  772. * So call somewhat different..
  773. * FIXME: the controls appear in the "playback" view!
  774. */
  775. /* .name = "Capture Source", */
  776. .name = "Input Source",
  777. .count = 2,
  778. .info = alc_mux_enum_info,
  779. .get = alc_mux_enum_get,
  780. .put = alc_mux_enum_put,
  781. },
  782. { } /* end */
  783. };
  784. /*
  785. * ALC880 5-stack model
  786. *
  787. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  788. * Side = 0x02 (0xd)
  789. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  790. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  791. */
  792. /* additional mixers to alc880_three_stack_mixer */
  793. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  794. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  795. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  796. { } /* end */
  797. };
  798. /* channel source setting (6/8 channel selection for 5-stack) */
  799. /* 6ch mode */
  800. static struct hda_verb alc880_fivestack_ch6_init[] = {
  801. /* set line-in to input, mute it */
  802. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  803. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  804. { } /* end */
  805. };
  806. /* 8ch mode */
  807. static struct hda_verb alc880_fivestack_ch8_init[] = {
  808. /* set line-in to output, unmute it */
  809. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  810. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  811. { } /* end */
  812. };
  813. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  814. { 6, alc880_fivestack_ch6_init },
  815. { 8, alc880_fivestack_ch8_init },
  816. };
  817. /*
  818. * ALC880 6-stack model
  819. *
  820. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  821. * Side = 0x05 (0x0f)
  822. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  823. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  824. */
  825. static hda_nid_t alc880_6st_dac_nids[4] = {
  826. /* front, rear, clfe, rear_surr */
  827. 0x02, 0x03, 0x04, 0x05
  828. };
  829. static struct hda_input_mux alc880_6stack_capture_source = {
  830. .num_items = 4,
  831. .items = {
  832. { "Mic", 0x0 },
  833. { "Front Mic", 0x1 },
  834. { "Line", 0x2 },
  835. { "CD", 0x4 },
  836. },
  837. };
  838. /* fixed 8-channels */
  839. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  840. { 8, NULL },
  841. };
  842. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  843. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  844. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  845. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  846. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  847. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  848. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  849. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  850. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  856. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  857. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  858. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  859. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  860. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  861. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  862. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  863. {
  864. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  865. .name = "Channel Mode",
  866. .info = alc_ch_mode_info,
  867. .get = alc_ch_mode_get,
  868. .put = alc_ch_mode_put,
  869. },
  870. { } /* end */
  871. };
  872. /*
  873. * ALC880 W810 model
  874. *
  875. * W810 has rear IO for:
  876. * Front (DAC 02)
  877. * Surround (DAC 03)
  878. * Center/LFE (DAC 04)
  879. * Digital out (06)
  880. *
  881. * The system also has a pair of internal speakers, and a headphone jack.
  882. * These are both connected to Line2 on the codec, hence to DAC 02.
  883. *
  884. * There is a variable resistor to control the speaker or headphone
  885. * volume. This is a hardware-only device without a software API.
  886. *
  887. * Plugging headphones in will disable the internal speakers. This is
  888. * implemented in hardware, not via the driver using jack sense. In
  889. * a similar fashion, plugging into the rear socket marked "front" will
  890. * disable both the speakers and headphones.
  891. *
  892. * For input, there's a microphone jack, and an "audio in" jack.
  893. * These may not do anything useful with this driver yet, because I
  894. * haven't setup any initialization verbs for these yet...
  895. */
  896. static hda_nid_t alc880_w810_dac_nids[3] = {
  897. /* front, rear/surround, clfe */
  898. 0x02, 0x03, 0x04
  899. };
  900. /* fixed 6 channels */
  901. static struct hda_channel_mode alc880_w810_modes[1] = {
  902. { 6, NULL }
  903. };
  904. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  905. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  906. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  907. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  908. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  909. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  910. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  911. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  912. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  913. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  914. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  915. { } /* end */
  916. };
  917. /*
  918. * Z710V model
  919. *
  920. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  921. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  922. * Line = 0x1a
  923. */
  924. static hda_nid_t alc880_z71v_dac_nids[1] = {
  925. 0x02
  926. };
  927. #define ALC880_Z71V_HP_DAC 0x03
  928. /* fixed 2 channels */
  929. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  930. { 2, NULL }
  931. };
  932. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  933. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  934. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  935. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  940. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  941. { } /* end */
  942. };
  943. /* FIXME! */
  944. /*
  945. * ALC880 F1734 model
  946. *
  947. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  948. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  949. */
  950. static hda_nid_t alc880_f1734_dac_nids[1] = {
  951. 0x03
  952. };
  953. #define ALC880_F1734_HP_DAC 0x02
  954. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  955. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  956. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  957. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  958. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  959. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  960. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /* FIXME! */
  966. /*
  967. * ALC880 ASUS model
  968. *
  969. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  970. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  971. * Mic = 0x18, Line = 0x1a
  972. */
  973. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  974. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  975. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  976. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  977. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  978. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  979. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  980. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  981. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  982. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  983. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  985. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  987. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  988. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  989. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  990. {
  991. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  992. .name = "Channel Mode",
  993. .info = alc_ch_mode_info,
  994. .get = alc_ch_mode_get,
  995. .put = alc_ch_mode_put,
  996. },
  997. { } /* end */
  998. };
  999. /* FIXME! */
  1000. /*
  1001. * ALC880 ASUS W1V model
  1002. *
  1003. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1004. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1005. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1006. */
  1007. /* additional mixers to alc880_asus_mixer */
  1008. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1009. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1010. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1011. { } /* end */
  1012. };
  1013. /* additional mixers to alc880_asus_mixer */
  1014. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1015. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1016. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1017. { } /* end */
  1018. };
  1019. /* TCL S700 */
  1020. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1021. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1022. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1023. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1024. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1025. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1027. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1028. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1029. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1030. {
  1031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1032. /* The multiple "Capture Source" controls confuse alsamixer
  1033. * So call somewhat different..
  1034. * FIXME: the controls appear in the "playback" view!
  1035. */
  1036. /* .name = "Capture Source", */
  1037. .name = "Input Source",
  1038. .count = 1,
  1039. .info = alc_mux_enum_info,
  1040. .get = alc_mux_enum_get,
  1041. .put = alc_mux_enum_put,
  1042. },
  1043. { } /* end */
  1044. };
  1045. /* Uniwill */
  1046. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1047. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1048. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1049. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1050. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1051. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1054. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1056. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1059. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1060. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1061. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1062. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1063. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1064. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1065. {
  1066. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1067. .name = "Channel Mode",
  1068. .info = alc_ch_mode_info,
  1069. .get = alc_ch_mode_get,
  1070. .put = alc_ch_mode_put,
  1071. },
  1072. { } /* end */
  1073. };
  1074. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1075. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1082. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1084. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1085. { } /* end */
  1086. };
  1087. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1088. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1089. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1091. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1093. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1094. { } /* end */
  1095. };
  1096. /*
  1097. * build control elements
  1098. */
  1099. static int alc_build_controls(struct hda_codec *codec)
  1100. {
  1101. struct alc_spec *spec = codec->spec;
  1102. int err;
  1103. int i;
  1104. for (i = 0; i < spec->num_mixers; i++) {
  1105. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1106. if (err < 0)
  1107. return err;
  1108. }
  1109. if (spec->multiout.dig_out_nid) {
  1110. err = snd_hda_create_spdif_out_ctls(codec,
  1111. spec->multiout.dig_out_nid);
  1112. if (err < 0)
  1113. return err;
  1114. }
  1115. if (spec->dig_in_nid) {
  1116. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1117. if (err < 0)
  1118. return err;
  1119. }
  1120. return 0;
  1121. }
  1122. /*
  1123. * initialize the codec volumes, etc
  1124. */
  1125. /*
  1126. * generic initialization of ADC, input mixers and output mixers
  1127. */
  1128. static struct hda_verb alc880_volume_init_verbs[] = {
  1129. /*
  1130. * Unmute ADC0-2 and set the default input to mic-in
  1131. */
  1132. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1134. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1135. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1136. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1137. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1138. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1139. * mixer widget
  1140. * Note: PASD motherboards uses the Line In 2 as the input for front
  1141. * panel mic (mic 2)
  1142. */
  1143. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1149. /*
  1150. * Set up output mixers (0x0c - 0x0f)
  1151. */
  1152. /* set vol=0 to output mixers */
  1153. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1154. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1155. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1156. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1157. /* set up input amps for analog loopback */
  1158. /* Amp Indices: DAC = 0, mixer = 1 */
  1159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1160. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1161. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1162. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1163. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1164. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1165. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1166. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1167. { }
  1168. };
  1169. /*
  1170. * 3-stack pin configuration:
  1171. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1172. */
  1173. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1174. /*
  1175. * preset connection lists of input pins
  1176. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1177. */
  1178. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1179. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1180. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1181. /*
  1182. * Set pin mode and muting
  1183. */
  1184. /* set front pin widgets 0x14 for output */
  1185. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1186. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1187. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1188. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1189. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1190. /* Mic2 (as headphone out) for HP output */
  1191. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1192. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. /* Line In pin widget for input */
  1194. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1195. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1196. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1197. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1198. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1199. /* CD pin widget for input */
  1200. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1201. { }
  1202. };
  1203. /*
  1204. * 5-stack pin configuration:
  1205. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1206. * line-in/side = 0x1a, f-mic = 0x1b
  1207. */
  1208. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1209. /*
  1210. * preset connection lists of input pins
  1211. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1212. */
  1213. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1214. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1215. /*
  1216. * Set pin mode and muting
  1217. */
  1218. /* set pin widgets 0x14-0x17 for output */
  1219. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1222. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1223. /* unmute pins for output (no gain on this amp) */
  1224. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1226. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1228. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1229. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1230. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1231. /* Mic2 (as headphone out) for HP output */
  1232. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1233. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1234. /* Line In pin widget for input */
  1235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1236. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1237. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1238. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1239. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1240. /* CD pin widget for input */
  1241. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1242. { }
  1243. };
  1244. /*
  1245. * W810 pin configuration:
  1246. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1247. */
  1248. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1249. /* hphone/speaker input selector: front DAC */
  1250. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1251. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1258. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. { }
  1260. };
  1261. /*
  1262. * Z71V pin configuration:
  1263. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1264. */
  1265. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1266. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1267. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1268. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1270. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1271. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1273. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1274. { }
  1275. };
  1276. /*
  1277. * 6-stack pin configuration:
  1278. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1279. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1280. */
  1281. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1282. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1283. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1288. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1289. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1290. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1291. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1292. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1293. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1294. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1295. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1296. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1297. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1298. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1300. { }
  1301. };
  1302. /*
  1303. * Uniwill pin configuration:
  1304. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1305. * line = 0x1a
  1306. */
  1307. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1308. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1309. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1310. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1313. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1314. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1318. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1319. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1320. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1321. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1323. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1329. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1330. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1331. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1332. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1333. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1334. { }
  1335. };
  1336. /*
  1337. * Uniwill P53
  1338. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1339. */
  1340. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1341. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1342. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1347. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1361. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1362. { }
  1363. };
  1364. static struct hda_verb alc880_beep_init_verbs[] = {
  1365. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1366. { }
  1367. };
  1368. /* toggle speaker-output according to the hp-jack state */
  1369. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1370. {
  1371. unsigned int present;
  1372. unsigned char bits;
  1373. present = snd_hda_codec_read(codec, 0x14, 0,
  1374. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1375. bits = present ? 0x80 : 0;
  1376. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1377. 0x80, bits);
  1378. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1379. 0x80, bits);
  1380. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1381. 0x80, bits);
  1382. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1383. 0x80, bits);
  1384. }
  1385. /* auto-toggle front mic */
  1386. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1387. {
  1388. unsigned int present;
  1389. unsigned char bits;
  1390. present = snd_hda_codec_read(codec, 0x18, 0,
  1391. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1392. bits = present ? 0x80 : 0;
  1393. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1394. 0x80, bits);
  1395. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1396. 0x80, bits);
  1397. }
  1398. static void alc880_uniwill_automute(struct hda_codec *codec)
  1399. {
  1400. alc880_uniwill_hp_automute(codec);
  1401. alc880_uniwill_mic_automute(codec);
  1402. }
  1403. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1404. unsigned int res)
  1405. {
  1406. /* Looks like the unsol event is incompatible with the standard
  1407. * definition. 4bit tag is placed at 28 bit!
  1408. */
  1409. switch (res >> 28) {
  1410. case ALC880_HP_EVENT:
  1411. alc880_uniwill_hp_automute(codec);
  1412. break;
  1413. case ALC880_MIC_EVENT:
  1414. alc880_uniwill_mic_automute(codec);
  1415. break;
  1416. }
  1417. }
  1418. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1419. {
  1420. unsigned int present;
  1421. unsigned char bits;
  1422. present = snd_hda_codec_read(codec, 0x14, 0,
  1423. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1424. bits = present ? 0x80 : 0;
  1425. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1426. 0x80, bits);
  1427. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1428. 0x80, bits);
  1429. }
  1430. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1431. {
  1432. unsigned int present;
  1433. present = snd_hda_codec_read(codec, 0x21, 0,
  1434. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1435. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1436. 0x7f, present);
  1437. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1438. 0x7f, present);
  1439. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1440. 0x7f, present);
  1441. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1442. 0x7f, present);
  1443. }
  1444. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1445. unsigned int res)
  1446. {
  1447. /* Looks like the unsol event is incompatible with the standard
  1448. * definition. 4bit tag is placed at 28 bit!
  1449. */
  1450. if ((res >> 28) == ALC880_HP_EVENT)
  1451. alc880_uniwill_p53_hp_automute(codec);
  1452. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1453. alc880_uniwill_p53_dcvol_automute(codec);
  1454. }
  1455. /* FIXME! */
  1456. /*
  1457. * F1734 pin configuration:
  1458. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1459. */
  1460. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1461. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1462. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1463. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1464. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1465. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1466. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1469. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1470. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1471. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1472. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1473. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1474. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1475. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1476. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1477. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1478. { }
  1479. };
  1480. /* FIXME! */
  1481. /*
  1482. * ASUS pin configuration:
  1483. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1484. */
  1485. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1486. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1487. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1488. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1489. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1491. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1495. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1496. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1500. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1501. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1502. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1504. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1505. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1506. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1507. { }
  1508. };
  1509. /* Enable GPIO mask and set output */
  1510. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1511. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1512. /* Clevo m520g init */
  1513. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1514. /* headphone output */
  1515. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1516. /* line-out */
  1517. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1519. /* Line-in */
  1520. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1521. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. /* CD */
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. /* Mic1 (rear panel) */
  1526. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1527. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. /* Mic2 (front panel) */
  1529. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1531. /* headphone */
  1532. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1533. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* change to EAPD mode */
  1535. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1536. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1537. { }
  1538. };
  1539. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1540. /* change to EAPD mode */
  1541. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1542. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1543. /* Headphone output */
  1544. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1545. /* Front output*/
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1547. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1548. /* Line In pin widget for input */
  1549. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1550. /* CD pin widget for input */
  1551. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1552. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1553. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1554. /* change to EAPD mode */
  1555. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1556. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1557. { }
  1558. };
  1559. /*
  1560. * LG m1 express dual
  1561. *
  1562. * Pin assignment:
  1563. * Rear Line-In/Out (blue): 0x14
  1564. * Build-in Mic-In: 0x15
  1565. * Speaker-out: 0x17
  1566. * HP-Out (green): 0x1b
  1567. * Mic-In/Out (red): 0x19
  1568. * SPDIF-Out: 0x1e
  1569. */
  1570. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1571. static hda_nid_t alc880_lg_dac_nids[3] = {
  1572. 0x05, 0x02, 0x03
  1573. };
  1574. /* seems analog CD is not working */
  1575. static struct hda_input_mux alc880_lg_capture_source = {
  1576. .num_items = 3,
  1577. .items = {
  1578. { "Mic", 0x1 },
  1579. { "Line", 0x5 },
  1580. { "Internal Mic", 0x6 },
  1581. },
  1582. };
  1583. /* 2,4,6 channel modes */
  1584. static struct hda_verb alc880_lg_ch2_init[] = {
  1585. /* set line-in and mic-in to input */
  1586. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1587. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1588. { }
  1589. };
  1590. static struct hda_verb alc880_lg_ch4_init[] = {
  1591. /* set line-in to out and mic-in to input */
  1592. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1593. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1594. { }
  1595. };
  1596. static struct hda_verb alc880_lg_ch6_init[] = {
  1597. /* set line-in and mic-in to output */
  1598. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1599. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1600. { }
  1601. };
  1602. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1603. { 2, alc880_lg_ch2_init },
  1604. { 4, alc880_lg_ch4_init },
  1605. { 6, alc880_lg_ch6_init },
  1606. };
  1607. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1608. /* FIXME: it's not really "master" but front channels */
  1609. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1610. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1611. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1612. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1613. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1614. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1615. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1616. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1617. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1618. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1619. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1620. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1621. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1622. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1623. {
  1624. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1625. .name = "Channel Mode",
  1626. .info = alc_ch_mode_info,
  1627. .get = alc_ch_mode_get,
  1628. .put = alc_ch_mode_put,
  1629. },
  1630. { } /* end */
  1631. };
  1632. static struct hda_verb alc880_lg_init_verbs[] = {
  1633. /* set capture source to mic-in */
  1634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1636. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1637. /* mute all amp mixer inputs */
  1638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1640. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1641. /* line-in to input */
  1642. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1643. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1644. /* built-in mic */
  1645. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1646. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* speaker-out */
  1648. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1649. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. /* mic-in to input */
  1651. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1652. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1653. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1654. /* HP-out */
  1655. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1656. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1657. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1658. /* jack sense */
  1659. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1660. { }
  1661. };
  1662. /* toggle speaker-output according to the hp-jack state */
  1663. static void alc880_lg_automute(struct hda_codec *codec)
  1664. {
  1665. unsigned int present;
  1666. unsigned char bits;
  1667. present = snd_hda_codec_read(codec, 0x1b, 0,
  1668. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1669. bits = present ? 0x80 : 0;
  1670. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1671. 0x80, bits);
  1672. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1673. 0x80, bits);
  1674. }
  1675. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1676. {
  1677. /* Looks like the unsol event is incompatible with the standard
  1678. * definition. 4bit tag is placed at 28 bit!
  1679. */
  1680. if ((res >> 28) == 0x01)
  1681. alc880_lg_automute(codec);
  1682. }
  1683. /*
  1684. * LG LW20
  1685. *
  1686. * Pin assignment:
  1687. * Speaker-out: 0x14
  1688. * Mic-In: 0x18
  1689. * Built-in Mic-In: 0x19 (?)
  1690. * HP-Out: 0x1b
  1691. * SPDIF-Out: 0x1e
  1692. */
  1693. /* seems analog CD is not working */
  1694. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1695. .num_items = 2,
  1696. .items = {
  1697. { "Mic", 0x0 },
  1698. { "Internal Mic", 0x1 },
  1699. },
  1700. };
  1701. #define alc880_lg_lw_modes alc880_threestack_modes
  1702. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1703. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1704. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1705. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1706. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1707. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1708. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1709. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1710. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1711. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1712. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1713. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1714. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1715. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1716. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1717. {
  1718. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1719. .name = "Channel Mode",
  1720. .info = alc_ch_mode_info,
  1721. .get = alc_ch_mode_get,
  1722. .put = alc_ch_mode_put,
  1723. },
  1724. { } /* end */
  1725. };
  1726. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1727. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1728. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1729. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1730. /* set capture source to mic-in */
  1731. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1733. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1734. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1735. /* speaker-out */
  1736. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1737. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1738. /* HP-out */
  1739. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1740. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1741. /* mic-in to input */
  1742. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1743. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1744. /* built-in mic */
  1745. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1746. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1747. /* jack sense */
  1748. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1749. { }
  1750. };
  1751. /* toggle speaker-output according to the hp-jack state */
  1752. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1753. {
  1754. unsigned int present;
  1755. unsigned char bits;
  1756. present = snd_hda_codec_read(codec, 0x1b, 0,
  1757. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1758. bits = present ? 0x80 : 0;
  1759. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1760. 0x80, bits);
  1761. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1762. 0x80, bits);
  1763. }
  1764. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1765. {
  1766. /* Looks like the unsol event is incompatible with the standard
  1767. * definition. 4bit tag is placed at 28 bit!
  1768. */
  1769. if ((res >> 28) == 0x01)
  1770. alc880_lg_lw_automute(codec);
  1771. }
  1772. /*
  1773. * Common callbacks
  1774. */
  1775. static int alc_init(struct hda_codec *codec)
  1776. {
  1777. struct alc_spec *spec = codec->spec;
  1778. unsigned int i;
  1779. for (i = 0; i < spec->num_init_verbs; i++)
  1780. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1781. if (spec->init_hook)
  1782. spec->init_hook(codec);
  1783. return 0;
  1784. }
  1785. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1786. {
  1787. struct alc_spec *spec = codec->spec;
  1788. if (spec->unsol_event)
  1789. spec->unsol_event(codec, res);
  1790. }
  1791. #ifdef CONFIG_PM
  1792. /*
  1793. * resume
  1794. */
  1795. static int alc_resume(struct hda_codec *codec)
  1796. {
  1797. struct alc_spec *spec = codec->spec;
  1798. int i;
  1799. alc_init(codec);
  1800. for (i = 0; i < spec->num_mixers; i++)
  1801. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1802. if (spec->multiout.dig_out_nid)
  1803. snd_hda_resume_spdif_out(codec);
  1804. if (spec->dig_in_nid)
  1805. snd_hda_resume_spdif_in(codec);
  1806. return 0;
  1807. }
  1808. #endif
  1809. /*
  1810. * Analog playback callbacks
  1811. */
  1812. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1813. struct hda_codec *codec,
  1814. struct snd_pcm_substream *substream)
  1815. {
  1816. struct alc_spec *spec = codec->spec;
  1817. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1818. }
  1819. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1820. struct hda_codec *codec,
  1821. unsigned int stream_tag,
  1822. unsigned int format,
  1823. struct snd_pcm_substream *substream)
  1824. {
  1825. struct alc_spec *spec = codec->spec;
  1826. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1827. stream_tag, format, substream);
  1828. }
  1829. static int alc880_playback_pcm_cleanup(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_cleanup(codec, &spec->multiout);
  1835. }
  1836. /*
  1837. * Digital out
  1838. */
  1839. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1840. struct hda_codec *codec,
  1841. struct snd_pcm_substream *substream)
  1842. {
  1843. struct alc_spec *spec = codec->spec;
  1844. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1845. }
  1846. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1847. struct hda_codec *codec,
  1848. unsigned int stream_tag,
  1849. unsigned int format,
  1850. struct snd_pcm_substream *substream)
  1851. {
  1852. struct alc_spec *spec = codec->spec;
  1853. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1854. stream_tag, format, substream);
  1855. }
  1856. static int alc880_dig_playback_pcm_close(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_close(codec, &spec->multiout);
  1862. }
  1863. /*
  1864. * Analog capture
  1865. */
  1866. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1867. struct hda_codec *codec,
  1868. unsigned int stream_tag,
  1869. unsigned int format,
  1870. struct snd_pcm_substream *substream)
  1871. {
  1872. struct alc_spec *spec = codec->spec;
  1873. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1874. stream_tag, 0, format);
  1875. return 0;
  1876. }
  1877. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1878. struct hda_codec *codec,
  1879. struct snd_pcm_substream *substream)
  1880. {
  1881. struct alc_spec *spec = codec->spec;
  1882. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1883. 0, 0, 0);
  1884. return 0;
  1885. }
  1886. /*
  1887. */
  1888. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1889. .substreams = 1,
  1890. .channels_min = 2,
  1891. .channels_max = 8,
  1892. /* NID is set in alc_build_pcms */
  1893. .ops = {
  1894. .open = alc880_playback_pcm_open,
  1895. .prepare = alc880_playback_pcm_prepare,
  1896. .cleanup = alc880_playback_pcm_cleanup
  1897. },
  1898. };
  1899. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1900. .substreams = 2,
  1901. .channels_min = 2,
  1902. .channels_max = 2,
  1903. /* NID is set in alc_build_pcms */
  1904. .ops = {
  1905. .prepare = alc880_capture_pcm_prepare,
  1906. .cleanup = alc880_capture_pcm_cleanup
  1907. },
  1908. };
  1909. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1910. .substreams = 1,
  1911. .channels_min = 2,
  1912. .channels_max = 2,
  1913. /* NID is set in alc_build_pcms */
  1914. .ops = {
  1915. .open = alc880_dig_playback_pcm_open,
  1916. .close = alc880_dig_playback_pcm_close,
  1917. .prepare = alc880_dig_playback_pcm_prepare
  1918. },
  1919. };
  1920. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1921. .substreams = 1,
  1922. .channels_min = 2,
  1923. .channels_max = 2,
  1924. /* NID is set in alc_build_pcms */
  1925. };
  1926. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1927. static struct hda_pcm_stream alc_pcm_null_playback = {
  1928. .substreams = 0,
  1929. .channels_min = 0,
  1930. .channels_max = 0,
  1931. };
  1932. static int alc_build_pcms(struct hda_codec *codec)
  1933. {
  1934. struct alc_spec *spec = codec->spec;
  1935. struct hda_pcm *info = spec->pcm_rec;
  1936. int i;
  1937. codec->num_pcms = 1;
  1938. codec->pcm_info = info;
  1939. info->name = spec->stream_name_analog;
  1940. if (spec->stream_analog_playback) {
  1941. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1942. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1943. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1944. }
  1945. if (spec->stream_analog_capture) {
  1946. snd_assert(spec->adc_nids, return -EINVAL);
  1947. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1948. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1949. }
  1950. if (spec->channel_mode) {
  1951. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1952. for (i = 0; i < spec->num_channel_mode; i++) {
  1953. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1954. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1955. }
  1956. }
  1957. }
  1958. /* SPDIF for stream index #1 */
  1959. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1960. codec->num_pcms = 2;
  1961. info = spec->pcm_rec + 1;
  1962. info->name = spec->stream_name_digital;
  1963. if (spec->multiout.dig_out_nid &&
  1964. spec->stream_digital_playback) {
  1965. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1966. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1967. }
  1968. if (spec->dig_in_nid &&
  1969. spec->stream_digital_capture) {
  1970. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1971. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1972. }
  1973. }
  1974. /* If the use of more than one ADC is requested for the current
  1975. * model, configure a second analog capture-only PCM.
  1976. */
  1977. /* Additional Analaog capture for index #2 */
  1978. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1979. spec->adc_nids) {
  1980. codec->num_pcms = 3;
  1981. info = spec->pcm_rec + 2;
  1982. info->name = spec->stream_name_analog;
  1983. /* No playback stream for second PCM */
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1986. if (spec->stream_analog_capture) {
  1987. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1988. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1989. }
  1990. }
  1991. return 0;
  1992. }
  1993. static void alc_free(struct hda_codec *codec)
  1994. {
  1995. struct alc_spec *spec = codec->spec;
  1996. unsigned int i;
  1997. if (!spec)
  1998. return;
  1999. if (spec->kctl_alloc) {
  2000. for (i = 0; i < spec->num_kctl_used; i++)
  2001. kfree(spec->kctl_alloc[i].name);
  2002. kfree(spec->kctl_alloc);
  2003. }
  2004. kfree(spec);
  2005. }
  2006. /*
  2007. */
  2008. static struct hda_codec_ops alc_patch_ops = {
  2009. .build_controls = alc_build_controls,
  2010. .build_pcms = alc_build_pcms,
  2011. .init = alc_init,
  2012. .free = alc_free,
  2013. .unsol_event = alc_unsol_event,
  2014. #ifdef CONFIG_PM
  2015. .resume = alc_resume,
  2016. #endif
  2017. };
  2018. /*
  2019. * Test configuration for debugging
  2020. *
  2021. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2022. * enum controls.
  2023. */
  2024. #ifdef CONFIG_SND_DEBUG
  2025. static hda_nid_t alc880_test_dac_nids[4] = {
  2026. 0x02, 0x03, 0x04, 0x05
  2027. };
  2028. static struct hda_input_mux alc880_test_capture_source = {
  2029. .num_items = 7,
  2030. .items = {
  2031. { "In-1", 0x0 },
  2032. { "In-2", 0x1 },
  2033. { "In-3", 0x2 },
  2034. { "In-4", 0x3 },
  2035. { "CD", 0x4 },
  2036. { "Front", 0x5 },
  2037. { "Surround", 0x6 },
  2038. },
  2039. };
  2040. static struct hda_channel_mode alc880_test_modes[4] = {
  2041. { 2, NULL },
  2042. { 4, NULL },
  2043. { 6, NULL },
  2044. { 8, NULL },
  2045. };
  2046. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2047. struct snd_ctl_elem_info *uinfo)
  2048. {
  2049. static char *texts[] = {
  2050. "N/A", "Line Out", "HP Out",
  2051. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2052. };
  2053. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2054. uinfo->count = 1;
  2055. uinfo->value.enumerated.items = 8;
  2056. if (uinfo->value.enumerated.item >= 8)
  2057. uinfo->value.enumerated.item = 7;
  2058. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2059. return 0;
  2060. }
  2061. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2062. struct snd_ctl_elem_value *ucontrol)
  2063. {
  2064. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2065. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2066. unsigned int pin_ctl, item = 0;
  2067. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2068. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2069. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2070. if (pin_ctl & AC_PINCTL_HP_EN)
  2071. item = 2;
  2072. else
  2073. item = 1;
  2074. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2075. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2076. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2077. case AC_PINCTL_VREF_50: item = 4; break;
  2078. case AC_PINCTL_VREF_GRD: item = 5; break;
  2079. case AC_PINCTL_VREF_80: item = 6; break;
  2080. case AC_PINCTL_VREF_100: item = 7; break;
  2081. }
  2082. }
  2083. ucontrol->value.enumerated.item[0] = item;
  2084. return 0;
  2085. }
  2086. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2087. struct snd_ctl_elem_value *ucontrol)
  2088. {
  2089. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2090. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2091. static unsigned int ctls[] = {
  2092. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2093. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2094. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2095. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2096. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2097. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2098. };
  2099. unsigned int old_ctl, new_ctl;
  2100. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2101. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2102. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2103. if (old_ctl != new_ctl) {
  2104. snd_hda_codec_write(codec, nid, 0,
  2105. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2106. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2107. (ucontrol->value.enumerated.item[0] >= 3 ?
  2108. 0xb080 : 0xb000));
  2109. return 1;
  2110. }
  2111. return 0;
  2112. }
  2113. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2114. struct snd_ctl_elem_info *uinfo)
  2115. {
  2116. static char *texts[] = {
  2117. "Front", "Surround", "CLFE", "Side"
  2118. };
  2119. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2120. uinfo->count = 1;
  2121. uinfo->value.enumerated.items = 4;
  2122. if (uinfo->value.enumerated.item >= 4)
  2123. uinfo->value.enumerated.item = 3;
  2124. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2125. return 0;
  2126. }
  2127. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2128. struct snd_ctl_elem_value *ucontrol)
  2129. {
  2130. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2131. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2132. unsigned int sel;
  2133. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2134. ucontrol->value.enumerated.item[0] = sel & 3;
  2135. return 0;
  2136. }
  2137. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2138. struct snd_ctl_elem_value *ucontrol)
  2139. {
  2140. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2141. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2142. unsigned int sel;
  2143. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2144. if (ucontrol->value.enumerated.item[0] != sel) {
  2145. sel = ucontrol->value.enumerated.item[0] & 3;
  2146. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2147. return 1;
  2148. }
  2149. return 0;
  2150. }
  2151. #define PIN_CTL_TEST(xname,nid) { \
  2152. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2153. .name = xname, \
  2154. .info = alc_test_pin_ctl_info, \
  2155. .get = alc_test_pin_ctl_get, \
  2156. .put = alc_test_pin_ctl_put, \
  2157. .private_value = nid \
  2158. }
  2159. #define PIN_SRC_TEST(xname,nid) { \
  2160. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2161. .name = xname, \
  2162. .info = alc_test_pin_src_info, \
  2163. .get = alc_test_pin_src_get, \
  2164. .put = alc_test_pin_src_put, \
  2165. .private_value = nid \
  2166. }
  2167. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2168. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2169. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2170. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2171. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2172. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2173. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2174. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2175. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2176. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2177. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2178. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2179. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2180. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2181. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2182. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2183. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2184. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2185. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2186. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2187. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2188. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2189. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2190. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2191. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2192. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2193. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2194. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2195. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2196. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2197. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2198. {
  2199. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2200. .name = "Channel Mode",
  2201. .info = alc_ch_mode_info,
  2202. .get = alc_ch_mode_get,
  2203. .put = alc_ch_mode_put,
  2204. },
  2205. { } /* end */
  2206. };
  2207. static struct hda_verb alc880_test_init_verbs[] = {
  2208. /* Unmute inputs of 0x0c - 0x0f */
  2209. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2210. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2211. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2212. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2213. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2214. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2215. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2216. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2217. /* Vol output for 0x0c-0x0f */
  2218. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2219. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2220. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2221. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2222. /* Set output pins 0x14-0x17 */
  2223. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2224. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2225. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2226. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2227. /* Unmute output pins 0x14-0x17 */
  2228. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2229. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2230. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2231. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2232. /* Set input pins 0x18-0x1c */
  2233. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2234. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2236. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2237. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2238. /* Mute input pins 0x18-0x1b */
  2239. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2240. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2241. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2242. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2243. /* ADC set up */
  2244. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2245. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2246. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2247. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2248. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2249. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2250. /* Analog input/passthru */
  2251. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2252. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2253. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2254. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2255. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2256. { }
  2257. };
  2258. #endif
  2259. /*
  2260. */
  2261. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2262. [ALC880_3ST] = "3stack",
  2263. [ALC880_TCL_S700] = "tcl",
  2264. [ALC880_3ST_DIG] = "3stack-digout",
  2265. [ALC880_CLEVO] = "clevo",
  2266. [ALC880_5ST] = "5stack",
  2267. [ALC880_5ST_DIG] = "5stack-digout",
  2268. [ALC880_W810] = "w810",
  2269. [ALC880_Z71V] = "z71v",
  2270. [ALC880_6ST] = "6stack",
  2271. [ALC880_6ST_DIG] = "6stack-digout",
  2272. [ALC880_ASUS] = "asus",
  2273. [ALC880_ASUS_W1V] = "asus-w1v",
  2274. [ALC880_ASUS_DIG] = "asus-dig",
  2275. [ALC880_ASUS_DIG2] = "asus-dig2",
  2276. [ALC880_UNIWILL_DIG] = "uniwill",
  2277. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2278. [ALC880_FUJITSU] = "fujitsu",
  2279. [ALC880_F1734] = "F1734",
  2280. [ALC880_LG] = "lg",
  2281. [ALC880_LG_LW] = "lg-lw",
  2282. #ifdef CONFIG_SND_DEBUG
  2283. [ALC880_TEST] = "test",
  2284. #endif
  2285. [ALC880_AUTO] = "auto",
  2286. };
  2287. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2288. /* Broken BIOS configuration */
  2289. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2290. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2291. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2292. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2293. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2294. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2295. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2296. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2297. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2298. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2299. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2300. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2301. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2302. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2303. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2304. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2305. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2306. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2307. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2308. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2309. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2310. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2311. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2312. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2313. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2314. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2315. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2316. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2317. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2318. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2319. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2320. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2321. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2322. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2323. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2324. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2325. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2326. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2327. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2328. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2329. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2330. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2331. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2332. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2333. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2334. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2335. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2336. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2337. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2338. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2339. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2340. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2341. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2342. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2343. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2344. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2345. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2346. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2347. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2348. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2349. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2350. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2351. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2352. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2353. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2354. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2355. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2356. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2357. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2358. {}
  2359. };
  2360. /*
  2361. * ALC880 codec presets
  2362. */
  2363. static struct alc_config_preset alc880_presets[] = {
  2364. [ALC880_3ST] = {
  2365. .mixers = { alc880_three_stack_mixer },
  2366. .init_verbs = { alc880_volume_init_verbs,
  2367. alc880_pin_3stack_init_verbs },
  2368. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2369. .dac_nids = alc880_dac_nids,
  2370. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2371. .channel_mode = alc880_threestack_modes,
  2372. .need_dac_fix = 1,
  2373. .input_mux = &alc880_capture_source,
  2374. },
  2375. [ALC880_3ST_DIG] = {
  2376. .mixers = { alc880_three_stack_mixer },
  2377. .init_verbs = { alc880_volume_init_verbs,
  2378. alc880_pin_3stack_init_verbs },
  2379. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2380. .dac_nids = alc880_dac_nids,
  2381. .dig_out_nid = ALC880_DIGOUT_NID,
  2382. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2383. .channel_mode = alc880_threestack_modes,
  2384. .need_dac_fix = 1,
  2385. .input_mux = &alc880_capture_source,
  2386. },
  2387. [ALC880_TCL_S700] = {
  2388. .mixers = { alc880_tcl_s700_mixer },
  2389. .init_verbs = { alc880_volume_init_verbs,
  2390. alc880_pin_tcl_S700_init_verbs,
  2391. alc880_gpio2_init_verbs },
  2392. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2393. .dac_nids = alc880_dac_nids,
  2394. .hp_nid = 0x03,
  2395. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2396. .channel_mode = alc880_2_jack_modes,
  2397. .input_mux = &alc880_capture_source,
  2398. },
  2399. [ALC880_5ST] = {
  2400. .mixers = { alc880_three_stack_mixer,
  2401. alc880_five_stack_mixer},
  2402. .init_verbs = { alc880_volume_init_verbs,
  2403. alc880_pin_5stack_init_verbs },
  2404. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2405. .dac_nids = alc880_dac_nids,
  2406. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2407. .channel_mode = alc880_fivestack_modes,
  2408. .input_mux = &alc880_capture_source,
  2409. },
  2410. [ALC880_5ST_DIG] = {
  2411. .mixers = { alc880_three_stack_mixer,
  2412. alc880_five_stack_mixer },
  2413. .init_verbs = { alc880_volume_init_verbs,
  2414. alc880_pin_5stack_init_verbs },
  2415. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2416. .dac_nids = alc880_dac_nids,
  2417. .dig_out_nid = ALC880_DIGOUT_NID,
  2418. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2419. .channel_mode = alc880_fivestack_modes,
  2420. .input_mux = &alc880_capture_source,
  2421. },
  2422. [ALC880_6ST] = {
  2423. .mixers = { alc880_six_stack_mixer },
  2424. .init_verbs = { alc880_volume_init_verbs,
  2425. alc880_pin_6stack_init_verbs },
  2426. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2427. .dac_nids = alc880_6st_dac_nids,
  2428. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2429. .channel_mode = alc880_sixstack_modes,
  2430. .input_mux = &alc880_6stack_capture_source,
  2431. },
  2432. [ALC880_6ST_DIG] = {
  2433. .mixers = { alc880_six_stack_mixer },
  2434. .init_verbs = { alc880_volume_init_verbs,
  2435. alc880_pin_6stack_init_verbs },
  2436. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2437. .dac_nids = alc880_6st_dac_nids,
  2438. .dig_out_nid = ALC880_DIGOUT_NID,
  2439. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2440. .channel_mode = alc880_sixstack_modes,
  2441. .input_mux = &alc880_6stack_capture_source,
  2442. },
  2443. [ALC880_W810] = {
  2444. .mixers = { alc880_w810_base_mixer },
  2445. .init_verbs = { alc880_volume_init_verbs,
  2446. alc880_pin_w810_init_verbs,
  2447. alc880_gpio2_init_verbs },
  2448. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2449. .dac_nids = alc880_w810_dac_nids,
  2450. .dig_out_nid = ALC880_DIGOUT_NID,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2452. .channel_mode = alc880_w810_modes,
  2453. .input_mux = &alc880_capture_source,
  2454. },
  2455. [ALC880_Z71V] = {
  2456. .mixers = { alc880_z71v_mixer },
  2457. .init_verbs = { alc880_volume_init_verbs,
  2458. alc880_pin_z71v_init_verbs },
  2459. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2460. .dac_nids = alc880_z71v_dac_nids,
  2461. .dig_out_nid = ALC880_DIGOUT_NID,
  2462. .hp_nid = 0x03,
  2463. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2464. .channel_mode = alc880_2_jack_modes,
  2465. .input_mux = &alc880_capture_source,
  2466. },
  2467. [ALC880_F1734] = {
  2468. .mixers = { alc880_f1734_mixer },
  2469. .init_verbs = { alc880_volume_init_verbs,
  2470. alc880_pin_f1734_init_verbs },
  2471. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2472. .dac_nids = alc880_f1734_dac_nids,
  2473. .hp_nid = 0x02,
  2474. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2475. .channel_mode = alc880_2_jack_modes,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_ASUS] = {
  2479. .mixers = { alc880_asus_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_asus_init_verbs,
  2482. alc880_gpio1_init_verbs },
  2483. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2484. .dac_nids = alc880_asus_dac_nids,
  2485. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2486. .channel_mode = alc880_asus_modes,
  2487. .need_dac_fix = 1,
  2488. .input_mux = &alc880_capture_source,
  2489. },
  2490. [ALC880_ASUS_DIG] = {
  2491. .mixers = { alc880_asus_mixer },
  2492. .init_verbs = { alc880_volume_init_verbs,
  2493. alc880_pin_asus_init_verbs,
  2494. alc880_gpio1_init_verbs },
  2495. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2496. .dac_nids = alc880_asus_dac_nids,
  2497. .dig_out_nid = ALC880_DIGOUT_NID,
  2498. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2499. .channel_mode = alc880_asus_modes,
  2500. .need_dac_fix = 1,
  2501. .input_mux = &alc880_capture_source,
  2502. },
  2503. [ALC880_ASUS_DIG2] = {
  2504. .mixers = { alc880_asus_mixer },
  2505. .init_verbs = { alc880_volume_init_verbs,
  2506. alc880_pin_asus_init_verbs,
  2507. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2508. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2509. .dac_nids = alc880_asus_dac_nids,
  2510. .dig_out_nid = ALC880_DIGOUT_NID,
  2511. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2512. .channel_mode = alc880_asus_modes,
  2513. .need_dac_fix = 1,
  2514. .input_mux = &alc880_capture_source,
  2515. },
  2516. [ALC880_ASUS_W1V] = {
  2517. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2518. .init_verbs = { alc880_volume_init_verbs,
  2519. alc880_pin_asus_init_verbs,
  2520. alc880_gpio1_init_verbs },
  2521. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2522. .dac_nids = alc880_asus_dac_nids,
  2523. .dig_out_nid = ALC880_DIGOUT_NID,
  2524. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2525. .channel_mode = alc880_asus_modes,
  2526. .need_dac_fix = 1,
  2527. .input_mux = &alc880_capture_source,
  2528. },
  2529. [ALC880_UNIWILL_DIG] = {
  2530. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2531. .init_verbs = { alc880_volume_init_verbs,
  2532. alc880_pin_asus_init_verbs },
  2533. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2534. .dac_nids = alc880_asus_dac_nids,
  2535. .dig_out_nid = ALC880_DIGOUT_NID,
  2536. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2537. .channel_mode = alc880_asus_modes,
  2538. .need_dac_fix = 1,
  2539. .input_mux = &alc880_capture_source,
  2540. },
  2541. [ALC880_UNIWILL] = {
  2542. .mixers = { alc880_uniwill_mixer },
  2543. .init_verbs = { alc880_volume_init_verbs,
  2544. alc880_uniwill_init_verbs },
  2545. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2546. .dac_nids = alc880_asus_dac_nids,
  2547. .dig_out_nid = ALC880_DIGOUT_NID,
  2548. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2549. .channel_mode = alc880_threestack_modes,
  2550. .need_dac_fix = 1,
  2551. .input_mux = &alc880_capture_source,
  2552. .unsol_event = alc880_uniwill_unsol_event,
  2553. .init_hook = alc880_uniwill_automute,
  2554. },
  2555. [ALC880_UNIWILL_P53] = {
  2556. .mixers = { alc880_uniwill_p53_mixer },
  2557. .init_verbs = { alc880_volume_init_verbs,
  2558. alc880_uniwill_p53_init_verbs },
  2559. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2560. .dac_nids = alc880_asus_dac_nids,
  2561. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2562. .channel_mode = alc880_threestack_modes,
  2563. .input_mux = &alc880_capture_source,
  2564. .unsol_event = alc880_uniwill_p53_unsol_event,
  2565. .init_hook = alc880_uniwill_p53_hp_automute,
  2566. },
  2567. [ALC880_FUJITSU] = {
  2568. .mixers = { alc880_fujitsu_mixer,
  2569. alc880_pcbeep_mixer, },
  2570. .init_verbs = { alc880_volume_init_verbs,
  2571. alc880_uniwill_p53_init_verbs,
  2572. alc880_beep_init_verbs },
  2573. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2574. .dac_nids = alc880_dac_nids,
  2575. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2576. .channel_mode = alc880_2_jack_modes,
  2577. .input_mux = &alc880_capture_source,
  2578. .unsol_event = alc880_uniwill_p53_unsol_event,
  2579. .init_hook = alc880_uniwill_p53_hp_automute,
  2580. },
  2581. [ALC880_CLEVO] = {
  2582. .mixers = { alc880_three_stack_mixer },
  2583. .init_verbs = { alc880_volume_init_verbs,
  2584. alc880_pin_clevo_init_verbs },
  2585. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2586. .dac_nids = alc880_dac_nids,
  2587. .hp_nid = 0x03,
  2588. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2589. .channel_mode = alc880_threestack_modes,
  2590. .need_dac_fix = 1,
  2591. .input_mux = &alc880_capture_source,
  2592. },
  2593. [ALC880_LG] = {
  2594. .mixers = { alc880_lg_mixer },
  2595. .init_verbs = { alc880_volume_init_verbs,
  2596. alc880_lg_init_verbs },
  2597. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2598. .dac_nids = alc880_lg_dac_nids,
  2599. .dig_out_nid = ALC880_DIGOUT_NID,
  2600. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2601. .channel_mode = alc880_lg_ch_modes,
  2602. .need_dac_fix = 1,
  2603. .input_mux = &alc880_lg_capture_source,
  2604. .unsol_event = alc880_lg_unsol_event,
  2605. .init_hook = alc880_lg_automute,
  2606. },
  2607. [ALC880_LG_LW] = {
  2608. .mixers = { alc880_lg_lw_mixer },
  2609. .init_verbs = { alc880_volume_init_verbs,
  2610. alc880_lg_lw_init_verbs },
  2611. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2612. .dac_nids = alc880_dac_nids,
  2613. .dig_out_nid = ALC880_DIGOUT_NID,
  2614. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2615. .channel_mode = alc880_lg_lw_modes,
  2616. .input_mux = &alc880_lg_lw_capture_source,
  2617. .unsol_event = alc880_lg_lw_unsol_event,
  2618. .init_hook = alc880_lg_lw_automute,
  2619. },
  2620. #ifdef CONFIG_SND_DEBUG
  2621. [ALC880_TEST] = {
  2622. .mixers = { alc880_test_mixer },
  2623. .init_verbs = { alc880_test_init_verbs },
  2624. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2625. .dac_nids = alc880_test_dac_nids,
  2626. .dig_out_nid = ALC880_DIGOUT_NID,
  2627. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2628. .channel_mode = alc880_test_modes,
  2629. .input_mux = &alc880_test_capture_source,
  2630. },
  2631. #endif
  2632. };
  2633. /*
  2634. * Automatic parse of I/O pins from the BIOS configuration
  2635. */
  2636. #define NUM_CONTROL_ALLOC 32
  2637. #define NUM_VERB_ALLOC 32
  2638. enum {
  2639. ALC_CTL_WIDGET_VOL,
  2640. ALC_CTL_WIDGET_MUTE,
  2641. ALC_CTL_BIND_MUTE,
  2642. };
  2643. static struct snd_kcontrol_new alc880_control_templates[] = {
  2644. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2645. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2646. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2647. };
  2648. /* add dynamic controls */
  2649. static int add_control(struct alc_spec *spec, int type, const char *name,
  2650. unsigned long val)
  2651. {
  2652. struct snd_kcontrol_new *knew;
  2653. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2654. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2655. /* array + terminator */
  2656. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2657. if (!knew)
  2658. return -ENOMEM;
  2659. if (spec->kctl_alloc) {
  2660. memcpy(knew, spec->kctl_alloc,
  2661. sizeof(*knew) * spec->num_kctl_alloc);
  2662. kfree(spec->kctl_alloc);
  2663. }
  2664. spec->kctl_alloc = knew;
  2665. spec->num_kctl_alloc = num;
  2666. }
  2667. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2668. *knew = alc880_control_templates[type];
  2669. knew->name = kstrdup(name, GFP_KERNEL);
  2670. if (!knew->name)
  2671. return -ENOMEM;
  2672. knew->private_value = val;
  2673. spec->num_kctl_used++;
  2674. return 0;
  2675. }
  2676. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2677. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2678. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2679. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2680. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2681. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2682. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2683. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2684. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2685. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2686. #define ALC880_PIN_CD_NID 0x1c
  2687. /* fill in the dac_nids table from the parsed pin configuration */
  2688. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2689. const struct auto_pin_cfg *cfg)
  2690. {
  2691. hda_nid_t nid;
  2692. int assigned[4];
  2693. int i, j;
  2694. memset(assigned, 0, sizeof(assigned));
  2695. spec->multiout.dac_nids = spec->private_dac_nids;
  2696. /* check the pins hardwired to audio widget */
  2697. for (i = 0; i < cfg->line_outs; i++) {
  2698. nid = cfg->line_out_pins[i];
  2699. if (alc880_is_fixed_pin(nid)) {
  2700. int idx = alc880_fixed_pin_idx(nid);
  2701. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2702. assigned[idx] = 1;
  2703. }
  2704. }
  2705. /* left pins can be connect to any audio widget */
  2706. for (i = 0; i < cfg->line_outs; i++) {
  2707. nid = cfg->line_out_pins[i];
  2708. if (alc880_is_fixed_pin(nid))
  2709. continue;
  2710. /* search for an empty channel */
  2711. for (j = 0; j < cfg->line_outs; j++) {
  2712. if (!assigned[j]) {
  2713. spec->multiout.dac_nids[i] =
  2714. alc880_idx_to_dac(j);
  2715. assigned[j] = 1;
  2716. break;
  2717. }
  2718. }
  2719. }
  2720. spec->multiout.num_dacs = cfg->line_outs;
  2721. return 0;
  2722. }
  2723. /* add playback controls from the parsed DAC table */
  2724. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2725. const struct auto_pin_cfg *cfg)
  2726. {
  2727. char name[32];
  2728. static const char *chname[4] = {
  2729. "Front", "Surround", NULL /*CLFE*/, "Side"
  2730. };
  2731. hda_nid_t nid;
  2732. int i, err;
  2733. for (i = 0; i < cfg->line_outs; i++) {
  2734. if (!spec->multiout.dac_nids[i])
  2735. continue;
  2736. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2737. if (i == 2) {
  2738. /* Center/LFE */
  2739. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2740. "Center Playback Volume",
  2741. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2742. HDA_OUTPUT));
  2743. if (err < 0)
  2744. return err;
  2745. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2746. "LFE Playback Volume",
  2747. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2748. HDA_OUTPUT));
  2749. if (err < 0)
  2750. return err;
  2751. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2752. "Center Playback Switch",
  2753. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2754. HDA_INPUT));
  2755. if (err < 0)
  2756. return err;
  2757. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2758. "LFE Playback Switch",
  2759. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2760. HDA_INPUT));
  2761. if (err < 0)
  2762. return err;
  2763. } else {
  2764. sprintf(name, "%s Playback Volume", chname[i]);
  2765. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2766. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2767. HDA_OUTPUT));
  2768. if (err < 0)
  2769. return err;
  2770. sprintf(name, "%s Playback Switch", chname[i]);
  2771. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2772. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2773. HDA_INPUT));
  2774. if (err < 0)
  2775. return err;
  2776. }
  2777. }
  2778. return 0;
  2779. }
  2780. /* add playback controls for speaker and HP outputs */
  2781. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2782. const char *pfx)
  2783. {
  2784. hda_nid_t nid;
  2785. int err;
  2786. char name[32];
  2787. if (!pin)
  2788. return 0;
  2789. if (alc880_is_fixed_pin(pin)) {
  2790. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2791. /* specify the DAC as the extra output */
  2792. if (!spec->multiout.hp_nid)
  2793. spec->multiout.hp_nid = nid;
  2794. else
  2795. spec->multiout.extra_out_nid[0] = nid;
  2796. /* control HP volume/switch on the output mixer amp */
  2797. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2798. sprintf(name, "%s Playback Volume", pfx);
  2799. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2800. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2801. if (err < 0)
  2802. return err;
  2803. sprintf(name, "%s Playback Switch", pfx);
  2804. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2805. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2806. if (err < 0)
  2807. return err;
  2808. } else if (alc880_is_multi_pin(pin)) {
  2809. /* set manual connection */
  2810. /* we have only a switch on HP-out PIN */
  2811. sprintf(name, "%s Playback Switch", pfx);
  2812. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2813. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2814. if (err < 0)
  2815. return err;
  2816. }
  2817. return 0;
  2818. }
  2819. /* create input playback/capture controls for the given pin */
  2820. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2821. const char *ctlname,
  2822. int idx, hda_nid_t mix_nid)
  2823. {
  2824. char name[32];
  2825. int err;
  2826. sprintf(name, "%s Playback Volume", ctlname);
  2827. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2828. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2829. if (err < 0)
  2830. return err;
  2831. sprintf(name, "%s Playback Switch", ctlname);
  2832. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2833. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2834. if (err < 0)
  2835. return err;
  2836. return 0;
  2837. }
  2838. /* create playback/capture controls for input pins */
  2839. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2840. const struct auto_pin_cfg *cfg)
  2841. {
  2842. struct hda_input_mux *imux = &spec->private_imux;
  2843. int i, err, idx;
  2844. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2845. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2846. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2847. err = new_analog_input(spec, cfg->input_pins[i],
  2848. auto_pin_cfg_labels[i],
  2849. idx, 0x0b);
  2850. if (err < 0)
  2851. return err;
  2852. imux->items[imux->num_items].label =
  2853. auto_pin_cfg_labels[i];
  2854. imux->items[imux->num_items].index =
  2855. alc880_input_pin_idx(cfg->input_pins[i]);
  2856. imux->num_items++;
  2857. }
  2858. }
  2859. return 0;
  2860. }
  2861. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2862. hda_nid_t nid, int pin_type,
  2863. int dac_idx)
  2864. {
  2865. /* set as output */
  2866. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2867. pin_type);
  2868. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2869. AMP_OUT_UNMUTE);
  2870. /* need the manual connection? */
  2871. if (alc880_is_multi_pin(nid)) {
  2872. struct alc_spec *spec = codec->spec;
  2873. int idx = alc880_multi_pin_idx(nid);
  2874. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2875. AC_VERB_SET_CONNECT_SEL,
  2876. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2877. }
  2878. }
  2879. static int get_pin_type(int line_out_type)
  2880. {
  2881. if (line_out_type == AUTO_PIN_HP_OUT)
  2882. return PIN_HP;
  2883. else
  2884. return PIN_OUT;
  2885. }
  2886. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2887. {
  2888. struct alc_spec *spec = codec->spec;
  2889. int i;
  2890. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2891. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2892. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2893. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2894. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2895. }
  2896. }
  2897. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2898. {
  2899. struct alc_spec *spec = codec->spec;
  2900. hda_nid_t pin;
  2901. pin = spec->autocfg.speaker_pins[0];
  2902. if (pin) /* connect to front */
  2903. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2904. pin = spec->autocfg.hp_pins[0];
  2905. if (pin) /* connect to front */
  2906. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2907. }
  2908. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2909. {
  2910. struct alc_spec *spec = codec->spec;
  2911. int i;
  2912. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2913. hda_nid_t nid = spec->autocfg.input_pins[i];
  2914. if (alc880_is_input_pin(nid)) {
  2915. snd_hda_codec_write(codec, nid, 0,
  2916. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2917. i <= AUTO_PIN_FRONT_MIC ?
  2918. PIN_VREF80 : PIN_IN);
  2919. if (nid != ALC880_PIN_CD_NID)
  2920. snd_hda_codec_write(codec, nid, 0,
  2921. AC_VERB_SET_AMP_GAIN_MUTE,
  2922. AMP_OUT_MUTE);
  2923. }
  2924. }
  2925. }
  2926. /* parse the BIOS configuration and set up the alc_spec */
  2927. /* return 1 if successful, 0 if the proper config is not found,
  2928. * or a negative error code
  2929. */
  2930. static int alc880_parse_auto_config(struct hda_codec *codec)
  2931. {
  2932. struct alc_spec *spec = codec->spec;
  2933. int err;
  2934. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2935. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2936. alc880_ignore);
  2937. if (err < 0)
  2938. return err;
  2939. if (!spec->autocfg.line_outs)
  2940. return 0; /* can't find valid BIOS pin config */
  2941. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2942. if (err < 0)
  2943. return err;
  2944. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2945. if (err < 0)
  2946. return err;
  2947. err = alc880_auto_create_extra_out(spec,
  2948. spec->autocfg.speaker_pins[0],
  2949. "Speaker");
  2950. if (err < 0)
  2951. return err;
  2952. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2953. "Headphone");
  2954. if (err < 0)
  2955. return err;
  2956. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2957. if (err < 0)
  2958. return err;
  2959. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2960. if (spec->autocfg.dig_out_pin)
  2961. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2962. if (spec->autocfg.dig_in_pin)
  2963. spec->dig_in_nid = ALC880_DIGIN_NID;
  2964. if (spec->kctl_alloc)
  2965. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2966. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2967. spec->num_mux_defs = 1;
  2968. spec->input_mux = &spec->private_imux;
  2969. return 1;
  2970. }
  2971. /* additional initialization for auto-configuration model */
  2972. static void alc880_auto_init(struct hda_codec *codec)
  2973. {
  2974. alc880_auto_init_multi_out(codec);
  2975. alc880_auto_init_extra_out(codec);
  2976. alc880_auto_init_analog_input(codec);
  2977. }
  2978. /*
  2979. * OK, here we have finally the patch for ALC880
  2980. */
  2981. static int patch_alc880(struct hda_codec *codec)
  2982. {
  2983. struct alc_spec *spec;
  2984. int board_config;
  2985. int err;
  2986. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2987. if (spec == NULL)
  2988. return -ENOMEM;
  2989. codec->spec = spec;
  2990. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2991. alc880_models,
  2992. alc880_cfg_tbl);
  2993. if (board_config < 0) {
  2994. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2995. "trying auto-probe from BIOS...\n");
  2996. board_config = ALC880_AUTO;
  2997. }
  2998. if (board_config == ALC880_AUTO) {
  2999. /* automatic parse from the BIOS config */
  3000. err = alc880_parse_auto_config(codec);
  3001. if (err < 0) {
  3002. alc_free(codec);
  3003. return err;
  3004. } else if (!err) {
  3005. printk(KERN_INFO
  3006. "hda_codec: Cannot set up configuration "
  3007. "from BIOS. Using 3-stack mode...\n");
  3008. board_config = ALC880_3ST;
  3009. }
  3010. }
  3011. if (board_config != ALC880_AUTO)
  3012. setup_preset(spec, &alc880_presets[board_config]);
  3013. spec->stream_name_analog = "ALC880 Analog";
  3014. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3015. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3016. spec->stream_name_digital = "ALC880 Digital";
  3017. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3018. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3019. if (!spec->adc_nids && spec->input_mux) {
  3020. /* check whether NID 0x07 is valid */
  3021. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3022. /* get type */
  3023. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3024. if (wcap != AC_WID_AUD_IN) {
  3025. spec->adc_nids = alc880_adc_nids_alt;
  3026. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3027. spec->mixers[spec->num_mixers] =
  3028. alc880_capture_alt_mixer;
  3029. spec->num_mixers++;
  3030. } else {
  3031. spec->adc_nids = alc880_adc_nids;
  3032. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3033. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3034. spec->num_mixers++;
  3035. }
  3036. }
  3037. codec->patch_ops = alc_patch_ops;
  3038. if (board_config == ALC880_AUTO)
  3039. spec->init_hook = alc880_auto_init;
  3040. return 0;
  3041. }
  3042. /*
  3043. * ALC260 support
  3044. */
  3045. static hda_nid_t alc260_dac_nids[1] = {
  3046. /* front */
  3047. 0x02,
  3048. };
  3049. static hda_nid_t alc260_adc_nids[1] = {
  3050. /* ADC0 */
  3051. 0x04,
  3052. };
  3053. static hda_nid_t alc260_adc_nids_alt[1] = {
  3054. /* ADC1 */
  3055. 0x05,
  3056. };
  3057. static hda_nid_t alc260_hp_adc_nids[2] = {
  3058. /* ADC1, 0 */
  3059. 0x05, 0x04
  3060. };
  3061. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3062. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3063. */
  3064. static hda_nid_t alc260_dual_adc_nids[2] = {
  3065. /* ADC0, ADC1 */
  3066. 0x04, 0x05
  3067. };
  3068. #define ALC260_DIGOUT_NID 0x03
  3069. #define ALC260_DIGIN_NID 0x06
  3070. static struct hda_input_mux alc260_capture_source = {
  3071. .num_items = 4,
  3072. .items = {
  3073. { "Mic", 0x0 },
  3074. { "Front Mic", 0x1 },
  3075. { "Line", 0x2 },
  3076. { "CD", 0x4 },
  3077. },
  3078. };
  3079. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3080. * headphone jack and the internal CD lines since these are the only pins at
  3081. * which audio can appear. For flexibility, also allow the option of
  3082. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3083. * connection to the mixer output).
  3084. */
  3085. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3086. {
  3087. .num_items = 3,
  3088. .items = {
  3089. { "Mic/Line", 0x0 },
  3090. { "CD", 0x4 },
  3091. { "Headphone", 0x2 },
  3092. },
  3093. },
  3094. {
  3095. .num_items = 4,
  3096. .items = {
  3097. { "Mic/Line", 0x0 },
  3098. { "CD", 0x4 },
  3099. { "Headphone", 0x2 },
  3100. { "Mixer", 0x5 },
  3101. },
  3102. },
  3103. };
  3104. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3105. * the Fujitsu S702x, but jacks are marked differently.
  3106. */
  3107. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3108. {
  3109. .num_items = 4,
  3110. .items = {
  3111. { "Mic", 0x0 },
  3112. { "Line", 0x2 },
  3113. { "CD", 0x4 },
  3114. { "Headphone", 0x5 },
  3115. },
  3116. },
  3117. {
  3118. .num_items = 5,
  3119. .items = {
  3120. { "Mic", 0x0 },
  3121. { "Line", 0x2 },
  3122. { "CD", 0x4 },
  3123. { "Headphone", 0x6 },
  3124. { "Mixer", 0x5 },
  3125. },
  3126. },
  3127. };
  3128. /*
  3129. * This is just place-holder, so there's something for alc_build_pcms to look
  3130. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3131. * element which allows changing the channel mode, so the verb list is
  3132. * never used.
  3133. */
  3134. static struct hda_channel_mode alc260_modes[1] = {
  3135. { 2, NULL },
  3136. };
  3137. /* Mixer combinations
  3138. *
  3139. * basic: base_output + input + pc_beep + capture
  3140. * HP: base_output + input + capture_alt
  3141. * HP_3013: hp_3013 + input + capture
  3142. * fujitsu: fujitsu + capture
  3143. * acer: acer + capture
  3144. */
  3145. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3146. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3147. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3148. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3149. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3150. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3151. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3152. { } /* end */
  3153. };
  3154. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3155. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3156. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3157. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3158. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3159. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3160. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3161. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3162. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3163. { } /* end */
  3164. };
  3165. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3166. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3167. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3168. { } /* end */
  3169. };
  3170. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3171. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3172. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3173. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3174. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3175. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3176. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3177. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3178. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3179. { } /* end */
  3180. };
  3181. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3182. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3183. */
  3184. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3185. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3186. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3187. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3188. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3189. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3193. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3195. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3196. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3197. { } /* end */
  3198. };
  3199. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3200. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3201. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3202. * datasheet doesn't mention this restriction. At this stage it's not clear
  3203. * whether this behaviour is intentional or is a hardware bug in chip
  3204. * revisions available in early 2006. Therefore for now allow the
  3205. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3206. * that the lack of mic bias for this NID is intentional we could change the
  3207. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3208. *
  3209. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3210. * don't appear to make the mic bias available from the "line" jack, even
  3211. * though the NID used for this jack (0x14) can supply it. The theory is
  3212. * that perhaps Acer have included blocking capacitors between the ALC260
  3213. * and the output jack. If this turns out to be the case for all such
  3214. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3215. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3216. *
  3217. * The C20x Tablet series have a mono internal speaker which is controlled
  3218. * via the chip's Mono sum widget and pin complex, so include the necessary
  3219. * controls for such models. On models without a "mono speaker" the control
  3220. * won't do anything.
  3221. */
  3222. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3223. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3224. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3225. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3226. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3227. HDA_OUTPUT),
  3228. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3229. HDA_INPUT),
  3230. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3231. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3232. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3233. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3234. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3235. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3236. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3237. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3238. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3239. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3240. { } /* end */
  3241. };
  3242. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3243. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3244. */
  3245. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3246. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3247. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3248. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3249. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3250. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3251. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3252. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3253. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3254. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3255. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3256. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3257. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3258. { } /* end */
  3259. };
  3260. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3261. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3262. */
  3263. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3264. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3265. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3266. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3268. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3269. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3270. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3271. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3272. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3273. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3274. { } /* end */
  3275. };
  3276. /* capture mixer elements */
  3277. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3278. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3279. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3280. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3282. {
  3283. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3284. /* The multiple "Capture Source" controls confuse alsamixer
  3285. * So call somewhat different..
  3286. * FIXME: the controls appear in the "playback" view!
  3287. */
  3288. /* .name = "Capture Source", */
  3289. .name = "Input Source",
  3290. .count = 2,
  3291. .info = alc_mux_enum_info,
  3292. .get = alc_mux_enum_get,
  3293. .put = alc_mux_enum_put,
  3294. },
  3295. { } /* end */
  3296. };
  3297. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3298. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3299. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3300. {
  3301. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3302. /* The multiple "Capture Source" controls confuse alsamixer
  3303. * So call somewhat different..
  3304. * FIXME: the controls appear in the "playback" view!
  3305. */
  3306. /* .name = "Capture Source", */
  3307. .name = "Input Source",
  3308. .count = 1,
  3309. .info = alc_mux_enum_info,
  3310. .get = alc_mux_enum_get,
  3311. .put = alc_mux_enum_put,
  3312. },
  3313. { } /* end */
  3314. };
  3315. /*
  3316. * initialization verbs
  3317. */
  3318. static struct hda_verb alc260_init_verbs[] = {
  3319. /* Line In pin widget for input */
  3320. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3321. /* CD pin widget for input */
  3322. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3323. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3324. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3325. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3326. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3327. /* LINE-2 is used for line-out in rear */
  3328. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3329. /* select line-out */
  3330. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3331. /* LINE-OUT pin */
  3332. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3333. /* enable HP */
  3334. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3335. /* enable Mono */
  3336. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3337. /* mute capture amp left and right */
  3338. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3339. /* set connection select to line in (default select for this ADC) */
  3340. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3341. /* mute capture amp left and right */
  3342. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3343. /* set connection select to line in (default select for this ADC) */
  3344. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3345. /* set vol=0 Line-Out mixer amp left and right */
  3346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3347. /* unmute pin widget amp left and right (no gain on this amp) */
  3348. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3349. /* set vol=0 HP mixer amp left and right */
  3350. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3351. /* unmute pin widget amp left and right (no gain on this amp) */
  3352. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3353. /* set vol=0 Mono mixer amp left and right */
  3354. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3355. /* unmute pin widget amp left and right (no gain on this amp) */
  3356. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3357. /* unmute LINE-2 out pin */
  3358. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3359. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3360. * Line In 2 = 0x03
  3361. */
  3362. /* mute CD */
  3363. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3364. /* mute Line In */
  3365. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3366. /* mute Mic */
  3367. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3368. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3369. /* mute Front out path */
  3370. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3371. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3372. /* mute Headphone out path */
  3373. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3374. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3375. /* mute Mono out path */
  3376. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3377. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3378. { }
  3379. };
  3380. #if 0 /* should be identical with alc260_init_verbs? */
  3381. static struct hda_verb alc260_hp_init_verbs[] = {
  3382. /* Headphone and output */
  3383. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3384. /* mono output */
  3385. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3386. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3387. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3388. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3389. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3390. /* Line In pin widget for input */
  3391. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3392. /* Line-2 pin widget for output */
  3393. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3394. /* CD pin widget for input */
  3395. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3396. /* unmute amp left and right */
  3397. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3398. /* set connection select to line in (default select for this ADC) */
  3399. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3400. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3402. /* mute pin widget amp left and right (no gain on this amp) */
  3403. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3404. /* unmute HP mixer amp left and right (volume = 0) */
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3406. /* mute pin widget amp left and right (no gain on this amp) */
  3407. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3408. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3409. * Line In 2 = 0x03
  3410. */
  3411. /* unmute CD */
  3412. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3413. /* unmute Line In */
  3414. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3415. /* unmute Mic */
  3416. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3417. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3418. /* Unmute Front out path */
  3419. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3420. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3421. /* Unmute Headphone out path */
  3422. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3423. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3424. /* Unmute Mono out path */
  3425. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3426. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3427. { }
  3428. };
  3429. #endif
  3430. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3431. /* Line out and output */
  3432. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3433. /* mono output */
  3434. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3435. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3436. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3437. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3438. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3439. /* Line In pin widget for input */
  3440. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3441. /* Headphone pin widget for output */
  3442. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3443. /* CD pin widget for input */
  3444. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3445. /* unmute amp left and right */
  3446. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3447. /* set connection select to line in (default select for this ADC) */
  3448. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3449. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3451. /* mute pin widget amp left and right (no gain on this amp) */
  3452. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3453. /* unmute HP mixer amp left and right (volume = 0) */
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3455. /* mute pin widget amp left and right (no gain on this amp) */
  3456. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3457. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3458. * Line In 2 = 0x03
  3459. */
  3460. /* unmute CD */
  3461. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3462. /* unmute Line In */
  3463. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3464. /* unmute Mic */
  3465. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3466. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3467. /* Unmute Front out path */
  3468. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3469. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3470. /* Unmute Headphone out path */
  3471. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3472. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3473. /* Unmute Mono out path */
  3474. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3475. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3476. { }
  3477. };
  3478. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3479. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3480. * audio = 0x16, internal speaker = 0x10.
  3481. */
  3482. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3483. /* Disable all GPIOs */
  3484. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3485. /* Internal speaker is connected to headphone pin */
  3486. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3487. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3488. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3489. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3490. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3491. /* Ensure all other unused pins are disabled and muted. */
  3492. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3493. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3494. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3495. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3496. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3497. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3500. /* Disable digital (SPDIF) pins */
  3501. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3502. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3503. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3504. * when acting as an output.
  3505. */
  3506. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3507. /* Start with output sum widgets muted and their output gains at min */
  3508. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3509. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3510. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3511. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3512. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3513. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3514. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3516. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3517. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3518. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3519. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3520. * If the pin mode is changed by the user the pin mode control will
  3521. * take care of enabling the pin's input/output buffers as needed.
  3522. * Therefore there's no need to enable the input buffer at this
  3523. * stage.
  3524. */
  3525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3526. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3527. * mixer ctrl)
  3528. */
  3529. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3530. /* Mute capture amp left and right */
  3531. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. /* Set ADC connection select to match default mixer setting - line
  3533. * in (on mic1 pin)
  3534. */
  3535. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3536. /* Do the same for the second ADC: mute capture input amp and
  3537. * set ADC connection to line in (on mic1 pin)
  3538. */
  3539. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3541. /* Mute all inputs to mixer widget (even unconnected ones) */
  3542. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3543. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3544. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3545. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3546. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3547. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3548. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3549. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3550. { }
  3551. };
  3552. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3553. * similar laptops (adapted from Fujitsu init verbs).
  3554. */
  3555. static struct hda_verb alc260_acer_init_verbs[] = {
  3556. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3557. * the headphone jack. Turn this on and rely on the standard mute
  3558. * methods whenever the user wants to turn these outputs off.
  3559. */
  3560. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3561. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3562. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3563. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3564. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3565. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3566. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3567. /* Line In jack is connected to Line1 pin */
  3568. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3569. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3570. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3571. /* Ensure all other unused pins are disabled and muted. */
  3572. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3573. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3574. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3575. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3576. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3577. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3578. /* Disable digital (SPDIF) pins */
  3579. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3580. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3581. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3582. * bus when acting as outputs.
  3583. */
  3584. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3585. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3586. /* Start with output sum widgets muted and their output gains at min */
  3587. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3588. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3589. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3590. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3591. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3592. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3593. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3594. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3595. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3596. /* Unmute Line-out pin widget amp left and right
  3597. * (no equiv mixer ctrl)
  3598. */
  3599. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3600. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3601. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3602. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3603. * inputs. If the pin mode is changed by the user the pin mode control
  3604. * will take care of enabling the pin's input/output buffers as needed.
  3605. * Therefore there's no need to enable the input buffer at this
  3606. * stage.
  3607. */
  3608. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3609. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3610. /* Mute capture amp left and right */
  3611. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3612. /* Set ADC connection select to match default mixer setting - mic
  3613. * (on mic1 pin)
  3614. */
  3615. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3616. /* Do similar with the second ADC: mute capture input amp and
  3617. * set ADC connection to mic to match ALSA's default state.
  3618. */
  3619. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3620. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3621. /* Mute all inputs to mixer widget (even unconnected ones) */
  3622. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3623. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3624. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3625. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3626. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3628. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3630. { }
  3631. };
  3632. static struct hda_verb alc260_will_verbs[] = {
  3633. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3634. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3635. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3636. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3637. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3638. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3639. {}
  3640. };
  3641. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3642. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3643. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3644. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3645. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3646. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3647. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3648. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3649. {}
  3650. };
  3651. /* toggle speaker-output according to the hp-jack state */
  3652. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3653. {
  3654. unsigned int present;
  3655. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3656. present = snd_hda_codec_read(codec, 0x0f, 0,
  3657. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3658. if (present) {
  3659. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3660. snd_hda_codec_write(codec, 0x0f, 0,
  3661. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3662. } else {
  3663. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3664. snd_hda_codec_write(codec, 0x0f, 0,
  3665. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3666. }
  3667. }
  3668. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3669. unsigned int res)
  3670. {
  3671. if ((res >> 26) == ALC880_HP_EVENT)
  3672. alc260_replacer_672v_automute(codec);
  3673. }
  3674. /* Test configuration for debugging, modelled after the ALC880 test
  3675. * configuration.
  3676. */
  3677. #ifdef CONFIG_SND_DEBUG
  3678. static hda_nid_t alc260_test_dac_nids[1] = {
  3679. 0x02,
  3680. };
  3681. static hda_nid_t alc260_test_adc_nids[2] = {
  3682. 0x04, 0x05,
  3683. };
  3684. /* For testing the ALC260, each input MUX needs its own definition since
  3685. * the signal assignments are different. This assumes that the first ADC
  3686. * is NID 0x04.
  3687. */
  3688. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3689. {
  3690. .num_items = 7,
  3691. .items = {
  3692. { "MIC1 pin", 0x0 },
  3693. { "MIC2 pin", 0x1 },
  3694. { "LINE1 pin", 0x2 },
  3695. { "LINE2 pin", 0x3 },
  3696. { "CD pin", 0x4 },
  3697. { "LINE-OUT pin", 0x5 },
  3698. { "HP-OUT pin", 0x6 },
  3699. },
  3700. },
  3701. {
  3702. .num_items = 8,
  3703. .items = {
  3704. { "MIC1 pin", 0x0 },
  3705. { "MIC2 pin", 0x1 },
  3706. { "LINE1 pin", 0x2 },
  3707. { "LINE2 pin", 0x3 },
  3708. { "CD pin", 0x4 },
  3709. { "Mixer", 0x5 },
  3710. { "LINE-OUT pin", 0x6 },
  3711. { "HP-OUT pin", 0x7 },
  3712. },
  3713. },
  3714. };
  3715. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3716. /* Output driver widgets */
  3717. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3718. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3719. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3720. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3721. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3722. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3723. /* Modes for retasking pin widgets
  3724. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3725. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3726. * mention this restriction. At this stage it's not clear whether
  3727. * this behaviour is intentional or is a hardware bug in chip
  3728. * revisions available at least up until early 2006. Therefore for
  3729. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3730. * choices, but if it turns out that the lack of mic bias for these
  3731. * NIDs is intentional we could change their modes from
  3732. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3733. */
  3734. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3735. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3736. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3737. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3738. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3739. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3740. /* Loopback mixer controls */
  3741. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3742. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3743. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3744. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3745. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3746. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3747. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3748. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3749. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3750. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3751. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3752. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3753. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3754. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3755. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3756. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3757. /* Controls for GPIO pins, assuming they are configured as outputs */
  3758. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3759. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3760. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3761. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3762. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3763. * is ambigious as to which NID is which; testing on laptops which
  3764. * make this output available should provide clarification.
  3765. */
  3766. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3767. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3768. { } /* end */
  3769. };
  3770. static struct hda_verb alc260_test_init_verbs[] = {
  3771. /* Enable all GPIOs as outputs with an initial value of 0 */
  3772. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3773. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3774. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3775. /* Enable retasking pins as output, initially without power amp */
  3776. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3777. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3778. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3779. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3780. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3781. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3782. /* Disable digital (SPDIF) pins initially, but users can enable
  3783. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3784. * payload also sets the generation to 0, output to be in "consumer"
  3785. * PCM format, copyright asserted, no pre-emphasis and no validity
  3786. * control.
  3787. */
  3788. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3789. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3790. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3791. * OUT1 sum bus when acting as an output.
  3792. */
  3793. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3794. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3795. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3796. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3797. /* Start with output sum widgets muted and their output gains at min */
  3798. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3799. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3800. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3801. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3802. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3803. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3804. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3805. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3806. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3807. /* Unmute retasking pin widget output buffers since the default
  3808. * state appears to be output. As the pin mode is changed by the
  3809. * user the pin mode control will take care of enabling the pin's
  3810. * input/output buffers as needed.
  3811. */
  3812. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3813. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3814. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3815. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3816. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3817. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3818. /* Also unmute the mono-out pin widget */
  3819. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3820. /* Mute capture amp left and right */
  3821. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3822. /* Set ADC connection select to match default mixer setting (mic1
  3823. * pin)
  3824. */
  3825. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3826. /* Do the same for the second ADC: mute capture input amp and
  3827. * set ADC connection to mic1 pin
  3828. */
  3829. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3830. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3831. /* Mute all inputs to mixer widget (even unconnected ones) */
  3832. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3833. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3834. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3835. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3836. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3837. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3838. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3839. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3840. { }
  3841. };
  3842. #endif
  3843. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3844. .substreams = 1,
  3845. .channels_min = 2,
  3846. .channels_max = 2,
  3847. };
  3848. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3849. .substreams = 1,
  3850. .channels_min = 2,
  3851. .channels_max = 2,
  3852. };
  3853. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3854. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3855. /*
  3856. * for BIOS auto-configuration
  3857. */
  3858. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3859. const char *pfx)
  3860. {
  3861. hda_nid_t nid_vol;
  3862. unsigned long vol_val, sw_val;
  3863. char name[32];
  3864. int err;
  3865. if (nid >= 0x0f && nid < 0x11) {
  3866. nid_vol = nid - 0x7;
  3867. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3868. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3869. } else if (nid == 0x11) {
  3870. nid_vol = nid - 0x7;
  3871. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3872. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3873. } else if (nid >= 0x12 && nid <= 0x15) {
  3874. nid_vol = 0x08;
  3875. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3876. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3877. } else
  3878. return 0; /* N/A */
  3879. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3880. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3881. if (err < 0)
  3882. return err;
  3883. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3884. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3885. if (err < 0)
  3886. return err;
  3887. return 1;
  3888. }
  3889. /* add playback controls from the parsed DAC table */
  3890. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3891. const struct auto_pin_cfg *cfg)
  3892. {
  3893. hda_nid_t nid;
  3894. int err;
  3895. spec->multiout.num_dacs = 1;
  3896. spec->multiout.dac_nids = spec->private_dac_nids;
  3897. spec->multiout.dac_nids[0] = 0x02;
  3898. nid = cfg->line_out_pins[0];
  3899. if (nid) {
  3900. err = alc260_add_playback_controls(spec, nid, "Front");
  3901. if (err < 0)
  3902. return err;
  3903. }
  3904. nid = cfg->speaker_pins[0];
  3905. if (nid) {
  3906. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3907. if (err < 0)
  3908. return err;
  3909. }
  3910. nid = cfg->hp_pins[0];
  3911. if (nid) {
  3912. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3913. if (err < 0)
  3914. return err;
  3915. }
  3916. return 0;
  3917. }
  3918. /* create playback/capture controls for input pins */
  3919. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3920. const struct auto_pin_cfg *cfg)
  3921. {
  3922. struct hda_input_mux *imux = &spec->private_imux;
  3923. int i, err, idx;
  3924. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3925. if (cfg->input_pins[i] >= 0x12) {
  3926. idx = cfg->input_pins[i] - 0x12;
  3927. err = new_analog_input(spec, cfg->input_pins[i],
  3928. auto_pin_cfg_labels[i], idx,
  3929. 0x07);
  3930. if (err < 0)
  3931. return err;
  3932. imux->items[imux->num_items].label =
  3933. auto_pin_cfg_labels[i];
  3934. imux->items[imux->num_items].index = idx;
  3935. imux->num_items++;
  3936. }
  3937. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3938. idx = cfg->input_pins[i] - 0x09;
  3939. err = new_analog_input(spec, cfg->input_pins[i],
  3940. auto_pin_cfg_labels[i], idx,
  3941. 0x07);
  3942. if (err < 0)
  3943. return err;
  3944. imux->items[imux->num_items].label =
  3945. auto_pin_cfg_labels[i];
  3946. imux->items[imux->num_items].index = idx;
  3947. imux->num_items++;
  3948. }
  3949. }
  3950. return 0;
  3951. }
  3952. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3953. hda_nid_t nid, int pin_type,
  3954. int sel_idx)
  3955. {
  3956. /* set as output */
  3957. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3958. pin_type);
  3959. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3960. AMP_OUT_UNMUTE);
  3961. /* need the manual connection? */
  3962. if (nid >= 0x12) {
  3963. int idx = nid - 0x12;
  3964. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3965. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3966. }
  3967. }
  3968. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3969. {
  3970. struct alc_spec *spec = codec->spec;
  3971. hda_nid_t nid;
  3972. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3973. nid = spec->autocfg.line_out_pins[0];
  3974. if (nid) {
  3975. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3976. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3977. }
  3978. nid = spec->autocfg.speaker_pins[0];
  3979. if (nid)
  3980. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3981. nid = spec->autocfg.hp_pins[0];
  3982. if (nid)
  3983. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3984. }
  3985. #define ALC260_PIN_CD_NID 0x16
  3986. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3987. {
  3988. struct alc_spec *spec = codec->spec;
  3989. int i;
  3990. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3991. hda_nid_t nid = spec->autocfg.input_pins[i];
  3992. if (nid >= 0x12) {
  3993. snd_hda_codec_write(codec, nid, 0,
  3994. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3995. i <= AUTO_PIN_FRONT_MIC ?
  3996. PIN_VREF80 : PIN_IN);
  3997. if (nid != ALC260_PIN_CD_NID)
  3998. snd_hda_codec_write(codec, nid, 0,
  3999. AC_VERB_SET_AMP_GAIN_MUTE,
  4000. AMP_OUT_MUTE);
  4001. }
  4002. }
  4003. }
  4004. /*
  4005. * generic initialization of ADC, input mixers and output mixers
  4006. */
  4007. static struct hda_verb alc260_volume_init_verbs[] = {
  4008. /*
  4009. * Unmute ADC0-1 and set the default input to mic-in
  4010. */
  4011. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4012. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4013. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4014. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4015. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4016. * mixer widget
  4017. * Note: PASD motherboards uses the Line In 2 as the input for
  4018. * front panel mic (mic 2)
  4019. */
  4020. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4021. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4022. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4023. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4024. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4025. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4026. /*
  4027. * Set up output mixers (0x08 - 0x0a)
  4028. */
  4029. /* set vol=0 to output mixers */
  4030. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4031. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4032. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4033. /* set up input amps for analog loopback */
  4034. /* Amp Indices: DAC = 0, mixer = 1 */
  4035. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4036. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4037. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4038. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4039. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4040. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4041. { }
  4042. };
  4043. static int alc260_parse_auto_config(struct hda_codec *codec)
  4044. {
  4045. struct alc_spec *spec = codec->spec;
  4046. unsigned int wcap;
  4047. int err;
  4048. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4049. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4050. alc260_ignore);
  4051. if (err < 0)
  4052. return err;
  4053. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4054. if (err < 0)
  4055. return err;
  4056. if (!spec->kctl_alloc)
  4057. return 0; /* can't find valid BIOS pin config */
  4058. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4059. if (err < 0)
  4060. return err;
  4061. spec->multiout.max_channels = 2;
  4062. if (spec->autocfg.dig_out_pin)
  4063. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4064. if (spec->kctl_alloc)
  4065. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4066. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4067. spec->num_mux_defs = 1;
  4068. spec->input_mux = &spec->private_imux;
  4069. /* check whether NID 0x04 is valid */
  4070. wcap = get_wcaps(codec, 0x04);
  4071. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4072. if (wcap != AC_WID_AUD_IN) {
  4073. spec->adc_nids = alc260_adc_nids_alt;
  4074. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4075. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4076. } else {
  4077. spec->adc_nids = alc260_adc_nids;
  4078. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4079. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4080. }
  4081. spec->num_mixers++;
  4082. return 1;
  4083. }
  4084. /* additional initialization for auto-configuration model */
  4085. static void alc260_auto_init(struct hda_codec *codec)
  4086. {
  4087. alc260_auto_init_multi_out(codec);
  4088. alc260_auto_init_analog_input(codec);
  4089. }
  4090. /*
  4091. * ALC260 configurations
  4092. */
  4093. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4094. [ALC260_BASIC] = "basic",
  4095. [ALC260_HP] = "hp",
  4096. [ALC260_HP_3013] = "hp-3013",
  4097. [ALC260_FUJITSU_S702X] = "fujitsu",
  4098. [ALC260_ACER] = "acer",
  4099. [ALC260_WILL] = "will",
  4100. [ALC260_REPLACER_672V] = "replacer",
  4101. #ifdef CONFIG_SND_DEBUG
  4102. [ALC260_TEST] = "test",
  4103. #endif
  4104. [ALC260_AUTO] = "auto",
  4105. };
  4106. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4107. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4108. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4109. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4110. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4111. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4112. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4113. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4114. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4115. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4116. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4117. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4118. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4119. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4120. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4121. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4122. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4123. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4124. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4125. {}
  4126. };
  4127. static struct alc_config_preset alc260_presets[] = {
  4128. [ALC260_BASIC] = {
  4129. .mixers = { alc260_base_output_mixer,
  4130. alc260_input_mixer,
  4131. alc260_pc_beep_mixer,
  4132. alc260_capture_mixer },
  4133. .init_verbs = { alc260_init_verbs },
  4134. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4135. .dac_nids = alc260_dac_nids,
  4136. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4137. .adc_nids = alc260_adc_nids,
  4138. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4139. .channel_mode = alc260_modes,
  4140. .input_mux = &alc260_capture_source,
  4141. },
  4142. [ALC260_HP] = {
  4143. .mixers = { alc260_base_output_mixer,
  4144. alc260_input_mixer,
  4145. alc260_capture_alt_mixer },
  4146. .init_verbs = { alc260_init_verbs },
  4147. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4148. .dac_nids = alc260_dac_nids,
  4149. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4150. .adc_nids = alc260_hp_adc_nids,
  4151. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4152. .channel_mode = alc260_modes,
  4153. .input_mux = &alc260_capture_source,
  4154. },
  4155. [ALC260_HP_3013] = {
  4156. .mixers = { alc260_hp_3013_mixer,
  4157. alc260_input_mixer,
  4158. alc260_capture_alt_mixer },
  4159. .init_verbs = { alc260_hp_3013_init_verbs },
  4160. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4161. .dac_nids = alc260_dac_nids,
  4162. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4163. .adc_nids = alc260_hp_adc_nids,
  4164. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4165. .channel_mode = alc260_modes,
  4166. .input_mux = &alc260_capture_source,
  4167. },
  4168. [ALC260_FUJITSU_S702X] = {
  4169. .mixers = { alc260_fujitsu_mixer,
  4170. alc260_capture_mixer },
  4171. .init_verbs = { alc260_fujitsu_init_verbs },
  4172. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4173. .dac_nids = alc260_dac_nids,
  4174. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4175. .adc_nids = alc260_dual_adc_nids,
  4176. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4177. .channel_mode = alc260_modes,
  4178. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4179. .input_mux = alc260_fujitsu_capture_sources,
  4180. },
  4181. [ALC260_ACER] = {
  4182. .mixers = { alc260_acer_mixer,
  4183. alc260_capture_mixer },
  4184. .init_verbs = { alc260_acer_init_verbs },
  4185. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4186. .dac_nids = alc260_dac_nids,
  4187. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4188. .adc_nids = alc260_dual_adc_nids,
  4189. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4190. .channel_mode = alc260_modes,
  4191. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4192. .input_mux = alc260_acer_capture_sources,
  4193. },
  4194. [ALC260_WILL] = {
  4195. .mixers = { alc260_will_mixer,
  4196. alc260_capture_mixer },
  4197. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4198. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4199. .dac_nids = alc260_dac_nids,
  4200. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4201. .adc_nids = alc260_adc_nids,
  4202. .dig_out_nid = ALC260_DIGOUT_NID,
  4203. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4204. .channel_mode = alc260_modes,
  4205. .input_mux = &alc260_capture_source,
  4206. },
  4207. [ALC260_REPLACER_672V] = {
  4208. .mixers = { alc260_replacer_672v_mixer,
  4209. alc260_capture_mixer },
  4210. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4211. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4212. .dac_nids = alc260_dac_nids,
  4213. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4214. .adc_nids = alc260_adc_nids,
  4215. .dig_out_nid = ALC260_DIGOUT_NID,
  4216. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4217. .channel_mode = alc260_modes,
  4218. .input_mux = &alc260_capture_source,
  4219. .unsol_event = alc260_replacer_672v_unsol_event,
  4220. .init_hook = alc260_replacer_672v_automute,
  4221. },
  4222. #ifdef CONFIG_SND_DEBUG
  4223. [ALC260_TEST] = {
  4224. .mixers = { alc260_test_mixer,
  4225. alc260_capture_mixer },
  4226. .init_verbs = { alc260_test_init_verbs },
  4227. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4228. .dac_nids = alc260_test_dac_nids,
  4229. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4230. .adc_nids = alc260_test_adc_nids,
  4231. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4232. .channel_mode = alc260_modes,
  4233. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4234. .input_mux = alc260_test_capture_sources,
  4235. },
  4236. #endif
  4237. };
  4238. static int patch_alc260(struct hda_codec *codec)
  4239. {
  4240. struct alc_spec *spec;
  4241. int err, board_config;
  4242. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4243. if (spec == NULL)
  4244. return -ENOMEM;
  4245. codec->spec = spec;
  4246. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4247. alc260_models,
  4248. alc260_cfg_tbl);
  4249. if (board_config < 0) {
  4250. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4251. "trying auto-probe from BIOS...\n");
  4252. board_config = ALC260_AUTO;
  4253. }
  4254. if (board_config == ALC260_AUTO) {
  4255. /* automatic parse from the BIOS config */
  4256. err = alc260_parse_auto_config(codec);
  4257. if (err < 0) {
  4258. alc_free(codec);
  4259. return err;
  4260. } else if (!err) {
  4261. printk(KERN_INFO
  4262. "hda_codec: Cannot set up configuration "
  4263. "from BIOS. Using base mode...\n");
  4264. board_config = ALC260_BASIC;
  4265. }
  4266. }
  4267. if (board_config != ALC260_AUTO)
  4268. setup_preset(spec, &alc260_presets[board_config]);
  4269. spec->stream_name_analog = "ALC260 Analog";
  4270. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4271. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4272. spec->stream_name_digital = "ALC260 Digital";
  4273. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4274. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4275. codec->patch_ops = alc_patch_ops;
  4276. if (board_config == ALC260_AUTO)
  4277. spec->init_hook = alc260_auto_init;
  4278. return 0;
  4279. }
  4280. /*
  4281. * ALC882 support
  4282. *
  4283. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4284. * configuration. Each pin widget can choose any input DACs and a mixer.
  4285. * Each ADC is connected from a mixer of all inputs. This makes possible
  4286. * 6-channel independent captures.
  4287. *
  4288. * In addition, an independent DAC for the multi-playback (not used in this
  4289. * driver yet).
  4290. */
  4291. #define ALC882_DIGOUT_NID 0x06
  4292. #define ALC882_DIGIN_NID 0x0a
  4293. static struct hda_channel_mode alc882_ch_modes[1] = {
  4294. { 8, NULL }
  4295. };
  4296. static hda_nid_t alc882_dac_nids[4] = {
  4297. /* front, rear, clfe, rear_surr */
  4298. 0x02, 0x03, 0x04, 0x05
  4299. };
  4300. /* identical with ALC880 */
  4301. #define alc882_adc_nids alc880_adc_nids
  4302. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4303. /* input MUX */
  4304. /* FIXME: should be a matrix-type input source selection */
  4305. static struct hda_input_mux alc882_capture_source = {
  4306. .num_items = 4,
  4307. .items = {
  4308. { "Mic", 0x0 },
  4309. { "Front Mic", 0x1 },
  4310. { "Line", 0x2 },
  4311. { "CD", 0x4 },
  4312. },
  4313. };
  4314. #define alc882_mux_enum_info alc_mux_enum_info
  4315. #define alc882_mux_enum_get alc_mux_enum_get
  4316. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4317. struct snd_ctl_elem_value *ucontrol)
  4318. {
  4319. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4320. struct alc_spec *spec = codec->spec;
  4321. const struct hda_input_mux *imux = spec->input_mux;
  4322. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4323. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4324. hda_nid_t nid = capture_mixers[adc_idx];
  4325. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4326. unsigned int i, idx;
  4327. idx = ucontrol->value.enumerated.item[0];
  4328. if (idx >= imux->num_items)
  4329. idx = imux->num_items - 1;
  4330. if (*cur_val == idx && !codec->in_resume)
  4331. return 0;
  4332. for (i = 0; i < imux->num_items; i++) {
  4333. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4334. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4335. v | (imux->items[i].index << 8));
  4336. }
  4337. *cur_val = idx;
  4338. return 1;
  4339. }
  4340. /*
  4341. * 2ch mode
  4342. */
  4343. static struct hda_verb alc882_3ST_ch2_init[] = {
  4344. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4345. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4346. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4347. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4348. { } /* end */
  4349. };
  4350. /*
  4351. * 6ch mode
  4352. */
  4353. static struct hda_verb alc882_3ST_ch6_init[] = {
  4354. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4355. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4356. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4357. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4358. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4359. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4360. { } /* end */
  4361. };
  4362. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4363. { 2, alc882_3ST_ch2_init },
  4364. { 6, alc882_3ST_ch6_init },
  4365. };
  4366. /*
  4367. * 6ch mode
  4368. */
  4369. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4370. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4371. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4372. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4373. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4374. { } /* end */
  4375. };
  4376. /*
  4377. * 8ch mode
  4378. */
  4379. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4380. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4381. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4382. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4383. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4384. { } /* end */
  4385. };
  4386. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4387. { 6, alc882_sixstack_ch6_init },
  4388. { 8, alc882_sixstack_ch8_init },
  4389. };
  4390. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4391. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4392. */
  4393. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4394. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4395. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4396. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4397. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4398. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4399. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4400. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4401. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4402. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4403. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4404. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4405. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4406. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4407. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4408. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4409. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4410. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4411. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4412. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4413. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4414. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4415. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4416. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4417. { } /* end */
  4418. };
  4419. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4420. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4421. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  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("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4430. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4431. { } /* end */
  4432. };
  4433. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4434. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4435. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4436. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4444. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4445. { } /* end */
  4446. };
  4447. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4448. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4449. */
  4450. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4451. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4452. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4454. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4455. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4456. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4458. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4459. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4460. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4461. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4462. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4463. { } /* end */
  4464. };
  4465. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4466. {
  4467. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4468. .name = "Channel Mode",
  4469. .info = alc_ch_mode_info,
  4470. .get = alc_ch_mode_get,
  4471. .put = alc_ch_mode_put,
  4472. },
  4473. { } /* end */
  4474. };
  4475. static struct hda_verb alc882_init_verbs[] = {
  4476. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4477. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4478. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4479. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4480. /* Rear mixer */
  4481. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4482. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4483. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4484. /* CLFE mixer */
  4485. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4486. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4487. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4488. /* Side mixer */
  4489. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4490. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4491. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4492. /* Front Pin: output 0 (0x0c) */
  4493. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4495. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4496. /* Rear Pin: output 1 (0x0d) */
  4497. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4498. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4499. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4500. /* CLFE Pin: output 2 (0x0e) */
  4501. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4502. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4503. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4504. /* Side Pin: output 3 (0x0f) */
  4505. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4506. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4507. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4508. /* Mic (rear) pin: input vref at 80% */
  4509. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4510. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4511. /* Front Mic pin: input vref at 80% */
  4512. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4513. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4514. /* Line In pin: input */
  4515. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4516. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4517. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4518. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4519. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4520. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4521. /* CD pin widget for input */
  4522. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4523. /* FIXME: use matrix-type input source selection */
  4524. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4525. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4526. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4527. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4528. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4529. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4530. /* Input mixer2 */
  4531. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4532. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4533. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4534. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4535. /* Input mixer3 */
  4536. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4537. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4538. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4539. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4540. /* ADC1: mute amp left and right */
  4541. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4542. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4543. /* ADC2: mute amp left and right */
  4544. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4545. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4546. /* ADC3: mute amp left and right */
  4547. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4548. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4549. { }
  4550. };
  4551. static struct hda_verb alc882_eapd_verbs[] = {
  4552. /* change to EAPD mode */
  4553. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4554. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4555. { }
  4556. };
  4557. /* Mac Pro test */
  4558. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4559. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4560. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4561. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4562. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4563. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4564. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4565. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4566. { } /* end */
  4567. };
  4568. static struct hda_verb alc882_macpro_init_verbs[] = {
  4569. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4570. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4571. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4572. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4573. /* Front Pin: output 0 (0x0c) */
  4574. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4575. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4576. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4577. /* Front Mic pin: input vref at 80% */
  4578. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4579. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4580. /* Speaker: output */
  4581. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4582. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4583. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4584. /* Headphone output (output 0 - 0x0c) */
  4585. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4586. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4587. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4588. /* FIXME: use matrix-type input source selection */
  4589. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4590. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4591. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4592. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4593. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4594. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4595. /* Input mixer2 */
  4596. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4597. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4598. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4599. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4600. /* Input mixer3 */
  4601. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4602. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4603. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4604. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4605. /* ADC1: mute amp left and right */
  4606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4607. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4608. /* ADC2: mute amp left and right */
  4609. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4610. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4611. /* ADC3: mute amp left and right */
  4612. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4613. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4614. { }
  4615. };
  4616. static struct hda_verb alc882_targa_verbs[] = {
  4617. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4618. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4619. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4620. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4621. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4622. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4623. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4624. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4625. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4626. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4627. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4628. { } /* end */
  4629. };
  4630. /* toggle speaker-output according to the hp-jack state */
  4631. static void alc882_targa_automute(struct hda_codec *codec)
  4632. {
  4633. unsigned int present;
  4634. present = snd_hda_codec_read(codec, 0x14, 0,
  4635. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4636. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4637. 0x80, present ? 0x80 : 0);
  4638. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4639. 0x80, present ? 0x80 : 0);
  4640. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4641. }
  4642. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4643. {
  4644. /* Looks like the unsol event is incompatible with the standard
  4645. * definition. 4bit tag is placed at 26 bit!
  4646. */
  4647. if (((res >> 26) == ALC880_HP_EVENT)) {
  4648. alc882_targa_automute(codec);
  4649. }
  4650. }
  4651. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4652. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4653. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4654. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4655. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4656. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4657. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4658. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4659. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4660. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4661. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4662. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4663. { } /* end */
  4664. };
  4665. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4666. {
  4667. unsigned int gpiostate, gpiomask, gpiodir;
  4668. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4669. AC_VERB_GET_GPIO_DATA, 0);
  4670. if (!muted)
  4671. gpiostate |= (1 << pin);
  4672. else
  4673. gpiostate &= ~(1 << pin);
  4674. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4675. AC_VERB_GET_GPIO_MASK, 0);
  4676. gpiomask |= (1 << pin);
  4677. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4678. AC_VERB_GET_GPIO_DIRECTION, 0);
  4679. gpiodir |= (1 << pin);
  4680. snd_hda_codec_write(codec, codec->afg, 0,
  4681. AC_VERB_SET_GPIO_MASK, gpiomask);
  4682. snd_hda_codec_write(codec, codec->afg, 0,
  4683. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4684. msleep(1);
  4685. snd_hda_codec_write(codec, codec->afg, 0,
  4686. AC_VERB_SET_GPIO_DATA, gpiostate);
  4687. }
  4688. /*
  4689. * generic initialization of ADC, input mixers and output mixers
  4690. */
  4691. static struct hda_verb alc882_auto_init_verbs[] = {
  4692. /*
  4693. * Unmute ADC0-2 and set the default input to mic-in
  4694. */
  4695. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4696. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4697. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4698. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4699. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4700. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4701. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4702. * mixer widget
  4703. * Note: PASD motherboards uses the Line In 2 as the input for
  4704. * front panel mic (mic 2)
  4705. */
  4706. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4707. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4709. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4710. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4711. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4712. /*
  4713. * Set up output mixers (0x0c - 0x0f)
  4714. */
  4715. /* set vol=0 to output mixers */
  4716. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4717. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4718. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4719. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4720. /* set up input amps for analog loopback */
  4721. /* Amp Indices: DAC = 0, mixer = 1 */
  4722. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4723. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4724. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4725. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4726. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4727. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4728. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4729. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4730. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4731. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4732. /* FIXME: use matrix-type input source selection */
  4733. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4734. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4735. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4736. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4737. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4738. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4739. /* Input mixer2 */
  4740. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4741. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4742. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4743. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4744. /* Input mixer3 */
  4745. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4746. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4747. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4748. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4749. { }
  4750. };
  4751. /* capture mixer elements */
  4752. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4753. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4754. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4755. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4756. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4757. {
  4758. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4759. /* The multiple "Capture Source" controls confuse alsamixer
  4760. * So call somewhat different..
  4761. * FIXME: the controls appear in the "playback" view!
  4762. */
  4763. /* .name = "Capture Source", */
  4764. .name = "Input Source",
  4765. .count = 2,
  4766. .info = alc882_mux_enum_info,
  4767. .get = alc882_mux_enum_get,
  4768. .put = alc882_mux_enum_put,
  4769. },
  4770. { } /* end */
  4771. };
  4772. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4773. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4774. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4775. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4776. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4777. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4778. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4779. {
  4780. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4781. /* The multiple "Capture Source" controls confuse alsamixer
  4782. * So call somewhat different..
  4783. * FIXME: the controls appear in the "playback" view!
  4784. */
  4785. /* .name = "Capture Source", */
  4786. .name = "Input Source",
  4787. .count = 3,
  4788. .info = alc882_mux_enum_info,
  4789. .get = alc882_mux_enum_get,
  4790. .put = alc882_mux_enum_put,
  4791. },
  4792. { } /* end */
  4793. };
  4794. /* pcm configuration: identiacal with ALC880 */
  4795. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4796. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4797. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4798. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4799. /*
  4800. * configuration and preset
  4801. */
  4802. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4803. [ALC882_3ST_DIG] = "3stack-dig",
  4804. [ALC882_6ST_DIG] = "6stack-dig",
  4805. [ALC882_ARIMA] = "arima",
  4806. [ALC882_W2JC] = "w2jc",
  4807. [ALC885_MACPRO] = "macpro",
  4808. [ALC882_AUTO] = "auto",
  4809. };
  4810. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4811. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4812. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4813. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4814. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4815. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4816. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4817. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4818. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4819. {}
  4820. };
  4821. static struct alc_config_preset alc882_presets[] = {
  4822. [ALC882_3ST_DIG] = {
  4823. .mixers = { alc882_base_mixer },
  4824. .init_verbs = { alc882_init_verbs },
  4825. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4826. .dac_nids = alc882_dac_nids,
  4827. .dig_out_nid = ALC882_DIGOUT_NID,
  4828. .dig_in_nid = ALC882_DIGIN_NID,
  4829. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4830. .channel_mode = alc882_ch_modes,
  4831. .need_dac_fix = 1,
  4832. .input_mux = &alc882_capture_source,
  4833. },
  4834. [ALC882_6ST_DIG] = {
  4835. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4836. .init_verbs = { alc882_init_verbs },
  4837. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4838. .dac_nids = alc882_dac_nids,
  4839. .dig_out_nid = ALC882_DIGOUT_NID,
  4840. .dig_in_nid = ALC882_DIGIN_NID,
  4841. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4842. .channel_mode = alc882_sixstack_modes,
  4843. .input_mux = &alc882_capture_source,
  4844. },
  4845. [ALC882_ARIMA] = {
  4846. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4847. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4848. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4849. .dac_nids = alc882_dac_nids,
  4850. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4851. .channel_mode = alc882_sixstack_modes,
  4852. .input_mux = &alc882_capture_source,
  4853. },
  4854. [ALC882_W2JC] = {
  4855. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4856. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4857. alc880_gpio1_init_verbs },
  4858. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4859. .dac_nids = alc882_dac_nids,
  4860. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4861. .channel_mode = alc880_threestack_modes,
  4862. .need_dac_fix = 1,
  4863. .input_mux = &alc882_capture_source,
  4864. .dig_out_nid = ALC882_DIGOUT_NID,
  4865. },
  4866. [ALC885_MACPRO] = {
  4867. .mixers = { alc882_macpro_mixer },
  4868. .init_verbs = { alc882_macpro_init_verbs },
  4869. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4870. .dac_nids = alc882_dac_nids,
  4871. .dig_out_nid = ALC882_DIGOUT_NID,
  4872. .dig_in_nid = ALC882_DIGIN_NID,
  4873. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4874. .channel_mode = alc882_ch_modes,
  4875. .input_mux = &alc882_capture_source,
  4876. },
  4877. [ALC882_TARGA] = {
  4878. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4879. alc882_capture_mixer },
  4880. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4881. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4882. .dac_nids = alc882_dac_nids,
  4883. .dig_out_nid = ALC882_DIGOUT_NID,
  4884. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4885. .adc_nids = alc882_adc_nids,
  4886. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4887. .channel_mode = alc882_3ST_6ch_modes,
  4888. .need_dac_fix = 1,
  4889. .input_mux = &alc882_capture_source,
  4890. .unsol_event = alc882_targa_unsol_event,
  4891. .init_hook = alc882_targa_automute,
  4892. },
  4893. [ALC882_ASUS_A7J] = {
  4894. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4895. alc882_capture_mixer },
  4896. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4897. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4898. .dac_nids = alc882_dac_nids,
  4899. .dig_out_nid = ALC882_DIGOUT_NID,
  4900. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4901. .adc_nids = alc882_adc_nids,
  4902. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4903. .channel_mode = alc882_3ST_6ch_modes,
  4904. .need_dac_fix = 1,
  4905. .input_mux = &alc882_capture_source,
  4906. },
  4907. };
  4908. /*
  4909. * BIOS auto configuration
  4910. */
  4911. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4912. hda_nid_t nid, int pin_type,
  4913. int dac_idx)
  4914. {
  4915. /* set as output */
  4916. struct alc_spec *spec = codec->spec;
  4917. int idx;
  4918. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4919. idx = 4;
  4920. else
  4921. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4922. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4923. pin_type);
  4924. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4925. AMP_OUT_UNMUTE);
  4926. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4927. }
  4928. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4929. {
  4930. struct alc_spec *spec = codec->spec;
  4931. int i;
  4932. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4933. for (i = 0; i <= HDA_SIDE; i++) {
  4934. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4935. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4936. if (nid)
  4937. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4938. i);
  4939. }
  4940. }
  4941. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4942. {
  4943. struct alc_spec *spec = codec->spec;
  4944. hda_nid_t pin;
  4945. pin = spec->autocfg.hp_pins[0];
  4946. if (pin) /* connect to front */
  4947. /* use dac 0 */
  4948. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4949. }
  4950. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4951. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4952. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4953. {
  4954. struct alc_spec *spec = codec->spec;
  4955. int i;
  4956. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4957. hda_nid_t nid = spec->autocfg.input_pins[i];
  4958. if (alc882_is_input_pin(nid)) {
  4959. snd_hda_codec_write(codec, nid, 0,
  4960. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4961. i <= AUTO_PIN_FRONT_MIC ?
  4962. PIN_VREF80 : PIN_IN);
  4963. if (nid != ALC882_PIN_CD_NID)
  4964. snd_hda_codec_write(codec, nid, 0,
  4965. AC_VERB_SET_AMP_GAIN_MUTE,
  4966. AMP_OUT_MUTE);
  4967. }
  4968. }
  4969. }
  4970. /* almost identical with ALC880 parser... */
  4971. static int alc882_parse_auto_config(struct hda_codec *codec)
  4972. {
  4973. struct alc_spec *spec = codec->spec;
  4974. int err = alc880_parse_auto_config(codec);
  4975. if (err < 0)
  4976. return err;
  4977. else if (err > 0)
  4978. /* hack - override the init verbs */
  4979. spec->init_verbs[0] = alc882_auto_init_verbs;
  4980. return err;
  4981. }
  4982. /* additional initialization for auto-configuration model */
  4983. static void alc882_auto_init(struct hda_codec *codec)
  4984. {
  4985. alc882_auto_init_multi_out(codec);
  4986. alc882_auto_init_hp_out(codec);
  4987. alc882_auto_init_analog_input(codec);
  4988. }
  4989. static int patch_alc882(struct hda_codec *codec)
  4990. {
  4991. struct alc_spec *spec;
  4992. int err, board_config;
  4993. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4994. if (spec == NULL)
  4995. return -ENOMEM;
  4996. codec->spec = spec;
  4997. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4998. alc882_models,
  4999. alc882_cfg_tbl);
  5000. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5001. /* Pick up systems that don't supply PCI SSID */
  5002. switch (codec->subsystem_id) {
  5003. case 0x106b0c00: /* Mac Pro */
  5004. board_config = ALC885_MACPRO;
  5005. break;
  5006. default:
  5007. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5008. "trying auto-probe from BIOS...\n");
  5009. board_config = ALC882_AUTO;
  5010. }
  5011. }
  5012. if (board_config == ALC882_AUTO) {
  5013. /* automatic parse from the BIOS config */
  5014. err = alc882_parse_auto_config(codec);
  5015. if (err < 0) {
  5016. alc_free(codec);
  5017. return err;
  5018. } else if (!err) {
  5019. printk(KERN_INFO
  5020. "hda_codec: Cannot set up configuration "
  5021. "from BIOS. Using base mode...\n");
  5022. board_config = ALC882_3ST_DIG;
  5023. }
  5024. }
  5025. if (board_config != ALC882_AUTO)
  5026. setup_preset(spec, &alc882_presets[board_config]);
  5027. if (board_config == ALC885_MACPRO) {
  5028. alc882_gpio_mute(codec, 0, 0);
  5029. alc882_gpio_mute(codec, 1, 0);
  5030. }
  5031. spec->stream_name_analog = "ALC882 Analog";
  5032. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5033. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5034. spec->stream_name_digital = "ALC882 Digital";
  5035. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5036. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5037. if (!spec->adc_nids && spec->input_mux) {
  5038. /* check whether NID 0x07 is valid */
  5039. unsigned int wcap = get_wcaps(codec, 0x07);
  5040. /* get type */
  5041. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5042. if (wcap != AC_WID_AUD_IN) {
  5043. spec->adc_nids = alc882_adc_nids_alt;
  5044. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5045. spec->mixers[spec->num_mixers] =
  5046. alc882_capture_alt_mixer;
  5047. spec->num_mixers++;
  5048. } else {
  5049. spec->adc_nids = alc882_adc_nids;
  5050. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5051. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5052. spec->num_mixers++;
  5053. }
  5054. }
  5055. codec->patch_ops = alc_patch_ops;
  5056. if (board_config == ALC882_AUTO)
  5057. spec->init_hook = alc882_auto_init;
  5058. return 0;
  5059. }
  5060. /*
  5061. * ALC883 support
  5062. *
  5063. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5064. * configuration. Each pin widget can choose any input DACs and a mixer.
  5065. * Each ADC is connected from a mixer of all inputs. This makes possible
  5066. * 6-channel independent captures.
  5067. *
  5068. * In addition, an independent DAC for the multi-playback (not used in this
  5069. * driver yet).
  5070. */
  5071. #define ALC883_DIGOUT_NID 0x06
  5072. #define ALC883_DIGIN_NID 0x0a
  5073. static hda_nid_t alc883_dac_nids[4] = {
  5074. /* front, rear, clfe, rear_surr */
  5075. 0x02, 0x04, 0x03, 0x05
  5076. };
  5077. static hda_nid_t alc883_adc_nids[2] = {
  5078. /* ADC1-2 */
  5079. 0x08, 0x09,
  5080. };
  5081. /* input MUX */
  5082. /* FIXME: should be a matrix-type input source selection */
  5083. static struct hda_input_mux alc883_capture_source = {
  5084. .num_items = 4,
  5085. .items = {
  5086. { "Mic", 0x0 },
  5087. { "Front Mic", 0x1 },
  5088. { "Line", 0x2 },
  5089. { "CD", 0x4 },
  5090. },
  5091. };
  5092. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5093. .num_items = 2,
  5094. .items = {
  5095. { "Mic", 0x1 },
  5096. { "Line", 0x2 },
  5097. },
  5098. };
  5099. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5100. .num_items = 4,
  5101. .items = {
  5102. { "Mic", 0x0 },
  5103. { "iMic", 0x1 },
  5104. { "Line", 0x2 },
  5105. { "CD", 0x4 },
  5106. },
  5107. };
  5108. #define alc883_mux_enum_info alc_mux_enum_info
  5109. #define alc883_mux_enum_get alc_mux_enum_get
  5110. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5111. struct snd_ctl_elem_value *ucontrol)
  5112. {
  5113. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5114. struct alc_spec *spec = codec->spec;
  5115. const struct hda_input_mux *imux = spec->input_mux;
  5116. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5117. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5118. hda_nid_t nid = capture_mixers[adc_idx];
  5119. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5120. unsigned int i, idx;
  5121. idx = ucontrol->value.enumerated.item[0];
  5122. if (idx >= imux->num_items)
  5123. idx = imux->num_items - 1;
  5124. if (*cur_val == idx && !codec->in_resume)
  5125. return 0;
  5126. for (i = 0; i < imux->num_items; i++) {
  5127. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5128. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5129. v | (imux->items[i].index << 8));
  5130. }
  5131. *cur_val = idx;
  5132. return 1;
  5133. }
  5134. /*
  5135. * 2ch mode
  5136. */
  5137. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5138. { 2, NULL }
  5139. };
  5140. /*
  5141. * 2ch mode
  5142. */
  5143. static struct hda_verb alc883_3ST_ch2_init[] = {
  5144. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5145. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5146. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5147. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5148. { } /* end */
  5149. };
  5150. /*
  5151. * 6ch mode
  5152. */
  5153. static struct hda_verb alc883_3ST_ch6_init[] = {
  5154. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5155. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5156. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5157. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5158. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5159. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5160. { } /* end */
  5161. };
  5162. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5163. { 2, alc883_3ST_ch2_init },
  5164. { 6, alc883_3ST_ch6_init },
  5165. };
  5166. /*
  5167. * 6ch mode
  5168. */
  5169. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5170. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5171. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5172. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5173. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5174. { } /* end */
  5175. };
  5176. /*
  5177. * 8ch mode
  5178. */
  5179. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5180. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5181. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5182. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5183. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5184. { } /* end */
  5185. };
  5186. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5187. { 6, alc883_sixstack_ch6_init },
  5188. { 8, alc883_sixstack_ch8_init },
  5189. };
  5190. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5191. /* eanable EAPD on medion laptop */
  5192. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5193. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5194. { }
  5195. };
  5196. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5197. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5198. */
  5199. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5200. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5201. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5202. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5203. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5204. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5205. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5206. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5207. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5208. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5209. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5210. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5211. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5212. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5213. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5214. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5215. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5216. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5217. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5218. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5219. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5220. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5221. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5222. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5223. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5224. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5225. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5226. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5227. {
  5228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5229. /* .name = "Capture Source", */
  5230. .name = "Input Source",
  5231. .count = 2,
  5232. .info = alc883_mux_enum_info,
  5233. .get = alc883_mux_enum_get,
  5234. .put = alc883_mux_enum_put,
  5235. },
  5236. { } /* end */
  5237. };
  5238. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5239. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5240. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5241. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5242. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5243. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5244. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5245. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5246. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5247. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5248. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5249. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5250. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5251. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5252. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5253. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5254. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5255. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5256. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5257. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5258. {
  5259. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5260. /* .name = "Capture Source", */
  5261. .name = "Input Source",
  5262. .count = 2,
  5263. .info = alc883_mux_enum_info,
  5264. .get = alc883_mux_enum_get,
  5265. .put = alc883_mux_enum_put,
  5266. },
  5267. { } /* end */
  5268. };
  5269. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5270. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5271. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5272. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5273. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5274. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5275. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5276. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5277. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5278. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5279. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5280. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5281. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5282. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5283. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5284. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5285. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5286. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5287. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5288. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5289. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5290. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5291. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5292. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5293. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5294. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5295. {
  5296. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5297. /* .name = "Capture Source", */
  5298. .name = "Input Source",
  5299. .count = 2,
  5300. .info = alc883_mux_enum_info,
  5301. .get = alc883_mux_enum_get,
  5302. .put = alc883_mux_enum_put,
  5303. },
  5304. { } /* end */
  5305. };
  5306. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5307. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5308. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5309. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5310. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5311. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5312. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5313. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5314. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5315. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5316. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5317. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5318. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5319. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5320. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5321. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5322. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5323. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5324. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5325. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5326. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5327. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5328. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5330. {
  5331. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5332. /* .name = "Capture Source", */
  5333. .name = "Input Source",
  5334. .count = 1,
  5335. .info = alc883_mux_enum_info,
  5336. .get = alc883_mux_enum_get,
  5337. .put = alc883_mux_enum_put,
  5338. },
  5339. { } /* end */
  5340. };
  5341. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5342. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5343. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5344. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5345. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5346. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5347. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5348. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5349. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5350. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5351. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5352. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5353. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5354. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5355. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5356. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5357. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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_tagra_2ch_mixer[] = {
  5374. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5375. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5376. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5377. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5378. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5380. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5381. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5382. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5383. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5384. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5385. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5386. {
  5387. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5388. /* .name = "Capture Source", */
  5389. .name = "Input Source",
  5390. .count = 2,
  5391. .info = alc883_mux_enum_info,
  5392. .get = alc883_mux_enum_get,
  5393. .put = alc883_mux_enum_put,
  5394. },
  5395. { } /* end */
  5396. };
  5397. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5398. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5399. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5400. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5401. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5402. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5403. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5407. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5408. {
  5409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5410. /* .name = "Capture Source", */
  5411. .name = "Input Source",
  5412. .count = 1,
  5413. .info = alc883_mux_enum_info,
  5414. .get = alc883_mux_enum_get,
  5415. .put = alc883_mux_enum_put,
  5416. },
  5417. { } /* end */
  5418. };
  5419. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5420. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5421. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5422. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5423. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5424. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5425. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5426. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5428. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5430. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5433. {
  5434. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5435. /* .name = "Capture Source", */
  5436. .name = "Input Source",
  5437. .count = 2,
  5438. .info = alc883_mux_enum_info,
  5439. .get = alc883_mux_enum_get,
  5440. .put = alc883_mux_enum_put,
  5441. },
  5442. { } /* end */
  5443. };
  5444. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5445. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5446. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5447. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5448. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5449. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5450. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5451. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5452. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5453. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5454. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5455. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5456. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5457. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5458. {
  5459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5460. /* .name = "Capture Source", */
  5461. .name = "Input Source",
  5462. .count = 2,
  5463. .info = alc883_mux_enum_info,
  5464. .get = alc883_mux_enum_get,
  5465. .put = alc883_mux_enum_put,
  5466. },
  5467. { } /* end */
  5468. };
  5469. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5470. {
  5471. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5472. .name = "Channel Mode",
  5473. .info = alc_ch_mode_info,
  5474. .get = alc_ch_mode_get,
  5475. .put = alc_ch_mode_put,
  5476. },
  5477. { } /* end */
  5478. };
  5479. static struct hda_verb alc883_init_verbs[] = {
  5480. /* ADC1: mute amp left and right */
  5481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5482. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5483. /* ADC2: mute amp left and right */
  5484. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5485. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5486. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5487. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5488. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5489. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5490. /* Rear mixer */
  5491. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5492. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5493. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5494. /* CLFE mixer */
  5495. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5496. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5497. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5498. /* Side mixer */
  5499. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5500. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5501. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5502. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5503. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5504. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5505. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5506. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5507. /* Front Pin: output 0 (0x0c) */
  5508. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5510. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5511. /* Rear Pin: output 1 (0x0d) */
  5512. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5513. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5514. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5515. /* CLFE Pin: output 2 (0x0e) */
  5516. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5517. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5518. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5519. /* Side Pin: output 3 (0x0f) */
  5520. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5521. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5522. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5523. /* Mic (rear) pin: input vref at 80% */
  5524. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5525. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5526. /* Front Mic pin: input vref at 80% */
  5527. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5528. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5529. /* Line In pin: input */
  5530. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5531. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5532. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5533. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5534. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5535. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5536. /* CD pin widget for input */
  5537. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5538. /* FIXME: use matrix-type input source selection */
  5539. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5540. /* Input mixer2 */
  5541. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5542. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5543. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5544. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5545. /* Input mixer3 */
  5546. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5547. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5548. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5549. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5550. { }
  5551. };
  5552. static struct hda_verb alc883_tagra_verbs[] = {
  5553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5554. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5555. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5556. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5557. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5558. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5559. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5560. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5561. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5562. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5563. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5564. { } /* end */
  5565. };
  5566. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5567. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5568. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5569. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5570. { } /* end */
  5571. };
  5572. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5573. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5574. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5575. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5576. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5577. { } /* end */
  5578. };
  5579. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5580. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5581. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5582. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5583. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5584. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5585. { } /* end */
  5586. };
  5587. /* toggle front-jack and RCA according to the hp-jack state */
  5588. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5589. {
  5590. unsigned int present;
  5591. present = snd_hda_codec_read(codec, 0x1b, 0,
  5592. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5593. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5594. 0x80, present ? 0x80 : 0);
  5595. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5596. 0x80, present ? 0x80 : 0);
  5597. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5598. 0x80, present ? 0x80 : 0);
  5599. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5600. 0x80, present ? 0x80 : 0);
  5601. }
  5602. /* toggle RCA according to the front-jack state */
  5603. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5604. {
  5605. unsigned int present;
  5606. present = snd_hda_codec_read(codec, 0x14, 0,
  5607. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5608. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5609. 0x80, present ? 0x80 : 0);
  5610. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5611. 0x80, present ? 0x80 : 0);
  5612. }
  5613. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5614. unsigned int res)
  5615. {
  5616. if ((res >> 26) == ALC880_HP_EVENT)
  5617. alc888_lenovo_ms7195_front_automute(codec);
  5618. if ((res >> 26) == ALC880_FRONT_EVENT)
  5619. alc888_lenovo_ms7195_rca_automute(codec);
  5620. }
  5621. static struct hda_verb alc883_medion_md2_verbs[] = {
  5622. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5623. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5624. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5625. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5626. { } /* end */
  5627. };
  5628. /* toggle speaker-output according to the hp-jack state */
  5629. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5630. {
  5631. unsigned int present;
  5632. present = snd_hda_codec_read(codec, 0x14, 0,
  5633. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5634. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5635. 0x80, present ? 0x80 : 0);
  5636. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5637. 0x80, present ? 0x80 : 0);
  5638. }
  5639. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5640. unsigned int res)
  5641. {
  5642. if ((res >> 26) == ALC880_HP_EVENT)
  5643. alc883_medion_md2_automute(codec);
  5644. }
  5645. /* toggle speaker-output according to the hp-jack state */
  5646. static void alc883_tagra_automute(struct hda_codec *codec)
  5647. {
  5648. unsigned int present;
  5649. unsigned char bits;
  5650. present = snd_hda_codec_read(codec, 0x14, 0,
  5651. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5652. bits = present ? 0x80 : 0;
  5653. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5654. 0x80, bits);
  5655. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5656. 0x80, bits);
  5657. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5658. present ? 1 : 3);
  5659. }
  5660. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5661. {
  5662. if ((res >> 26) == ALC880_HP_EVENT)
  5663. alc883_tagra_automute(codec);
  5664. }
  5665. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5666. {
  5667. unsigned int present;
  5668. unsigned char bits;
  5669. present = snd_hda_codec_read(codec, 0x14, 0,
  5670. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5671. bits = present ? 0x80 : 0;
  5672. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5673. 0x80, bits);
  5674. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5675. 0x80, bits);
  5676. }
  5677. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5678. {
  5679. unsigned int present;
  5680. unsigned char bits;
  5681. present = snd_hda_codec_read(codec, 0x1b, 0,
  5682. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5683. bits = present ? 0x80 : 0;
  5684. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5685. 0x80, bits);
  5686. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5687. 0x80, bits);
  5688. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5689. 0x80, bits);
  5690. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5691. 0x80, bits);
  5692. }
  5693. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5694. unsigned int res)
  5695. {
  5696. if ((res >> 26) == ALC880_HP_EVENT)
  5697. alc883_lenovo_101e_all_automute(codec);
  5698. if ((res >> 26) == ALC880_FRONT_EVENT)
  5699. alc883_lenovo_101e_ispeaker_automute(codec);
  5700. }
  5701. /*
  5702. * generic initialization of ADC, input mixers and output mixers
  5703. */
  5704. static struct hda_verb alc883_auto_init_verbs[] = {
  5705. /*
  5706. * Unmute ADC0-2 and set the default input to mic-in
  5707. */
  5708. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5709. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5710. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5711. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5712. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5713. * mixer widget
  5714. * Note: PASD motherboards uses the Line In 2 as the input for
  5715. * front panel mic (mic 2)
  5716. */
  5717. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5718. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5719. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5720. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5721. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5722. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5723. /*
  5724. * Set up output mixers (0x0c - 0x0f)
  5725. */
  5726. /* set vol=0 to output mixers */
  5727. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5729. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5730. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5731. /* set up input amps for analog loopback */
  5732. /* Amp Indices: DAC = 0, mixer = 1 */
  5733. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5734. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5735. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5736. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5737. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5738. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5739. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5740. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5741. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5742. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5743. /* FIXME: use matrix-type input source selection */
  5744. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5745. /* Input mixer1 */
  5746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5748. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5749. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5750. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5751. /* Input mixer2 */
  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(3)}, */
  5756. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5757. { }
  5758. };
  5759. /* capture mixer elements */
  5760. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5761. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5762. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5763. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5764. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5765. {
  5766. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5767. /* The multiple "Capture Source" controls confuse alsamixer
  5768. * So call somewhat different..
  5769. * FIXME: the controls appear in the "playback" view!
  5770. */
  5771. /* .name = "Capture Source", */
  5772. .name = "Input Source",
  5773. .count = 2,
  5774. .info = alc882_mux_enum_info,
  5775. .get = alc882_mux_enum_get,
  5776. .put = alc882_mux_enum_put,
  5777. },
  5778. { } /* end */
  5779. };
  5780. /* pcm configuration: identiacal with ALC880 */
  5781. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5782. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5783. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5784. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5785. /*
  5786. * configuration and preset
  5787. */
  5788. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5789. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5790. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5791. [ALC883_3ST_6ch] = "3stack-6ch",
  5792. [ALC883_6ST_DIG] = "6stack-dig",
  5793. [ALC883_TARGA_DIG] = "targa-dig",
  5794. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5795. [ALC883_ACER] = "acer",
  5796. [ALC883_MEDION] = "medion",
  5797. [ALC883_MEDION_MD2] = "medion-md2",
  5798. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5799. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5800. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5801. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5802. [ALC883_AUTO] = "auto",
  5803. };
  5804. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5805. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5806. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5807. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5808. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5809. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5810. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5811. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5812. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5813. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5814. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5815. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5816. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5817. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5818. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5819. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5820. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5821. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5822. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5823. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5824. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5825. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5826. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5827. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5828. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5829. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5830. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5831. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5832. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5833. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5834. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5835. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
  5836. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5837. {}
  5838. };
  5839. static struct alc_config_preset alc883_presets[] = {
  5840. [ALC883_3ST_2ch_DIG] = {
  5841. .mixers = { alc883_3ST_2ch_mixer },
  5842. .init_verbs = { alc883_init_verbs },
  5843. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5844. .dac_nids = alc883_dac_nids,
  5845. .dig_out_nid = ALC883_DIGOUT_NID,
  5846. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5847. .adc_nids = alc883_adc_nids,
  5848. .dig_in_nid = ALC883_DIGIN_NID,
  5849. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5850. .channel_mode = alc883_3ST_2ch_modes,
  5851. .input_mux = &alc883_capture_source,
  5852. },
  5853. [ALC883_3ST_6ch_DIG] = {
  5854. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5855. .init_verbs = { alc883_init_verbs },
  5856. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5857. .dac_nids = alc883_dac_nids,
  5858. .dig_out_nid = ALC883_DIGOUT_NID,
  5859. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5860. .adc_nids = alc883_adc_nids,
  5861. .dig_in_nid = ALC883_DIGIN_NID,
  5862. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5863. .channel_mode = alc883_3ST_6ch_modes,
  5864. .need_dac_fix = 1,
  5865. .input_mux = &alc883_capture_source,
  5866. },
  5867. [ALC883_3ST_6ch] = {
  5868. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5869. .init_verbs = { alc883_init_verbs },
  5870. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5871. .dac_nids = alc883_dac_nids,
  5872. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5873. .adc_nids = alc883_adc_nids,
  5874. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5875. .channel_mode = alc883_3ST_6ch_modes,
  5876. .need_dac_fix = 1,
  5877. .input_mux = &alc883_capture_source,
  5878. },
  5879. [ALC883_6ST_DIG] = {
  5880. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5881. .init_verbs = { alc883_init_verbs },
  5882. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5883. .dac_nids = alc883_dac_nids,
  5884. .dig_out_nid = ALC883_DIGOUT_NID,
  5885. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5886. .adc_nids = alc883_adc_nids,
  5887. .dig_in_nid = ALC883_DIGIN_NID,
  5888. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5889. .channel_mode = alc883_sixstack_modes,
  5890. .input_mux = &alc883_capture_source,
  5891. },
  5892. [ALC883_TARGA_DIG] = {
  5893. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5894. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5895. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5896. .dac_nids = alc883_dac_nids,
  5897. .dig_out_nid = ALC883_DIGOUT_NID,
  5898. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5899. .adc_nids = alc883_adc_nids,
  5900. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5901. .channel_mode = alc883_3ST_6ch_modes,
  5902. .need_dac_fix = 1,
  5903. .input_mux = &alc883_capture_source,
  5904. .unsol_event = alc883_tagra_unsol_event,
  5905. .init_hook = alc883_tagra_automute,
  5906. },
  5907. [ALC883_TARGA_2ch_DIG] = {
  5908. .mixers = { alc883_tagra_2ch_mixer},
  5909. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5910. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5911. .dac_nids = alc883_dac_nids,
  5912. .dig_out_nid = ALC883_DIGOUT_NID,
  5913. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5914. .adc_nids = alc883_adc_nids,
  5915. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5916. .channel_mode = alc883_3ST_2ch_modes,
  5917. .input_mux = &alc883_capture_source,
  5918. .unsol_event = alc883_tagra_unsol_event,
  5919. .init_hook = alc883_tagra_automute,
  5920. },
  5921. [ALC883_ACER] = {
  5922. .mixers = { alc883_base_mixer,
  5923. alc883_chmode_mixer },
  5924. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5925. * and the headphone jack. Turn this on and rely on the
  5926. * standard mute methods whenever the user wants to turn
  5927. * these outputs off.
  5928. */
  5929. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5930. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5931. .dac_nids = alc883_dac_nids,
  5932. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5933. .adc_nids = alc883_adc_nids,
  5934. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5935. .channel_mode = alc883_3ST_2ch_modes,
  5936. .input_mux = &alc883_capture_source,
  5937. },
  5938. [ALC883_MEDION] = {
  5939. .mixers = { alc883_fivestack_mixer,
  5940. alc883_chmode_mixer },
  5941. .init_verbs = { alc883_init_verbs,
  5942. alc883_medion_eapd_verbs },
  5943. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5944. .dac_nids = alc883_dac_nids,
  5945. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5946. .adc_nids = alc883_adc_nids,
  5947. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5948. .channel_mode = alc883_sixstack_modes,
  5949. .input_mux = &alc883_capture_source,
  5950. },
  5951. [ALC883_MEDION_MD2] = {
  5952. .mixers = { alc883_medion_md2_mixer},
  5953. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5954. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5955. .dac_nids = alc883_dac_nids,
  5956. .dig_out_nid = ALC883_DIGOUT_NID,
  5957. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5958. .adc_nids = alc883_adc_nids,
  5959. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5960. .channel_mode = alc883_3ST_2ch_modes,
  5961. .input_mux = &alc883_capture_source,
  5962. .unsol_event = alc883_medion_md2_unsol_event,
  5963. .init_hook = alc883_medion_md2_automute,
  5964. },
  5965. [ALC883_LAPTOP_EAPD] = {
  5966. .mixers = { alc883_base_mixer,
  5967. alc883_chmode_mixer },
  5968. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5969. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5970. .dac_nids = alc883_dac_nids,
  5971. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5972. .adc_nids = alc883_adc_nids,
  5973. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5974. .channel_mode = alc883_3ST_2ch_modes,
  5975. .input_mux = &alc883_capture_source,
  5976. },
  5977. [ALC883_LENOVO_101E_2ch] = {
  5978. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5979. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5980. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5981. .dac_nids = alc883_dac_nids,
  5982. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5983. .adc_nids = alc883_adc_nids,
  5984. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5985. .channel_mode = alc883_3ST_2ch_modes,
  5986. .input_mux = &alc883_lenovo_101e_capture_source,
  5987. .unsol_event = alc883_lenovo_101e_unsol_event,
  5988. .init_hook = alc883_lenovo_101e_all_automute,
  5989. },
  5990. [ALC883_LENOVO_NB0763] = {
  5991. .mixers = { alc883_lenovo_nb0763_mixer },
  5992. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5993. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5994. .dac_nids = alc883_dac_nids,
  5995. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5996. .adc_nids = alc883_adc_nids,
  5997. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5998. .channel_mode = alc883_3ST_2ch_modes,
  5999. .need_dac_fix = 1,
  6000. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6001. .unsol_event = alc883_medion_md2_unsol_event,
  6002. .init_hook = alc883_medion_md2_automute,
  6003. },
  6004. [ALC888_LENOVO_MS7195_DIG] = {
  6005. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6006. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6007. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6008. .dac_nids = alc883_dac_nids,
  6009. .dig_out_nid = ALC883_DIGOUT_NID,
  6010. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6011. .adc_nids = alc883_adc_nids,
  6012. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6013. .channel_mode = alc883_3ST_6ch_modes,
  6014. .need_dac_fix = 1,
  6015. .input_mux = &alc883_capture_source,
  6016. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6017. .init_hook = alc888_lenovo_ms7195_front_automute,
  6018. },
  6019. };
  6020. /*
  6021. * BIOS auto configuration
  6022. */
  6023. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6024. hda_nid_t nid, int pin_type,
  6025. int dac_idx)
  6026. {
  6027. /* set as output */
  6028. struct alc_spec *spec = codec->spec;
  6029. int idx;
  6030. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6031. idx = 4;
  6032. else
  6033. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6034. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6035. pin_type);
  6036. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6037. AMP_OUT_UNMUTE);
  6038. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6039. }
  6040. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6041. {
  6042. struct alc_spec *spec = codec->spec;
  6043. int i;
  6044. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6045. for (i = 0; i <= HDA_SIDE; i++) {
  6046. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6047. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6048. if (nid)
  6049. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6050. i);
  6051. }
  6052. }
  6053. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6054. {
  6055. struct alc_spec *spec = codec->spec;
  6056. hda_nid_t pin;
  6057. pin = spec->autocfg.hp_pins[0];
  6058. if (pin) /* connect to front */
  6059. /* use dac 0 */
  6060. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6061. }
  6062. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6063. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6064. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6065. {
  6066. struct alc_spec *spec = codec->spec;
  6067. int i;
  6068. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6069. hda_nid_t nid = spec->autocfg.input_pins[i];
  6070. if (alc883_is_input_pin(nid)) {
  6071. snd_hda_codec_write(codec, nid, 0,
  6072. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6073. (i <= AUTO_PIN_FRONT_MIC ?
  6074. PIN_VREF80 : PIN_IN));
  6075. if (nid != ALC883_PIN_CD_NID)
  6076. snd_hda_codec_write(codec, nid, 0,
  6077. AC_VERB_SET_AMP_GAIN_MUTE,
  6078. AMP_OUT_MUTE);
  6079. }
  6080. }
  6081. }
  6082. /* almost identical with ALC880 parser... */
  6083. static int alc883_parse_auto_config(struct hda_codec *codec)
  6084. {
  6085. struct alc_spec *spec = codec->spec;
  6086. int err = alc880_parse_auto_config(codec);
  6087. if (err < 0)
  6088. return err;
  6089. else if (err > 0)
  6090. /* hack - override the init verbs */
  6091. spec->init_verbs[0] = alc883_auto_init_verbs;
  6092. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6093. spec->num_mixers++;
  6094. return err;
  6095. }
  6096. /* additional initialization for auto-configuration model */
  6097. static void alc883_auto_init(struct hda_codec *codec)
  6098. {
  6099. alc883_auto_init_multi_out(codec);
  6100. alc883_auto_init_hp_out(codec);
  6101. alc883_auto_init_analog_input(codec);
  6102. }
  6103. static int patch_alc883(struct hda_codec *codec)
  6104. {
  6105. struct alc_spec *spec;
  6106. int err, board_config;
  6107. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6108. if (spec == NULL)
  6109. return -ENOMEM;
  6110. codec->spec = spec;
  6111. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6112. alc883_models,
  6113. alc883_cfg_tbl);
  6114. if (board_config < 0) {
  6115. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6116. "trying auto-probe from BIOS...\n");
  6117. board_config = ALC883_AUTO;
  6118. }
  6119. if (board_config == ALC883_AUTO) {
  6120. /* automatic parse from the BIOS config */
  6121. err = alc883_parse_auto_config(codec);
  6122. if (err < 0) {
  6123. alc_free(codec);
  6124. return err;
  6125. } else if (!err) {
  6126. printk(KERN_INFO
  6127. "hda_codec: Cannot set up configuration "
  6128. "from BIOS. Using base mode...\n");
  6129. board_config = ALC883_3ST_2ch_DIG;
  6130. }
  6131. }
  6132. if (board_config != ALC883_AUTO)
  6133. setup_preset(spec, &alc883_presets[board_config]);
  6134. spec->stream_name_analog = "ALC883 Analog";
  6135. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6136. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6137. spec->stream_name_digital = "ALC883 Digital";
  6138. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6139. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6140. if (!spec->adc_nids && spec->input_mux) {
  6141. spec->adc_nids = alc883_adc_nids;
  6142. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6143. }
  6144. codec->patch_ops = alc_patch_ops;
  6145. if (board_config == ALC883_AUTO)
  6146. spec->init_hook = alc883_auto_init;
  6147. return 0;
  6148. }
  6149. /*
  6150. * ALC262 support
  6151. */
  6152. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6153. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6154. #define alc262_dac_nids alc260_dac_nids
  6155. #define alc262_adc_nids alc882_adc_nids
  6156. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6157. #define alc262_modes alc260_modes
  6158. #define alc262_capture_source alc882_capture_source
  6159. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6160. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6161. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6162. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6163. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6164. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6165. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6166. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6167. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6168. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6169. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6170. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6171. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6172. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6173. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6174. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6175. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6176. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6177. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6178. { } /* end */
  6179. };
  6180. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6181. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6182. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6183. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6184. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6185. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6186. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6187. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6188. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6190. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6191. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6192. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6193. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6194. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6195. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6196. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6197. { } /* end */
  6198. };
  6199. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6200. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6201. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6202. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6203. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6204. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6205. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6206. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6207. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6208. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6209. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6210. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6211. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6212. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6213. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6214. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6215. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6216. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6217. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6218. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6219. { } /* end */
  6220. };
  6221. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6222. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6223. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6224. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6225. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6226. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6227. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6228. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6229. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6230. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6231. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6232. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6233. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6234. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6235. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6236. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6237. { } /* end */
  6238. };
  6239. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6240. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6241. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6242. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6243. { } /* end */
  6244. };
  6245. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6246. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6247. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6248. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6249. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6250. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6251. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6252. { } /* end */
  6253. };
  6254. #define alc262_capture_mixer alc882_capture_mixer
  6255. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6256. /*
  6257. * generic initialization of ADC, input mixers and output mixers
  6258. */
  6259. static struct hda_verb alc262_init_verbs[] = {
  6260. /*
  6261. * Unmute ADC0-2 and set the default input to mic-in
  6262. */
  6263. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6264. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6265. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6266. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6267. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6268. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6269. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6270. * mixer widget
  6271. * Note: PASD motherboards uses the Line In 2 as the input for
  6272. * front panel mic (mic 2)
  6273. */
  6274. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6280. /*
  6281. * Set up output mixers (0x0c - 0x0e)
  6282. */
  6283. /* set vol=0 to output mixers */
  6284. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6285. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6286. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6287. /* set up input amps for analog loopback */
  6288. /* Amp Indices: DAC = 0, mixer = 1 */
  6289. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6290. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6291. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6292. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6293. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6294. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6295. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6296. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6297. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6298. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6299. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6300. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6301. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6302. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6303. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6304. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6305. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6306. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6307. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6308. /* FIXME: use matrix-type input source selection */
  6309. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6310. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6311. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6312. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6313. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6314. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6315. /* Input mixer2 */
  6316. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6317. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6318. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6319. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6320. /* Input mixer3 */
  6321. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6322. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6323. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6324. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6325. { }
  6326. };
  6327. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6328. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6329. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6330. {}
  6331. };
  6332. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6333. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6334. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6335. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6336. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6337. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6338. {}
  6339. };
  6340. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6341. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6342. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6343. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6344. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6345. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6346. };
  6347. /* mute/unmute internal speaker according to the hp jack and mute state */
  6348. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6349. {
  6350. struct alc_spec *spec = codec->spec;
  6351. unsigned int mute;
  6352. if (force || !spec->sense_updated) {
  6353. unsigned int present;
  6354. /* need to execute and sync at first */
  6355. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6356. present = snd_hda_codec_read(codec, 0x15, 0,
  6357. AC_VERB_GET_PIN_SENSE, 0);
  6358. spec->jack_present = (present & 0x80000000) != 0;
  6359. spec->sense_updated = 1;
  6360. }
  6361. if (spec->jack_present) {
  6362. /* mute internal speaker */
  6363. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6364. 0x80, 0x80);
  6365. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6366. 0x80, 0x80);
  6367. } else {
  6368. /* unmute internal speaker if necessary */
  6369. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6370. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6371. 0x80, mute & 0x80);
  6372. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6373. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6374. 0x80, mute & 0x80);
  6375. }
  6376. }
  6377. /* unsolicited event for HP jack sensing */
  6378. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6379. unsigned int res)
  6380. {
  6381. if ((res >> 26) != ALC880_HP_EVENT)
  6382. return;
  6383. alc262_hippo_automute(codec, 1);
  6384. }
  6385. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6386. {
  6387. struct alc_spec *spec = codec->spec;
  6388. unsigned int mute;
  6389. if (force || !spec->sense_updated) {
  6390. unsigned int present;
  6391. /* need to execute and sync at first */
  6392. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6393. present = snd_hda_codec_read(codec, 0x1b, 0,
  6394. AC_VERB_GET_PIN_SENSE, 0);
  6395. spec->jack_present = (present & 0x80000000) != 0;
  6396. spec->sense_updated = 1;
  6397. }
  6398. if (spec->jack_present) {
  6399. /* mute internal speaker */
  6400. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6401. 0x80, 0x80);
  6402. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6403. 0x80, 0x80);
  6404. } else {
  6405. /* unmute internal speaker if necessary */
  6406. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6407. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6408. 0x80, mute & 0x80);
  6409. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6410. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6411. 0x80, mute & 0x80);
  6412. }
  6413. }
  6414. /* unsolicited event for HP jack sensing */
  6415. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6416. unsigned int res)
  6417. {
  6418. if ((res >> 26) != ALC880_HP_EVENT)
  6419. return;
  6420. alc262_hippo1_automute(codec, 1);
  6421. }
  6422. /*
  6423. * fujitsu model
  6424. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6425. */
  6426. #define ALC_HP_EVENT 0x37
  6427. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6428. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6429. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6430. {}
  6431. };
  6432. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6433. .num_items = 2,
  6434. .items = {
  6435. { "Mic", 0x0 },
  6436. { "CD", 0x4 },
  6437. },
  6438. };
  6439. static struct hda_input_mux alc262_HP_capture_source = {
  6440. .num_items = 5,
  6441. .items = {
  6442. { "Mic", 0x0 },
  6443. { "Front Mic", 0x3 },
  6444. { "Line", 0x2 },
  6445. { "CD", 0x4 },
  6446. { "AUX IN", 0x6 },
  6447. },
  6448. };
  6449. /* mute/unmute internal speaker according to the hp jack and mute state */
  6450. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6451. {
  6452. struct alc_spec *spec = codec->spec;
  6453. unsigned int mute;
  6454. if (force || !spec->sense_updated) {
  6455. unsigned int present;
  6456. /* need to execute and sync at first */
  6457. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6458. present = snd_hda_codec_read(codec, 0x14, 0,
  6459. AC_VERB_GET_PIN_SENSE, 0);
  6460. spec->jack_present = (present & 0x80000000) != 0;
  6461. spec->sense_updated = 1;
  6462. }
  6463. if (spec->jack_present) {
  6464. /* mute internal speaker */
  6465. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6466. 0x80, 0x80);
  6467. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6468. 0x80, 0x80);
  6469. } else {
  6470. /* unmute internal speaker if necessary */
  6471. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6472. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6473. 0x80, mute & 0x80);
  6474. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6475. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6476. 0x80, mute & 0x80);
  6477. }
  6478. }
  6479. /* unsolicited event for HP jack sensing */
  6480. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6481. unsigned int res)
  6482. {
  6483. if ((res >> 26) != ALC_HP_EVENT)
  6484. return;
  6485. alc262_fujitsu_automute(codec, 1);
  6486. }
  6487. /* bind volumes of both NID 0x0c and 0x0d */
  6488. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6489. struct snd_ctl_elem_value *ucontrol)
  6490. {
  6491. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6492. long *valp = ucontrol->value.integer.value;
  6493. int change;
  6494. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6495. 0x7f, valp[0] & 0x7f);
  6496. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6497. 0x7f, valp[1] & 0x7f);
  6498. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6499. 0x7f, valp[0] & 0x7f);
  6500. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6501. 0x7f, valp[1] & 0x7f);
  6502. return change;
  6503. }
  6504. /* bind hp and internal speaker mute (with plug check) */
  6505. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6506. struct snd_ctl_elem_value *ucontrol)
  6507. {
  6508. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6509. long *valp = ucontrol->value.integer.value;
  6510. int change;
  6511. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6512. 0x80, valp[0] ? 0 : 0x80);
  6513. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6514. 0x80, valp[1] ? 0 : 0x80);
  6515. if (change || codec->in_resume)
  6516. alc262_fujitsu_automute(codec, codec->in_resume);
  6517. return change;
  6518. }
  6519. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6520. {
  6521. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6522. .name = "Master Playback Volume",
  6523. .info = snd_hda_mixer_amp_volume_info,
  6524. .get = snd_hda_mixer_amp_volume_get,
  6525. .put = alc262_fujitsu_master_vol_put,
  6526. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6527. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6528. },
  6529. {
  6530. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6531. .name = "Master Playback Switch",
  6532. .info = snd_hda_mixer_amp_switch_info,
  6533. .get = snd_hda_mixer_amp_switch_get,
  6534. .put = alc262_fujitsu_master_sw_put,
  6535. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6536. },
  6537. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6538. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6539. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6540. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6541. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6542. { } /* end */
  6543. };
  6544. /* additional init verbs for Benq laptops */
  6545. static struct hda_verb alc262_EAPD_verbs[] = {
  6546. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6547. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6548. {}
  6549. };
  6550. /* add playback controls from the parsed DAC table */
  6551. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6552. const struct auto_pin_cfg *cfg)
  6553. {
  6554. hda_nid_t nid;
  6555. int err;
  6556. spec->multiout.num_dacs = 1; /* only use one dac */
  6557. spec->multiout.dac_nids = spec->private_dac_nids;
  6558. spec->multiout.dac_nids[0] = 2;
  6559. nid = cfg->line_out_pins[0];
  6560. if (nid) {
  6561. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6562. "Front Playback Volume",
  6563. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6564. if (err < 0)
  6565. return err;
  6566. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6567. "Front Playback Switch",
  6568. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6569. if (err < 0)
  6570. return err;
  6571. }
  6572. nid = cfg->speaker_pins[0];
  6573. if (nid) {
  6574. if (nid == 0x16) {
  6575. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6576. "Speaker Playback Volume",
  6577. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6578. HDA_OUTPUT));
  6579. if (err < 0)
  6580. return err;
  6581. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6582. "Speaker Playback Switch",
  6583. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6584. HDA_OUTPUT));
  6585. if (err < 0)
  6586. return err;
  6587. } else {
  6588. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6589. "Speaker Playback Switch",
  6590. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6591. HDA_OUTPUT));
  6592. if (err < 0)
  6593. return err;
  6594. }
  6595. }
  6596. nid = cfg->hp_pins[0];
  6597. if (nid) {
  6598. /* spec->multiout.hp_nid = 2; */
  6599. if (nid == 0x16) {
  6600. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6601. "Headphone Playback Volume",
  6602. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6603. HDA_OUTPUT));
  6604. if (err < 0)
  6605. return err;
  6606. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6607. "Headphone Playback Switch",
  6608. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6609. HDA_OUTPUT));
  6610. if (err < 0)
  6611. return err;
  6612. } else {
  6613. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6614. "Headphone Playback Switch",
  6615. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6616. HDA_OUTPUT));
  6617. if (err < 0)
  6618. return err;
  6619. }
  6620. }
  6621. return 0;
  6622. }
  6623. /* identical with ALC880 */
  6624. #define alc262_auto_create_analog_input_ctls \
  6625. alc880_auto_create_analog_input_ctls
  6626. /*
  6627. * generic initialization of ADC, input mixers and output mixers
  6628. */
  6629. static struct hda_verb alc262_volume_init_verbs[] = {
  6630. /*
  6631. * Unmute ADC0-2 and set the default input to mic-in
  6632. */
  6633. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6635. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6636. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6637. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6638. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6639. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6640. * mixer widget
  6641. * Note: PASD motherboards uses the Line In 2 as the input for
  6642. * front panel mic (mic 2)
  6643. */
  6644. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6645. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6646. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6647. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6648. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6649. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6650. /*
  6651. * Set up output mixers (0x0c - 0x0f)
  6652. */
  6653. /* set vol=0 to output mixers */
  6654. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6655. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6656. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6657. /* set up input amps for analog loopback */
  6658. /* Amp Indices: DAC = 0, mixer = 1 */
  6659. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6660. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6661. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6662. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6663. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6664. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6665. /* FIXME: use matrix-type input source selection */
  6666. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6667. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6668. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6669. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6670. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6671. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6672. /* Input mixer2 */
  6673. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6674. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6675. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6676. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6677. /* Input mixer3 */
  6678. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6679. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6680. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6681. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6682. { }
  6683. };
  6684. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6685. /*
  6686. * Unmute ADC0-2 and set the default input to mic-in
  6687. */
  6688. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6689. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6690. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6692. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6693. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6694. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6695. * mixer widget
  6696. * Note: PASD motherboards uses the Line In 2 as the input for
  6697. * front panel mic (mic 2)
  6698. */
  6699. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6705. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6706. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6707. /*
  6708. * Set up output mixers (0x0c - 0x0e)
  6709. */
  6710. /* set vol=0 to output mixers */
  6711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6712. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6713. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6714. /* set up input amps for analog loopback */
  6715. /* Amp Indices: DAC = 0, mixer = 1 */
  6716. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6717. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6718. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6719. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6720. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6721. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6722. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6723. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6724. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6725. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6726. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6727. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6728. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6729. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6730. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6731. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6732. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6733. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6734. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6735. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6736. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6737. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6738. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6739. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6740. /* FIXME: use matrix-type input source selection */
  6741. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6742. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6743. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6744. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6745. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6746. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6747. /* Input mixer2 */
  6748. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6749. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6750. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6751. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6752. /* Input mixer3 */
  6753. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6754. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6755. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6756. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6757. { }
  6758. };
  6759. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6760. /*
  6761. * Unmute ADC0-2 and set the default input to mic-in
  6762. */
  6763. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6764. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6765. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6766. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6767. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6768. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6769. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6770. * mixer widget
  6771. * Note: PASD motherboards uses the Line In 2 as the input for front
  6772. * panel mic (mic 2)
  6773. */
  6774. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6775. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6776. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6777. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6778. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6779. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6780. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6781. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6782. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6783. /*
  6784. * Set up output mixers (0x0c - 0x0e)
  6785. */
  6786. /* set vol=0 to output mixers */
  6787. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6788. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6789. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6790. /* set up input amps for analog loopback */
  6791. /* Amp Indices: DAC = 0, mixer = 1 */
  6792. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6793. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6794. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6795. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6796. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6797. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6798. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6799. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6800. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6801. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6802. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6803. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6804. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6805. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6806. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6807. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6808. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6809. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6810. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6811. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6812. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6813. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6814. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6815. /* FIXME: use matrix-type input source selection */
  6816. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6817. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6818. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6819. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6820. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6821. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6822. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6823. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6824. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6825. /* Input mixer2 */
  6826. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6827. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6828. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6829. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6830. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6831. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6832. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6833. /* Input mixer3 */
  6834. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6835. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6837. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6838. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6839. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6840. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6841. { }
  6842. };
  6843. /* pcm configuration: identiacal with ALC880 */
  6844. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6845. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6846. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6847. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6848. /*
  6849. * BIOS auto configuration
  6850. */
  6851. static int alc262_parse_auto_config(struct hda_codec *codec)
  6852. {
  6853. struct alc_spec *spec = codec->spec;
  6854. int err;
  6855. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6856. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6857. alc262_ignore);
  6858. if (err < 0)
  6859. return err;
  6860. if (!spec->autocfg.line_outs)
  6861. return 0; /* can't find valid BIOS pin config */
  6862. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6863. if (err < 0)
  6864. return err;
  6865. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6866. if (err < 0)
  6867. return err;
  6868. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6869. if (spec->autocfg.dig_out_pin)
  6870. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6871. if (spec->autocfg.dig_in_pin)
  6872. spec->dig_in_nid = ALC262_DIGIN_NID;
  6873. if (spec->kctl_alloc)
  6874. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6875. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6876. spec->num_mux_defs = 1;
  6877. spec->input_mux = &spec->private_imux;
  6878. return 1;
  6879. }
  6880. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6881. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6882. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6883. /* init callback for auto-configuration model -- overriding the default init */
  6884. static void alc262_auto_init(struct hda_codec *codec)
  6885. {
  6886. alc262_auto_init_multi_out(codec);
  6887. alc262_auto_init_hp_out(codec);
  6888. alc262_auto_init_analog_input(codec);
  6889. }
  6890. /*
  6891. * configuration and preset
  6892. */
  6893. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6894. [ALC262_BASIC] = "basic",
  6895. [ALC262_HIPPO] = "hippo",
  6896. [ALC262_HIPPO_1] = "hippo_1",
  6897. [ALC262_FUJITSU] = "fujitsu",
  6898. [ALC262_HP_BPC] = "hp-bpc",
  6899. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6900. [ALC262_BENQ_ED8] = "benq",
  6901. [ALC262_BENQ_ED8] = "sony-assamd",
  6902. [ALC262_AUTO] = "auto",
  6903. };
  6904. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6905. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6906. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6907. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6908. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  6909. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  6910. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6911. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  6912. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6913. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  6914. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6915. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6916. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6917. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6918. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6919. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6920. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6921. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6922. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6923. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6924. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6925. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6926. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6927. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6928. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6929. {}
  6930. };
  6931. static struct alc_config_preset alc262_presets[] = {
  6932. [ALC262_BASIC] = {
  6933. .mixers = { alc262_base_mixer },
  6934. .init_verbs = { alc262_init_verbs },
  6935. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6936. .dac_nids = alc262_dac_nids,
  6937. .hp_nid = 0x03,
  6938. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6939. .channel_mode = alc262_modes,
  6940. .input_mux = &alc262_capture_source,
  6941. },
  6942. [ALC262_HIPPO] = {
  6943. .mixers = { alc262_base_mixer },
  6944. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6945. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6946. .dac_nids = alc262_dac_nids,
  6947. .hp_nid = 0x03,
  6948. .dig_out_nid = ALC262_DIGOUT_NID,
  6949. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6950. .channel_mode = alc262_modes,
  6951. .input_mux = &alc262_capture_source,
  6952. .unsol_event = alc262_hippo_unsol_event,
  6953. },
  6954. [ALC262_HIPPO_1] = {
  6955. .mixers = { alc262_hippo1_mixer },
  6956. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6957. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6958. .dac_nids = alc262_dac_nids,
  6959. .hp_nid = 0x02,
  6960. .dig_out_nid = ALC262_DIGOUT_NID,
  6961. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6962. .channel_mode = alc262_modes,
  6963. .input_mux = &alc262_capture_source,
  6964. .unsol_event = alc262_hippo1_unsol_event,
  6965. },
  6966. [ALC262_FUJITSU] = {
  6967. .mixers = { alc262_fujitsu_mixer },
  6968. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6969. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6970. .dac_nids = alc262_dac_nids,
  6971. .hp_nid = 0x03,
  6972. .dig_out_nid = ALC262_DIGOUT_NID,
  6973. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6974. .channel_mode = alc262_modes,
  6975. .input_mux = &alc262_fujitsu_capture_source,
  6976. .unsol_event = alc262_fujitsu_unsol_event,
  6977. },
  6978. [ALC262_HP_BPC] = {
  6979. .mixers = { alc262_HP_BPC_mixer },
  6980. .init_verbs = { alc262_HP_BPC_init_verbs },
  6981. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6982. .dac_nids = alc262_dac_nids,
  6983. .hp_nid = 0x03,
  6984. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6985. .channel_mode = alc262_modes,
  6986. .input_mux = &alc262_HP_capture_source,
  6987. },
  6988. [ALC262_HP_BPC_D7000_WF] = {
  6989. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6990. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6991. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6992. .dac_nids = alc262_dac_nids,
  6993. .hp_nid = 0x03,
  6994. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6995. .channel_mode = alc262_modes,
  6996. .input_mux = &alc262_HP_capture_source,
  6997. },
  6998. [ALC262_HP_BPC_D7000_WL] = {
  6999. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7000. alc262_HP_BPC_WildWest_option_mixer },
  7001. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7002. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7003. .dac_nids = alc262_dac_nids,
  7004. .hp_nid = 0x03,
  7005. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7006. .channel_mode = alc262_modes,
  7007. .input_mux = &alc262_HP_capture_source,
  7008. },
  7009. [ALC262_BENQ_ED8] = {
  7010. .mixers = { alc262_base_mixer },
  7011. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7012. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7013. .dac_nids = alc262_dac_nids,
  7014. .hp_nid = 0x03,
  7015. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7016. .channel_mode = alc262_modes,
  7017. .input_mux = &alc262_capture_source,
  7018. },
  7019. [ALC262_SONY_ASSAMD] = {
  7020. .mixers = { alc262_sony_mixer },
  7021. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7022. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7023. .dac_nids = alc262_dac_nids,
  7024. .hp_nid = 0x02,
  7025. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7026. .channel_mode = alc262_modes,
  7027. .input_mux = &alc262_capture_source,
  7028. .unsol_event = alc262_hippo_unsol_event,
  7029. },
  7030. };
  7031. static int patch_alc262(struct hda_codec *codec)
  7032. {
  7033. struct alc_spec *spec;
  7034. int board_config;
  7035. int err;
  7036. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7037. if (spec == NULL)
  7038. return -ENOMEM;
  7039. codec->spec = spec;
  7040. #if 0
  7041. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7042. * under-run
  7043. */
  7044. {
  7045. int tmp;
  7046. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7047. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7048. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7049. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7050. }
  7051. #endif
  7052. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7053. alc262_models,
  7054. alc262_cfg_tbl);
  7055. if (board_config < 0) {
  7056. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7057. "trying auto-probe from BIOS...\n");
  7058. board_config = ALC262_AUTO;
  7059. }
  7060. if (board_config == ALC262_AUTO) {
  7061. /* automatic parse from the BIOS config */
  7062. err = alc262_parse_auto_config(codec);
  7063. if (err < 0) {
  7064. alc_free(codec);
  7065. return err;
  7066. } else if (!err) {
  7067. printk(KERN_INFO
  7068. "hda_codec: Cannot set up configuration "
  7069. "from BIOS. Using base mode...\n");
  7070. board_config = ALC262_BASIC;
  7071. }
  7072. }
  7073. if (board_config != ALC262_AUTO)
  7074. setup_preset(spec, &alc262_presets[board_config]);
  7075. spec->stream_name_analog = "ALC262 Analog";
  7076. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7077. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7078. spec->stream_name_digital = "ALC262 Digital";
  7079. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7080. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7081. if (!spec->adc_nids && spec->input_mux) {
  7082. /* check whether NID 0x07 is valid */
  7083. unsigned int wcap = get_wcaps(codec, 0x07);
  7084. /* get type */
  7085. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7086. if (wcap != AC_WID_AUD_IN) {
  7087. spec->adc_nids = alc262_adc_nids_alt;
  7088. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7089. spec->mixers[spec->num_mixers] =
  7090. alc262_capture_alt_mixer;
  7091. spec->num_mixers++;
  7092. } else {
  7093. spec->adc_nids = alc262_adc_nids;
  7094. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7095. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7096. spec->num_mixers++;
  7097. }
  7098. }
  7099. codec->patch_ops = alc_patch_ops;
  7100. if (board_config == ALC262_AUTO)
  7101. spec->init_hook = alc262_auto_init;
  7102. return 0;
  7103. }
  7104. /*
  7105. * ALC268 channel source setting (2 channel)
  7106. */
  7107. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7108. #define alc268_modes alc260_modes
  7109. static hda_nid_t alc268_dac_nids[2] = {
  7110. /* front, hp */
  7111. 0x02, 0x03
  7112. };
  7113. static hda_nid_t alc268_adc_nids[2] = {
  7114. /* ADC0-1 */
  7115. 0x08, 0x07
  7116. };
  7117. static hda_nid_t alc268_adc_nids_alt[1] = {
  7118. /* ADC0 */
  7119. 0x08
  7120. };
  7121. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7122. /* output mixer control */
  7123. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7124. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7125. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7126. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7127. { }
  7128. };
  7129. /*
  7130. * generic initialization of ADC, input mixers and output mixers
  7131. */
  7132. static struct hda_verb alc268_base_init_verbs[] = {
  7133. /* Unmute DAC0-1 and set vol = 0 */
  7134. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7135. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7136. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7137. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7138. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7139. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7140. /*
  7141. * Set up output mixers (0x0c - 0x0e)
  7142. */
  7143. /* set vol=0 to output mixers */
  7144. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7145. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7146. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7147. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7148. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7149. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7150. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7151. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7152. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7153. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7154. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7155. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7156. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7157. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7158. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7159. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7160. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7161. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7162. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7163. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7164. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7165. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7166. /* FIXME: use matrix-type input source selection */
  7167. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7168. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7169. /* Input mixer2 */
  7170. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7171. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7172. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7173. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7174. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7175. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7176. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7177. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7178. { }
  7179. };
  7180. /*
  7181. * generic initialization of ADC, input mixers and output mixers
  7182. */
  7183. static struct hda_verb alc268_volume_init_verbs[] = {
  7184. /* set output DAC */
  7185. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7186. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7187. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7188. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7189. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7190. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7191. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7192. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7193. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7198. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7199. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7200. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7201. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7202. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7203. /* set PCBEEP vol = 0 */
  7204. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7205. { }
  7206. };
  7207. #define alc268_mux_enum_info alc_mux_enum_info
  7208. #define alc268_mux_enum_get alc_mux_enum_get
  7209. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7210. struct snd_ctl_elem_value *ucontrol)
  7211. {
  7212. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7213. struct alc_spec *spec = codec->spec;
  7214. const struct hda_input_mux *imux = spec->input_mux;
  7215. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7216. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7217. hda_nid_t nid = capture_mixers[adc_idx];
  7218. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7219. unsigned int i, idx;
  7220. idx = ucontrol->value.enumerated.item[0];
  7221. if (idx >= imux->num_items)
  7222. idx = imux->num_items - 1;
  7223. if (*cur_val == idx && !codec->in_resume)
  7224. return 0;
  7225. for (i = 0; i < imux->num_items; i++) {
  7226. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7227. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7228. v | (imux->items[i].index << 8));
  7229. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7230. idx );
  7231. }
  7232. *cur_val = idx;
  7233. return 1;
  7234. }
  7235. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7236. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7237. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7238. {
  7239. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7240. /* The multiple "Capture Source" controls confuse alsamixer
  7241. * So call somewhat different..
  7242. * FIXME: the controls appear in the "playback" view!
  7243. */
  7244. /* .name = "Capture Source", */
  7245. .name = "Input Source",
  7246. .count = 1,
  7247. .info = alc268_mux_enum_info,
  7248. .get = alc268_mux_enum_get,
  7249. .put = alc268_mux_enum_put,
  7250. },
  7251. { } /* end */
  7252. };
  7253. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7254. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7255. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7256. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7257. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7258. {
  7259. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7260. /* The multiple "Capture Source" controls confuse alsamixer
  7261. * So call somewhat different..
  7262. * FIXME: the controls appear in the "playback" view!
  7263. */
  7264. /* .name = "Capture Source", */
  7265. .name = "Input Source",
  7266. .count = 2,
  7267. .info = alc268_mux_enum_info,
  7268. .get = alc268_mux_enum_get,
  7269. .put = alc268_mux_enum_put,
  7270. },
  7271. { } /* end */
  7272. };
  7273. static struct hda_input_mux alc268_capture_source = {
  7274. .num_items = 4,
  7275. .items = {
  7276. { "Mic", 0x0 },
  7277. { "Front Mic", 0x1 },
  7278. { "Line", 0x2 },
  7279. { "CD", 0x3 },
  7280. },
  7281. };
  7282. /* create input playback/capture controls for the given pin */
  7283. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7284. const char *ctlname, int idx)
  7285. {
  7286. char name[32];
  7287. int err;
  7288. sprintf(name, "%s Playback Volume", ctlname);
  7289. if (nid == 0x14) {
  7290. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7291. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7292. HDA_OUTPUT));
  7293. if (err < 0)
  7294. return err;
  7295. } else if (nid == 0x15) {
  7296. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7297. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7298. HDA_OUTPUT));
  7299. if (err < 0)
  7300. return err;
  7301. } else
  7302. return -1;
  7303. sprintf(name, "%s Playback Switch", ctlname);
  7304. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7305. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7306. if (err < 0)
  7307. return err;
  7308. return 0;
  7309. }
  7310. /* add playback controls from the parsed DAC table */
  7311. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7312. const struct auto_pin_cfg *cfg)
  7313. {
  7314. hda_nid_t nid;
  7315. int err;
  7316. spec->multiout.num_dacs = 2; /* only use one dac */
  7317. spec->multiout.dac_nids = spec->private_dac_nids;
  7318. spec->multiout.dac_nids[0] = 2;
  7319. spec->multiout.dac_nids[1] = 3;
  7320. nid = cfg->line_out_pins[0];
  7321. if (nid)
  7322. alc268_new_analog_output(spec, nid, "Front", 0);
  7323. nid = cfg->speaker_pins[0];
  7324. if (nid == 0x1d) {
  7325. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7326. "Speaker Playback Volume",
  7327. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7328. if (err < 0)
  7329. return err;
  7330. }
  7331. nid = cfg->hp_pins[0];
  7332. if (nid)
  7333. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7334. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7335. if (nid == 0x16) {
  7336. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7337. "Mono Playback Switch",
  7338. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7339. if (err < 0)
  7340. return err;
  7341. }
  7342. return 0;
  7343. }
  7344. /* create playback/capture controls for input pins */
  7345. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7346. const struct auto_pin_cfg *cfg)
  7347. {
  7348. struct hda_input_mux *imux = &spec->private_imux;
  7349. int i, idx1;
  7350. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7351. switch(cfg->input_pins[i]) {
  7352. case 0x18:
  7353. idx1 = 0; /* Mic 1 */
  7354. break;
  7355. case 0x19:
  7356. idx1 = 1; /* Mic 2 */
  7357. break;
  7358. case 0x1a:
  7359. idx1 = 2; /* Line In */
  7360. break;
  7361. case 0x1c:
  7362. idx1 = 3; /* CD */
  7363. break;
  7364. default:
  7365. continue;
  7366. }
  7367. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7368. imux->items[imux->num_items].index = idx1;
  7369. imux->num_items++;
  7370. }
  7371. return 0;
  7372. }
  7373. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7374. {
  7375. struct alc_spec *spec = codec->spec;
  7376. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7377. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7378. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7379. unsigned int dac_vol1, dac_vol2;
  7380. if (speaker_nid) {
  7381. snd_hda_codec_write(codec, speaker_nid, 0,
  7382. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7383. snd_hda_codec_write(codec, 0x0f, 0,
  7384. AC_VERB_SET_AMP_GAIN_MUTE,
  7385. AMP_IN_UNMUTE(1));
  7386. snd_hda_codec_write(codec, 0x10, 0,
  7387. AC_VERB_SET_AMP_GAIN_MUTE,
  7388. AMP_IN_UNMUTE(1));
  7389. } else {
  7390. snd_hda_codec_write(codec, 0x0f, 0,
  7391. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7392. snd_hda_codec_write(codec, 0x10, 0,
  7393. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7394. }
  7395. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7396. if (line_nid == 0x14)
  7397. dac_vol2 = AMP_OUT_ZERO;
  7398. else if (line_nid == 0x15)
  7399. dac_vol1 = AMP_OUT_ZERO;
  7400. if (hp_nid == 0x14)
  7401. dac_vol2 = AMP_OUT_ZERO;
  7402. else if (hp_nid == 0x15)
  7403. dac_vol1 = AMP_OUT_ZERO;
  7404. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7405. spec->autocfg.line_out_pins[1] != 0x16 ||
  7406. spec->autocfg.line_out_pins[2] != 0x16)
  7407. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7408. snd_hda_codec_write(codec, 0x02, 0,
  7409. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7410. snd_hda_codec_write(codec, 0x03, 0,
  7411. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7412. }
  7413. /* pcm configuration: identiacal with ALC880 */
  7414. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7415. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7416. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7417. /*
  7418. * BIOS auto configuration
  7419. */
  7420. static int alc268_parse_auto_config(struct hda_codec *codec)
  7421. {
  7422. struct alc_spec *spec = codec->spec;
  7423. int err;
  7424. static hda_nid_t alc268_ignore[] = { 0 };
  7425. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7426. alc268_ignore);
  7427. if (err < 0)
  7428. return err;
  7429. if (!spec->autocfg.line_outs)
  7430. return 0; /* can't find valid BIOS pin config */
  7431. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7432. if (err < 0)
  7433. return err;
  7434. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7435. if (err < 0)
  7436. return err;
  7437. spec->multiout.max_channels = 2;
  7438. /* digital only support output */
  7439. if (spec->autocfg.dig_out_pin)
  7440. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7441. if (spec->kctl_alloc)
  7442. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7443. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7444. spec->num_mux_defs = 1;
  7445. spec->input_mux = &spec->private_imux;
  7446. return 1;
  7447. }
  7448. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7449. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7450. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7451. /* init callback for auto-configuration model -- overriding the default init */
  7452. static void alc268_auto_init(struct hda_codec *codec)
  7453. {
  7454. alc268_auto_init_multi_out(codec);
  7455. alc268_auto_init_hp_out(codec);
  7456. alc268_auto_init_mono_speaker_out(codec);
  7457. alc268_auto_init_analog_input(codec);
  7458. }
  7459. /*
  7460. * configuration and preset
  7461. */
  7462. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7463. [ALC268_3ST] = "3stack",
  7464. [ALC268_AUTO] = "auto",
  7465. };
  7466. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7467. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7468. {}
  7469. };
  7470. static struct alc_config_preset alc268_presets[] = {
  7471. [ALC268_3ST] = {
  7472. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7473. .init_verbs = { alc268_base_init_verbs },
  7474. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7475. .dac_nids = alc268_dac_nids,
  7476. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7477. .adc_nids = alc268_adc_nids_alt,
  7478. .hp_nid = 0x03,
  7479. .dig_out_nid = ALC268_DIGOUT_NID,
  7480. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7481. .channel_mode = alc268_modes,
  7482. .input_mux = &alc268_capture_source,
  7483. },
  7484. };
  7485. static int patch_alc268(struct hda_codec *codec)
  7486. {
  7487. struct alc_spec *spec;
  7488. int board_config;
  7489. int err;
  7490. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7491. if (spec == NULL)
  7492. return -ENOMEM;
  7493. codec->spec = spec;
  7494. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7495. alc268_models,
  7496. alc268_cfg_tbl);
  7497. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7498. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7499. "trying auto-probe from BIOS...\n");
  7500. board_config = ALC268_AUTO;
  7501. }
  7502. if (board_config == ALC268_AUTO) {
  7503. /* automatic parse from the BIOS config */
  7504. err = alc268_parse_auto_config(codec);
  7505. if (err < 0) {
  7506. alc_free(codec);
  7507. return err;
  7508. } else if (!err) {
  7509. printk(KERN_INFO
  7510. "hda_codec: Cannot set up configuration "
  7511. "from BIOS. Using base mode...\n");
  7512. board_config = ALC268_3ST;
  7513. }
  7514. }
  7515. if (board_config != ALC268_AUTO)
  7516. setup_preset(spec, &alc268_presets[board_config]);
  7517. spec->stream_name_analog = "ALC268 Analog";
  7518. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7519. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7520. spec->stream_name_digital = "ALC268 Digital";
  7521. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7522. if (board_config == ALC268_AUTO) {
  7523. if (!spec->adc_nids && spec->input_mux) {
  7524. /* check whether NID 0x07 is valid */
  7525. unsigned int wcap = get_wcaps(codec, 0x07);
  7526. /* get type */
  7527. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7528. if (wcap != AC_WID_AUD_IN) {
  7529. spec->adc_nids = alc268_adc_nids_alt;
  7530. spec->num_adc_nids =
  7531. ARRAY_SIZE(alc268_adc_nids_alt);
  7532. spec->mixers[spec->num_mixers] =
  7533. alc268_capture_alt_mixer;
  7534. spec->num_mixers++;
  7535. } else {
  7536. spec->adc_nids = alc268_adc_nids;
  7537. spec->num_adc_nids =
  7538. ARRAY_SIZE(alc268_adc_nids);
  7539. spec->mixers[spec->num_mixers] =
  7540. alc268_capture_mixer;
  7541. spec->num_mixers++;
  7542. }
  7543. }
  7544. }
  7545. codec->patch_ops = alc_patch_ops;
  7546. if (board_config == ALC268_AUTO)
  7547. spec->init_hook = alc268_auto_init;
  7548. return 0;
  7549. }
  7550. /*
  7551. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7552. */
  7553. /*
  7554. * set the path ways for 2 channel output
  7555. * need to set the codec line out and mic 1 pin widgets to inputs
  7556. */
  7557. static struct hda_verb alc861_threestack_ch2_init[] = {
  7558. /* set pin widget 1Ah (line in) for input */
  7559. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7560. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7561. * the vref
  7562. */
  7563. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7564. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7565. #if 0
  7566. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7567. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7568. #endif
  7569. { } /* end */
  7570. };
  7571. /*
  7572. * 6ch mode
  7573. * need to set the codec line out and mic 1 pin widgets to outputs
  7574. */
  7575. static struct hda_verb alc861_threestack_ch6_init[] = {
  7576. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7577. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7578. /* set pin widget 18h (mic1) for output (CLFE)*/
  7579. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7580. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7581. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7582. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7583. #if 0
  7584. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7585. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7586. #endif
  7587. { } /* end */
  7588. };
  7589. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7590. { 2, alc861_threestack_ch2_init },
  7591. { 6, alc861_threestack_ch6_init },
  7592. };
  7593. /* Set mic1 as input and unmute the mixer */
  7594. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7595. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7596. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7597. { } /* end */
  7598. };
  7599. /* Set mic1 as output and mute mixer */
  7600. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7601. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7602. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7603. { } /* end */
  7604. };
  7605. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7606. { 2, alc861_uniwill_m31_ch2_init },
  7607. { 4, alc861_uniwill_m31_ch4_init },
  7608. };
  7609. /* Set mic1 and line-in as input and unmute the mixer */
  7610. static struct hda_verb alc861_asus_ch2_init[] = {
  7611. /* set pin widget 1Ah (line in) for input */
  7612. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7613. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7614. * the vref
  7615. */
  7616. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7617. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7618. #if 0
  7619. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7620. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7621. #endif
  7622. { } /* end */
  7623. };
  7624. /* Set mic1 nad line-in as output and mute mixer */
  7625. static struct hda_verb alc861_asus_ch6_init[] = {
  7626. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7627. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7628. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7629. /* set pin widget 18h (mic1) for output (CLFE)*/
  7630. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7631. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7632. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7633. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7634. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7635. #if 0
  7636. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7637. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7638. #endif
  7639. { } /* end */
  7640. };
  7641. static struct hda_channel_mode alc861_asus_modes[2] = {
  7642. { 2, alc861_asus_ch2_init },
  7643. { 6, alc861_asus_ch6_init },
  7644. };
  7645. /* patch-ALC861 */
  7646. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7647. /* output mixer control */
  7648. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7649. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7650. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7651. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7652. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7653. /*Input mixer control */
  7654. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7655. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7656. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7657. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7658. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7659. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7660. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7661. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7662. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7663. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7664. /* Capture mixer control */
  7665. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7666. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7667. {
  7668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7669. .name = "Capture Source",
  7670. .count = 1,
  7671. .info = alc_mux_enum_info,
  7672. .get = alc_mux_enum_get,
  7673. .put = alc_mux_enum_put,
  7674. },
  7675. { } /* end */
  7676. };
  7677. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7678. /* output mixer control */
  7679. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7680. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7681. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7682. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7683. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7684. /* Input mixer control */
  7685. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7686. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7687. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7688. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7689. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7690. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7691. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7692. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7693. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7694. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7695. /* Capture mixer control */
  7696. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7697. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7698. {
  7699. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7700. .name = "Capture Source",
  7701. .count = 1,
  7702. .info = alc_mux_enum_info,
  7703. .get = alc_mux_enum_get,
  7704. .put = alc_mux_enum_put,
  7705. },
  7706. {
  7707. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7708. .name = "Channel Mode",
  7709. .info = alc_ch_mode_info,
  7710. .get = alc_ch_mode_get,
  7711. .put = alc_ch_mode_put,
  7712. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7713. },
  7714. { } /* end */
  7715. };
  7716. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7717. /* output mixer control */
  7718. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7719. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7720. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7721. /*Capture mixer control */
  7722. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7723. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7724. {
  7725. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7726. .name = "Capture Source",
  7727. .count = 1,
  7728. .info = alc_mux_enum_info,
  7729. .get = alc_mux_enum_get,
  7730. .put = alc_mux_enum_put,
  7731. },
  7732. { } /* end */
  7733. };
  7734. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7735. /* output mixer control */
  7736. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7737. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7738. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7739. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7740. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7741. /* Input mixer control */
  7742. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7743. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7744. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7745. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7746. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7747. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7748. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7749. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7750. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7751. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7752. /* Capture mixer control */
  7753. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7754. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7755. {
  7756. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7757. .name = "Capture Source",
  7758. .count = 1,
  7759. .info = alc_mux_enum_info,
  7760. .get = alc_mux_enum_get,
  7761. .put = alc_mux_enum_put,
  7762. },
  7763. {
  7764. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7765. .name = "Channel Mode",
  7766. .info = alc_ch_mode_info,
  7767. .get = alc_ch_mode_get,
  7768. .put = alc_ch_mode_put,
  7769. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7770. },
  7771. { } /* end */
  7772. };
  7773. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7774. /* output mixer control */
  7775. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7776. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7777. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7778. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7779. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7780. /* Input mixer control */
  7781. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7782. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7783. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7784. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7785. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7786. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7787. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7788. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7789. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7790. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7791. /* Capture mixer control */
  7792. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7793. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7794. {
  7795. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7796. .name = "Capture Source",
  7797. .count = 1,
  7798. .info = alc_mux_enum_info,
  7799. .get = alc_mux_enum_get,
  7800. .put = alc_mux_enum_put,
  7801. },
  7802. {
  7803. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7804. .name = "Channel Mode",
  7805. .info = alc_ch_mode_info,
  7806. .get = alc_ch_mode_get,
  7807. .put = alc_ch_mode_put,
  7808. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7809. },
  7810. { }
  7811. };
  7812. /* additional mixer */
  7813. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7814. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7815. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7816. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7817. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7818. { }
  7819. };
  7820. /*
  7821. * generic initialization of ADC, input mixers and output mixers
  7822. */
  7823. static struct hda_verb alc861_base_init_verbs[] = {
  7824. /*
  7825. * Unmute ADC0 and set the default input to mic-in
  7826. */
  7827. /* port-A for surround (rear panel) */
  7828. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7829. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7830. /* port-B for mic-in (rear panel) with vref */
  7831. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7832. /* port-C for line-in (rear panel) */
  7833. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7834. /* port-D for Front */
  7835. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7836. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7837. /* port-E for HP out (front panel) */
  7838. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7839. /* route front PCM to HP */
  7840. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7841. /* port-F for mic-in (front panel) with vref */
  7842. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7843. /* port-G for CLFE (rear panel) */
  7844. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7845. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7846. /* port-H for side (rear panel) */
  7847. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7848. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7849. /* CD-in */
  7850. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7851. /* route front mic to ADC1*/
  7852. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7853. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7854. /* Unmute DAC0~3 & spdif out*/
  7855. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7856. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7857. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7858. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7859. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7860. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7861. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7862. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7863. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7864. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7865. /* Unmute Stereo Mixer 15 */
  7866. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7867. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7868. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7869. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7870. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7871. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7872. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7873. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7874. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7875. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7876. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7877. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7878. /* hp used DAC 3 (Front) */
  7879. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7880. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7881. { }
  7882. };
  7883. static struct hda_verb alc861_threestack_init_verbs[] = {
  7884. /*
  7885. * Unmute ADC0 and set the default input to mic-in
  7886. */
  7887. /* port-A for surround (rear panel) */
  7888. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7889. /* port-B for mic-in (rear panel) with vref */
  7890. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7891. /* port-C for line-in (rear panel) */
  7892. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7893. /* port-D for Front */
  7894. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7895. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7896. /* port-E for HP out (front panel) */
  7897. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7898. /* route front PCM to HP */
  7899. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7900. /* port-F for mic-in (front panel) with vref */
  7901. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7902. /* port-G for CLFE (rear panel) */
  7903. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7904. /* port-H for side (rear panel) */
  7905. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7906. /* CD-in */
  7907. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7908. /* route front mic to ADC1*/
  7909. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7910. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7911. /* Unmute DAC0~3 & spdif out*/
  7912. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7913. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7914. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7915. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7916. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7917. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7918. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7919. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7920. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7921. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7922. /* Unmute Stereo Mixer 15 */
  7923. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7924. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7925. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7926. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7927. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7928. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7929. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7930. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7931. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7932. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7933. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7934. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7935. /* hp used DAC 3 (Front) */
  7936. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7937. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7938. { }
  7939. };
  7940. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7941. /*
  7942. * Unmute ADC0 and set the default input to mic-in
  7943. */
  7944. /* port-A for surround (rear panel) */
  7945. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7946. /* port-B for mic-in (rear panel) with vref */
  7947. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7948. /* port-C for line-in (rear panel) */
  7949. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7950. /* port-D for Front */
  7951. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7952. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7953. /* port-E for HP out (front panel) */
  7954. /* this has to be set to VREF80 */
  7955. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7956. /* route front PCM to HP */
  7957. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7958. /* port-F for mic-in (front panel) with vref */
  7959. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7960. /* port-G for CLFE (rear panel) */
  7961. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7962. /* port-H for side (rear panel) */
  7963. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7964. /* CD-in */
  7965. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7966. /* route front mic to ADC1*/
  7967. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7968. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7969. /* Unmute DAC0~3 & spdif out*/
  7970. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7971. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7972. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7973. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7974. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7975. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7976. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7977. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7978. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7979. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7980. /* Unmute Stereo Mixer 15 */
  7981. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7982. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7983. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7984. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7985. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7986. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7987. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7988. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7989. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7990. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7991. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7992. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7993. /* hp used DAC 3 (Front) */
  7994. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7995. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7996. { }
  7997. };
  7998. static struct hda_verb alc861_asus_init_verbs[] = {
  7999. /*
  8000. * Unmute ADC0 and set the default input to mic-in
  8001. */
  8002. /* port-A for surround (rear panel)
  8003. * according to codec#0 this is the HP jack
  8004. */
  8005. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8006. /* route front PCM to HP */
  8007. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8008. /* port-B for mic-in (rear panel) with vref */
  8009. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8010. /* port-C for line-in (rear panel) */
  8011. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8012. /* port-D for Front */
  8013. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8014. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8015. /* port-E for HP out (front panel) */
  8016. /* this has to be set to VREF80 */
  8017. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8018. /* route front PCM to HP */
  8019. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8020. /* port-F for mic-in (front panel) with vref */
  8021. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8022. /* port-G for CLFE (rear panel) */
  8023. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8024. /* port-H for side (rear panel) */
  8025. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8026. /* CD-in */
  8027. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8028. /* route front mic to ADC1*/
  8029. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8030. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8031. /* Unmute DAC0~3 & spdif out*/
  8032. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8033. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8034. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8035. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8036. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8037. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8038. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8039. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8040. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8041. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8042. /* Unmute Stereo Mixer 15 */
  8043. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8044. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8045. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8046. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8047. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8048. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8049. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8050. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8051. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8052. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8053. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8054. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8055. /* hp used DAC 3 (Front) */
  8056. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8057. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8058. { }
  8059. };
  8060. /* additional init verbs for ASUS laptops */
  8061. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8062. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8063. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8064. { }
  8065. };
  8066. /*
  8067. * generic initialization of ADC, input mixers and output mixers
  8068. */
  8069. static struct hda_verb alc861_auto_init_verbs[] = {
  8070. /*
  8071. * Unmute ADC0 and set the default input to mic-in
  8072. */
  8073. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8074. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8075. /* Unmute DAC0~3 & spdif out*/
  8076. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8077. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8078. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8079. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8080. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8081. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8082. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8083. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8084. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8085. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8086. /* Unmute Stereo Mixer 15 */
  8087. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8088. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8089. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8090. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8091. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8092. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8093. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8094. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8095. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8096. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8097. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8098. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8099. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8100. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8101. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8102. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8103. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8104. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8105. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8106. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8107. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8108. { }
  8109. };
  8110. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8111. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8112. { }
  8113. };
  8114. /* toggle speaker-output according to the hp-jack state */
  8115. static void alc861_toshiba_automute(struct hda_codec *codec)
  8116. {
  8117. unsigned int present;
  8118. present = snd_hda_codec_read(codec, 0x0f, 0,
  8119. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8120. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8121. 0x80, present ? 0x80 : 0);
  8122. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8123. 0x80, present ? 0x80 : 0);
  8124. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8125. 0x80, present ? 0 : 0x80);
  8126. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8127. 0x80, present ? 0 : 0x80);
  8128. }
  8129. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8130. unsigned int res)
  8131. {
  8132. if ((res >> 26) == ALC880_HP_EVENT)
  8133. alc861_toshiba_automute(codec);
  8134. }
  8135. /* pcm configuration: identiacal with ALC880 */
  8136. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8137. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8138. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8139. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8140. #define ALC861_DIGOUT_NID 0x07
  8141. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8142. { 8, NULL }
  8143. };
  8144. static hda_nid_t alc861_dac_nids[4] = {
  8145. /* front, surround, clfe, side */
  8146. 0x03, 0x06, 0x05, 0x04
  8147. };
  8148. static hda_nid_t alc660_dac_nids[3] = {
  8149. /* front, clfe, surround */
  8150. 0x03, 0x05, 0x06
  8151. };
  8152. static hda_nid_t alc861_adc_nids[1] = {
  8153. /* ADC0-2 */
  8154. 0x08,
  8155. };
  8156. static struct hda_input_mux alc861_capture_source = {
  8157. .num_items = 5,
  8158. .items = {
  8159. { "Mic", 0x0 },
  8160. { "Front Mic", 0x3 },
  8161. { "Line", 0x1 },
  8162. { "CD", 0x4 },
  8163. { "Mixer", 0x5 },
  8164. },
  8165. };
  8166. /* fill in the dac_nids table from the parsed pin configuration */
  8167. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8168. const struct auto_pin_cfg *cfg)
  8169. {
  8170. int i;
  8171. hda_nid_t nid;
  8172. spec->multiout.dac_nids = spec->private_dac_nids;
  8173. for (i = 0; i < cfg->line_outs; i++) {
  8174. nid = cfg->line_out_pins[i];
  8175. if (nid) {
  8176. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8177. continue;
  8178. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8179. }
  8180. }
  8181. spec->multiout.num_dacs = cfg->line_outs;
  8182. return 0;
  8183. }
  8184. /* add playback controls from the parsed DAC table */
  8185. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8186. const struct auto_pin_cfg *cfg)
  8187. {
  8188. char name[32];
  8189. static const char *chname[4] = {
  8190. "Front", "Surround", NULL /*CLFE*/, "Side"
  8191. };
  8192. hda_nid_t nid;
  8193. int i, idx, err;
  8194. for (i = 0; i < cfg->line_outs; i++) {
  8195. nid = spec->multiout.dac_nids[i];
  8196. if (!nid)
  8197. continue;
  8198. if (nid == 0x05) {
  8199. /* Center/LFE */
  8200. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8201. "Center Playback Switch",
  8202. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8203. HDA_OUTPUT));
  8204. if (err < 0)
  8205. return err;
  8206. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8207. "LFE Playback Switch",
  8208. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8209. HDA_OUTPUT));
  8210. if (err < 0)
  8211. return err;
  8212. } else {
  8213. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8214. idx++)
  8215. if (nid == alc861_dac_nids[idx])
  8216. break;
  8217. sprintf(name, "%s Playback Switch", chname[idx]);
  8218. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8219. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8220. HDA_OUTPUT));
  8221. if (err < 0)
  8222. return err;
  8223. }
  8224. }
  8225. return 0;
  8226. }
  8227. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8228. {
  8229. int err;
  8230. hda_nid_t nid;
  8231. if (!pin)
  8232. return 0;
  8233. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8234. nid = 0x03;
  8235. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8236. "Headphone Playback Switch",
  8237. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8238. if (err < 0)
  8239. return err;
  8240. spec->multiout.hp_nid = nid;
  8241. }
  8242. return 0;
  8243. }
  8244. /* create playback/capture controls for input pins */
  8245. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8246. const struct auto_pin_cfg *cfg)
  8247. {
  8248. struct hda_input_mux *imux = &spec->private_imux;
  8249. int i, err, idx, idx1;
  8250. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8251. switch (cfg->input_pins[i]) {
  8252. case 0x0c:
  8253. idx1 = 1;
  8254. idx = 2; /* Line In */
  8255. break;
  8256. case 0x0f:
  8257. idx1 = 2;
  8258. idx = 2; /* Line In */
  8259. break;
  8260. case 0x0d:
  8261. idx1 = 0;
  8262. idx = 1; /* Mic In */
  8263. break;
  8264. case 0x10:
  8265. idx1 = 3;
  8266. idx = 1; /* Mic In */
  8267. break;
  8268. case 0x11:
  8269. idx1 = 4;
  8270. idx = 0; /* CD */
  8271. break;
  8272. default:
  8273. continue;
  8274. }
  8275. err = new_analog_input(spec, cfg->input_pins[i],
  8276. auto_pin_cfg_labels[i], idx, 0x15);
  8277. if (err < 0)
  8278. return err;
  8279. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8280. imux->items[imux->num_items].index = idx1;
  8281. imux->num_items++;
  8282. }
  8283. return 0;
  8284. }
  8285. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8286. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8287. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8288. {
  8289. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8290. /* The multiple "Capture Source" controls confuse alsamixer
  8291. * So call somewhat different..
  8292. *FIXME: the controls appear in the "playback" view!
  8293. */
  8294. /* .name = "Capture Source", */
  8295. .name = "Input Source",
  8296. .count = 1,
  8297. .info = alc_mux_enum_info,
  8298. .get = alc_mux_enum_get,
  8299. .put = alc_mux_enum_put,
  8300. },
  8301. { } /* end */
  8302. };
  8303. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8304. hda_nid_t nid,
  8305. int pin_type, int dac_idx)
  8306. {
  8307. /* set as output */
  8308. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8309. pin_type);
  8310. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8311. AMP_OUT_UNMUTE);
  8312. }
  8313. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8314. {
  8315. struct alc_spec *spec = codec->spec;
  8316. int i;
  8317. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8318. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8319. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8320. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8321. if (nid)
  8322. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8323. spec->multiout.dac_nids[i]);
  8324. }
  8325. }
  8326. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8327. {
  8328. struct alc_spec *spec = codec->spec;
  8329. hda_nid_t pin;
  8330. pin = spec->autocfg.hp_pins[0];
  8331. if (pin) /* connect to front */
  8332. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8333. spec->multiout.dac_nids[0]);
  8334. }
  8335. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8336. {
  8337. struct alc_spec *spec = codec->spec;
  8338. int i;
  8339. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8340. hda_nid_t nid = spec->autocfg.input_pins[i];
  8341. if (nid >= 0x0c && nid <= 0x11) {
  8342. snd_hda_codec_write(codec, nid, 0,
  8343. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8344. i <= AUTO_PIN_FRONT_MIC ?
  8345. PIN_VREF80 : PIN_IN);
  8346. }
  8347. }
  8348. }
  8349. /* parse the BIOS configuration and set up the alc_spec */
  8350. /* return 1 if successful, 0 if the proper config is not found,
  8351. * or a negative error code
  8352. */
  8353. static int alc861_parse_auto_config(struct hda_codec *codec)
  8354. {
  8355. struct alc_spec *spec = codec->spec;
  8356. int err;
  8357. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8358. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8359. alc861_ignore);
  8360. if (err < 0)
  8361. return err;
  8362. if (!spec->autocfg.line_outs)
  8363. return 0; /* can't find valid BIOS pin config */
  8364. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8365. if (err < 0)
  8366. return err;
  8367. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8368. if (err < 0)
  8369. return err;
  8370. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8371. if (err < 0)
  8372. return err;
  8373. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8374. if (err < 0)
  8375. return err;
  8376. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8377. if (spec->autocfg.dig_out_pin)
  8378. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8379. if (spec->kctl_alloc)
  8380. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8381. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8382. spec->num_mux_defs = 1;
  8383. spec->input_mux = &spec->private_imux;
  8384. spec->adc_nids = alc861_adc_nids;
  8385. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8386. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8387. spec->num_mixers++;
  8388. return 1;
  8389. }
  8390. /* additional initialization for auto-configuration model */
  8391. static void alc861_auto_init(struct hda_codec *codec)
  8392. {
  8393. alc861_auto_init_multi_out(codec);
  8394. alc861_auto_init_hp_out(codec);
  8395. alc861_auto_init_analog_input(codec);
  8396. }
  8397. /*
  8398. * configuration and preset
  8399. */
  8400. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8401. [ALC861_3ST] = "3stack",
  8402. [ALC660_3ST] = "3stack-660",
  8403. [ALC861_3ST_DIG] = "3stack-dig",
  8404. [ALC861_6ST_DIG] = "6stack-dig",
  8405. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8406. [ALC861_TOSHIBA] = "toshiba",
  8407. [ALC861_ASUS] = "asus",
  8408. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8409. [ALC861_AUTO] = "auto",
  8410. };
  8411. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8412. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8413. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8414. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8415. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8416. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8417. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8418. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  8419. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8420. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8421. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8422. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8423. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8424. {}
  8425. };
  8426. static struct alc_config_preset alc861_presets[] = {
  8427. [ALC861_3ST] = {
  8428. .mixers = { alc861_3ST_mixer },
  8429. .init_verbs = { alc861_threestack_init_verbs },
  8430. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8431. .dac_nids = alc861_dac_nids,
  8432. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8433. .channel_mode = alc861_threestack_modes,
  8434. .need_dac_fix = 1,
  8435. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8436. .adc_nids = alc861_adc_nids,
  8437. .input_mux = &alc861_capture_source,
  8438. },
  8439. [ALC861_3ST_DIG] = {
  8440. .mixers = { alc861_base_mixer },
  8441. .init_verbs = { alc861_threestack_init_verbs },
  8442. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8443. .dac_nids = alc861_dac_nids,
  8444. .dig_out_nid = ALC861_DIGOUT_NID,
  8445. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8446. .channel_mode = alc861_threestack_modes,
  8447. .need_dac_fix = 1,
  8448. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8449. .adc_nids = alc861_adc_nids,
  8450. .input_mux = &alc861_capture_source,
  8451. },
  8452. [ALC861_6ST_DIG] = {
  8453. .mixers = { alc861_base_mixer },
  8454. .init_verbs = { alc861_base_init_verbs },
  8455. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8456. .dac_nids = alc861_dac_nids,
  8457. .dig_out_nid = ALC861_DIGOUT_NID,
  8458. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8459. .channel_mode = alc861_8ch_modes,
  8460. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8461. .adc_nids = alc861_adc_nids,
  8462. .input_mux = &alc861_capture_source,
  8463. },
  8464. [ALC660_3ST] = {
  8465. .mixers = { alc861_3ST_mixer },
  8466. .init_verbs = { alc861_threestack_init_verbs },
  8467. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8468. .dac_nids = alc660_dac_nids,
  8469. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8470. .channel_mode = alc861_threestack_modes,
  8471. .need_dac_fix = 1,
  8472. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8473. .adc_nids = alc861_adc_nids,
  8474. .input_mux = &alc861_capture_source,
  8475. },
  8476. [ALC861_UNIWILL_M31] = {
  8477. .mixers = { alc861_uniwill_m31_mixer },
  8478. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8479. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8480. .dac_nids = alc861_dac_nids,
  8481. .dig_out_nid = ALC861_DIGOUT_NID,
  8482. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8483. .channel_mode = alc861_uniwill_m31_modes,
  8484. .need_dac_fix = 1,
  8485. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8486. .adc_nids = alc861_adc_nids,
  8487. .input_mux = &alc861_capture_source,
  8488. },
  8489. [ALC861_TOSHIBA] = {
  8490. .mixers = { alc861_toshiba_mixer },
  8491. .init_verbs = { alc861_base_init_verbs,
  8492. alc861_toshiba_init_verbs },
  8493. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8494. .dac_nids = alc861_dac_nids,
  8495. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8496. .channel_mode = alc883_3ST_2ch_modes,
  8497. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8498. .adc_nids = alc861_adc_nids,
  8499. .input_mux = &alc861_capture_source,
  8500. .unsol_event = alc861_toshiba_unsol_event,
  8501. .init_hook = alc861_toshiba_automute,
  8502. },
  8503. [ALC861_ASUS] = {
  8504. .mixers = { alc861_asus_mixer },
  8505. .init_verbs = { alc861_asus_init_verbs },
  8506. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8507. .dac_nids = alc861_dac_nids,
  8508. .dig_out_nid = ALC861_DIGOUT_NID,
  8509. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8510. .channel_mode = alc861_asus_modes,
  8511. .need_dac_fix = 1,
  8512. .hp_nid = 0x06,
  8513. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8514. .adc_nids = alc861_adc_nids,
  8515. .input_mux = &alc861_capture_source,
  8516. },
  8517. [ALC861_ASUS_LAPTOP] = {
  8518. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8519. .init_verbs = { alc861_asus_init_verbs,
  8520. alc861_asus_laptop_init_verbs },
  8521. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8522. .dac_nids = alc861_dac_nids,
  8523. .dig_out_nid = ALC861_DIGOUT_NID,
  8524. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8525. .channel_mode = alc883_3ST_2ch_modes,
  8526. .need_dac_fix = 1,
  8527. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8528. .adc_nids = alc861_adc_nids,
  8529. .input_mux = &alc861_capture_source,
  8530. },
  8531. };
  8532. static int patch_alc861(struct hda_codec *codec)
  8533. {
  8534. struct alc_spec *spec;
  8535. int board_config;
  8536. int err;
  8537. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8538. if (spec == NULL)
  8539. return -ENOMEM;
  8540. codec->spec = spec;
  8541. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8542. alc861_models,
  8543. alc861_cfg_tbl);
  8544. if (board_config < 0) {
  8545. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8546. "trying auto-probe from BIOS...\n");
  8547. board_config = ALC861_AUTO;
  8548. }
  8549. if (board_config == ALC861_AUTO) {
  8550. /* automatic parse from the BIOS config */
  8551. err = alc861_parse_auto_config(codec);
  8552. if (err < 0) {
  8553. alc_free(codec);
  8554. return err;
  8555. } else if (!err) {
  8556. printk(KERN_INFO
  8557. "hda_codec: Cannot set up configuration "
  8558. "from BIOS. Using base mode...\n");
  8559. board_config = ALC861_3ST_DIG;
  8560. }
  8561. }
  8562. if (board_config != ALC861_AUTO)
  8563. setup_preset(spec, &alc861_presets[board_config]);
  8564. spec->stream_name_analog = "ALC861 Analog";
  8565. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8566. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8567. spec->stream_name_digital = "ALC861 Digital";
  8568. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8569. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8570. codec->patch_ops = alc_patch_ops;
  8571. if (board_config == ALC861_AUTO)
  8572. spec->init_hook = alc861_auto_init;
  8573. return 0;
  8574. }
  8575. /*
  8576. * ALC861-VD support
  8577. *
  8578. * Based on ALC882
  8579. *
  8580. * In addition, an independent DAC
  8581. */
  8582. #define ALC861VD_DIGOUT_NID 0x06
  8583. static hda_nid_t alc861vd_dac_nids[4] = {
  8584. /* front, surr, clfe, side surr */
  8585. 0x02, 0x03, 0x04, 0x05
  8586. };
  8587. /* dac_nids for ALC660vd are in a different order - according to
  8588. * Realtek's driver.
  8589. * This should probably tesult in a different mixer for 6stack models
  8590. * of ALC660vd codecs, but for now there is only 3stack mixer
  8591. * - and it is the same as in 861vd.
  8592. * adc_nids in ALC660vd are (is) the same as in 861vd
  8593. */
  8594. static hda_nid_t alc660vd_dac_nids[3] = {
  8595. /* front, rear, clfe, rear_surr */
  8596. 0x02, 0x04, 0x03
  8597. };
  8598. static hda_nid_t alc861vd_adc_nids[1] = {
  8599. /* ADC0 */
  8600. 0x09,
  8601. };
  8602. /* input MUX */
  8603. /* FIXME: should be a matrix-type input source selection */
  8604. static struct hda_input_mux alc861vd_capture_source = {
  8605. .num_items = 4,
  8606. .items = {
  8607. { "Mic", 0x0 },
  8608. { "Front Mic", 0x1 },
  8609. { "Line", 0x2 },
  8610. { "CD", 0x4 },
  8611. },
  8612. };
  8613. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8614. .num_items = 3,
  8615. .items = {
  8616. { "Front Mic", 0x0 },
  8617. { "ATAPI Mic", 0x1 },
  8618. { "Line In", 0x5 },
  8619. },
  8620. };
  8621. #define alc861vd_mux_enum_info alc_mux_enum_info
  8622. #define alc861vd_mux_enum_get alc_mux_enum_get
  8623. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8624. struct snd_ctl_elem_value *ucontrol)
  8625. {
  8626. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8627. struct alc_spec *spec = codec->spec;
  8628. const struct hda_input_mux *imux = spec->input_mux;
  8629. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8630. static hda_nid_t capture_mixers[1] = { 0x22 };
  8631. hda_nid_t nid = capture_mixers[adc_idx];
  8632. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8633. unsigned int i, idx;
  8634. idx = ucontrol->value.enumerated.item[0];
  8635. if (idx >= imux->num_items)
  8636. idx = imux->num_items - 1;
  8637. if (*cur_val == idx && !codec->in_resume)
  8638. return 0;
  8639. for (i = 0; i < imux->num_items; i++) {
  8640. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8641. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8642. v | (imux->items[i].index << 8));
  8643. }
  8644. *cur_val = idx;
  8645. return 1;
  8646. }
  8647. /*
  8648. * 2ch mode
  8649. */
  8650. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8651. { 2, NULL }
  8652. };
  8653. /*
  8654. * 6ch mode
  8655. */
  8656. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8657. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8658. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8659. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8660. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8661. { } /* end */
  8662. };
  8663. /*
  8664. * 8ch mode
  8665. */
  8666. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8667. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8668. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8669. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8670. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8671. { } /* end */
  8672. };
  8673. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8674. { 6, alc861vd_6stack_ch6_init },
  8675. { 8, alc861vd_6stack_ch8_init },
  8676. };
  8677. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8678. {
  8679. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8680. .name = "Channel Mode",
  8681. .info = alc_ch_mode_info,
  8682. .get = alc_ch_mode_get,
  8683. .put = alc_ch_mode_put,
  8684. },
  8685. { } /* end */
  8686. };
  8687. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8688. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8689. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8690. {
  8691. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8692. /* The multiple "Capture Source" controls confuse alsamixer
  8693. * So call somewhat different..
  8694. *FIXME: the controls appear in the "playback" view!
  8695. */
  8696. /* .name = "Capture Source", */
  8697. .name = "Input Source",
  8698. .count = 1,
  8699. .info = alc861vd_mux_enum_info,
  8700. .get = alc861vd_mux_enum_get,
  8701. .put = alc861vd_mux_enum_put,
  8702. },
  8703. { } /* end */
  8704. };
  8705. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8706. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8707. */
  8708. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8709. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8710. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8711. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8712. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8713. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8714. HDA_OUTPUT),
  8715. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8716. HDA_OUTPUT),
  8717. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8718. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8719. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8720. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8721. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8722. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8724. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8725. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8728. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8729. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8730. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8731. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8732. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8733. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8734. { } /* end */
  8735. };
  8736. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8737. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8738. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8739. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8740. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8741. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8742. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8743. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8744. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8745. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8746. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8747. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8748. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8749. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8750. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8751. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8752. { } /* end */
  8753. };
  8754. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8755. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8756. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8757. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8759. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8760. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8761. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8762. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8763. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8764. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8765. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8766. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8767. { } /* end */
  8768. };
  8769. /* Pin assignment: Front=0x14, HP = 0x15,
  8770. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8771. */
  8772. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8773. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8774. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8775. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8776. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8777. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8778. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8779. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8780. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8781. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8782. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8783. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8784. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8785. {
  8786. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8787. /* .name = "Capture Source", */
  8788. .name = "Input Source",
  8789. .count = 1,
  8790. .info = alc882_mux_enum_info,
  8791. .get = alc882_mux_enum_get,
  8792. .put = alc882_mux_enum_put,
  8793. },
  8794. { } /* end */
  8795. };
  8796. /*
  8797. * generic initialization of ADC, input mixers and output mixers
  8798. */
  8799. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8800. /*
  8801. * Unmute ADC0 and set the default input to mic-in
  8802. */
  8803. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8804. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8805. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8806. * the analog-loopback mixer widget
  8807. */
  8808. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8809. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8810. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8811. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8813. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8814. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8816. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8817. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8818. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8819. /*
  8820. * Set up output mixers (0x02 - 0x05)
  8821. */
  8822. /* set vol=0 to output mixers */
  8823. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8824. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8825. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8826. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8827. /* set up input amps for analog loopback */
  8828. /* Amp Indices: DAC = 0, mixer = 1 */
  8829. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8830. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8831. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8832. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8833. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8834. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8835. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8836. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8837. { }
  8838. };
  8839. /*
  8840. * 3-stack pin configuration:
  8841. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8842. */
  8843. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8844. /*
  8845. * Set pin mode and muting
  8846. */
  8847. /* set front pin widgets 0x14 for output */
  8848. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8849. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8850. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8851. /* Mic (rear) pin: input vref at 80% */
  8852. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8853. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8854. /* Front Mic pin: input vref at 80% */
  8855. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8856. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8857. /* Line In pin: input */
  8858. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8859. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8860. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8861. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8862. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8863. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8864. /* CD pin widget for input */
  8865. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8866. { }
  8867. };
  8868. /*
  8869. * 6-stack pin configuration:
  8870. */
  8871. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8872. /*
  8873. * Set pin mode and muting
  8874. */
  8875. /* set front pin widgets 0x14 for output */
  8876. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8877. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8878. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8879. /* Rear Pin: output 1 (0x0d) */
  8880. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8881. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8882. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8883. /* CLFE Pin: output 2 (0x0e) */
  8884. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8885. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8886. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8887. /* Side Pin: output 3 (0x0f) */
  8888. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8889. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8890. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8891. /* Mic (rear) pin: input vref at 80% */
  8892. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8893. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8894. /* Front Mic pin: input vref at 80% */
  8895. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8896. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8897. /* Line In pin: input */
  8898. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8899. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8900. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8901. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8902. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8903. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8904. /* CD pin widget for input */
  8905. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8906. { }
  8907. };
  8908. static struct hda_verb alc861vd_eapd_verbs[] = {
  8909. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8910. { }
  8911. };
  8912. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8913. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8914. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8916. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8917. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8918. {}
  8919. };
  8920. /* toggle speaker-output according to the hp-jack state */
  8921. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8922. {
  8923. unsigned int present;
  8924. unsigned char bits;
  8925. present = snd_hda_codec_read(codec, 0x1b, 0,
  8926. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8927. bits = present ? 0x80 : 0;
  8928. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8929. 0x80, bits);
  8930. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8931. 0x80, bits);
  8932. }
  8933. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8934. {
  8935. unsigned int present;
  8936. unsigned char bits;
  8937. present = snd_hda_codec_read(codec, 0x18, 0,
  8938. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8939. bits = present ? 0x80 : 0;
  8940. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8941. 0x80, bits);
  8942. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8943. 0x80, bits);
  8944. }
  8945. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8946. {
  8947. alc861vd_lenovo_hp_automute(codec);
  8948. alc861vd_lenovo_mic_automute(codec);
  8949. }
  8950. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8951. unsigned int res)
  8952. {
  8953. switch (res >> 26) {
  8954. case ALC880_HP_EVENT:
  8955. alc861vd_lenovo_hp_automute(codec);
  8956. break;
  8957. case ALC880_MIC_EVENT:
  8958. alc861vd_lenovo_mic_automute(codec);
  8959. break;
  8960. }
  8961. }
  8962. static struct hda_verb alc861vd_dallas_verbs[] = {
  8963. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8964. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8965. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8966. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8967. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8968. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8969. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8970. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8971. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8974. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8975. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8976. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8977. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8978. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8979. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8980. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8981. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8982. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8983. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8984. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8985. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8986. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8987. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8988. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8989. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8990. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8994. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8995. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8996. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8997. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8998. { } /* end */
  8999. };
  9000. /* toggle speaker-output according to the hp-jack state */
  9001. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9002. {
  9003. unsigned int present;
  9004. present = snd_hda_codec_read(codec, 0x15, 0,
  9005. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9006. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9007. 0x80, present ? 0x80 : 0);
  9008. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9009. 0x80, present ? 0x80 : 0);
  9010. }
  9011. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9012. {
  9013. if ((res >> 26) == ALC880_HP_EVENT)
  9014. alc861vd_dallas_automute(codec);
  9015. }
  9016. /* pcm configuration: identiacal with ALC880 */
  9017. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9018. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9019. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9020. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9021. /*
  9022. * configuration and preset
  9023. */
  9024. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9025. [ALC660VD_3ST] = "3stack-660",
  9026. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9027. [ALC861VD_3ST] = "3stack",
  9028. [ALC861VD_3ST_DIG] = "3stack-digout",
  9029. [ALC861VD_6ST_DIG] = "6stack-digout",
  9030. [ALC861VD_LENOVO] = "lenovo",
  9031. [ALC861VD_DALLAS] = "dallas",
  9032. [ALC861VD_AUTO] = "auto",
  9033. };
  9034. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9035. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9036. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9037. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9038. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9039. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9040. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9041. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9042. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9043. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9044. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9045. {}
  9046. };
  9047. static struct alc_config_preset alc861vd_presets[] = {
  9048. [ALC660VD_3ST] = {
  9049. .mixers = { alc861vd_3st_mixer },
  9050. .init_verbs = { alc861vd_volume_init_verbs,
  9051. alc861vd_3stack_init_verbs },
  9052. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9053. .dac_nids = alc660vd_dac_nids,
  9054. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9055. .adc_nids = alc861vd_adc_nids,
  9056. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9057. .channel_mode = alc861vd_3stack_2ch_modes,
  9058. .input_mux = &alc861vd_capture_source,
  9059. },
  9060. [ALC660VD_3ST_DIG] = {
  9061. .mixers = { alc861vd_3st_mixer },
  9062. .init_verbs = { alc861vd_volume_init_verbs,
  9063. alc861vd_3stack_init_verbs },
  9064. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9065. .dac_nids = alc660vd_dac_nids,
  9066. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9067. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9068. .adc_nids = alc861vd_adc_nids,
  9069. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9070. .channel_mode = alc861vd_3stack_2ch_modes,
  9071. .input_mux = &alc861vd_capture_source,
  9072. },
  9073. [ALC861VD_3ST] = {
  9074. .mixers = { alc861vd_3st_mixer },
  9075. .init_verbs = { alc861vd_volume_init_verbs,
  9076. alc861vd_3stack_init_verbs },
  9077. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9078. .dac_nids = alc861vd_dac_nids,
  9079. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9080. .channel_mode = alc861vd_3stack_2ch_modes,
  9081. .input_mux = &alc861vd_capture_source,
  9082. },
  9083. [ALC861VD_3ST_DIG] = {
  9084. .mixers = { alc861vd_3st_mixer },
  9085. .init_verbs = { alc861vd_volume_init_verbs,
  9086. alc861vd_3stack_init_verbs },
  9087. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9088. .dac_nids = alc861vd_dac_nids,
  9089. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9090. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9091. .channel_mode = alc861vd_3stack_2ch_modes,
  9092. .input_mux = &alc861vd_capture_source,
  9093. },
  9094. [ALC861VD_6ST_DIG] = {
  9095. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9096. .init_verbs = { alc861vd_volume_init_verbs,
  9097. alc861vd_6stack_init_verbs },
  9098. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9099. .dac_nids = alc861vd_dac_nids,
  9100. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9101. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9102. .channel_mode = alc861vd_6stack_modes,
  9103. .input_mux = &alc861vd_capture_source,
  9104. },
  9105. [ALC861VD_LENOVO] = {
  9106. .mixers = { alc861vd_lenovo_mixer },
  9107. .init_verbs = { alc861vd_volume_init_verbs,
  9108. alc861vd_3stack_init_verbs,
  9109. alc861vd_eapd_verbs,
  9110. alc861vd_lenovo_unsol_verbs },
  9111. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9112. .dac_nids = alc660vd_dac_nids,
  9113. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9114. .adc_nids = alc861vd_adc_nids,
  9115. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9116. .channel_mode = alc861vd_3stack_2ch_modes,
  9117. .input_mux = &alc861vd_capture_source,
  9118. .unsol_event = alc861vd_lenovo_unsol_event,
  9119. .init_hook = alc861vd_lenovo_automute,
  9120. },
  9121. [ALC861VD_DALLAS] = {
  9122. .mixers = { alc861vd_dallas_mixer },
  9123. .init_verbs = { alc861vd_dallas_verbs },
  9124. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9125. .dac_nids = alc861vd_dac_nids,
  9126. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9127. .adc_nids = alc861vd_adc_nids,
  9128. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9129. .channel_mode = alc861vd_3stack_2ch_modes,
  9130. .input_mux = &alc861vd_dallas_capture_source,
  9131. .unsol_event = alc861vd_dallas_unsol_event,
  9132. .init_hook = alc861vd_dallas_automute,
  9133. },
  9134. };
  9135. /*
  9136. * BIOS auto configuration
  9137. */
  9138. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9139. hda_nid_t nid, int pin_type, int dac_idx)
  9140. {
  9141. /* set as output */
  9142. snd_hda_codec_write(codec, nid, 0,
  9143. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9144. snd_hda_codec_write(codec, nid, 0,
  9145. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9146. }
  9147. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9148. {
  9149. struct alc_spec *spec = codec->spec;
  9150. int i;
  9151. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9152. for (i = 0; i <= HDA_SIDE; i++) {
  9153. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9154. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9155. if (nid)
  9156. alc861vd_auto_set_output_and_unmute(codec, nid,
  9157. pin_type, i);
  9158. }
  9159. }
  9160. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9161. {
  9162. struct alc_spec *spec = codec->spec;
  9163. hda_nid_t pin;
  9164. pin = spec->autocfg.hp_pins[0];
  9165. if (pin) /* connect to front and use dac 0 */
  9166. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9167. }
  9168. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9169. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9170. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9171. {
  9172. struct alc_spec *spec = codec->spec;
  9173. int i;
  9174. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9175. hda_nid_t nid = spec->autocfg.input_pins[i];
  9176. if (alc861vd_is_input_pin(nid)) {
  9177. snd_hda_codec_write(codec, nid, 0,
  9178. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9179. i <= AUTO_PIN_FRONT_MIC ?
  9180. PIN_VREF80 : PIN_IN);
  9181. if (nid != ALC861VD_PIN_CD_NID)
  9182. snd_hda_codec_write(codec, nid, 0,
  9183. AC_VERB_SET_AMP_GAIN_MUTE,
  9184. AMP_OUT_MUTE);
  9185. }
  9186. }
  9187. }
  9188. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9189. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9190. /* add playback controls from the parsed DAC table */
  9191. /* Based on ALC880 version. But ALC861VD has separate,
  9192. * different NIDs for mute/unmute switch and volume control */
  9193. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9194. const struct auto_pin_cfg *cfg)
  9195. {
  9196. char name[32];
  9197. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9198. hda_nid_t nid_v, nid_s;
  9199. int i, err;
  9200. for (i = 0; i < cfg->line_outs; i++) {
  9201. if (!spec->multiout.dac_nids[i])
  9202. continue;
  9203. nid_v = alc861vd_idx_to_mixer_vol(
  9204. alc880_dac_to_idx(
  9205. spec->multiout.dac_nids[i]));
  9206. nid_s = alc861vd_idx_to_mixer_switch(
  9207. alc880_dac_to_idx(
  9208. spec->multiout.dac_nids[i]));
  9209. if (i == 2) {
  9210. /* Center/LFE */
  9211. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9212. "Center Playback Volume",
  9213. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9214. HDA_OUTPUT));
  9215. if (err < 0)
  9216. return err;
  9217. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9218. "LFE Playback Volume",
  9219. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9220. HDA_OUTPUT));
  9221. if (err < 0)
  9222. return err;
  9223. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9224. "Center Playback Switch",
  9225. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9226. HDA_INPUT));
  9227. if (err < 0)
  9228. return err;
  9229. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9230. "LFE Playback Switch",
  9231. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9232. HDA_INPUT));
  9233. if (err < 0)
  9234. return err;
  9235. } else {
  9236. sprintf(name, "%s Playback Volume", chname[i]);
  9237. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9238. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9239. HDA_OUTPUT));
  9240. if (err < 0)
  9241. return err;
  9242. sprintf(name, "%s Playback Switch", chname[i]);
  9243. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9244. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9245. HDA_INPUT));
  9246. if (err < 0)
  9247. return err;
  9248. }
  9249. }
  9250. return 0;
  9251. }
  9252. /* add playback controls for speaker and HP outputs */
  9253. /* Based on ALC880 version. But ALC861VD has separate,
  9254. * different NIDs for mute/unmute switch and volume control */
  9255. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9256. hda_nid_t pin, const char *pfx)
  9257. {
  9258. hda_nid_t nid_v, nid_s;
  9259. int err;
  9260. char name[32];
  9261. if (!pin)
  9262. return 0;
  9263. if (alc880_is_fixed_pin(pin)) {
  9264. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9265. /* specify the DAC as the extra output */
  9266. if (!spec->multiout.hp_nid)
  9267. spec->multiout.hp_nid = nid_v;
  9268. else
  9269. spec->multiout.extra_out_nid[0] = nid_v;
  9270. /* control HP volume/switch on the output mixer amp */
  9271. nid_v = alc861vd_idx_to_mixer_vol(
  9272. alc880_fixed_pin_idx(pin));
  9273. nid_s = alc861vd_idx_to_mixer_switch(
  9274. alc880_fixed_pin_idx(pin));
  9275. sprintf(name, "%s Playback Volume", pfx);
  9276. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9277. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9278. if (err < 0)
  9279. return err;
  9280. sprintf(name, "%s Playback Switch", pfx);
  9281. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9282. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9283. if (err < 0)
  9284. return err;
  9285. } else if (alc880_is_multi_pin(pin)) {
  9286. /* set manual connection */
  9287. /* we have only a switch on HP-out PIN */
  9288. sprintf(name, "%s Playback Switch", pfx);
  9289. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9290. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9291. if (err < 0)
  9292. return err;
  9293. }
  9294. return 0;
  9295. }
  9296. /* parse the BIOS configuration and set up the alc_spec
  9297. * return 1 if successful, 0 if the proper config is not found,
  9298. * or a negative error code
  9299. * Based on ALC880 version - had to change it to override
  9300. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9301. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9302. {
  9303. struct alc_spec *spec = codec->spec;
  9304. int err;
  9305. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9306. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9307. alc861vd_ignore);
  9308. if (err < 0)
  9309. return err;
  9310. if (!spec->autocfg.line_outs)
  9311. return 0; /* can't find valid BIOS pin config */
  9312. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9313. if (err < 0)
  9314. return err;
  9315. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9316. if (err < 0)
  9317. return err;
  9318. err = alc861vd_auto_create_extra_out(spec,
  9319. spec->autocfg.speaker_pins[0],
  9320. "Speaker");
  9321. if (err < 0)
  9322. return err;
  9323. err = alc861vd_auto_create_extra_out(spec,
  9324. spec->autocfg.hp_pins[0],
  9325. "Headphone");
  9326. if (err < 0)
  9327. return err;
  9328. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9329. if (err < 0)
  9330. return err;
  9331. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9332. if (spec->autocfg.dig_out_pin)
  9333. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9334. if (spec->kctl_alloc)
  9335. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9336. spec->init_verbs[spec->num_init_verbs++]
  9337. = alc861vd_volume_init_verbs;
  9338. spec->num_mux_defs = 1;
  9339. spec->input_mux = &spec->private_imux;
  9340. return 1;
  9341. }
  9342. /* additional initialization for auto-configuration model */
  9343. static void alc861vd_auto_init(struct hda_codec *codec)
  9344. {
  9345. alc861vd_auto_init_multi_out(codec);
  9346. alc861vd_auto_init_hp_out(codec);
  9347. alc861vd_auto_init_analog_input(codec);
  9348. }
  9349. static int patch_alc861vd(struct hda_codec *codec)
  9350. {
  9351. struct alc_spec *spec;
  9352. int err, board_config;
  9353. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9354. if (spec == NULL)
  9355. return -ENOMEM;
  9356. codec->spec = spec;
  9357. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9358. alc861vd_models,
  9359. alc861vd_cfg_tbl);
  9360. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9361. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9362. "ALC861VD, trying auto-probe from BIOS...\n");
  9363. board_config = ALC861VD_AUTO;
  9364. }
  9365. if (board_config == ALC861VD_AUTO) {
  9366. /* automatic parse from the BIOS config */
  9367. err = alc861vd_parse_auto_config(codec);
  9368. if (err < 0) {
  9369. alc_free(codec);
  9370. return err;
  9371. } else if (!err) {
  9372. printk(KERN_INFO
  9373. "hda_codec: Cannot set up configuration "
  9374. "from BIOS. Using base mode...\n");
  9375. board_config = ALC861VD_3ST;
  9376. }
  9377. }
  9378. if (board_config != ALC861VD_AUTO)
  9379. setup_preset(spec, &alc861vd_presets[board_config]);
  9380. spec->stream_name_analog = "ALC861VD Analog";
  9381. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9382. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9383. spec->stream_name_digital = "ALC861VD Digital";
  9384. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9385. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9386. spec->adc_nids = alc861vd_adc_nids;
  9387. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9388. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9389. spec->num_mixers++;
  9390. codec->patch_ops = alc_patch_ops;
  9391. if (board_config == ALC861VD_AUTO)
  9392. spec->init_hook = alc861vd_auto_init;
  9393. return 0;
  9394. }
  9395. /*
  9396. * ALC662 support
  9397. *
  9398. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9399. * configuration. Each pin widget can choose any input DACs and a mixer.
  9400. * Each ADC is connected from a mixer of all inputs. This makes possible
  9401. * 6-channel independent captures.
  9402. *
  9403. * In addition, an independent DAC for the multi-playback (not used in this
  9404. * driver yet).
  9405. */
  9406. #define ALC662_DIGOUT_NID 0x06
  9407. #define ALC662_DIGIN_NID 0x0a
  9408. static hda_nid_t alc662_dac_nids[4] = {
  9409. /* front, rear, clfe, rear_surr */
  9410. 0x02, 0x03, 0x04
  9411. };
  9412. static hda_nid_t alc662_adc_nids[1] = {
  9413. /* ADC1-2 */
  9414. 0x09,
  9415. };
  9416. /* input MUX */
  9417. /* FIXME: should be a matrix-type input source selection */
  9418. static struct hda_input_mux alc662_capture_source = {
  9419. .num_items = 4,
  9420. .items = {
  9421. { "Mic", 0x0 },
  9422. { "Front Mic", 0x1 },
  9423. { "Line", 0x2 },
  9424. { "CD", 0x4 },
  9425. },
  9426. };
  9427. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9428. .num_items = 2,
  9429. .items = {
  9430. { "Mic", 0x1 },
  9431. { "Line", 0x2 },
  9432. },
  9433. };
  9434. #define alc662_mux_enum_info alc_mux_enum_info
  9435. #define alc662_mux_enum_get alc_mux_enum_get
  9436. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9437. struct snd_ctl_elem_value *ucontrol)
  9438. {
  9439. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9440. struct alc_spec *spec = codec->spec;
  9441. const struct hda_input_mux *imux = spec->input_mux;
  9442. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9443. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9444. hda_nid_t nid = capture_mixers[adc_idx];
  9445. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9446. unsigned int i, idx;
  9447. idx = ucontrol->value.enumerated.item[0];
  9448. if (idx >= imux->num_items)
  9449. idx = imux->num_items - 1;
  9450. if (*cur_val == idx && !codec->in_resume)
  9451. return 0;
  9452. for (i = 0; i < imux->num_items; i++) {
  9453. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9454. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9455. v | (imux->items[i].index << 8));
  9456. }
  9457. *cur_val = idx;
  9458. return 1;
  9459. }
  9460. /*
  9461. * 2ch mode
  9462. */
  9463. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9464. { 2, NULL }
  9465. };
  9466. /*
  9467. * 2ch mode
  9468. */
  9469. static struct hda_verb alc662_3ST_ch2_init[] = {
  9470. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9471. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9472. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9473. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9474. { } /* end */
  9475. };
  9476. /*
  9477. * 6ch mode
  9478. */
  9479. static struct hda_verb alc662_3ST_ch6_init[] = {
  9480. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9481. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9482. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9483. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9484. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9485. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9486. { } /* end */
  9487. };
  9488. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9489. { 2, alc662_3ST_ch2_init },
  9490. { 6, alc662_3ST_ch6_init },
  9491. };
  9492. /*
  9493. * 2ch mode
  9494. */
  9495. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9496. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9497. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9498. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9499. { } /* end */
  9500. };
  9501. /*
  9502. * 6ch mode
  9503. */
  9504. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9505. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9506. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9507. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9508. { } /* end */
  9509. };
  9510. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9511. { 2, alc662_sixstack_ch6_init },
  9512. { 6, alc662_sixstack_ch8_init },
  9513. };
  9514. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9515. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9516. */
  9517. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9518. /* output mixer control */
  9519. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9520. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9521. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9522. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9523. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9524. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9525. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9526. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9527. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9528. /*Input mixer control */
  9529. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9530. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9531. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9532. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9533. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9534. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9535. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9536. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9537. /* Capture mixer control */
  9538. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9539. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9540. {
  9541. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9542. .name = "Capture Source",
  9543. .count = 1,
  9544. .info = alc_mux_enum_info,
  9545. .get = alc_mux_enum_get,
  9546. .put = alc_mux_enum_put,
  9547. },
  9548. { } /* end */
  9549. };
  9550. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9551. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9552. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9553. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9554. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9555. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9556. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9557. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9558. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9559. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9560. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9561. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9562. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9563. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9564. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9565. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9566. {
  9567. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9568. /* .name = "Capture Source", */
  9569. .name = "Input Source",
  9570. .count = 1,
  9571. .info = alc662_mux_enum_info,
  9572. .get = alc662_mux_enum_get,
  9573. .put = alc662_mux_enum_put,
  9574. },
  9575. { } /* end */
  9576. };
  9577. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9578. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9579. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9580. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9581. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9582. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9583. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9584. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9585. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9586. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9587. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9588. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9589. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9590. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9591. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9592. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9593. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9594. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9597. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9598. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9599. {
  9600. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9601. /* .name = "Capture Source", */
  9602. .name = "Input Source",
  9603. .count = 1,
  9604. .info = alc662_mux_enum_info,
  9605. .get = alc662_mux_enum_get,
  9606. .put = alc662_mux_enum_put,
  9607. },
  9608. { } /* end */
  9609. };
  9610. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9611. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9612. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9613. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9614. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9615. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9616. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9617. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9619. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9620. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9621. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9622. {
  9623. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9624. /* .name = "Capture Source", */
  9625. .name = "Input Source",
  9626. .count = 1,
  9627. .info = alc662_mux_enum_info,
  9628. .get = alc662_mux_enum_get,
  9629. .put = alc662_mux_enum_put,
  9630. },
  9631. { } /* end */
  9632. };
  9633. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9634. {
  9635. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9636. .name = "Channel Mode",
  9637. .info = alc_ch_mode_info,
  9638. .get = alc_ch_mode_get,
  9639. .put = alc_ch_mode_put,
  9640. },
  9641. { } /* end */
  9642. };
  9643. static struct hda_verb alc662_init_verbs[] = {
  9644. /* ADC: mute amp left and right */
  9645. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9646. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9647. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9648. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9649. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9650. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9651. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9652. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9653. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9654. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9655. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9656. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9657. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9658. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9659. /* Front Pin: output 0 (0x0c) */
  9660. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9661. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9662. /* Rear Pin: output 1 (0x0d) */
  9663. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9664. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9665. /* CLFE Pin: output 2 (0x0e) */
  9666. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9667. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9668. /* Mic (rear) pin: input vref at 80% */
  9669. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9670. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9671. /* Front Mic pin: input vref at 80% */
  9672. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9673. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9674. /* Line In pin: input */
  9675. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9676. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9677. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9678. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9679. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9680. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9681. /* CD pin widget for input */
  9682. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9683. /* FIXME: use matrix-type input source selection */
  9684. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9685. /* Input mixer */
  9686. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9687. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9688. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9689. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9690. { }
  9691. };
  9692. static struct hda_verb alc662_sue_init_verbs[] = {
  9693. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9694. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9695. {}
  9696. };
  9697. /*
  9698. * generic initialization of ADC, input mixers and output mixers
  9699. */
  9700. static struct hda_verb alc662_auto_init_verbs[] = {
  9701. /*
  9702. * Unmute ADC and set the default input to mic-in
  9703. */
  9704. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9705. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9706. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9707. * mixer widget
  9708. * Note: PASD motherboards uses the Line In 2 as the input for front
  9709. * panel mic (mic 2)
  9710. */
  9711. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9712. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9713. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9714. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9715. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9716. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9717. /*
  9718. * Set up output mixers (0x0c - 0x0f)
  9719. */
  9720. /* set vol=0 to output mixers */
  9721. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9722. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9723. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9724. /* set up input amps for analog loopback */
  9725. /* Amp Indices: DAC = 0, mixer = 1 */
  9726. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9727. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9728. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9729. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9730. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9731. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9732. /* FIXME: use matrix-type input source selection */
  9733. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9734. /* Input mixer */
  9735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9736. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9737. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9738. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9739. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9740. { }
  9741. };
  9742. /* capture mixer elements */
  9743. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9744. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9745. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9746. {
  9747. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9748. /* The multiple "Capture Source" controls confuse alsamixer
  9749. * So call somewhat different..
  9750. * FIXME: the controls appear in the "playback" view!
  9751. */
  9752. /* .name = "Capture Source", */
  9753. .name = "Input Source",
  9754. .count = 1,
  9755. .info = alc882_mux_enum_info,
  9756. .get = alc882_mux_enum_get,
  9757. .put = alc882_mux_enum_put,
  9758. },
  9759. { } /* end */
  9760. };
  9761. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9762. {
  9763. unsigned int present;
  9764. unsigned char bits;
  9765. present = snd_hda_codec_read(codec, 0x14, 0,
  9766. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9767. bits = present ? 0x80 : 0;
  9768. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9769. 0x80, bits);
  9770. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9771. 0x80, bits);
  9772. }
  9773. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9774. {
  9775. unsigned int present;
  9776. unsigned char bits;
  9777. present = snd_hda_codec_read(codec, 0x1b, 0,
  9778. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9779. bits = present ? 0x80 : 0;
  9780. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9781. 0x80, bits);
  9782. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9783. 0x80, bits);
  9784. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9785. 0x80, bits);
  9786. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9787. 0x80, bits);
  9788. }
  9789. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9790. unsigned int res)
  9791. {
  9792. if ((res >> 26) == ALC880_HP_EVENT)
  9793. alc662_lenovo_101e_all_automute(codec);
  9794. if ((res >> 26) == ALC880_FRONT_EVENT)
  9795. alc662_lenovo_101e_ispeaker_automute(codec);
  9796. }
  9797. /* pcm configuration: identiacal with ALC880 */
  9798. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9799. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9800. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9801. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9802. /*
  9803. * configuration and preset
  9804. */
  9805. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9806. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9807. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9808. [ALC662_3ST_6ch] = "3stack-6ch",
  9809. [ALC662_5ST_DIG] = "6stack-dig",
  9810. [ALC662_LENOVO_101E] = "lenovo-101e",
  9811. [ALC662_AUTO] = "auto",
  9812. };
  9813. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9814. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9815. {}
  9816. };
  9817. static struct alc_config_preset alc662_presets[] = {
  9818. [ALC662_3ST_2ch_DIG] = {
  9819. .mixers = { alc662_3ST_2ch_mixer },
  9820. .init_verbs = { alc662_init_verbs },
  9821. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9822. .dac_nids = alc662_dac_nids,
  9823. .dig_out_nid = ALC662_DIGOUT_NID,
  9824. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9825. .adc_nids = alc662_adc_nids,
  9826. .dig_in_nid = ALC662_DIGIN_NID,
  9827. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9828. .channel_mode = alc662_3ST_2ch_modes,
  9829. .input_mux = &alc662_capture_source,
  9830. },
  9831. [ALC662_3ST_6ch_DIG] = {
  9832. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9833. .init_verbs = { alc662_init_verbs },
  9834. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9835. .dac_nids = alc662_dac_nids,
  9836. .dig_out_nid = ALC662_DIGOUT_NID,
  9837. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9838. .adc_nids = alc662_adc_nids,
  9839. .dig_in_nid = ALC662_DIGIN_NID,
  9840. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9841. .channel_mode = alc662_3ST_6ch_modes,
  9842. .need_dac_fix = 1,
  9843. .input_mux = &alc662_capture_source,
  9844. },
  9845. [ALC662_3ST_6ch] = {
  9846. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9847. .init_verbs = { alc662_init_verbs },
  9848. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9849. .dac_nids = alc662_dac_nids,
  9850. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9851. .adc_nids = alc662_adc_nids,
  9852. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9853. .channel_mode = alc662_3ST_6ch_modes,
  9854. .need_dac_fix = 1,
  9855. .input_mux = &alc662_capture_source,
  9856. },
  9857. [ALC662_5ST_DIG] = {
  9858. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9859. .init_verbs = { alc662_init_verbs },
  9860. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9861. .dac_nids = alc662_dac_nids,
  9862. .dig_out_nid = ALC662_DIGOUT_NID,
  9863. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9864. .adc_nids = alc662_adc_nids,
  9865. .dig_in_nid = ALC662_DIGIN_NID,
  9866. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9867. .channel_mode = alc662_5stack_modes,
  9868. .input_mux = &alc662_capture_source,
  9869. },
  9870. [ALC662_LENOVO_101E] = {
  9871. .mixers = { alc662_lenovo_101e_mixer },
  9872. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9873. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9874. .dac_nids = alc662_dac_nids,
  9875. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9876. .adc_nids = alc662_adc_nids,
  9877. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9878. .channel_mode = alc662_3ST_2ch_modes,
  9879. .input_mux = &alc662_lenovo_101e_capture_source,
  9880. .unsol_event = alc662_lenovo_101e_unsol_event,
  9881. .init_hook = alc662_lenovo_101e_all_automute,
  9882. },
  9883. };
  9884. /*
  9885. * BIOS auto configuration
  9886. */
  9887. /* add playback controls from the parsed DAC table */
  9888. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9889. const struct auto_pin_cfg *cfg)
  9890. {
  9891. char name[32];
  9892. static const char *chname[4] = {
  9893. "Front", "Surround", NULL /*CLFE*/, "Side"
  9894. };
  9895. hda_nid_t nid;
  9896. int i, err;
  9897. for (i = 0; i < cfg->line_outs; i++) {
  9898. if (!spec->multiout.dac_nids[i])
  9899. continue;
  9900. nid = alc880_idx_to_dac(i);
  9901. if (i == 2) {
  9902. /* Center/LFE */
  9903. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9904. "Center Playback Volume",
  9905. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9906. HDA_OUTPUT));
  9907. if (err < 0)
  9908. return err;
  9909. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9910. "LFE Playback Volume",
  9911. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9912. HDA_OUTPUT));
  9913. if (err < 0)
  9914. return err;
  9915. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9916. "Center Playback Switch",
  9917. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9918. HDA_INPUT));
  9919. if (err < 0)
  9920. return err;
  9921. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9922. "LFE Playback Switch",
  9923. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9924. HDA_INPUT));
  9925. if (err < 0)
  9926. return err;
  9927. } else {
  9928. sprintf(name, "%s Playback Volume", chname[i]);
  9929. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9930. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9931. HDA_OUTPUT));
  9932. if (err < 0)
  9933. return err;
  9934. sprintf(name, "%s Playback Switch", chname[i]);
  9935. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9936. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9937. HDA_INPUT));
  9938. if (err < 0)
  9939. return err;
  9940. }
  9941. }
  9942. return 0;
  9943. }
  9944. /* add playback controls for speaker and HP outputs */
  9945. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9946. const char *pfx)
  9947. {
  9948. hda_nid_t nid;
  9949. int err;
  9950. char name[32];
  9951. if (!pin)
  9952. return 0;
  9953. if (alc880_is_fixed_pin(pin)) {
  9954. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9955. /* printk("DAC nid=%x\n",nid); */
  9956. /* specify the DAC as the extra output */
  9957. if (!spec->multiout.hp_nid)
  9958. spec->multiout.hp_nid = nid;
  9959. else
  9960. spec->multiout.extra_out_nid[0] = nid;
  9961. /* control HP volume/switch on the output mixer amp */
  9962. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9963. sprintf(name, "%s Playback Volume", pfx);
  9964. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9965. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9966. if (err < 0)
  9967. return err;
  9968. sprintf(name, "%s Playback Switch", pfx);
  9969. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9970. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9971. if (err < 0)
  9972. return err;
  9973. } else if (alc880_is_multi_pin(pin)) {
  9974. /* set manual connection */
  9975. /* we have only a switch on HP-out PIN */
  9976. sprintf(name, "%s Playback Switch", pfx);
  9977. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9978. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9979. if (err < 0)
  9980. return err;
  9981. }
  9982. return 0;
  9983. }
  9984. /* create playback/capture controls for input pins */
  9985. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9986. const struct auto_pin_cfg *cfg)
  9987. {
  9988. struct hda_input_mux *imux = &spec->private_imux;
  9989. int i, err, idx;
  9990. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9991. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9992. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9993. err = new_analog_input(spec, cfg->input_pins[i],
  9994. auto_pin_cfg_labels[i],
  9995. idx, 0x0b);
  9996. if (err < 0)
  9997. return err;
  9998. imux->items[imux->num_items].label =
  9999. auto_pin_cfg_labels[i];
  10000. imux->items[imux->num_items].index =
  10001. alc880_input_pin_idx(cfg->input_pins[i]);
  10002. imux->num_items++;
  10003. }
  10004. }
  10005. return 0;
  10006. }
  10007. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10008. hda_nid_t nid, int pin_type,
  10009. int dac_idx)
  10010. {
  10011. /* set as output */
  10012. snd_hda_codec_write(codec, nid, 0,
  10013. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10014. snd_hda_codec_write(codec, nid, 0,
  10015. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10016. /* need the manual connection? */
  10017. if (alc880_is_multi_pin(nid)) {
  10018. struct alc_spec *spec = codec->spec;
  10019. int idx = alc880_multi_pin_idx(nid);
  10020. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10021. AC_VERB_SET_CONNECT_SEL,
  10022. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10023. }
  10024. }
  10025. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10026. {
  10027. struct alc_spec *spec = codec->spec;
  10028. int i;
  10029. for (i = 0; i <= HDA_SIDE; i++) {
  10030. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10031. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10032. if (nid)
  10033. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10034. i);
  10035. }
  10036. }
  10037. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10038. {
  10039. struct alc_spec *spec = codec->spec;
  10040. hda_nid_t pin;
  10041. pin = spec->autocfg.hp_pins[0];
  10042. if (pin) /* connect to front */
  10043. /* use dac 0 */
  10044. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10045. }
  10046. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10047. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10048. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10049. {
  10050. struct alc_spec *spec = codec->spec;
  10051. int i;
  10052. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10053. hda_nid_t nid = spec->autocfg.input_pins[i];
  10054. if (alc662_is_input_pin(nid)) {
  10055. snd_hda_codec_write(codec, nid, 0,
  10056. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10057. (i <= AUTO_PIN_FRONT_MIC ?
  10058. PIN_VREF80 : PIN_IN));
  10059. if (nid != ALC662_PIN_CD_NID)
  10060. snd_hda_codec_write(codec, nid, 0,
  10061. AC_VERB_SET_AMP_GAIN_MUTE,
  10062. AMP_OUT_MUTE);
  10063. }
  10064. }
  10065. }
  10066. static int alc662_parse_auto_config(struct hda_codec *codec)
  10067. {
  10068. struct alc_spec *spec = codec->spec;
  10069. int err;
  10070. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10071. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10072. alc662_ignore);
  10073. if (err < 0)
  10074. return err;
  10075. if (!spec->autocfg.line_outs)
  10076. return 0; /* can't find valid BIOS pin config */
  10077. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10078. if (err < 0)
  10079. return err;
  10080. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10081. if (err < 0)
  10082. return err;
  10083. err = alc662_auto_create_extra_out(spec,
  10084. spec->autocfg.speaker_pins[0],
  10085. "Speaker");
  10086. if (err < 0)
  10087. return err;
  10088. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10089. "Headphone");
  10090. if (err < 0)
  10091. return err;
  10092. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10093. if (err < 0)
  10094. return err;
  10095. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10096. if (spec->autocfg.dig_out_pin)
  10097. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10098. if (spec->kctl_alloc)
  10099. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10100. spec->num_mux_defs = 1;
  10101. spec->input_mux = &spec->private_imux;
  10102. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10103. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10104. spec->num_mixers++;
  10105. return 1;
  10106. }
  10107. /* additional initialization for auto-configuration model */
  10108. static void alc662_auto_init(struct hda_codec *codec)
  10109. {
  10110. alc662_auto_init_multi_out(codec);
  10111. alc662_auto_init_hp_out(codec);
  10112. alc662_auto_init_analog_input(codec);
  10113. }
  10114. static int patch_alc662(struct hda_codec *codec)
  10115. {
  10116. struct alc_spec *spec;
  10117. int err, board_config;
  10118. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10119. if (!spec)
  10120. return -ENOMEM;
  10121. codec->spec = spec;
  10122. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10123. alc662_models,
  10124. alc662_cfg_tbl);
  10125. if (board_config < 0) {
  10126. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10127. "trying auto-probe from BIOS...\n");
  10128. board_config = ALC662_AUTO;
  10129. }
  10130. if (board_config == ALC662_AUTO) {
  10131. /* automatic parse from the BIOS config */
  10132. err = alc662_parse_auto_config(codec);
  10133. if (err < 0) {
  10134. alc_free(codec);
  10135. return err;
  10136. } else if (!err) {
  10137. printk(KERN_INFO
  10138. "hda_codec: Cannot set up configuration "
  10139. "from BIOS. Using base mode...\n");
  10140. board_config = ALC662_3ST_2ch_DIG;
  10141. }
  10142. }
  10143. if (board_config != ALC662_AUTO)
  10144. setup_preset(spec, &alc662_presets[board_config]);
  10145. spec->stream_name_analog = "ALC662 Analog";
  10146. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10147. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10148. spec->stream_name_digital = "ALC662 Digital";
  10149. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10150. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10151. if (!spec->adc_nids && spec->input_mux) {
  10152. spec->adc_nids = alc662_adc_nids;
  10153. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10154. }
  10155. codec->patch_ops = alc_patch_ops;
  10156. if (board_config == ALC662_AUTO)
  10157. spec->init_hook = alc662_auto_init;
  10158. return 0;
  10159. }
  10160. /*
  10161. * patch entries
  10162. */
  10163. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10164. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10165. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10166. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10167. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10168. .patch = patch_alc861 },
  10169. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10170. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10171. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10172. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10173. .patch = patch_alc883 },
  10174. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10175. .patch = patch_alc662 },
  10176. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10177. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10178. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10179. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10180. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10181. {} /* terminator */
  10182. };