patch_realtek.c 372 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263
  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. ALC861VD_3ST,
  118. ALC861VD_3ST_DIG,
  119. ALC861VD_6ST_DIG,
  120. ALC861VD_LENOVO,
  121. ALC861VD_DALLAS,
  122. ALC861VD_AUTO,
  123. ALC861VD_MODEL_LAST,
  124. };
  125. /* ALC662 models */
  126. enum {
  127. ALC662_3ST_2ch_DIG,
  128. ALC662_3ST_6ch_DIG,
  129. ALC662_3ST_6ch,
  130. ALC662_5ST_DIG,
  131. ALC662_LENOVO_101E,
  132. ALC662_AUTO,
  133. ALC662_MODEL_LAST,
  134. };
  135. /* ALC882 models */
  136. enum {
  137. ALC882_3ST_DIG,
  138. ALC882_6ST_DIG,
  139. ALC882_ARIMA,
  140. ALC882_W2JC,
  141. ALC882_TARGA,
  142. ALC882_ASUS_A7J,
  143. ALC885_MACPRO,
  144. ALC882_AUTO,
  145. ALC882_MODEL_LAST,
  146. };
  147. /* ALC883 models */
  148. enum {
  149. ALC883_3ST_2ch_DIG,
  150. ALC883_3ST_6ch_DIG,
  151. ALC883_3ST_6ch,
  152. ALC883_6ST_DIG,
  153. ALC883_TARGA_DIG,
  154. ALC883_TARGA_2ch_DIG,
  155. ALC883_ACER,
  156. ALC883_MEDION,
  157. ALC883_MEDION_MD2,
  158. ALC883_LAPTOP_EAPD,
  159. ALC883_LENOVO_101E_2ch,
  160. ALC883_LENOVO_NB0763,
  161. ALC888_LENOVO_MS7195_DIG,
  162. ALC883_AUTO,
  163. ALC883_MODEL_LAST,
  164. };
  165. /* for GPIO Poll */
  166. #define GPIO_MASK 0x03
  167. struct alc_spec {
  168. /* codec parameterization */
  169. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  170. unsigned int num_mixers;
  171. const struct hda_verb *init_verbs[5]; /* initialization verbs
  172. * don't forget NULL
  173. * termination!
  174. */
  175. unsigned int num_init_verbs;
  176. char *stream_name_analog; /* analog PCM stream */
  177. struct hda_pcm_stream *stream_analog_playback;
  178. struct hda_pcm_stream *stream_analog_capture;
  179. char *stream_name_digital; /* digital PCM stream */
  180. struct hda_pcm_stream *stream_digital_playback;
  181. struct hda_pcm_stream *stream_digital_capture;
  182. /* playback */
  183. struct hda_multi_out multiout; /* playback set-up
  184. * max_channels, dacs must be set
  185. * dig_out_nid and hp_nid are optional
  186. */
  187. /* capture */
  188. unsigned int num_adc_nids;
  189. hda_nid_t *adc_nids;
  190. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  191. /* capture source */
  192. unsigned int num_mux_defs;
  193. const struct hda_input_mux *input_mux;
  194. unsigned int cur_mux[3];
  195. /* channel model */
  196. const struct hda_channel_mode *channel_mode;
  197. int num_channel_mode;
  198. int need_dac_fix;
  199. /* PCM information */
  200. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  201. /* dynamic controls, init_verbs and input_mux */
  202. struct auto_pin_cfg autocfg;
  203. unsigned int num_kctl_alloc, num_kctl_used;
  204. struct snd_kcontrol_new *kctl_alloc;
  205. struct hda_input_mux private_imux;
  206. hda_nid_t private_dac_nids[5];
  207. /* hooks */
  208. void (*init_hook)(struct hda_codec *codec);
  209. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  210. /* for pin sensing */
  211. unsigned int sense_updated: 1;
  212. unsigned int jack_present: 1;
  213. };
  214. /*
  215. * configuration template - to be copied to the spec instance
  216. */
  217. struct alc_config_preset {
  218. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  219. * with spec
  220. */
  221. const struct hda_verb *init_verbs[5];
  222. unsigned int num_dacs;
  223. hda_nid_t *dac_nids;
  224. hda_nid_t dig_out_nid; /* optional */
  225. hda_nid_t hp_nid; /* optional */
  226. unsigned int num_adc_nids;
  227. hda_nid_t *adc_nids;
  228. hda_nid_t dig_in_nid;
  229. unsigned int num_channel_mode;
  230. const struct hda_channel_mode *channel_mode;
  231. int need_dac_fix;
  232. unsigned int num_mux_defs;
  233. const struct hda_input_mux *input_mux;
  234. void (*unsol_event)(struct hda_codec *, unsigned int);
  235. void (*init_hook)(struct hda_codec *);
  236. };
  237. /*
  238. * input MUX handling
  239. */
  240. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  241. struct snd_ctl_elem_info *uinfo)
  242. {
  243. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  244. struct alc_spec *spec = codec->spec;
  245. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  246. if (mux_idx >= spec->num_mux_defs)
  247. mux_idx = 0;
  248. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  249. }
  250. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  251. struct snd_ctl_elem_value *ucontrol)
  252. {
  253. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  254. struct alc_spec *spec = codec->spec;
  255. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  256. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  257. return 0;
  258. }
  259. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_value *ucontrol)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  265. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  266. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  267. spec->adc_nids[adc_idx],
  268. &spec->cur_mux[adc_idx]);
  269. }
  270. /*
  271. * channel mode setting
  272. */
  273. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  274. struct snd_ctl_elem_info *uinfo)
  275. {
  276. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  277. struct alc_spec *spec = codec->spec;
  278. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  279. spec->num_channel_mode);
  280. }
  281. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  282. struct snd_ctl_elem_value *ucontrol)
  283. {
  284. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  285. struct alc_spec *spec = codec->spec;
  286. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  287. spec->num_channel_mode,
  288. spec->multiout.max_channels);
  289. }
  290. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  291. struct snd_ctl_elem_value *ucontrol)
  292. {
  293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  294. struct alc_spec *spec = codec->spec;
  295. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  296. spec->num_channel_mode,
  297. &spec->multiout.max_channels);
  298. if (err >= 0 && spec->need_dac_fix)
  299. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  300. return err;
  301. }
  302. /*
  303. * Control the mode of pin widget settings via the mixer. "pc" is used
  304. * instead of "%" to avoid consequences of accidently treating the % as
  305. * being part of a format specifier. Maximum allowed length of a value is
  306. * 63 characters plus NULL terminator.
  307. *
  308. * Note: some retasking pin complexes seem to ignore requests for input
  309. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  310. * are requested. Therefore order this list so that this behaviour will not
  311. * cause problems when mixer clients move through the enum sequentially.
  312. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  313. * March 2006.
  314. */
  315. static char *alc_pin_mode_names[] = {
  316. "Mic 50pc bias", "Mic 80pc bias",
  317. "Line in", "Line out", "Headphone out",
  318. };
  319. static unsigned char alc_pin_mode_values[] = {
  320. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  321. };
  322. /* The control can present all 5 options, or it can limit the options based
  323. * in the pin being assumed to be exclusively an input or an output pin. In
  324. * addition, "input" pins may or may not process the mic bias option
  325. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  326. * accept requests for bias as of chip versions up to March 2006) and/or
  327. * wiring in the computer.
  328. */
  329. #define ALC_PIN_DIR_IN 0x00
  330. #define ALC_PIN_DIR_OUT 0x01
  331. #define ALC_PIN_DIR_INOUT 0x02
  332. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  333. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  334. /* Info about the pin modes supported by the different pin direction modes.
  335. * For each direction the minimum and maximum values are given.
  336. */
  337. static signed char alc_pin_mode_dir_info[5][2] = {
  338. { 0, 2 }, /* ALC_PIN_DIR_IN */
  339. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  340. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  341. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  342. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  343. };
  344. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  345. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  346. #define alc_pin_mode_n_items(_dir) \
  347. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  348. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  349. struct snd_ctl_elem_info *uinfo)
  350. {
  351. unsigned int item_num = uinfo->value.enumerated.item;
  352. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  353. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  354. uinfo->count = 1;
  355. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  356. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  357. item_num = alc_pin_mode_min(dir);
  358. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  359. return 0;
  360. }
  361. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  362. struct snd_ctl_elem_value *ucontrol)
  363. {
  364. unsigned int i;
  365. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  366. hda_nid_t nid = kcontrol->private_value & 0xffff;
  367. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  368. long *valp = ucontrol->value.integer.value;
  369. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  370. AC_VERB_GET_PIN_WIDGET_CONTROL,
  371. 0x00);
  372. /* Find enumerated value for current pinctl setting */
  373. i = alc_pin_mode_min(dir);
  374. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  375. i++;
  376. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  377. return 0;
  378. }
  379. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  380. struct snd_ctl_elem_value *ucontrol)
  381. {
  382. signed int change;
  383. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  384. hda_nid_t nid = kcontrol->private_value & 0xffff;
  385. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  386. long val = *ucontrol->value.integer.value;
  387. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  388. AC_VERB_GET_PIN_WIDGET_CONTROL,
  389. 0x00);
  390. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  391. val = alc_pin_mode_min(dir);
  392. change = pinctl != alc_pin_mode_values[val];
  393. if (change) {
  394. /* Set pin mode to that requested */
  395. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  396. alc_pin_mode_values[val]);
  397. /* Also enable the retasking pin's input/output as required
  398. * for the requested pin mode. Enum values of 2 or less are
  399. * input modes.
  400. *
  401. * Dynamically switching the input/output buffers probably
  402. * reduces noise slightly (particularly on input) so we'll
  403. * do it. However, having both input and output buffers
  404. * enabled simultaneously doesn't seem to be problematic if
  405. * this turns out to be necessary in the future.
  406. */
  407. if (val <= 2) {
  408. snd_hda_codec_write(codec, nid, 0,
  409. AC_VERB_SET_AMP_GAIN_MUTE,
  410. AMP_OUT_MUTE);
  411. snd_hda_codec_write(codec, nid, 0,
  412. AC_VERB_SET_AMP_GAIN_MUTE,
  413. AMP_IN_UNMUTE(0));
  414. } else {
  415. snd_hda_codec_write(codec, nid, 0,
  416. AC_VERB_SET_AMP_GAIN_MUTE,
  417. AMP_IN_MUTE(0));
  418. snd_hda_codec_write(codec, nid, 0,
  419. AC_VERB_SET_AMP_GAIN_MUTE,
  420. AMP_OUT_UNMUTE);
  421. }
  422. }
  423. return change;
  424. }
  425. #define ALC_PIN_MODE(xname, nid, dir) \
  426. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  427. .info = alc_pin_mode_info, \
  428. .get = alc_pin_mode_get, \
  429. .put = alc_pin_mode_put, \
  430. .private_value = nid | (dir<<16) }
  431. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  432. * together using a mask with more than one bit set. This control is
  433. * currently used only by the ALC260 test model. At this stage they are not
  434. * needed for any "production" models.
  435. */
  436. #ifdef CONFIG_SND_DEBUG
  437. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  438. struct snd_ctl_elem_info *uinfo)
  439. {
  440. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  441. uinfo->count = 1;
  442. uinfo->value.integer.min = 0;
  443. uinfo->value.integer.max = 1;
  444. return 0;
  445. }
  446. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  447. struct snd_ctl_elem_value *ucontrol)
  448. {
  449. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  450. hda_nid_t nid = kcontrol->private_value & 0xffff;
  451. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  452. long *valp = ucontrol->value.integer.value;
  453. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  454. AC_VERB_GET_GPIO_DATA, 0x00);
  455. *valp = (val & mask) != 0;
  456. return 0;
  457. }
  458. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  459. struct snd_ctl_elem_value *ucontrol)
  460. {
  461. signed int change;
  462. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  463. hda_nid_t nid = kcontrol->private_value & 0xffff;
  464. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  465. long val = *ucontrol->value.integer.value;
  466. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  467. AC_VERB_GET_GPIO_DATA,
  468. 0x00);
  469. /* Set/unset the masked GPIO bit(s) as needed */
  470. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  471. if (val == 0)
  472. gpio_data &= ~mask;
  473. else
  474. gpio_data |= mask;
  475. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  476. return change;
  477. }
  478. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  479. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  480. .info = alc_gpio_data_info, \
  481. .get = alc_gpio_data_get, \
  482. .put = alc_gpio_data_put, \
  483. .private_value = nid | (mask<<16) }
  484. #endif /* CONFIG_SND_DEBUG */
  485. /* A switch control to allow the enabling of the digital IO pins on the
  486. * ALC260. This is incredibly simplistic; the intention of this control is
  487. * to provide something in the test model allowing digital outputs to be
  488. * identified if present. If models are found which can utilise these
  489. * outputs a more complete mixer control can be devised for those models if
  490. * necessary.
  491. */
  492. #ifdef CONFIG_SND_DEBUG
  493. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  494. struct snd_ctl_elem_info *uinfo)
  495. {
  496. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  497. uinfo->count = 1;
  498. uinfo->value.integer.min = 0;
  499. uinfo->value.integer.max = 1;
  500. return 0;
  501. }
  502. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  503. struct snd_ctl_elem_value *ucontrol)
  504. {
  505. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  506. hda_nid_t nid = kcontrol->private_value & 0xffff;
  507. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  508. long *valp = ucontrol->value.integer.value;
  509. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  510. AC_VERB_GET_DIGI_CONVERT, 0x00);
  511. *valp = (val & mask) != 0;
  512. return 0;
  513. }
  514. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  515. struct snd_ctl_elem_value *ucontrol)
  516. {
  517. signed int change;
  518. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  519. hda_nid_t nid = kcontrol->private_value & 0xffff;
  520. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  521. long val = *ucontrol->value.integer.value;
  522. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  523. AC_VERB_GET_DIGI_CONVERT,
  524. 0x00);
  525. /* Set/unset the masked control bit(s) as needed */
  526. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  527. if (val==0)
  528. ctrl_data &= ~mask;
  529. else
  530. ctrl_data |= mask;
  531. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  532. ctrl_data);
  533. return change;
  534. }
  535. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  536. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  537. .info = alc_spdif_ctrl_info, \
  538. .get = alc_spdif_ctrl_get, \
  539. .put = alc_spdif_ctrl_put, \
  540. .private_value = nid | (mask<<16) }
  541. #endif /* CONFIG_SND_DEBUG */
  542. /*
  543. * set up from the preset table
  544. */
  545. static void setup_preset(struct alc_spec *spec,
  546. const struct alc_config_preset *preset)
  547. {
  548. int i;
  549. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  550. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  551. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  552. i++)
  553. spec->init_verbs[spec->num_init_verbs++] =
  554. preset->init_verbs[i];
  555. spec->channel_mode = preset->channel_mode;
  556. spec->num_channel_mode = preset->num_channel_mode;
  557. spec->need_dac_fix = preset->need_dac_fix;
  558. spec->multiout.max_channels = spec->channel_mode[0].channels;
  559. spec->multiout.num_dacs = preset->num_dacs;
  560. spec->multiout.dac_nids = preset->dac_nids;
  561. spec->multiout.dig_out_nid = preset->dig_out_nid;
  562. spec->multiout.hp_nid = preset->hp_nid;
  563. spec->num_mux_defs = preset->num_mux_defs;
  564. if (!spec->num_mux_defs)
  565. spec->num_mux_defs = 1;
  566. spec->input_mux = preset->input_mux;
  567. spec->num_adc_nids = preset->num_adc_nids;
  568. spec->adc_nids = preset->adc_nids;
  569. spec->dig_in_nid = preset->dig_in_nid;
  570. spec->unsol_event = preset->unsol_event;
  571. spec->init_hook = preset->init_hook;
  572. }
  573. /* Enable GPIO mask and set output */
  574. static struct hda_verb alc_gpio1_init_verbs[] = {
  575. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  576. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  578. { }
  579. };
  580. static struct hda_verb alc_gpio2_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  584. { }
  585. };
  586. static struct hda_verb alc_gpio3_init_verbs[] = {
  587. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  588. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  590. { }
  591. };
  592. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  593. * 31 ~ 16 : Manufacture ID
  594. * 15 ~ 8 : SKU ID
  595. * 7 ~ 0 : Assembly ID
  596. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  597. */
  598. static void alc_subsystem_id(struct hda_codec *codec,
  599. unsigned int porta, unsigned int porte,
  600. unsigned int portd)
  601. {
  602. unsigned int ass, tmp;
  603. ass = codec->subsystem_id;
  604. if (!(ass & 1))
  605. return;
  606. /* Override */
  607. tmp = (ass & 0x38) >> 3; /* external Amp control */
  608. switch (tmp) {
  609. case 1:
  610. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  611. break;
  612. case 3:
  613. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  614. break;
  615. case 7:
  616. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  617. break;
  618. case 5:
  619. switch (codec->vendor_id) {
  620. case 0x10ec0862:
  621. case 0x10ec0660:
  622. case 0x10ec0662:
  623. case 0x10ec0267:
  624. case 0x10ec0268:
  625. snd_hda_codec_write(codec, 0x14, 0,
  626. AC_VERB_SET_EAPD_BTLENABLE, 2);
  627. snd_hda_codec_write(codec, 0x15, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. return;
  630. }
  631. case 6:
  632. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  633. hda_nid_t port = 0;
  634. tmp = (ass & 0x1800) >> 11;
  635. switch (tmp) {
  636. case 0: port = porta; break;
  637. case 1: port = porte; break;
  638. case 2: port = portd; break;
  639. }
  640. if (port)
  641. snd_hda_codec_write(codec, port, 0,
  642. AC_VERB_SET_EAPD_BTLENABLE,
  643. 2);
  644. }
  645. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  647. (tmp == 5 ? 0x3040 : 0x3050));
  648. break;
  649. }
  650. }
  651. /*
  652. * ALC880 3-stack model
  653. *
  654. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  655. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  656. * F-Mic = 0x1b, HP = 0x19
  657. */
  658. static hda_nid_t alc880_dac_nids[4] = {
  659. /* front, rear, clfe, rear_surr */
  660. 0x02, 0x05, 0x04, 0x03
  661. };
  662. static hda_nid_t alc880_adc_nids[3] = {
  663. /* ADC0-2 */
  664. 0x07, 0x08, 0x09,
  665. };
  666. /* The datasheet says the node 0x07 is connected from inputs,
  667. * but it shows zero connection in the real implementation on some devices.
  668. * Note: this is a 915GAV bug, fixed on 915GLV
  669. */
  670. static hda_nid_t alc880_adc_nids_alt[2] = {
  671. /* ADC1-2 */
  672. 0x08, 0x09,
  673. };
  674. #define ALC880_DIGOUT_NID 0x06
  675. #define ALC880_DIGIN_NID 0x0a
  676. static struct hda_input_mux alc880_capture_source = {
  677. .num_items = 4,
  678. .items = {
  679. { "Mic", 0x0 },
  680. { "Front Mic", 0x3 },
  681. { "Line", 0x2 },
  682. { "CD", 0x4 },
  683. },
  684. };
  685. /* channel source setting (2/6 channel selection for 3-stack) */
  686. /* 2ch mode */
  687. static struct hda_verb alc880_threestack_ch2_init[] = {
  688. /* set line-in to input, mute it */
  689. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  690. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  691. /* set mic-in to input vref 80%, mute it */
  692. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  693. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  694. { } /* end */
  695. };
  696. /* 6ch mode */
  697. static struct hda_verb alc880_threestack_ch6_init[] = {
  698. /* set line-in to output, unmute it */
  699. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  700. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  701. /* set mic-in to output, unmute it */
  702. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  703. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  704. { } /* end */
  705. };
  706. static struct hda_channel_mode alc880_threestack_modes[2] = {
  707. { 2, alc880_threestack_ch2_init },
  708. { 6, alc880_threestack_ch6_init },
  709. };
  710. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  711. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  712. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  713. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  714. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  715. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  716. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  717. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  718. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  719. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  720. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  722. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  724. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  727. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  728. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  730. {
  731. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  732. .name = "Channel Mode",
  733. .info = alc_ch_mode_info,
  734. .get = alc_ch_mode_get,
  735. .put = alc_ch_mode_put,
  736. },
  737. { } /* end */
  738. };
  739. /* capture mixer elements */
  740. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  741. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  742. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  743. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  744. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  745. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  746. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  747. {
  748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  749. /* The multiple "Capture Source" controls confuse alsamixer
  750. * So call somewhat different..
  751. * FIXME: the controls appear in the "playback" view!
  752. */
  753. /* .name = "Capture Source", */
  754. .name = "Input Source",
  755. .count = 3,
  756. .info = alc_mux_enum_info,
  757. .get = alc_mux_enum_get,
  758. .put = alc_mux_enum_put,
  759. },
  760. { } /* end */
  761. };
  762. /* capture mixer elements (in case NID 0x07 not available) */
  763. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  764. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  765. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  766. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  767. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  768. {
  769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  770. /* The multiple "Capture Source" controls confuse alsamixer
  771. * So call somewhat different..
  772. * FIXME: the controls appear in the "playback" view!
  773. */
  774. /* .name = "Capture Source", */
  775. .name = "Input Source",
  776. .count = 2,
  777. .info = alc_mux_enum_info,
  778. .get = alc_mux_enum_get,
  779. .put = alc_mux_enum_put,
  780. },
  781. { } /* end */
  782. };
  783. /*
  784. * ALC880 5-stack model
  785. *
  786. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  787. * Side = 0x02 (0xd)
  788. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  789. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  790. */
  791. /* additional mixers to alc880_three_stack_mixer */
  792. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  793. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  794. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  795. { } /* end */
  796. };
  797. /* channel source setting (6/8 channel selection for 5-stack) */
  798. /* 6ch mode */
  799. static struct hda_verb alc880_fivestack_ch6_init[] = {
  800. /* set line-in to input, mute it */
  801. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  802. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  803. { } /* end */
  804. };
  805. /* 8ch mode */
  806. static struct hda_verb alc880_fivestack_ch8_init[] = {
  807. /* set line-in to output, unmute it */
  808. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  809. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  810. { } /* end */
  811. };
  812. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  813. { 6, alc880_fivestack_ch6_init },
  814. { 8, alc880_fivestack_ch8_init },
  815. };
  816. /*
  817. * ALC880 6-stack model
  818. *
  819. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  820. * Side = 0x05 (0x0f)
  821. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  822. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  823. */
  824. static hda_nid_t alc880_6st_dac_nids[4] = {
  825. /* front, rear, clfe, rear_surr */
  826. 0x02, 0x03, 0x04, 0x05
  827. };
  828. static struct hda_input_mux alc880_6stack_capture_source = {
  829. .num_items = 4,
  830. .items = {
  831. { "Mic", 0x0 },
  832. { "Front Mic", 0x1 },
  833. { "Line", 0x2 },
  834. { "CD", 0x4 },
  835. },
  836. };
  837. /* fixed 8-channels */
  838. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  839. { 8, NULL },
  840. };
  841. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  842. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  843. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  844. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  845. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  846. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  847. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  848. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  849. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  850. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  851. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  852. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  853. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  855. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  856. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  857. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  858. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  859. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  860. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  861. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  862. {
  863. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  864. .name = "Channel Mode",
  865. .info = alc_ch_mode_info,
  866. .get = alc_ch_mode_get,
  867. .put = alc_ch_mode_put,
  868. },
  869. { } /* end */
  870. };
  871. /*
  872. * ALC880 W810 model
  873. *
  874. * W810 has rear IO for:
  875. * Front (DAC 02)
  876. * Surround (DAC 03)
  877. * Center/LFE (DAC 04)
  878. * Digital out (06)
  879. *
  880. * The system also has a pair of internal speakers, and a headphone jack.
  881. * These are both connected to Line2 on the codec, hence to DAC 02.
  882. *
  883. * There is a variable resistor to control the speaker or headphone
  884. * volume. This is a hardware-only device without a software API.
  885. *
  886. * Plugging headphones in will disable the internal speakers. This is
  887. * implemented in hardware, not via the driver using jack sense. In
  888. * a similar fashion, plugging into the rear socket marked "front" will
  889. * disable both the speakers and headphones.
  890. *
  891. * For input, there's a microphone jack, and an "audio in" jack.
  892. * These may not do anything useful with this driver yet, because I
  893. * haven't setup any initialization verbs for these yet...
  894. */
  895. static hda_nid_t alc880_w810_dac_nids[3] = {
  896. /* front, rear/surround, clfe */
  897. 0x02, 0x03, 0x04
  898. };
  899. /* fixed 6 channels */
  900. static struct hda_channel_mode alc880_w810_modes[1] = {
  901. { 6, NULL }
  902. };
  903. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  904. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  905. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  906. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  907. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  908. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  909. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  910. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  911. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  912. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  913. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  914. { } /* end */
  915. };
  916. /*
  917. * Z710V model
  918. *
  919. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  920. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  921. * Line = 0x1a
  922. */
  923. static hda_nid_t alc880_z71v_dac_nids[1] = {
  924. 0x02
  925. };
  926. #define ALC880_Z71V_HP_DAC 0x03
  927. /* fixed 2 channels */
  928. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  929. { 2, NULL }
  930. };
  931. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  932. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  933. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  934. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  937. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  939. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  940. { } /* end */
  941. };
  942. /* FIXME! */
  943. /*
  944. * ALC880 F1734 model
  945. *
  946. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  947. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  948. */
  949. static hda_nid_t alc880_f1734_dac_nids[1] = {
  950. 0x03
  951. };
  952. #define ALC880_F1734_HP_DAC 0x02
  953. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  954. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  955. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  956. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  957. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  958. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  959. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  960. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  961. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  962. { } /* end */
  963. };
  964. /* FIXME! */
  965. /*
  966. * ALC880 ASUS model
  967. *
  968. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  969. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  970. * Mic = 0x18, Line = 0x1a
  971. */
  972. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  973. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  974. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  975. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  976. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  977. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  978. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  979. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  980. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  981. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  982. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  983. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  984. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  985. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  986. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  988. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  989. {
  990. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  991. .name = "Channel Mode",
  992. .info = alc_ch_mode_info,
  993. .get = alc_ch_mode_get,
  994. .put = alc_ch_mode_put,
  995. },
  996. { } /* end */
  997. };
  998. /* FIXME! */
  999. /*
  1000. * ALC880 ASUS W1V model
  1001. *
  1002. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1003. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1004. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1005. */
  1006. /* additional mixers to alc880_asus_mixer */
  1007. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1008. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1009. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1010. { } /* end */
  1011. };
  1012. /* additional mixers to alc880_asus_mixer */
  1013. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1014. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1015. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1016. { } /* end */
  1017. };
  1018. /* TCL S700 */
  1019. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1020. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1021. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1022. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1023. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1024. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1025. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1027. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1028. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1029. {
  1030. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1031. /* The multiple "Capture Source" controls confuse alsamixer
  1032. * So call somewhat different..
  1033. * FIXME: the controls appear in the "playback" view!
  1034. */
  1035. /* .name = "Capture Source", */
  1036. .name = "Input Source",
  1037. .count = 1,
  1038. .info = alc_mux_enum_info,
  1039. .get = alc_mux_enum_get,
  1040. .put = alc_mux_enum_put,
  1041. },
  1042. { } /* end */
  1043. };
  1044. /* Uniwill */
  1045. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1046. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1047. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1048. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1049. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1050. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1052. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1053. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1055. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1059. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1060. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1061. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1062. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1063. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1064. {
  1065. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1066. .name = "Channel Mode",
  1067. .info = alc_ch_mode_info,
  1068. .get = alc_ch_mode_get,
  1069. .put = alc_ch_mode_put,
  1070. },
  1071. { } /* end */
  1072. };
  1073. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1074. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1075. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1079. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1081. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1082. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1083. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1084. { } /* end */
  1085. };
  1086. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1087. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1088. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1090. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1092. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1093. { } /* end */
  1094. };
  1095. /*
  1096. * build control elements
  1097. */
  1098. static int alc_build_controls(struct hda_codec *codec)
  1099. {
  1100. struct alc_spec *spec = codec->spec;
  1101. int err;
  1102. int i;
  1103. for (i = 0; i < spec->num_mixers; i++) {
  1104. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1105. if (err < 0)
  1106. return err;
  1107. }
  1108. if (spec->multiout.dig_out_nid) {
  1109. err = snd_hda_create_spdif_out_ctls(codec,
  1110. spec->multiout.dig_out_nid);
  1111. if (err < 0)
  1112. return err;
  1113. }
  1114. if (spec->dig_in_nid) {
  1115. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1116. if (err < 0)
  1117. return err;
  1118. }
  1119. return 0;
  1120. }
  1121. /*
  1122. * initialize the codec volumes, etc
  1123. */
  1124. /*
  1125. * generic initialization of ADC, input mixers and output mixers
  1126. */
  1127. static struct hda_verb alc880_volume_init_verbs[] = {
  1128. /*
  1129. * Unmute ADC0-2 and set the default input to mic-in
  1130. */
  1131. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1132. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1133. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1134. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1135. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1136. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1137. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1138. * mixer widget
  1139. * Note: PASD motherboards uses the Line In 2 as the input for front
  1140. * panel mic (mic 2)
  1141. */
  1142. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1143. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1148. /*
  1149. * Set up output mixers (0x0c - 0x0f)
  1150. */
  1151. /* set vol=0 to output mixers */
  1152. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1153. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1154. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1155. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1156. /* set up input amps for analog loopback */
  1157. /* Amp Indices: DAC = 0, mixer = 1 */
  1158. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1160. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1161. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1162. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1163. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1164. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1165. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1166. { }
  1167. };
  1168. /*
  1169. * 3-stack pin configuration:
  1170. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1171. */
  1172. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1173. /*
  1174. * preset connection lists of input pins
  1175. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1176. */
  1177. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1178. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1179. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1180. /*
  1181. * Set pin mode and muting
  1182. */
  1183. /* set front pin widgets 0x14 for output */
  1184. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1187. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1188. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. /* Mic2 (as headphone out) for HP output */
  1190. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1191. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1192. /* Line In pin widget for input */
  1193. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1195. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1196. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1197. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1198. /* CD pin widget for input */
  1199. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1200. { }
  1201. };
  1202. /*
  1203. * 5-stack pin configuration:
  1204. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1205. * line-in/side = 0x1a, f-mic = 0x1b
  1206. */
  1207. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1208. /*
  1209. * preset connection lists of input pins
  1210. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1211. */
  1212. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1213. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1214. /*
  1215. * Set pin mode and muting
  1216. */
  1217. /* set pin widgets 0x14-0x17 for output */
  1218. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1219. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1222. /* unmute pins for output (no gain on this amp) */
  1223. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1224. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1226. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1228. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1229. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* Mic2 (as headphone out) for HP output */
  1231. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1232. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1233. /* Line In pin widget for input */
  1234. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1235. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1236. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1237. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1238. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1239. /* CD pin widget for input */
  1240. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1241. { }
  1242. };
  1243. /*
  1244. * W810 pin configuration:
  1245. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1246. */
  1247. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1248. /* hphone/speaker input selector: front DAC */
  1249. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1250. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1252. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1254. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1257. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1258. { }
  1259. };
  1260. /*
  1261. * Z71V pin configuration:
  1262. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1263. */
  1264. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1265. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1266. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1267. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1268. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1269. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1270. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1271. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1273. { }
  1274. };
  1275. /*
  1276. * 6-stack pin configuration:
  1277. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1278. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1279. */
  1280. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1281. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1282. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1287. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1288. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1289. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1290. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1291. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1292. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1293. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1294. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1295. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1296. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1297. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1299. { }
  1300. };
  1301. /*
  1302. * Uniwill pin configuration:
  1303. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1304. * line = 0x1a
  1305. */
  1306. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1307. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1308. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1309. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1311. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1312. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1313. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1317. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1318. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1319. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1320. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1321. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1322. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1326. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1327. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1328. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1329. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1330. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1331. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1332. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1333. { }
  1334. };
  1335. /*
  1336. * Uniwill P53
  1337. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1338. */
  1339. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1340. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1341. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1346. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1360. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1361. { }
  1362. };
  1363. static struct hda_verb alc880_beep_init_verbs[] = {
  1364. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1365. { }
  1366. };
  1367. /* toggle speaker-output according to the hp-jack state */
  1368. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1369. {
  1370. unsigned int present;
  1371. unsigned char bits;
  1372. present = snd_hda_codec_read(codec, 0x14, 0,
  1373. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1374. bits = present ? 0x80 : 0;
  1375. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1376. 0x80, bits);
  1377. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1378. 0x80, bits);
  1379. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1380. 0x80, bits);
  1381. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1382. 0x80, bits);
  1383. }
  1384. /* auto-toggle front mic */
  1385. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1386. {
  1387. unsigned int present;
  1388. unsigned char bits;
  1389. present = snd_hda_codec_read(codec, 0x18, 0,
  1390. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1391. bits = present ? 0x80 : 0;
  1392. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1393. 0x80, bits);
  1394. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1395. 0x80, bits);
  1396. }
  1397. static void alc880_uniwill_automute(struct hda_codec *codec)
  1398. {
  1399. alc880_uniwill_hp_automute(codec);
  1400. alc880_uniwill_mic_automute(codec);
  1401. }
  1402. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1403. unsigned int res)
  1404. {
  1405. /* Looks like the unsol event is incompatible with the standard
  1406. * definition. 4bit tag is placed at 28 bit!
  1407. */
  1408. switch (res >> 28) {
  1409. case ALC880_HP_EVENT:
  1410. alc880_uniwill_hp_automute(codec);
  1411. break;
  1412. case ALC880_MIC_EVENT:
  1413. alc880_uniwill_mic_automute(codec);
  1414. break;
  1415. }
  1416. }
  1417. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1418. {
  1419. unsigned int present;
  1420. unsigned char bits;
  1421. present = snd_hda_codec_read(codec, 0x14, 0,
  1422. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1423. bits = present ? 0x80 : 0;
  1424. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1425. 0x80, bits);
  1426. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1427. 0x80, bits);
  1428. }
  1429. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1430. {
  1431. unsigned int present;
  1432. present = snd_hda_codec_read(codec, 0x21, 0,
  1433. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1434. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1435. 0x7f, present);
  1436. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1437. 0x7f, present);
  1438. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1439. 0x7f, present);
  1440. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1441. 0x7f, present);
  1442. }
  1443. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1444. unsigned int res)
  1445. {
  1446. /* Looks like the unsol event is incompatible with the standard
  1447. * definition. 4bit tag is placed at 28 bit!
  1448. */
  1449. if ((res >> 28) == ALC880_HP_EVENT)
  1450. alc880_uniwill_p53_hp_automute(codec);
  1451. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1452. alc880_uniwill_p53_dcvol_automute(codec);
  1453. }
  1454. /* FIXME! */
  1455. /*
  1456. * F1734 pin configuration:
  1457. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1458. */
  1459. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1460. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1461. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1462. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1463. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1464. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1465. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1466. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1467. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1468. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1469. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1470. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1471. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1472. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1473. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1474. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1475. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1476. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1477. { }
  1478. };
  1479. /* FIXME! */
  1480. /*
  1481. * ASUS pin configuration:
  1482. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1483. */
  1484. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1485. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1486. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1487. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1488. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1495. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1499. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1500. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1501. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1502. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1503. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1504. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1505. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1506. { }
  1507. };
  1508. /* Enable GPIO mask and set output */
  1509. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1510. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1511. /* Clevo m520g init */
  1512. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1513. /* headphone output */
  1514. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1515. /* line-out */
  1516. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1518. /* Line-in */
  1519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1520. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. /* CD */
  1522. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1523. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. /* Mic1 (rear panel) */
  1525. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1526. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1527. /* Mic2 (front panel) */
  1528. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1529. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1530. /* headphone */
  1531. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1532. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1533. /* change to EAPD mode */
  1534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1536. { }
  1537. };
  1538. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1539. /* change to EAPD mode */
  1540. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1541. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1542. /* Headphone output */
  1543. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1544. /* Front output*/
  1545. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1546. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1547. /* Line In pin widget for input */
  1548. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1549. /* CD pin widget for input */
  1550. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1551. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1552. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1553. /* change to EAPD mode */
  1554. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1555. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1556. { }
  1557. };
  1558. /*
  1559. * LG m1 express dual
  1560. *
  1561. * Pin assignment:
  1562. * Rear Line-In/Out (blue): 0x14
  1563. * Build-in Mic-In: 0x15
  1564. * Speaker-out: 0x17
  1565. * HP-Out (green): 0x1b
  1566. * Mic-In/Out (red): 0x19
  1567. * SPDIF-Out: 0x1e
  1568. */
  1569. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1570. static hda_nid_t alc880_lg_dac_nids[3] = {
  1571. 0x05, 0x02, 0x03
  1572. };
  1573. /* seems analog CD is not working */
  1574. static struct hda_input_mux alc880_lg_capture_source = {
  1575. .num_items = 3,
  1576. .items = {
  1577. { "Mic", 0x1 },
  1578. { "Line", 0x5 },
  1579. { "Internal Mic", 0x6 },
  1580. },
  1581. };
  1582. /* 2,4,6 channel modes */
  1583. static struct hda_verb alc880_lg_ch2_init[] = {
  1584. /* set line-in and mic-in to input */
  1585. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1586. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1587. { }
  1588. };
  1589. static struct hda_verb alc880_lg_ch4_init[] = {
  1590. /* set line-in to out and mic-in to input */
  1591. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1592. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1593. { }
  1594. };
  1595. static struct hda_verb alc880_lg_ch6_init[] = {
  1596. /* set line-in and mic-in to output */
  1597. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1598. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1599. { }
  1600. };
  1601. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1602. { 2, alc880_lg_ch2_init },
  1603. { 4, alc880_lg_ch4_init },
  1604. { 6, alc880_lg_ch6_init },
  1605. };
  1606. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1607. /* FIXME: it's not really "master" but front channels */
  1608. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1609. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1610. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1611. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1612. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1613. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1614. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1615. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1616. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1617. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1618. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1619. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1620. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1621. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1622. {
  1623. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1624. .name = "Channel Mode",
  1625. .info = alc_ch_mode_info,
  1626. .get = alc_ch_mode_get,
  1627. .put = alc_ch_mode_put,
  1628. },
  1629. { } /* end */
  1630. };
  1631. static struct hda_verb alc880_lg_init_verbs[] = {
  1632. /* set capture source to mic-in */
  1633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1634. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1635. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1636. /* mute all amp mixer inputs */
  1637. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1640. /* line-in to input */
  1641. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1642. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1643. /* built-in mic */
  1644. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1645. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1646. /* speaker-out */
  1647. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1648. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1649. /* mic-in to input */
  1650. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1651. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1652. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1653. /* HP-out */
  1654. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1655. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1656. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1657. /* jack sense */
  1658. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1659. { }
  1660. };
  1661. /* toggle speaker-output according to the hp-jack state */
  1662. static void alc880_lg_automute(struct hda_codec *codec)
  1663. {
  1664. unsigned int present;
  1665. unsigned char bits;
  1666. present = snd_hda_codec_read(codec, 0x1b, 0,
  1667. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1668. bits = present ? 0x80 : 0;
  1669. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1670. 0x80, bits);
  1671. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1672. 0x80, bits);
  1673. }
  1674. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1675. {
  1676. /* Looks like the unsol event is incompatible with the standard
  1677. * definition. 4bit tag is placed at 28 bit!
  1678. */
  1679. if ((res >> 28) == 0x01)
  1680. alc880_lg_automute(codec);
  1681. }
  1682. /*
  1683. * LG LW20
  1684. *
  1685. * Pin assignment:
  1686. * Speaker-out: 0x14
  1687. * Mic-In: 0x18
  1688. * Built-in Mic-In: 0x19 (?)
  1689. * HP-Out: 0x1b
  1690. * SPDIF-Out: 0x1e
  1691. */
  1692. /* seems analog CD is not working */
  1693. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1694. .num_items = 2,
  1695. .items = {
  1696. { "Mic", 0x0 },
  1697. { "Internal Mic", 0x1 },
  1698. },
  1699. };
  1700. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1701. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1702. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1703. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1704. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1705. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1706. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1707. { } /* end */
  1708. };
  1709. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1710. /* set capture source to mic-in */
  1711. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1712. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1713. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1714. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1715. /* speaker-out */
  1716. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1717. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1718. /* HP-out */
  1719. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1720. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1721. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1722. /* mic-in to input */
  1723. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1724. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1725. /* built-in mic */
  1726. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1727. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1728. /* jack sense */
  1729. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1730. { }
  1731. };
  1732. /* toggle speaker-output according to the hp-jack state */
  1733. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1734. {
  1735. unsigned int present;
  1736. unsigned char bits;
  1737. present = snd_hda_codec_read(codec, 0x1b, 0,
  1738. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1739. bits = present ? 0x80 : 0;
  1740. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1741. 0x80, bits);
  1742. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1743. 0x80, bits);
  1744. }
  1745. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1746. {
  1747. /* Looks like the unsol event is incompatible with the standard
  1748. * definition. 4bit tag is placed at 28 bit!
  1749. */
  1750. if ((res >> 28) == 0x01)
  1751. alc880_lg_lw_automute(codec);
  1752. }
  1753. /*
  1754. * Common callbacks
  1755. */
  1756. static int alc_init(struct hda_codec *codec)
  1757. {
  1758. struct alc_spec *spec = codec->spec;
  1759. unsigned int i;
  1760. for (i = 0; i < spec->num_init_verbs; i++)
  1761. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1762. if (spec->init_hook)
  1763. spec->init_hook(codec);
  1764. return 0;
  1765. }
  1766. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1767. {
  1768. struct alc_spec *spec = codec->spec;
  1769. if (spec->unsol_event)
  1770. spec->unsol_event(codec, res);
  1771. }
  1772. #ifdef CONFIG_PM
  1773. /*
  1774. * resume
  1775. */
  1776. static int alc_resume(struct hda_codec *codec)
  1777. {
  1778. struct alc_spec *spec = codec->spec;
  1779. int i;
  1780. alc_init(codec);
  1781. for (i = 0; i < spec->num_mixers; i++)
  1782. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1783. if (spec->multiout.dig_out_nid)
  1784. snd_hda_resume_spdif_out(codec);
  1785. if (spec->dig_in_nid)
  1786. snd_hda_resume_spdif_in(codec);
  1787. return 0;
  1788. }
  1789. #endif
  1790. /*
  1791. * Analog playback callbacks
  1792. */
  1793. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1794. struct hda_codec *codec,
  1795. struct snd_pcm_substream *substream)
  1796. {
  1797. struct alc_spec *spec = codec->spec;
  1798. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1799. }
  1800. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1801. struct hda_codec *codec,
  1802. unsigned int stream_tag,
  1803. unsigned int format,
  1804. struct snd_pcm_substream *substream)
  1805. {
  1806. struct alc_spec *spec = codec->spec;
  1807. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1808. stream_tag, format, substream);
  1809. }
  1810. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1811. struct hda_codec *codec,
  1812. struct snd_pcm_substream *substream)
  1813. {
  1814. struct alc_spec *spec = codec->spec;
  1815. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1816. }
  1817. /*
  1818. * Digital out
  1819. */
  1820. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1821. struct hda_codec *codec,
  1822. struct snd_pcm_substream *substream)
  1823. {
  1824. struct alc_spec *spec = codec->spec;
  1825. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1826. }
  1827. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1828. struct hda_codec *codec,
  1829. unsigned int stream_tag,
  1830. unsigned int format,
  1831. struct snd_pcm_substream *substream)
  1832. {
  1833. struct alc_spec *spec = codec->spec;
  1834. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1835. stream_tag, format, substream);
  1836. }
  1837. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1838. struct hda_codec *codec,
  1839. struct snd_pcm_substream *substream)
  1840. {
  1841. struct alc_spec *spec = codec->spec;
  1842. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1843. }
  1844. /*
  1845. * Analog capture
  1846. */
  1847. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1848. struct hda_codec *codec,
  1849. unsigned int stream_tag,
  1850. unsigned int format,
  1851. struct snd_pcm_substream *substream)
  1852. {
  1853. struct alc_spec *spec = codec->spec;
  1854. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1855. stream_tag, 0, format);
  1856. return 0;
  1857. }
  1858. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1859. struct hda_codec *codec,
  1860. struct snd_pcm_substream *substream)
  1861. {
  1862. struct alc_spec *spec = codec->spec;
  1863. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1864. 0, 0, 0);
  1865. return 0;
  1866. }
  1867. /*
  1868. */
  1869. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1870. .substreams = 1,
  1871. .channels_min = 2,
  1872. .channels_max = 8,
  1873. /* NID is set in alc_build_pcms */
  1874. .ops = {
  1875. .open = alc880_playback_pcm_open,
  1876. .prepare = alc880_playback_pcm_prepare,
  1877. .cleanup = alc880_playback_pcm_cleanup
  1878. },
  1879. };
  1880. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1881. .substreams = 2,
  1882. .channels_min = 2,
  1883. .channels_max = 2,
  1884. /* NID is set in alc_build_pcms */
  1885. .ops = {
  1886. .prepare = alc880_capture_pcm_prepare,
  1887. .cleanup = alc880_capture_pcm_cleanup
  1888. },
  1889. };
  1890. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1891. .substreams = 1,
  1892. .channels_min = 2,
  1893. .channels_max = 2,
  1894. /* NID is set in alc_build_pcms */
  1895. .ops = {
  1896. .open = alc880_dig_playback_pcm_open,
  1897. .close = alc880_dig_playback_pcm_close,
  1898. .prepare = alc880_dig_playback_pcm_prepare
  1899. },
  1900. };
  1901. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1902. .substreams = 1,
  1903. .channels_min = 2,
  1904. .channels_max = 2,
  1905. /* NID is set in alc_build_pcms */
  1906. };
  1907. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1908. static struct hda_pcm_stream alc_pcm_null_playback = {
  1909. .substreams = 0,
  1910. .channels_min = 0,
  1911. .channels_max = 0,
  1912. };
  1913. static int alc_build_pcms(struct hda_codec *codec)
  1914. {
  1915. struct alc_spec *spec = codec->spec;
  1916. struct hda_pcm *info = spec->pcm_rec;
  1917. int i;
  1918. codec->num_pcms = 1;
  1919. codec->pcm_info = info;
  1920. info->name = spec->stream_name_analog;
  1921. if (spec->stream_analog_playback) {
  1922. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1923. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1924. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1925. }
  1926. if (spec->stream_analog_capture) {
  1927. snd_assert(spec->adc_nids, return -EINVAL);
  1928. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1929. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1930. }
  1931. if (spec->channel_mode) {
  1932. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1933. for (i = 0; i < spec->num_channel_mode; i++) {
  1934. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1935. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1936. }
  1937. }
  1938. }
  1939. /* SPDIF for stream index #1 */
  1940. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1941. codec->num_pcms = 2;
  1942. info = spec->pcm_rec + 1;
  1943. info->name = spec->stream_name_digital;
  1944. if (spec->multiout.dig_out_nid &&
  1945. spec->stream_digital_playback) {
  1946. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1947. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1948. }
  1949. if (spec->dig_in_nid &&
  1950. spec->stream_digital_capture) {
  1951. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1952. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1953. }
  1954. }
  1955. /* If the use of more than one ADC is requested for the current
  1956. * model, configure a second analog capture-only PCM.
  1957. */
  1958. /* Additional Analaog capture for index #2 */
  1959. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1960. spec->adc_nids) {
  1961. codec->num_pcms = 3;
  1962. info = spec->pcm_rec + 2;
  1963. info->name = spec->stream_name_analog;
  1964. /* No playback stream for second PCM */
  1965. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1966. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1967. if (spec->stream_analog_capture) {
  1968. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1969. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1970. }
  1971. }
  1972. return 0;
  1973. }
  1974. static void alc_free(struct hda_codec *codec)
  1975. {
  1976. struct alc_spec *spec = codec->spec;
  1977. unsigned int i;
  1978. if (!spec)
  1979. return;
  1980. if (spec->kctl_alloc) {
  1981. for (i = 0; i < spec->num_kctl_used; i++)
  1982. kfree(spec->kctl_alloc[i].name);
  1983. kfree(spec->kctl_alloc);
  1984. }
  1985. kfree(spec);
  1986. }
  1987. /*
  1988. */
  1989. static struct hda_codec_ops alc_patch_ops = {
  1990. .build_controls = alc_build_controls,
  1991. .build_pcms = alc_build_pcms,
  1992. .init = alc_init,
  1993. .free = alc_free,
  1994. .unsol_event = alc_unsol_event,
  1995. #ifdef CONFIG_PM
  1996. .resume = alc_resume,
  1997. #endif
  1998. };
  1999. /*
  2000. * Test configuration for debugging
  2001. *
  2002. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2003. * enum controls.
  2004. */
  2005. #ifdef CONFIG_SND_DEBUG
  2006. static hda_nid_t alc880_test_dac_nids[4] = {
  2007. 0x02, 0x03, 0x04, 0x05
  2008. };
  2009. static struct hda_input_mux alc880_test_capture_source = {
  2010. .num_items = 7,
  2011. .items = {
  2012. { "In-1", 0x0 },
  2013. { "In-2", 0x1 },
  2014. { "In-3", 0x2 },
  2015. { "In-4", 0x3 },
  2016. { "CD", 0x4 },
  2017. { "Front", 0x5 },
  2018. { "Surround", 0x6 },
  2019. },
  2020. };
  2021. static struct hda_channel_mode alc880_test_modes[4] = {
  2022. { 2, NULL },
  2023. { 4, NULL },
  2024. { 6, NULL },
  2025. { 8, NULL },
  2026. };
  2027. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2028. struct snd_ctl_elem_info *uinfo)
  2029. {
  2030. static char *texts[] = {
  2031. "N/A", "Line Out", "HP Out",
  2032. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2033. };
  2034. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2035. uinfo->count = 1;
  2036. uinfo->value.enumerated.items = 8;
  2037. if (uinfo->value.enumerated.item >= 8)
  2038. uinfo->value.enumerated.item = 7;
  2039. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2040. return 0;
  2041. }
  2042. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2043. struct snd_ctl_elem_value *ucontrol)
  2044. {
  2045. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2046. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2047. unsigned int pin_ctl, item = 0;
  2048. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2049. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2050. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2051. if (pin_ctl & AC_PINCTL_HP_EN)
  2052. item = 2;
  2053. else
  2054. item = 1;
  2055. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2056. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2057. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2058. case AC_PINCTL_VREF_50: item = 4; break;
  2059. case AC_PINCTL_VREF_GRD: item = 5; break;
  2060. case AC_PINCTL_VREF_80: item = 6; break;
  2061. case AC_PINCTL_VREF_100: item = 7; break;
  2062. }
  2063. }
  2064. ucontrol->value.enumerated.item[0] = item;
  2065. return 0;
  2066. }
  2067. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2068. struct snd_ctl_elem_value *ucontrol)
  2069. {
  2070. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2071. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2072. static unsigned int ctls[] = {
  2073. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2074. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2075. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2076. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2077. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2078. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2079. };
  2080. unsigned int old_ctl, new_ctl;
  2081. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2082. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2083. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2084. if (old_ctl != new_ctl) {
  2085. snd_hda_codec_write(codec, nid, 0,
  2086. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2087. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2088. (ucontrol->value.enumerated.item[0] >= 3 ?
  2089. 0xb080 : 0xb000));
  2090. return 1;
  2091. }
  2092. return 0;
  2093. }
  2094. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2095. struct snd_ctl_elem_info *uinfo)
  2096. {
  2097. static char *texts[] = {
  2098. "Front", "Surround", "CLFE", "Side"
  2099. };
  2100. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2101. uinfo->count = 1;
  2102. uinfo->value.enumerated.items = 4;
  2103. if (uinfo->value.enumerated.item >= 4)
  2104. uinfo->value.enumerated.item = 3;
  2105. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2106. return 0;
  2107. }
  2108. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2109. struct snd_ctl_elem_value *ucontrol)
  2110. {
  2111. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2112. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2113. unsigned int sel;
  2114. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2115. ucontrol->value.enumerated.item[0] = sel & 3;
  2116. return 0;
  2117. }
  2118. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2119. struct snd_ctl_elem_value *ucontrol)
  2120. {
  2121. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2122. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2123. unsigned int sel;
  2124. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2125. if (ucontrol->value.enumerated.item[0] != sel) {
  2126. sel = ucontrol->value.enumerated.item[0] & 3;
  2127. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2128. return 1;
  2129. }
  2130. return 0;
  2131. }
  2132. #define PIN_CTL_TEST(xname,nid) { \
  2133. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2134. .name = xname, \
  2135. .info = alc_test_pin_ctl_info, \
  2136. .get = alc_test_pin_ctl_get, \
  2137. .put = alc_test_pin_ctl_put, \
  2138. .private_value = nid \
  2139. }
  2140. #define PIN_SRC_TEST(xname,nid) { \
  2141. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2142. .name = xname, \
  2143. .info = alc_test_pin_src_info, \
  2144. .get = alc_test_pin_src_get, \
  2145. .put = alc_test_pin_src_put, \
  2146. .private_value = nid \
  2147. }
  2148. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2149. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2150. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2151. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2152. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2153. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2154. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2155. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2156. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2157. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2158. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2159. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2160. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2161. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2162. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2163. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2164. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2165. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2166. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2167. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2168. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2169. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2170. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2171. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2172. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2173. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2174. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2175. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2176. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2177. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2178. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2179. {
  2180. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2181. .name = "Channel Mode",
  2182. .info = alc_ch_mode_info,
  2183. .get = alc_ch_mode_get,
  2184. .put = alc_ch_mode_put,
  2185. },
  2186. { } /* end */
  2187. };
  2188. static struct hda_verb alc880_test_init_verbs[] = {
  2189. /* Unmute inputs of 0x0c - 0x0f */
  2190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2198. /* Vol output for 0x0c-0x0f */
  2199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2200. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2201. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2202. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2203. /* Set output pins 0x14-0x17 */
  2204. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2205. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2206. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2207. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2208. /* Unmute output pins 0x14-0x17 */
  2209. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2210. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2211. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2212. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2213. /* Set input pins 0x18-0x1c */
  2214. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2215. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2216. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2217. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2218. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2219. /* Mute input pins 0x18-0x1b */
  2220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2221. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2223. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2224. /* ADC set up */
  2225. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2226. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2227. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2228. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2229. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2230. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2231. /* Analog input/passthru */
  2232. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2233. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2234. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2235. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2236. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2237. { }
  2238. };
  2239. #endif
  2240. /*
  2241. */
  2242. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2243. [ALC880_3ST] = "3stack",
  2244. [ALC880_TCL_S700] = "tcl",
  2245. [ALC880_3ST_DIG] = "3stack-digout",
  2246. [ALC880_CLEVO] = "clevo",
  2247. [ALC880_5ST] = "5stack",
  2248. [ALC880_5ST_DIG] = "5stack-digout",
  2249. [ALC880_W810] = "w810",
  2250. [ALC880_Z71V] = "z71v",
  2251. [ALC880_6ST] = "6stack",
  2252. [ALC880_6ST_DIG] = "6stack-digout",
  2253. [ALC880_ASUS] = "asus",
  2254. [ALC880_ASUS_W1V] = "asus-w1v",
  2255. [ALC880_ASUS_DIG] = "asus-dig",
  2256. [ALC880_ASUS_DIG2] = "asus-dig2",
  2257. [ALC880_UNIWILL_DIG] = "uniwill",
  2258. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2259. [ALC880_FUJITSU] = "fujitsu",
  2260. [ALC880_F1734] = "F1734",
  2261. [ALC880_LG] = "lg",
  2262. [ALC880_LG_LW] = "lg-lw",
  2263. #ifdef CONFIG_SND_DEBUG
  2264. [ALC880_TEST] = "test",
  2265. #endif
  2266. [ALC880_AUTO] = "auto",
  2267. };
  2268. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2269. /* Broken BIOS configuration */
  2270. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2271. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2273. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2274. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2275. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2276. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2277. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2278. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2279. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2280. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2281. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2282. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2283. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2284. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2285. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2288. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2290. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2291. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2292. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2293. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2294. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2295. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2296. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2297. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2298. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2299. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2300. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2301. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2302. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2303. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2304. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2305. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2306. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2307. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2308. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2309. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2310. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2311. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2316. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2317. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2318. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2319. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2320. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2321. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2322. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2323. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2324. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2325. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2326. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2327. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2328. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2329. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2333. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2334. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2335. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2336. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2337. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2338. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2339. {}
  2340. };
  2341. /*
  2342. * ALC880 codec presets
  2343. */
  2344. static struct alc_config_preset alc880_presets[] = {
  2345. [ALC880_3ST] = {
  2346. .mixers = { alc880_three_stack_mixer },
  2347. .init_verbs = { alc880_volume_init_verbs,
  2348. alc880_pin_3stack_init_verbs },
  2349. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2350. .dac_nids = alc880_dac_nids,
  2351. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2352. .channel_mode = alc880_threestack_modes,
  2353. .need_dac_fix = 1,
  2354. .input_mux = &alc880_capture_source,
  2355. },
  2356. [ALC880_3ST_DIG] = {
  2357. .mixers = { alc880_three_stack_mixer },
  2358. .init_verbs = { alc880_volume_init_verbs,
  2359. alc880_pin_3stack_init_verbs },
  2360. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2361. .dac_nids = alc880_dac_nids,
  2362. .dig_out_nid = ALC880_DIGOUT_NID,
  2363. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2364. .channel_mode = alc880_threestack_modes,
  2365. .need_dac_fix = 1,
  2366. .input_mux = &alc880_capture_source,
  2367. },
  2368. [ALC880_TCL_S700] = {
  2369. .mixers = { alc880_tcl_s700_mixer },
  2370. .init_verbs = { alc880_volume_init_verbs,
  2371. alc880_pin_tcl_S700_init_verbs,
  2372. alc880_gpio2_init_verbs },
  2373. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2374. .dac_nids = alc880_dac_nids,
  2375. .hp_nid = 0x03,
  2376. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2377. .channel_mode = alc880_2_jack_modes,
  2378. .input_mux = &alc880_capture_source,
  2379. },
  2380. [ALC880_5ST] = {
  2381. .mixers = { alc880_three_stack_mixer,
  2382. alc880_five_stack_mixer},
  2383. .init_verbs = { alc880_volume_init_verbs,
  2384. alc880_pin_5stack_init_verbs },
  2385. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2386. .dac_nids = alc880_dac_nids,
  2387. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2388. .channel_mode = alc880_fivestack_modes,
  2389. .input_mux = &alc880_capture_source,
  2390. },
  2391. [ALC880_5ST_DIG] = {
  2392. .mixers = { alc880_three_stack_mixer,
  2393. alc880_five_stack_mixer },
  2394. .init_verbs = { alc880_volume_init_verbs,
  2395. alc880_pin_5stack_init_verbs },
  2396. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2397. .dac_nids = alc880_dac_nids,
  2398. .dig_out_nid = ALC880_DIGOUT_NID,
  2399. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2400. .channel_mode = alc880_fivestack_modes,
  2401. .input_mux = &alc880_capture_source,
  2402. },
  2403. [ALC880_6ST] = {
  2404. .mixers = { alc880_six_stack_mixer },
  2405. .init_verbs = { alc880_volume_init_verbs,
  2406. alc880_pin_6stack_init_verbs },
  2407. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2408. .dac_nids = alc880_6st_dac_nids,
  2409. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2410. .channel_mode = alc880_sixstack_modes,
  2411. .input_mux = &alc880_6stack_capture_source,
  2412. },
  2413. [ALC880_6ST_DIG] = {
  2414. .mixers = { alc880_six_stack_mixer },
  2415. .init_verbs = { alc880_volume_init_verbs,
  2416. alc880_pin_6stack_init_verbs },
  2417. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2418. .dac_nids = alc880_6st_dac_nids,
  2419. .dig_out_nid = ALC880_DIGOUT_NID,
  2420. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2421. .channel_mode = alc880_sixstack_modes,
  2422. .input_mux = &alc880_6stack_capture_source,
  2423. },
  2424. [ALC880_W810] = {
  2425. .mixers = { alc880_w810_base_mixer },
  2426. .init_verbs = { alc880_volume_init_verbs,
  2427. alc880_pin_w810_init_verbs,
  2428. alc880_gpio2_init_verbs },
  2429. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2430. .dac_nids = alc880_w810_dac_nids,
  2431. .dig_out_nid = ALC880_DIGOUT_NID,
  2432. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2433. .channel_mode = alc880_w810_modes,
  2434. .input_mux = &alc880_capture_source,
  2435. },
  2436. [ALC880_Z71V] = {
  2437. .mixers = { alc880_z71v_mixer },
  2438. .init_verbs = { alc880_volume_init_verbs,
  2439. alc880_pin_z71v_init_verbs },
  2440. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2441. .dac_nids = alc880_z71v_dac_nids,
  2442. .dig_out_nid = ALC880_DIGOUT_NID,
  2443. .hp_nid = 0x03,
  2444. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2445. .channel_mode = alc880_2_jack_modes,
  2446. .input_mux = &alc880_capture_source,
  2447. },
  2448. [ALC880_F1734] = {
  2449. .mixers = { alc880_f1734_mixer },
  2450. .init_verbs = { alc880_volume_init_verbs,
  2451. alc880_pin_f1734_init_verbs },
  2452. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2453. .dac_nids = alc880_f1734_dac_nids,
  2454. .hp_nid = 0x02,
  2455. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2456. .channel_mode = alc880_2_jack_modes,
  2457. .input_mux = &alc880_capture_source,
  2458. },
  2459. [ALC880_ASUS] = {
  2460. .mixers = { alc880_asus_mixer },
  2461. .init_verbs = { alc880_volume_init_verbs,
  2462. alc880_pin_asus_init_verbs,
  2463. alc880_gpio1_init_verbs },
  2464. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2465. .dac_nids = alc880_asus_dac_nids,
  2466. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2467. .channel_mode = alc880_asus_modes,
  2468. .need_dac_fix = 1,
  2469. .input_mux = &alc880_capture_source,
  2470. },
  2471. [ALC880_ASUS_DIG] = {
  2472. .mixers = { alc880_asus_mixer },
  2473. .init_verbs = { alc880_volume_init_verbs,
  2474. alc880_pin_asus_init_verbs,
  2475. alc880_gpio1_init_verbs },
  2476. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2477. .dac_nids = alc880_asus_dac_nids,
  2478. .dig_out_nid = ALC880_DIGOUT_NID,
  2479. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2480. .channel_mode = alc880_asus_modes,
  2481. .need_dac_fix = 1,
  2482. .input_mux = &alc880_capture_source,
  2483. },
  2484. [ALC880_ASUS_DIG2] = {
  2485. .mixers = { alc880_asus_mixer },
  2486. .init_verbs = { alc880_volume_init_verbs,
  2487. alc880_pin_asus_init_verbs,
  2488. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2489. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2490. .dac_nids = alc880_asus_dac_nids,
  2491. .dig_out_nid = ALC880_DIGOUT_NID,
  2492. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2493. .channel_mode = alc880_asus_modes,
  2494. .need_dac_fix = 1,
  2495. .input_mux = &alc880_capture_source,
  2496. },
  2497. [ALC880_ASUS_W1V] = {
  2498. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2499. .init_verbs = { alc880_volume_init_verbs,
  2500. alc880_pin_asus_init_verbs,
  2501. alc880_gpio1_init_verbs },
  2502. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2503. .dac_nids = alc880_asus_dac_nids,
  2504. .dig_out_nid = ALC880_DIGOUT_NID,
  2505. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2506. .channel_mode = alc880_asus_modes,
  2507. .need_dac_fix = 1,
  2508. .input_mux = &alc880_capture_source,
  2509. },
  2510. [ALC880_UNIWILL_DIG] = {
  2511. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2512. .init_verbs = { alc880_volume_init_verbs,
  2513. alc880_pin_asus_init_verbs },
  2514. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2515. .dac_nids = alc880_asus_dac_nids,
  2516. .dig_out_nid = ALC880_DIGOUT_NID,
  2517. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2518. .channel_mode = alc880_asus_modes,
  2519. .need_dac_fix = 1,
  2520. .input_mux = &alc880_capture_source,
  2521. },
  2522. [ALC880_UNIWILL] = {
  2523. .mixers = { alc880_uniwill_mixer },
  2524. .init_verbs = { alc880_volume_init_verbs,
  2525. alc880_uniwill_init_verbs },
  2526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2527. .dac_nids = alc880_asus_dac_nids,
  2528. .dig_out_nid = ALC880_DIGOUT_NID,
  2529. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2530. .channel_mode = alc880_threestack_modes,
  2531. .need_dac_fix = 1,
  2532. .input_mux = &alc880_capture_source,
  2533. .unsol_event = alc880_uniwill_unsol_event,
  2534. .init_hook = alc880_uniwill_automute,
  2535. },
  2536. [ALC880_UNIWILL_P53] = {
  2537. .mixers = { alc880_uniwill_p53_mixer },
  2538. .init_verbs = { alc880_volume_init_verbs,
  2539. alc880_uniwill_p53_init_verbs },
  2540. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2541. .dac_nids = alc880_asus_dac_nids,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2543. .channel_mode = alc880_threestack_modes,
  2544. .input_mux = &alc880_capture_source,
  2545. .unsol_event = alc880_uniwill_p53_unsol_event,
  2546. .init_hook = alc880_uniwill_p53_hp_automute,
  2547. },
  2548. [ALC880_FUJITSU] = {
  2549. .mixers = { alc880_fujitsu_mixer,
  2550. alc880_pcbeep_mixer, },
  2551. .init_verbs = { alc880_volume_init_verbs,
  2552. alc880_uniwill_p53_init_verbs,
  2553. alc880_beep_init_verbs },
  2554. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2555. .dac_nids = alc880_dac_nids,
  2556. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2557. .channel_mode = alc880_2_jack_modes,
  2558. .input_mux = &alc880_capture_source,
  2559. .unsol_event = alc880_uniwill_p53_unsol_event,
  2560. .init_hook = alc880_uniwill_p53_hp_automute,
  2561. },
  2562. [ALC880_CLEVO] = {
  2563. .mixers = { alc880_three_stack_mixer },
  2564. .init_verbs = { alc880_volume_init_verbs,
  2565. alc880_pin_clevo_init_verbs },
  2566. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2567. .dac_nids = alc880_dac_nids,
  2568. .hp_nid = 0x03,
  2569. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2570. .channel_mode = alc880_threestack_modes,
  2571. .need_dac_fix = 1,
  2572. .input_mux = &alc880_capture_source,
  2573. },
  2574. [ALC880_LG] = {
  2575. .mixers = { alc880_lg_mixer },
  2576. .init_verbs = { alc880_volume_init_verbs,
  2577. alc880_lg_init_verbs },
  2578. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2579. .dac_nids = alc880_lg_dac_nids,
  2580. .dig_out_nid = ALC880_DIGOUT_NID,
  2581. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2582. .channel_mode = alc880_lg_ch_modes,
  2583. .need_dac_fix = 1,
  2584. .input_mux = &alc880_lg_capture_source,
  2585. .unsol_event = alc880_lg_unsol_event,
  2586. .init_hook = alc880_lg_automute,
  2587. },
  2588. [ALC880_LG_LW] = {
  2589. .mixers = { alc880_lg_lw_mixer },
  2590. .init_verbs = { alc880_volume_init_verbs,
  2591. alc880_lg_lw_init_verbs },
  2592. .num_dacs = 1,
  2593. .dac_nids = alc880_dac_nids,
  2594. .dig_out_nid = ALC880_DIGOUT_NID,
  2595. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2596. .channel_mode = alc880_2_jack_modes,
  2597. .input_mux = &alc880_lg_lw_capture_source,
  2598. .unsol_event = alc880_lg_lw_unsol_event,
  2599. .init_hook = alc880_lg_lw_automute,
  2600. },
  2601. #ifdef CONFIG_SND_DEBUG
  2602. [ALC880_TEST] = {
  2603. .mixers = { alc880_test_mixer },
  2604. .init_verbs = { alc880_test_init_verbs },
  2605. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2606. .dac_nids = alc880_test_dac_nids,
  2607. .dig_out_nid = ALC880_DIGOUT_NID,
  2608. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2609. .channel_mode = alc880_test_modes,
  2610. .input_mux = &alc880_test_capture_source,
  2611. },
  2612. #endif
  2613. };
  2614. /*
  2615. * Automatic parse of I/O pins from the BIOS configuration
  2616. */
  2617. #define NUM_CONTROL_ALLOC 32
  2618. #define NUM_VERB_ALLOC 32
  2619. enum {
  2620. ALC_CTL_WIDGET_VOL,
  2621. ALC_CTL_WIDGET_MUTE,
  2622. ALC_CTL_BIND_MUTE,
  2623. };
  2624. static struct snd_kcontrol_new alc880_control_templates[] = {
  2625. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2626. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2627. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2628. };
  2629. /* add dynamic controls */
  2630. static int add_control(struct alc_spec *spec, int type, const char *name,
  2631. unsigned long val)
  2632. {
  2633. struct snd_kcontrol_new *knew;
  2634. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2635. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2636. /* array + terminator */
  2637. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2638. if (!knew)
  2639. return -ENOMEM;
  2640. if (spec->kctl_alloc) {
  2641. memcpy(knew, spec->kctl_alloc,
  2642. sizeof(*knew) * spec->num_kctl_alloc);
  2643. kfree(spec->kctl_alloc);
  2644. }
  2645. spec->kctl_alloc = knew;
  2646. spec->num_kctl_alloc = num;
  2647. }
  2648. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2649. *knew = alc880_control_templates[type];
  2650. knew->name = kstrdup(name, GFP_KERNEL);
  2651. if (!knew->name)
  2652. return -ENOMEM;
  2653. knew->private_value = val;
  2654. spec->num_kctl_used++;
  2655. return 0;
  2656. }
  2657. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2658. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2659. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2660. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2661. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2662. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2663. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2664. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2665. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2666. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2667. #define ALC880_PIN_CD_NID 0x1c
  2668. /* fill in the dac_nids table from the parsed pin configuration */
  2669. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2670. const struct auto_pin_cfg *cfg)
  2671. {
  2672. hda_nid_t nid;
  2673. int assigned[4];
  2674. int i, j;
  2675. memset(assigned, 0, sizeof(assigned));
  2676. spec->multiout.dac_nids = spec->private_dac_nids;
  2677. /* check the pins hardwired to audio widget */
  2678. for (i = 0; i < cfg->line_outs; i++) {
  2679. nid = cfg->line_out_pins[i];
  2680. if (alc880_is_fixed_pin(nid)) {
  2681. int idx = alc880_fixed_pin_idx(nid);
  2682. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2683. assigned[idx] = 1;
  2684. }
  2685. }
  2686. /* left pins can be connect to any audio widget */
  2687. for (i = 0; i < cfg->line_outs; i++) {
  2688. nid = cfg->line_out_pins[i];
  2689. if (alc880_is_fixed_pin(nid))
  2690. continue;
  2691. /* search for an empty channel */
  2692. for (j = 0; j < cfg->line_outs; j++) {
  2693. if (!assigned[j]) {
  2694. spec->multiout.dac_nids[i] =
  2695. alc880_idx_to_dac(j);
  2696. assigned[j] = 1;
  2697. break;
  2698. }
  2699. }
  2700. }
  2701. spec->multiout.num_dacs = cfg->line_outs;
  2702. return 0;
  2703. }
  2704. /* add playback controls from the parsed DAC table */
  2705. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2706. const struct auto_pin_cfg *cfg)
  2707. {
  2708. char name[32];
  2709. static const char *chname[4] = {
  2710. "Front", "Surround", NULL /*CLFE*/, "Side"
  2711. };
  2712. hda_nid_t nid;
  2713. int i, err;
  2714. for (i = 0; i < cfg->line_outs; i++) {
  2715. if (!spec->multiout.dac_nids[i])
  2716. continue;
  2717. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2718. if (i == 2) {
  2719. /* Center/LFE */
  2720. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2721. "Center Playback Volume",
  2722. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2723. HDA_OUTPUT));
  2724. if (err < 0)
  2725. return err;
  2726. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2727. "LFE Playback Volume",
  2728. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2729. HDA_OUTPUT));
  2730. if (err < 0)
  2731. return err;
  2732. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2733. "Center Playback Switch",
  2734. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2735. HDA_INPUT));
  2736. if (err < 0)
  2737. return err;
  2738. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2739. "LFE Playback Switch",
  2740. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2741. HDA_INPUT));
  2742. if (err < 0)
  2743. return err;
  2744. } else {
  2745. sprintf(name, "%s Playback Volume", chname[i]);
  2746. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2747. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2748. HDA_OUTPUT));
  2749. if (err < 0)
  2750. return err;
  2751. sprintf(name, "%s Playback Switch", chname[i]);
  2752. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2753. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2754. HDA_INPUT));
  2755. if (err < 0)
  2756. return err;
  2757. }
  2758. }
  2759. return 0;
  2760. }
  2761. /* add playback controls for speaker and HP outputs */
  2762. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2763. const char *pfx)
  2764. {
  2765. hda_nid_t nid;
  2766. int err;
  2767. char name[32];
  2768. if (!pin)
  2769. return 0;
  2770. if (alc880_is_fixed_pin(pin)) {
  2771. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2772. /* specify the DAC as the extra output */
  2773. if (!spec->multiout.hp_nid)
  2774. spec->multiout.hp_nid = nid;
  2775. else
  2776. spec->multiout.extra_out_nid[0] = nid;
  2777. /* control HP volume/switch on the output mixer amp */
  2778. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2779. sprintf(name, "%s Playback Volume", pfx);
  2780. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2781. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2782. if (err < 0)
  2783. return err;
  2784. sprintf(name, "%s Playback Switch", pfx);
  2785. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2786. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2787. if (err < 0)
  2788. return err;
  2789. } else if (alc880_is_multi_pin(pin)) {
  2790. /* set manual connection */
  2791. /* we have only a switch on HP-out PIN */
  2792. sprintf(name, "%s Playback Switch", pfx);
  2793. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2794. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2795. if (err < 0)
  2796. return err;
  2797. }
  2798. return 0;
  2799. }
  2800. /* create input playback/capture controls for the given pin */
  2801. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2802. const char *ctlname,
  2803. int idx, hda_nid_t mix_nid)
  2804. {
  2805. char name[32];
  2806. int err;
  2807. sprintf(name, "%s Playback Volume", ctlname);
  2808. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2809. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2810. if (err < 0)
  2811. return err;
  2812. sprintf(name, "%s Playback Switch", ctlname);
  2813. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2814. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2815. if (err < 0)
  2816. return err;
  2817. return 0;
  2818. }
  2819. /* create playback/capture controls for input pins */
  2820. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2821. const struct auto_pin_cfg *cfg)
  2822. {
  2823. struct hda_input_mux *imux = &spec->private_imux;
  2824. int i, err, idx;
  2825. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2826. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2827. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2828. err = new_analog_input(spec, cfg->input_pins[i],
  2829. auto_pin_cfg_labels[i],
  2830. idx, 0x0b);
  2831. if (err < 0)
  2832. return err;
  2833. imux->items[imux->num_items].label =
  2834. auto_pin_cfg_labels[i];
  2835. imux->items[imux->num_items].index =
  2836. alc880_input_pin_idx(cfg->input_pins[i]);
  2837. imux->num_items++;
  2838. }
  2839. }
  2840. return 0;
  2841. }
  2842. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2843. hda_nid_t nid, int pin_type,
  2844. int dac_idx)
  2845. {
  2846. /* set as output */
  2847. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2848. pin_type);
  2849. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2850. AMP_OUT_UNMUTE);
  2851. /* need the manual connection? */
  2852. if (alc880_is_multi_pin(nid)) {
  2853. struct alc_spec *spec = codec->spec;
  2854. int idx = alc880_multi_pin_idx(nid);
  2855. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2856. AC_VERB_SET_CONNECT_SEL,
  2857. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2858. }
  2859. }
  2860. static int get_pin_type(int line_out_type)
  2861. {
  2862. if (line_out_type == AUTO_PIN_HP_OUT)
  2863. return PIN_HP;
  2864. else
  2865. return PIN_OUT;
  2866. }
  2867. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2868. {
  2869. struct alc_spec *spec = codec->spec;
  2870. int i;
  2871. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2872. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2873. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2874. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2875. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2876. }
  2877. }
  2878. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2879. {
  2880. struct alc_spec *spec = codec->spec;
  2881. hda_nid_t pin;
  2882. pin = spec->autocfg.speaker_pins[0];
  2883. if (pin) /* connect to front */
  2884. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2885. pin = spec->autocfg.hp_pins[0];
  2886. if (pin) /* connect to front */
  2887. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2888. }
  2889. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2890. {
  2891. struct alc_spec *spec = codec->spec;
  2892. int i;
  2893. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2894. hda_nid_t nid = spec->autocfg.input_pins[i];
  2895. if (alc880_is_input_pin(nid)) {
  2896. snd_hda_codec_write(codec, nid, 0,
  2897. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2898. i <= AUTO_PIN_FRONT_MIC ?
  2899. PIN_VREF80 : PIN_IN);
  2900. if (nid != ALC880_PIN_CD_NID)
  2901. snd_hda_codec_write(codec, nid, 0,
  2902. AC_VERB_SET_AMP_GAIN_MUTE,
  2903. AMP_OUT_MUTE);
  2904. }
  2905. }
  2906. }
  2907. /* parse the BIOS configuration and set up the alc_spec */
  2908. /* return 1 if successful, 0 if the proper config is not found,
  2909. * or a negative error code
  2910. */
  2911. static int alc880_parse_auto_config(struct hda_codec *codec)
  2912. {
  2913. struct alc_spec *spec = codec->spec;
  2914. int err;
  2915. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2916. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2917. alc880_ignore);
  2918. if (err < 0)
  2919. return err;
  2920. if (!spec->autocfg.line_outs)
  2921. return 0; /* can't find valid BIOS pin config */
  2922. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2923. if (err < 0)
  2924. return err;
  2925. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2926. if (err < 0)
  2927. return err;
  2928. err = alc880_auto_create_extra_out(spec,
  2929. spec->autocfg.speaker_pins[0],
  2930. "Speaker");
  2931. if (err < 0)
  2932. return err;
  2933. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2934. "Headphone");
  2935. if (err < 0)
  2936. return err;
  2937. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2938. if (err < 0)
  2939. return err;
  2940. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2941. if (spec->autocfg.dig_out_pin)
  2942. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2943. if (spec->autocfg.dig_in_pin)
  2944. spec->dig_in_nid = ALC880_DIGIN_NID;
  2945. if (spec->kctl_alloc)
  2946. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2947. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2948. spec->num_mux_defs = 1;
  2949. spec->input_mux = &spec->private_imux;
  2950. return 1;
  2951. }
  2952. /* additional initialization for auto-configuration model */
  2953. static void alc880_auto_init(struct hda_codec *codec)
  2954. {
  2955. alc880_auto_init_multi_out(codec);
  2956. alc880_auto_init_extra_out(codec);
  2957. alc880_auto_init_analog_input(codec);
  2958. }
  2959. /*
  2960. * OK, here we have finally the patch for ALC880
  2961. */
  2962. static int patch_alc880(struct hda_codec *codec)
  2963. {
  2964. struct alc_spec *spec;
  2965. int board_config;
  2966. int err;
  2967. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2968. if (spec == NULL)
  2969. return -ENOMEM;
  2970. codec->spec = spec;
  2971. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2972. alc880_models,
  2973. alc880_cfg_tbl);
  2974. if (board_config < 0) {
  2975. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2976. "trying auto-probe from BIOS...\n");
  2977. board_config = ALC880_AUTO;
  2978. }
  2979. if (board_config == ALC880_AUTO) {
  2980. /* automatic parse from the BIOS config */
  2981. err = alc880_parse_auto_config(codec);
  2982. if (err < 0) {
  2983. alc_free(codec);
  2984. return err;
  2985. } else if (!err) {
  2986. printk(KERN_INFO
  2987. "hda_codec: Cannot set up configuration "
  2988. "from BIOS. Using 3-stack mode...\n");
  2989. board_config = ALC880_3ST;
  2990. }
  2991. }
  2992. if (board_config != ALC880_AUTO)
  2993. setup_preset(spec, &alc880_presets[board_config]);
  2994. spec->stream_name_analog = "ALC880 Analog";
  2995. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2996. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2997. spec->stream_name_digital = "ALC880 Digital";
  2998. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2999. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3000. if (!spec->adc_nids && spec->input_mux) {
  3001. /* check whether NID 0x07 is valid */
  3002. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3003. /* get type */
  3004. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3005. if (wcap != AC_WID_AUD_IN) {
  3006. spec->adc_nids = alc880_adc_nids_alt;
  3007. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3008. spec->mixers[spec->num_mixers] =
  3009. alc880_capture_alt_mixer;
  3010. spec->num_mixers++;
  3011. } else {
  3012. spec->adc_nids = alc880_adc_nids;
  3013. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3014. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3015. spec->num_mixers++;
  3016. }
  3017. }
  3018. codec->patch_ops = alc_patch_ops;
  3019. if (board_config == ALC880_AUTO)
  3020. spec->init_hook = alc880_auto_init;
  3021. return 0;
  3022. }
  3023. /*
  3024. * ALC260 support
  3025. */
  3026. static hda_nid_t alc260_dac_nids[1] = {
  3027. /* front */
  3028. 0x02,
  3029. };
  3030. static hda_nid_t alc260_adc_nids[1] = {
  3031. /* ADC0 */
  3032. 0x04,
  3033. };
  3034. static hda_nid_t alc260_adc_nids_alt[1] = {
  3035. /* ADC1 */
  3036. 0x05,
  3037. };
  3038. static hda_nid_t alc260_hp_adc_nids[2] = {
  3039. /* ADC1, 0 */
  3040. 0x05, 0x04
  3041. };
  3042. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3043. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3044. */
  3045. static hda_nid_t alc260_dual_adc_nids[2] = {
  3046. /* ADC0, ADC1 */
  3047. 0x04, 0x05
  3048. };
  3049. #define ALC260_DIGOUT_NID 0x03
  3050. #define ALC260_DIGIN_NID 0x06
  3051. static struct hda_input_mux alc260_capture_source = {
  3052. .num_items = 4,
  3053. .items = {
  3054. { "Mic", 0x0 },
  3055. { "Front Mic", 0x1 },
  3056. { "Line", 0x2 },
  3057. { "CD", 0x4 },
  3058. },
  3059. };
  3060. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3061. * headphone jack and the internal CD lines since these are the only pins at
  3062. * which audio can appear. For flexibility, also allow the option of
  3063. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3064. * connection to the mixer output).
  3065. */
  3066. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3067. {
  3068. .num_items = 3,
  3069. .items = {
  3070. { "Mic/Line", 0x0 },
  3071. { "CD", 0x4 },
  3072. { "Headphone", 0x2 },
  3073. },
  3074. },
  3075. {
  3076. .num_items = 4,
  3077. .items = {
  3078. { "Mic/Line", 0x0 },
  3079. { "CD", 0x4 },
  3080. { "Headphone", 0x2 },
  3081. { "Mixer", 0x5 },
  3082. },
  3083. },
  3084. };
  3085. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3086. * the Fujitsu S702x, but jacks are marked differently.
  3087. */
  3088. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3089. {
  3090. .num_items = 4,
  3091. .items = {
  3092. { "Mic", 0x0 },
  3093. { "Line", 0x2 },
  3094. { "CD", 0x4 },
  3095. { "Headphone", 0x5 },
  3096. },
  3097. },
  3098. {
  3099. .num_items = 5,
  3100. .items = {
  3101. { "Mic", 0x0 },
  3102. { "Line", 0x2 },
  3103. { "CD", 0x4 },
  3104. { "Headphone", 0x6 },
  3105. { "Mixer", 0x5 },
  3106. },
  3107. },
  3108. };
  3109. /*
  3110. * This is just place-holder, so there's something for alc_build_pcms to look
  3111. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3112. * element which allows changing the channel mode, so the verb list is
  3113. * never used.
  3114. */
  3115. static struct hda_channel_mode alc260_modes[1] = {
  3116. { 2, NULL },
  3117. };
  3118. /* Mixer combinations
  3119. *
  3120. * basic: base_output + input + pc_beep + capture
  3121. * HP: base_output + input + capture_alt
  3122. * HP_3013: hp_3013 + input + capture
  3123. * fujitsu: fujitsu + capture
  3124. * acer: acer + capture
  3125. */
  3126. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3127. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3128. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3129. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3130. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3131. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3132. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3133. { } /* end */
  3134. };
  3135. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3136. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3137. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3138. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3139. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3140. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3141. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3142. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3143. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3144. { } /* end */
  3145. };
  3146. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3147. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3148. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3149. { } /* end */
  3150. };
  3151. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3152. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3153. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3154. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3155. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3156. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3157. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3158. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3159. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3160. { } /* end */
  3161. };
  3162. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3163. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3164. */
  3165. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3166. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3167. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3168. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3169. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3170. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3171. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3172. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3173. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3174. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3175. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3176. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3177. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3178. { } /* end */
  3179. };
  3180. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3181. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3182. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3183. * datasheet doesn't mention this restriction. At this stage it's not clear
  3184. * whether this behaviour is intentional or is a hardware bug in chip
  3185. * revisions available in early 2006. Therefore for now allow the
  3186. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3187. * that the lack of mic bias for this NID is intentional we could change the
  3188. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3189. *
  3190. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3191. * don't appear to make the mic bias available from the "line" jack, even
  3192. * though the NID used for this jack (0x14) can supply it. The theory is
  3193. * that perhaps Acer have included blocking capacitors between the ALC260
  3194. * and the output jack. If this turns out to be the case for all such
  3195. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3196. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3197. *
  3198. * The C20x Tablet series have a mono internal speaker which is controlled
  3199. * via the chip's Mono sum widget and pin complex, so include the necessary
  3200. * controls for such models. On models without a "mono speaker" the control
  3201. * won't do anything.
  3202. */
  3203. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3204. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3205. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3206. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3207. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3208. HDA_OUTPUT),
  3209. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3210. HDA_INPUT),
  3211. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3212. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3213. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3214. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3215. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3216. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3217. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3218. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3220. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3221. { } /* end */
  3222. };
  3223. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3224. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3225. */
  3226. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3227. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3228. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3229. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3230. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3231. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3232. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3233. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3234. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3235. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3236. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3237. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3238. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3239. { } /* end */
  3240. };
  3241. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3242. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3243. */
  3244. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3245. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3246. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3247. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3248. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3249. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3250. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3251. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3252. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3253. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3254. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3255. { } /* end */
  3256. };
  3257. /* capture mixer elements */
  3258. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3259. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3260. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3261. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3262. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3263. {
  3264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3265. /* The multiple "Capture Source" controls confuse alsamixer
  3266. * So call somewhat different..
  3267. * FIXME: the controls appear in the "playback" view!
  3268. */
  3269. /* .name = "Capture Source", */
  3270. .name = "Input Source",
  3271. .count = 2,
  3272. .info = alc_mux_enum_info,
  3273. .get = alc_mux_enum_get,
  3274. .put = alc_mux_enum_put,
  3275. },
  3276. { } /* end */
  3277. };
  3278. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3279. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3281. {
  3282. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3283. /* The multiple "Capture Source" controls confuse alsamixer
  3284. * So call somewhat different..
  3285. * FIXME: the controls appear in the "playback" view!
  3286. */
  3287. /* .name = "Capture Source", */
  3288. .name = "Input Source",
  3289. .count = 1,
  3290. .info = alc_mux_enum_info,
  3291. .get = alc_mux_enum_get,
  3292. .put = alc_mux_enum_put,
  3293. },
  3294. { } /* end */
  3295. };
  3296. /*
  3297. * initialization verbs
  3298. */
  3299. static struct hda_verb alc260_init_verbs[] = {
  3300. /* Line In pin widget for input */
  3301. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3302. /* CD pin widget for input */
  3303. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3304. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3305. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3306. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3307. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3308. /* LINE-2 is used for line-out in rear */
  3309. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3310. /* select line-out */
  3311. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3312. /* LINE-OUT pin */
  3313. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3314. /* enable HP */
  3315. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3316. /* enable Mono */
  3317. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3318. /* mute capture amp left and right */
  3319. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3320. /* set connection select to line in (default select for this ADC) */
  3321. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3322. /* mute capture amp left and right */
  3323. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3324. /* set connection select to line in (default select for this ADC) */
  3325. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3326. /* set vol=0 Line-Out mixer amp left and right */
  3327. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3328. /* unmute pin widget amp left and right (no gain on this amp) */
  3329. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3330. /* set vol=0 HP mixer amp left and right */
  3331. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3332. /* unmute pin widget amp left and right (no gain on this amp) */
  3333. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3334. /* set vol=0 Mono mixer amp left and right */
  3335. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3336. /* unmute pin widget amp left and right (no gain on this amp) */
  3337. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3338. /* unmute LINE-2 out pin */
  3339. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3340. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3341. * Line In 2 = 0x03
  3342. */
  3343. /* mute CD */
  3344. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3345. /* mute Line In */
  3346. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3347. /* mute Mic */
  3348. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3349. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3350. /* mute Front out path */
  3351. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3352. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3353. /* mute Headphone out path */
  3354. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3355. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3356. /* mute Mono out path */
  3357. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3358. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3359. { }
  3360. };
  3361. #if 0 /* should be identical with alc260_init_verbs? */
  3362. static struct hda_verb alc260_hp_init_verbs[] = {
  3363. /* Headphone and output */
  3364. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3365. /* mono output */
  3366. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3367. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3368. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3369. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3370. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3371. /* Line In pin widget for input */
  3372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3373. /* Line-2 pin widget for output */
  3374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3375. /* CD pin widget for input */
  3376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3377. /* unmute amp left and right */
  3378. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3379. /* set connection select to line in (default select for this ADC) */
  3380. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3381. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3382. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3383. /* mute pin widget amp left and right (no gain on this amp) */
  3384. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3385. /* unmute HP mixer amp left and right (volume = 0) */
  3386. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3387. /* mute pin widget amp left and right (no gain on this amp) */
  3388. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3389. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3390. * Line In 2 = 0x03
  3391. */
  3392. /* unmute CD */
  3393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3394. /* unmute Line In */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3396. /* unmute Mic */
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3398. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3399. /* Unmute Front out path */
  3400. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3402. /* Unmute Headphone out path */
  3403. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3405. /* Unmute Mono out path */
  3406. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3408. { }
  3409. };
  3410. #endif
  3411. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3412. /* Line out and output */
  3413. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3414. /* mono output */
  3415. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3416. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3417. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3418. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3419. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Line In pin widget for input */
  3421. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3422. /* Headphone pin widget for output */
  3423. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3424. /* CD pin widget for input */
  3425. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3426. /* unmute amp left and right */
  3427. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3428. /* set connection select to line in (default select for this ADC) */
  3429. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3430. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3431. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3432. /* mute pin widget amp left and right (no gain on this amp) */
  3433. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3434. /* unmute HP mixer amp left and right (volume = 0) */
  3435. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3436. /* mute pin widget amp left and right (no gain on this amp) */
  3437. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3438. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3439. * Line In 2 = 0x03
  3440. */
  3441. /* unmute CD */
  3442. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3443. /* unmute Line In */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3445. /* unmute Mic */
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3447. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3448. /* Unmute Front out path */
  3449. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3451. /* Unmute Headphone out path */
  3452. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3454. /* Unmute Mono out path */
  3455. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3457. { }
  3458. };
  3459. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3460. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3461. * audio = 0x16, internal speaker = 0x10.
  3462. */
  3463. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3464. /* Disable all GPIOs */
  3465. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3466. /* Internal speaker is connected to headphone pin */
  3467. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3468. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3469. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3470. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3471. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3472. /* Ensure all other unused pins are disabled and muted. */
  3473. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3474. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3476. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3477. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3478. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3481. /* Disable digital (SPDIF) pins */
  3482. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3483. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3484. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3485. * when acting as an output.
  3486. */
  3487. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3488. /* Start with output sum widgets muted and their output gains at min */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3495. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3498. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3499. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3500. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3501. * If the pin mode is changed by the user the pin mode control will
  3502. * take care of enabling the pin's input/output buffers as needed.
  3503. * Therefore there's no need to enable the input buffer at this
  3504. * stage.
  3505. */
  3506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3507. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3508. * mixer ctrl)
  3509. */
  3510. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3511. /* Mute capture amp left and right */
  3512. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. /* Set ADC connection select to match default mixer setting - line
  3514. * in (on mic1 pin)
  3515. */
  3516. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3517. /* Do the same for the second ADC: mute capture input amp and
  3518. * set ADC connection to line in (on mic1 pin)
  3519. */
  3520. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3522. /* Mute all inputs to mixer widget (even unconnected ones) */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3531. { }
  3532. };
  3533. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3534. * similar laptops (adapted from Fujitsu init verbs).
  3535. */
  3536. static struct hda_verb alc260_acer_init_verbs[] = {
  3537. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3538. * the headphone jack. Turn this on and rely on the standard mute
  3539. * methods whenever the user wants to turn these outputs off.
  3540. */
  3541. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3542. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3543. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3544. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3545. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3546. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3547. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3548. /* Line In jack is connected to Line1 pin */
  3549. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3550. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3551. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3552. /* Ensure all other unused pins are disabled and muted. */
  3553. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3554. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3555. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3556. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3557. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3558. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3559. /* Disable digital (SPDIF) pins */
  3560. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3561. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3562. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3563. * bus when acting as outputs.
  3564. */
  3565. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3566. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3567. /* Start with output sum widgets muted and their output gains at min */
  3568. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3570. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3571. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3572. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3574. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3575. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3576. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3577. /* Unmute Line-out pin widget amp left and right
  3578. * (no equiv mixer ctrl)
  3579. */
  3580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3581. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3582. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3583. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3584. * inputs. If the pin mode is changed by the user the pin mode control
  3585. * will take care of enabling the pin's input/output buffers as needed.
  3586. * Therefore there's no need to enable the input buffer at this
  3587. * stage.
  3588. */
  3589. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3590. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3591. /* Mute capture amp left and right */
  3592. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3593. /* Set ADC connection select to match default mixer setting - mic
  3594. * (on mic1 pin)
  3595. */
  3596. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3597. /* Do similar with the second ADC: mute capture input amp and
  3598. * set ADC connection to mic to match ALSA's default state.
  3599. */
  3600. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3601. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3602. /* Mute all inputs to mixer widget (even unconnected ones) */
  3603. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3608. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3609. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3610. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3611. { }
  3612. };
  3613. static struct hda_verb alc260_will_verbs[] = {
  3614. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3617. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3618. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3619. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3620. {}
  3621. };
  3622. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3623. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3624. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3625. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3626. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3627. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3628. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3629. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3630. {}
  3631. };
  3632. /* toggle speaker-output according to the hp-jack state */
  3633. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3634. {
  3635. unsigned int present;
  3636. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3637. present = snd_hda_codec_read(codec, 0x0f, 0,
  3638. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3639. if (present) {
  3640. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3641. snd_hda_codec_write(codec, 0x0f, 0,
  3642. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3643. } else {
  3644. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3645. snd_hda_codec_write(codec, 0x0f, 0,
  3646. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3647. }
  3648. }
  3649. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3650. unsigned int res)
  3651. {
  3652. if ((res >> 26) == ALC880_HP_EVENT)
  3653. alc260_replacer_672v_automute(codec);
  3654. }
  3655. /* Test configuration for debugging, modelled after the ALC880 test
  3656. * configuration.
  3657. */
  3658. #ifdef CONFIG_SND_DEBUG
  3659. static hda_nid_t alc260_test_dac_nids[1] = {
  3660. 0x02,
  3661. };
  3662. static hda_nid_t alc260_test_adc_nids[2] = {
  3663. 0x04, 0x05,
  3664. };
  3665. /* For testing the ALC260, each input MUX needs its own definition since
  3666. * the signal assignments are different. This assumes that the first ADC
  3667. * is NID 0x04.
  3668. */
  3669. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3670. {
  3671. .num_items = 7,
  3672. .items = {
  3673. { "MIC1 pin", 0x0 },
  3674. { "MIC2 pin", 0x1 },
  3675. { "LINE1 pin", 0x2 },
  3676. { "LINE2 pin", 0x3 },
  3677. { "CD pin", 0x4 },
  3678. { "LINE-OUT pin", 0x5 },
  3679. { "HP-OUT pin", 0x6 },
  3680. },
  3681. },
  3682. {
  3683. .num_items = 8,
  3684. .items = {
  3685. { "MIC1 pin", 0x0 },
  3686. { "MIC2 pin", 0x1 },
  3687. { "LINE1 pin", 0x2 },
  3688. { "LINE2 pin", 0x3 },
  3689. { "CD pin", 0x4 },
  3690. { "Mixer", 0x5 },
  3691. { "LINE-OUT pin", 0x6 },
  3692. { "HP-OUT pin", 0x7 },
  3693. },
  3694. },
  3695. };
  3696. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3697. /* Output driver widgets */
  3698. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3699. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3700. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3701. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3702. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3703. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3704. /* Modes for retasking pin widgets
  3705. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3706. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3707. * mention this restriction. At this stage it's not clear whether
  3708. * this behaviour is intentional or is a hardware bug in chip
  3709. * revisions available at least up until early 2006. Therefore for
  3710. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3711. * choices, but if it turns out that the lack of mic bias for these
  3712. * NIDs is intentional we could change their modes from
  3713. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3714. */
  3715. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3716. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3717. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3718. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3719. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3720. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3721. /* Loopback mixer controls */
  3722. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3723. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3724. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3725. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3726. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3727. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3728. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3729. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3730. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3731. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3732. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3733. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3734. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3735. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3736. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3737. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3738. /* Controls for GPIO pins, assuming they are configured as outputs */
  3739. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3740. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3741. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3742. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3743. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3744. * is ambigious as to which NID is which; testing on laptops which
  3745. * make this output available should provide clarification.
  3746. */
  3747. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3748. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3749. { } /* end */
  3750. };
  3751. static struct hda_verb alc260_test_init_verbs[] = {
  3752. /* Enable all GPIOs as outputs with an initial value of 0 */
  3753. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3754. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3755. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3756. /* Enable retasking pins as output, initially without power amp */
  3757. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3758. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3759. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3760. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3761. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3762. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3763. /* Disable digital (SPDIF) pins initially, but users can enable
  3764. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3765. * payload also sets the generation to 0, output to be in "consumer"
  3766. * PCM format, copyright asserted, no pre-emphasis and no validity
  3767. * control.
  3768. */
  3769. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3770. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3771. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3772. * OUT1 sum bus when acting as an output.
  3773. */
  3774. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3775. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3776. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3777. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3778. /* Start with output sum widgets muted and their output gains at min */
  3779. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3781. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3782. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3783. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3784. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3785. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3786. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3787. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3788. /* Unmute retasking pin widget output buffers since the default
  3789. * state appears to be output. As the pin mode is changed by the
  3790. * user the pin mode control will take care of enabling the pin's
  3791. * input/output buffers as needed.
  3792. */
  3793. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3794. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3796. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3797. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3798. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3799. /* Also unmute the mono-out pin widget */
  3800. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3801. /* Mute capture amp left and right */
  3802. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3803. /* Set ADC connection select to match default mixer setting (mic1
  3804. * pin)
  3805. */
  3806. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3807. /* Do the same for the second ADC: mute capture input amp and
  3808. * set ADC connection to mic1 pin
  3809. */
  3810. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3811. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3812. /* Mute all inputs to mixer widget (even unconnected ones) */
  3813. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3815. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3816. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3817. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3818. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3819. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3820. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3821. { }
  3822. };
  3823. #endif
  3824. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3825. .substreams = 1,
  3826. .channels_min = 2,
  3827. .channels_max = 2,
  3828. };
  3829. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3830. .substreams = 1,
  3831. .channels_min = 2,
  3832. .channels_max = 2,
  3833. };
  3834. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3835. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3836. /*
  3837. * for BIOS auto-configuration
  3838. */
  3839. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3840. const char *pfx)
  3841. {
  3842. hda_nid_t nid_vol;
  3843. unsigned long vol_val, sw_val;
  3844. char name[32];
  3845. int err;
  3846. if (nid >= 0x0f && nid < 0x11) {
  3847. nid_vol = nid - 0x7;
  3848. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3849. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3850. } else if (nid == 0x11) {
  3851. nid_vol = nid - 0x7;
  3852. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3853. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3854. } else if (nid >= 0x12 && nid <= 0x15) {
  3855. nid_vol = 0x08;
  3856. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3857. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3858. } else
  3859. return 0; /* N/A */
  3860. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3861. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3862. if (err < 0)
  3863. return err;
  3864. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3865. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3866. if (err < 0)
  3867. return err;
  3868. return 1;
  3869. }
  3870. /* add playback controls from the parsed DAC table */
  3871. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3872. const struct auto_pin_cfg *cfg)
  3873. {
  3874. hda_nid_t nid;
  3875. int err;
  3876. spec->multiout.num_dacs = 1;
  3877. spec->multiout.dac_nids = spec->private_dac_nids;
  3878. spec->multiout.dac_nids[0] = 0x02;
  3879. nid = cfg->line_out_pins[0];
  3880. if (nid) {
  3881. err = alc260_add_playback_controls(spec, nid, "Front");
  3882. if (err < 0)
  3883. return err;
  3884. }
  3885. nid = cfg->speaker_pins[0];
  3886. if (nid) {
  3887. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3888. if (err < 0)
  3889. return err;
  3890. }
  3891. nid = cfg->hp_pins[0];
  3892. if (nid) {
  3893. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3894. if (err < 0)
  3895. return err;
  3896. }
  3897. return 0;
  3898. }
  3899. /* create playback/capture controls for input pins */
  3900. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3901. const struct auto_pin_cfg *cfg)
  3902. {
  3903. struct hda_input_mux *imux = &spec->private_imux;
  3904. int i, err, idx;
  3905. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3906. if (cfg->input_pins[i] >= 0x12) {
  3907. idx = cfg->input_pins[i] - 0x12;
  3908. err = new_analog_input(spec, cfg->input_pins[i],
  3909. auto_pin_cfg_labels[i], idx,
  3910. 0x07);
  3911. if (err < 0)
  3912. return err;
  3913. imux->items[imux->num_items].label =
  3914. auto_pin_cfg_labels[i];
  3915. imux->items[imux->num_items].index = idx;
  3916. imux->num_items++;
  3917. }
  3918. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3919. idx = cfg->input_pins[i] - 0x09;
  3920. err = new_analog_input(spec, cfg->input_pins[i],
  3921. auto_pin_cfg_labels[i], idx,
  3922. 0x07);
  3923. if (err < 0)
  3924. return err;
  3925. imux->items[imux->num_items].label =
  3926. auto_pin_cfg_labels[i];
  3927. imux->items[imux->num_items].index = idx;
  3928. imux->num_items++;
  3929. }
  3930. }
  3931. return 0;
  3932. }
  3933. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3934. hda_nid_t nid, int pin_type,
  3935. int sel_idx)
  3936. {
  3937. /* set as output */
  3938. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3939. pin_type);
  3940. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3941. AMP_OUT_UNMUTE);
  3942. /* need the manual connection? */
  3943. if (nid >= 0x12) {
  3944. int idx = nid - 0x12;
  3945. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3946. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3947. }
  3948. }
  3949. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3950. {
  3951. struct alc_spec *spec = codec->spec;
  3952. hda_nid_t nid;
  3953. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3954. nid = spec->autocfg.line_out_pins[0];
  3955. if (nid) {
  3956. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3957. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3958. }
  3959. nid = spec->autocfg.speaker_pins[0];
  3960. if (nid)
  3961. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3962. nid = spec->autocfg.hp_pins[0];
  3963. if (nid)
  3964. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3965. }
  3966. #define ALC260_PIN_CD_NID 0x16
  3967. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3968. {
  3969. struct alc_spec *spec = codec->spec;
  3970. int i;
  3971. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3972. hda_nid_t nid = spec->autocfg.input_pins[i];
  3973. if (nid >= 0x12) {
  3974. snd_hda_codec_write(codec, nid, 0,
  3975. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3976. i <= AUTO_PIN_FRONT_MIC ?
  3977. PIN_VREF80 : PIN_IN);
  3978. if (nid != ALC260_PIN_CD_NID)
  3979. snd_hda_codec_write(codec, nid, 0,
  3980. AC_VERB_SET_AMP_GAIN_MUTE,
  3981. AMP_OUT_MUTE);
  3982. }
  3983. }
  3984. }
  3985. /*
  3986. * generic initialization of ADC, input mixers and output mixers
  3987. */
  3988. static struct hda_verb alc260_volume_init_verbs[] = {
  3989. /*
  3990. * Unmute ADC0-1 and set the default input to mic-in
  3991. */
  3992. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3993. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3994. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3995. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3996. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3997. * mixer widget
  3998. * Note: PASD motherboards uses the Line In 2 as the input for
  3999. * front panel mic (mic 2)
  4000. */
  4001. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4002. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4003. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4007. /*
  4008. * Set up output mixers (0x08 - 0x0a)
  4009. */
  4010. /* set vol=0 to output mixers */
  4011. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4012. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4013. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4014. /* set up input amps for analog loopback */
  4015. /* Amp Indices: DAC = 0, mixer = 1 */
  4016. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4017. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4018. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4019. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4020. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4021. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4022. { }
  4023. };
  4024. static int alc260_parse_auto_config(struct hda_codec *codec)
  4025. {
  4026. struct alc_spec *spec = codec->spec;
  4027. unsigned int wcap;
  4028. int err;
  4029. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4030. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4031. alc260_ignore);
  4032. if (err < 0)
  4033. return err;
  4034. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4035. if (err < 0)
  4036. return err;
  4037. if (!spec->kctl_alloc)
  4038. return 0; /* can't find valid BIOS pin config */
  4039. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4040. if (err < 0)
  4041. return err;
  4042. spec->multiout.max_channels = 2;
  4043. if (spec->autocfg.dig_out_pin)
  4044. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4045. if (spec->kctl_alloc)
  4046. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4047. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4048. spec->num_mux_defs = 1;
  4049. spec->input_mux = &spec->private_imux;
  4050. /* check whether NID 0x04 is valid */
  4051. wcap = get_wcaps(codec, 0x04);
  4052. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4053. if (wcap != AC_WID_AUD_IN) {
  4054. spec->adc_nids = alc260_adc_nids_alt;
  4055. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4056. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4057. } else {
  4058. spec->adc_nids = alc260_adc_nids;
  4059. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4060. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4061. }
  4062. spec->num_mixers++;
  4063. return 1;
  4064. }
  4065. /* additional initialization for auto-configuration model */
  4066. static void alc260_auto_init(struct hda_codec *codec)
  4067. {
  4068. alc260_auto_init_multi_out(codec);
  4069. alc260_auto_init_analog_input(codec);
  4070. }
  4071. /*
  4072. * ALC260 configurations
  4073. */
  4074. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4075. [ALC260_BASIC] = "basic",
  4076. [ALC260_HP] = "hp",
  4077. [ALC260_HP_3013] = "hp-3013",
  4078. [ALC260_FUJITSU_S702X] = "fujitsu",
  4079. [ALC260_ACER] = "acer",
  4080. [ALC260_WILL] = "will",
  4081. [ALC260_REPLACER_672V] = "replacer",
  4082. #ifdef CONFIG_SND_DEBUG
  4083. [ALC260_TEST] = "test",
  4084. #endif
  4085. [ALC260_AUTO] = "auto",
  4086. };
  4087. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4088. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4089. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4090. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4091. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4092. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4093. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4094. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4095. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4096. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4097. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4098. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4099. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4100. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4101. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4102. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4103. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4104. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4105. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4106. {}
  4107. };
  4108. static struct alc_config_preset alc260_presets[] = {
  4109. [ALC260_BASIC] = {
  4110. .mixers = { alc260_base_output_mixer,
  4111. alc260_input_mixer,
  4112. alc260_pc_beep_mixer,
  4113. alc260_capture_mixer },
  4114. .init_verbs = { alc260_init_verbs },
  4115. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4116. .dac_nids = alc260_dac_nids,
  4117. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4118. .adc_nids = alc260_adc_nids,
  4119. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4120. .channel_mode = alc260_modes,
  4121. .input_mux = &alc260_capture_source,
  4122. },
  4123. [ALC260_HP] = {
  4124. .mixers = { alc260_base_output_mixer,
  4125. alc260_input_mixer,
  4126. alc260_capture_alt_mixer },
  4127. .init_verbs = { alc260_init_verbs },
  4128. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4129. .dac_nids = alc260_dac_nids,
  4130. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4131. .adc_nids = alc260_hp_adc_nids,
  4132. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4133. .channel_mode = alc260_modes,
  4134. .input_mux = &alc260_capture_source,
  4135. },
  4136. [ALC260_HP_3013] = {
  4137. .mixers = { alc260_hp_3013_mixer,
  4138. alc260_input_mixer,
  4139. alc260_capture_alt_mixer },
  4140. .init_verbs = { alc260_hp_3013_init_verbs },
  4141. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4142. .dac_nids = alc260_dac_nids,
  4143. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4144. .adc_nids = alc260_hp_adc_nids,
  4145. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4146. .channel_mode = alc260_modes,
  4147. .input_mux = &alc260_capture_source,
  4148. },
  4149. [ALC260_FUJITSU_S702X] = {
  4150. .mixers = { alc260_fujitsu_mixer,
  4151. alc260_capture_mixer },
  4152. .init_verbs = { alc260_fujitsu_init_verbs },
  4153. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4154. .dac_nids = alc260_dac_nids,
  4155. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4156. .adc_nids = alc260_dual_adc_nids,
  4157. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4158. .channel_mode = alc260_modes,
  4159. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4160. .input_mux = alc260_fujitsu_capture_sources,
  4161. },
  4162. [ALC260_ACER] = {
  4163. .mixers = { alc260_acer_mixer,
  4164. alc260_capture_mixer },
  4165. .init_verbs = { alc260_acer_init_verbs },
  4166. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4167. .dac_nids = alc260_dac_nids,
  4168. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4169. .adc_nids = alc260_dual_adc_nids,
  4170. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4171. .channel_mode = alc260_modes,
  4172. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4173. .input_mux = alc260_acer_capture_sources,
  4174. },
  4175. [ALC260_WILL] = {
  4176. .mixers = { alc260_will_mixer,
  4177. alc260_capture_mixer },
  4178. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4179. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4180. .dac_nids = alc260_dac_nids,
  4181. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4182. .adc_nids = alc260_adc_nids,
  4183. .dig_out_nid = ALC260_DIGOUT_NID,
  4184. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4185. .channel_mode = alc260_modes,
  4186. .input_mux = &alc260_capture_source,
  4187. },
  4188. [ALC260_REPLACER_672V] = {
  4189. .mixers = { alc260_replacer_672v_mixer,
  4190. alc260_capture_mixer },
  4191. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4192. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4193. .dac_nids = alc260_dac_nids,
  4194. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4195. .adc_nids = alc260_adc_nids,
  4196. .dig_out_nid = ALC260_DIGOUT_NID,
  4197. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4198. .channel_mode = alc260_modes,
  4199. .input_mux = &alc260_capture_source,
  4200. .unsol_event = alc260_replacer_672v_unsol_event,
  4201. .init_hook = alc260_replacer_672v_automute,
  4202. },
  4203. #ifdef CONFIG_SND_DEBUG
  4204. [ALC260_TEST] = {
  4205. .mixers = { alc260_test_mixer,
  4206. alc260_capture_mixer },
  4207. .init_verbs = { alc260_test_init_verbs },
  4208. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4209. .dac_nids = alc260_test_dac_nids,
  4210. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4211. .adc_nids = alc260_test_adc_nids,
  4212. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4213. .channel_mode = alc260_modes,
  4214. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4215. .input_mux = alc260_test_capture_sources,
  4216. },
  4217. #endif
  4218. };
  4219. static int patch_alc260(struct hda_codec *codec)
  4220. {
  4221. struct alc_spec *spec;
  4222. int err, board_config;
  4223. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4224. if (spec == NULL)
  4225. return -ENOMEM;
  4226. codec->spec = spec;
  4227. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4228. alc260_models,
  4229. alc260_cfg_tbl);
  4230. if (board_config < 0) {
  4231. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4232. "trying auto-probe from BIOS...\n");
  4233. board_config = ALC260_AUTO;
  4234. }
  4235. if (board_config == ALC260_AUTO) {
  4236. /* automatic parse from the BIOS config */
  4237. err = alc260_parse_auto_config(codec);
  4238. if (err < 0) {
  4239. alc_free(codec);
  4240. return err;
  4241. } else if (!err) {
  4242. printk(KERN_INFO
  4243. "hda_codec: Cannot set up configuration "
  4244. "from BIOS. Using base mode...\n");
  4245. board_config = ALC260_BASIC;
  4246. }
  4247. }
  4248. if (board_config != ALC260_AUTO)
  4249. setup_preset(spec, &alc260_presets[board_config]);
  4250. spec->stream_name_analog = "ALC260 Analog";
  4251. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4252. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4253. spec->stream_name_digital = "ALC260 Digital";
  4254. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4255. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4256. codec->patch_ops = alc_patch_ops;
  4257. if (board_config == ALC260_AUTO)
  4258. spec->init_hook = alc260_auto_init;
  4259. return 0;
  4260. }
  4261. /*
  4262. * ALC882 support
  4263. *
  4264. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4265. * configuration. Each pin widget can choose any input DACs and a mixer.
  4266. * Each ADC is connected from a mixer of all inputs. This makes possible
  4267. * 6-channel independent captures.
  4268. *
  4269. * In addition, an independent DAC for the multi-playback (not used in this
  4270. * driver yet).
  4271. */
  4272. #define ALC882_DIGOUT_NID 0x06
  4273. #define ALC882_DIGIN_NID 0x0a
  4274. static struct hda_channel_mode alc882_ch_modes[1] = {
  4275. { 8, NULL }
  4276. };
  4277. static hda_nid_t alc882_dac_nids[4] = {
  4278. /* front, rear, clfe, rear_surr */
  4279. 0x02, 0x03, 0x04, 0x05
  4280. };
  4281. /* identical with ALC880 */
  4282. #define alc882_adc_nids alc880_adc_nids
  4283. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4284. /* input MUX */
  4285. /* FIXME: should be a matrix-type input source selection */
  4286. static struct hda_input_mux alc882_capture_source = {
  4287. .num_items = 4,
  4288. .items = {
  4289. { "Mic", 0x0 },
  4290. { "Front Mic", 0x1 },
  4291. { "Line", 0x2 },
  4292. { "CD", 0x4 },
  4293. },
  4294. };
  4295. #define alc882_mux_enum_info alc_mux_enum_info
  4296. #define alc882_mux_enum_get alc_mux_enum_get
  4297. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4298. struct snd_ctl_elem_value *ucontrol)
  4299. {
  4300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4301. struct alc_spec *spec = codec->spec;
  4302. const struct hda_input_mux *imux = spec->input_mux;
  4303. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4304. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4305. hda_nid_t nid = capture_mixers[adc_idx];
  4306. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4307. unsigned int i, idx;
  4308. idx = ucontrol->value.enumerated.item[0];
  4309. if (idx >= imux->num_items)
  4310. idx = imux->num_items - 1;
  4311. if (*cur_val == idx && !codec->in_resume)
  4312. return 0;
  4313. for (i = 0; i < imux->num_items; i++) {
  4314. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4315. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4316. v | (imux->items[i].index << 8));
  4317. }
  4318. *cur_val = idx;
  4319. return 1;
  4320. }
  4321. /*
  4322. * 2ch mode
  4323. */
  4324. static struct hda_verb alc882_3ST_ch2_init[] = {
  4325. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4326. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4327. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4328. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4329. { } /* end */
  4330. };
  4331. /*
  4332. * 6ch mode
  4333. */
  4334. static struct hda_verb alc882_3ST_ch6_init[] = {
  4335. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4336. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4337. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4338. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4339. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4340. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4341. { } /* end */
  4342. };
  4343. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4344. { 2, alc882_3ST_ch2_init },
  4345. { 6, alc882_3ST_ch6_init },
  4346. };
  4347. /*
  4348. * 6ch mode
  4349. */
  4350. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4351. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4352. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4353. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4354. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4355. { } /* end */
  4356. };
  4357. /*
  4358. * 8ch mode
  4359. */
  4360. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4361. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4362. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4363. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4364. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4365. { } /* end */
  4366. };
  4367. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4368. { 6, alc882_sixstack_ch6_init },
  4369. { 8, alc882_sixstack_ch8_init },
  4370. };
  4371. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4372. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4373. */
  4374. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4375. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4376. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4378. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4379. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4380. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4381. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4382. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4383. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4384. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4385. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4386. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4387. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4391. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4392. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4393. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4394. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4395. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4396. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4397. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4398. { } /* end */
  4399. };
  4400. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4401. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4402. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4403. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4404. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4405. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4406. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4407. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4408. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4409. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4410. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4411. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4412. { } /* end */
  4413. };
  4414. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4415. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4416. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4417. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4418. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4419. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4420. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4421. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4422. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4423. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4424. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4425. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4426. { } /* end */
  4427. };
  4428. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4429. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4430. */
  4431. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4432. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4433. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4434. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4435. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4437. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4439. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4441. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4444. { } /* end */
  4445. };
  4446. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4447. {
  4448. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4449. .name = "Channel Mode",
  4450. .info = alc_ch_mode_info,
  4451. .get = alc_ch_mode_get,
  4452. .put = alc_ch_mode_put,
  4453. },
  4454. { } /* end */
  4455. };
  4456. static struct hda_verb alc882_init_verbs[] = {
  4457. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4458. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4459. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4461. /* Rear mixer */
  4462. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4464. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4465. /* CLFE mixer */
  4466. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4467. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4468. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4469. /* Side mixer */
  4470. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4471. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4472. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4473. /* Front Pin: output 0 (0x0c) */
  4474. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4475. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4476. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4477. /* Rear Pin: output 1 (0x0d) */
  4478. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4479. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4480. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4481. /* CLFE Pin: output 2 (0x0e) */
  4482. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4483. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4484. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4485. /* Side Pin: output 3 (0x0f) */
  4486. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4487. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4488. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4489. /* Mic (rear) pin: input vref at 80% */
  4490. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4491. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4492. /* Front Mic pin: input vref at 80% */
  4493. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4494. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4495. /* Line In pin: input */
  4496. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4497. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4498. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4499. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4500. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4501. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4502. /* CD pin widget for input */
  4503. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4504. /* FIXME: use matrix-type input source selection */
  4505. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4506. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4507. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4511. /* Input mixer2 */
  4512. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4516. /* Input mixer3 */
  4517. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4521. /* ADC1: mute amp left and right */
  4522. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4523. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4524. /* ADC2: mute amp left and right */
  4525. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4526. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4527. /* ADC3: mute amp left and right */
  4528. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4529. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4530. { }
  4531. };
  4532. static struct hda_verb alc882_eapd_verbs[] = {
  4533. /* change to EAPD mode */
  4534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4536. { }
  4537. };
  4538. /* Mac Pro test */
  4539. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4540. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4541. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4542. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4544. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4545. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4546. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4547. { } /* end */
  4548. };
  4549. static struct hda_verb alc882_macpro_init_verbs[] = {
  4550. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4551. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4554. /* Front Pin: output 0 (0x0c) */
  4555. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4556. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4557. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4558. /* Front Mic pin: input vref at 80% */
  4559. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4560. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4561. /* Speaker: output */
  4562. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4563. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4564. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4565. /* Headphone output (output 0 - 0x0c) */
  4566. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4567. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4568. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4569. /* FIXME: use matrix-type input source selection */
  4570. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4571. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4572. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4573. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4575. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4576. /* Input mixer2 */
  4577. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4578. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4580. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4581. /* Input mixer3 */
  4582. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4586. /* ADC1: mute amp left and right */
  4587. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4589. /* ADC2: mute amp left and right */
  4590. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4591. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4592. /* ADC3: mute amp left and right */
  4593. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4594. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4595. { }
  4596. };
  4597. static struct hda_verb alc882_targa_verbs[] = {
  4598. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4599. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4600. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4602. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4603. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4604. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4605. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4606. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4607. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4608. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4609. { } /* end */
  4610. };
  4611. /* toggle speaker-output according to the hp-jack state */
  4612. static void alc882_targa_automute(struct hda_codec *codec)
  4613. {
  4614. unsigned int present;
  4615. present = snd_hda_codec_read(codec, 0x14, 0,
  4616. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4617. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4618. 0x80, present ? 0x80 : 0);
  4619. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4620. 0x80, present ? 0x80 : 0);
  4621. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4622. }
  4623. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4624. {
  4625. /* Looks like the unsol event is incompatible with the standard
  4626. * definition. 4bit tag is placed at 26 bit!
  4627. */
  4628. if (((res >> 26) == ALC880_HP_EVENT)) {
  4629. alc882_targa_automute(codec);
  4630. }
  4631. }
  4632. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4633. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4635. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4636. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4637. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4638. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4639. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4640. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4641. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4642. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4643. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4644. { } /* end */
  4645. };
  4646. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4647. {
  4648. unsigned int gpiostate, gpiomask, gpiodir;
  4649. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4650. AC_VERB_GET_GPIO_DATA, 0);
  4651. if (!muted)
  4652. gpiostate |= (1 << pin);
  4653. else
  4654. gpiostate &= ~(1 << pin);
  4655. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4656. AC_VERB_GET_GPIO_MASK, 0);
  4657. gpiomask |= (1 << pin);
  4658. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4659. AC_VERB_GET_GPIO_DIRECTION, 0);
  4660. gpiodir |= (1 << pin);
  4661. snd_hda_codec_write(codec, codec->afg, 0,
  4662. AC_VERB_SET_GPIO_MASK, gpiomask);
  4663. snd_hda_codec_write(codec, codec->afg, 0,
  4664. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4665. msleep(1);
  4666. snd_hda_codec_write(codec, codec->afg, 0,
  4667. AC_VERB_SET_GPIO_DATA, gpiostate);
  4668. }
  4669. /*
  4670. * generic initialization of ADC, input mixers and output mixers
  4671. */
  4672. static struct hda_verb alc882_auto_init_verbs[] = {
  4673. /*
  4674. * Unmute ADC0-2 and set the default input to mic-in
  4675. */
  4676. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4677. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4678. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4679. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4680. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4682. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4683. * mixer widget
  4684. * Note: PASD motherboards uses the Line In 2 as the input for
  4685. * front panel mic (mic 2)
  4686. */
  4687. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4688. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4689. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4690. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4691. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4692. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4693. /*
  4694. * Set up output mixers (0x0c - 0x0f)
  4695. */
  4696. /* set vol=0 to output mixers */
  4697. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4698. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4699. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4700. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4701. /* set up input amps for analog loopback */
  4702. /* Amp Indices: DAC = 0, mixer = 1 */
  4703. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4704. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4705. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4706. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4707. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4708. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4709. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4710. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4711. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4712. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4713. /* FIXME: use matrix-type input source selection */
  4714. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4715. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4716. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4718. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4719. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4720. /* Input mixer2 */
  4721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4725. /* Input mixer3 */
  4726. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4730. { }
  4731. };
  4732. /* capture mixer elements */
  4733. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4734. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4735. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4736. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4737. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4738. {
  4739. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4740. /* The multiple "Capture Source" controls confuse alsamixer
  4741. * So call somewhat different..
  4742. * FIXME: the controls appear in the "playback" view!
  4743. */
  4744. /* .name = "Capture Source", */
  4745. .name = "Input Source",
  4746. .count = 2,
  4747. .info = alc882_mux_enum_info,
  4748. .get = alc882_mux_enum_get,
  4749. .put = alc882_mux_enum_put,
  4750. },
  4751. { } /* end */
  4752. };
  4753. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4754. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4755. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4756. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4757. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4758. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4759. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4760. {
  4761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4762. /* The multiple "Capture Source" controls confuse alsamixer
  4763. * So call somewhat different..
  4764. * FIXME: the controls appear in the "playback" view!
  4765. */
  4766. /* .name = "Capture Source", */
  4767. .name = "Input Source",
  4768. .count = 3,
  4769. .info = alc882_mux_enum_info,
  4770. .get = alc882_mux_enum_get,
  4771. .put = alc882_mux_enum_put,
  4772. },
  4773. { } /* end */
  4774. };
  4775. /* pcm configuration: identiacal with ALC880 */
  4776. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4777. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4778. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4779. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4780. /*
  4781. * configuration and preset
  4782. */
  4783. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4784. [ALC882_3ST_DIG] = "3stack-dig",
  4785. [ALC882_6ST_DIG] = "6stack-dig",
  4786. [ALC882_ARIMA] = "arima",
  4787. [ALC882_W2JC] = "w2jc",
  4788. [ALC885_MACPRO] = "macpro",
  4789. [ALC882_AUTO] = "auto",
  4790. };
  4791. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4792. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4793. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4794. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4795. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4796. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4797. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4798. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4799. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4800. {}
  4801. };
  4802. static struct alc_config_preset alc882_presets[] = {
  4803. [ALC882_3ST_DIG] = {
  4804. .mixers = { alc882_base_mixer },
  4805. .init_verbs = { alc882_init_verbs },
  4806. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4807. .dac_nids = alc882_dac_nids,
  4808. .dig_out_nid = ALC882_DIGOUT_NID,
  4809. .dig_in_nid = ALC882_DIGIN_NID,
  4810. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4811. .channel_mode = alc882_ch_modes,
  4812. .need_dac_fix = 1,
  4813. .input_mux = &alc882_capture_source,
  4814. },
  4815. [ALC882_6ST_DIG] = {
  4816. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4817. .init_verbs = { alc882_init_verbs },
  4818. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4819. .dac_nids = alc882_dac_nids,
  4820. .dig_out_nid = ALC882_DIGOUT_NID,
  4821. .dig_in_nid = ALC882_DIGIN_NID,
  4822. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4823. .channel_mode = alc882_sixstack_modes,
  4824. .input_mux = &alc882_capture_source,
  4825. },
  4826. [ALC882_ARIMA] = {
  4827. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4828. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4829. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4830. .dac_nids = alc882_dac_nids,
  4831. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4832. .channel_mode = alc882_sixstack_modes,
  4833. .input_mux = &alc882_capture_source,
  4834. },
  4835. [ALC882_W2JC] = {
  4836. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4837. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4838. alc880_gpio1_init_verbs },
  4839. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4840. .dac_nids = alc882_dac_nids,
  4841. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4842. .channel_mode = alc880_threestack_modes,
  4843. .need_dac_fix = 1,
  4844. .input_mux = &alc882_capture_source,
  4845. .dig_out_nid = ALC882_DIGOUT_NID,
  4846. },
  4847. [ALC885_MACPRO] = {
  4848. .mixers = { alc882_macpro_mixer },
  4849. .init_verbs = { alc882_macpro_init_verbs },
  4850. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4851. .dac_nids = alc882_dac_nids,
  4852. .dig_out_nid = ALC882_DIGOUT_NID,
  4853. .dig_in_nid = ALC882_DIGIN_NID,
  4854. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4855. .channel_mode = alc882_ch_modes,
  4856. .input_mux = &alc882_capture_source,
  4857. },
  4858. [ALC882_TARGA] = {
  4859. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4860. alc882_capture_mixer },
  4861. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4862. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4863. .dac_nids = alc882_dac_nids,
  4864. .dig_out_nid = ALC882_DIGOUT_NID,
  4865. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4866. .adc_nids = alc882_adc_nids,
  4867. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4868. .channel_mode = alc882_3ST_6ch_modes,
  4869. .need_dac_fix = 1,
  4870. .input_mux = &alc882_capture_source,
  4871. .unsol_event = alc882_targa_unsol_event,
  4872. .init_hook = alc882_targa_automute,
  4873. },
  4874. [ALC882_ASUS_A7J] = {
  4875. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4876. alc882_capture_mixer },
  4877. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4878. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4879. .dac_nids = alc882_dac_nids,
  4880. .dig_out_nid = ALC882_DIGOUT_NID,
  4881. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4882. .adc_nids = alc882_adc_nids,
  4883. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4884. .channel_mode = alc882_3ST_6ch_modes,
  4885. .need_dac_fix = 1,
  4886. .input_mux = &alc882_capture_source,
  4887. },
  4888. };
  4889. /*
  4890. * BIOS auto configuration
  4891. */
  4892. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4893. hda_nid_t nid, int pin_type,
  4894. int dac_idx)
  4895. {
  4896. /* set as output */
  4897. struct alc_spec *spec = codec->spec;
  4898. int idx;
  4899. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4900. idx = 4;
  4901. else
  4902. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4903. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4904. pin_type);
  4905. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4906. AMP_OUT_UNMUTE);
  4907. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4908. }
  4909. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4910. {
  4911. struct alc_spec *spec = codec->spec;
  4912. int i;
  4913. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4914. for (i = 0; i <= HDA_SIDE; i++) {
  4915. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4916. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4917. if (nid)
  4918. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4919. i);
  4920. }
  4921. }
  4922. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4923. {
  4924. struct alc_spec *spec = codec->spec;
  4925. hda_nid_t pin;
  4926. pin = spec->autocfg.hp_pins[0];
  4927. if (pin) /* connect to front */
  4928. /* use dac 0 */
  4929. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4930. }
  4931. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4932. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4933. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4934. {
  4935. struct alc_spec *spec = codec->spec;
  4936. int i;
  4937. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4938. hda_nid_t nid = spec->autocfg.input_pins[i];
  4939. if (alc882_is_input_pin(nid)) {
  4940. snd_hda_codec_write(codec, nid, 0,
  4941. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4942. i <= AUTO_PIN_FRONT_MIC ?
  4943. PIN_VREF80 : PIN_IN);
  4944. if (nid != ALC882_PIN_CD_NID)
  4945. snd_hda_codec_write(codec, nid, 0,
  4946. AC_VERB_SET_AMP_GAIN_MUTE,
  4947. AMP_OUT_MUTE);
  4948. }
  4949. }
  4950. }
  4951. /* almost identical with ALC880 parser... */
  4952. static int alc882_parse_auto_config(struct hda_codec *codec)
  4953. {
  4954. struct alc_spec *spec = codec->spec;
  4955. int err = alc880_parse_auto_config(codec);
  4956. if (err < 0)
  4957. return err;
  4958. else if (err > 0)
  4959. /* hack - override the init verbs */
  4960. spec->init_verbs[0] = alc882_auto_init_verbs;
  4961. return err;
  4962. }
  4963. /* additional initialization for auto-configuration model */
  4964. static void alc882_auto_init(struct hda_codec *codec)
  4965. {
  4966. alc882_auto_init_multi_out(codec);
  4967. alc882_auto_init_hp_out(codec);
  4968. alc882_auto_init_analog_input(codec);
  4969. }
  4970. static int patch_alc882(struct hda_codec *codec)
  4971. {
  4972. struct alc_spec *spec;
  4973. int err, board_config;
  4974. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4975. if (spec == NULL)
  4976. return -ENOMEM;
  4977. codec->spec = spec;
  4978. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4979. alc882_models,
  4980. alc882_cfg_tbl);
  4981. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4982. /* Pick up systems that don't supply PCI SSID */
  4983. switch (codec->subsystem_id) {
  4984. case 0x106b0c00: /* Mac Pro */
  4985. board_config = ALC885_MACPRO;
  4986. break;
  4987. default:
  4988. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4989. "trying auto-probe from BIOS...\n");
  4990. board_config = ALC882_AUTO;
  4991. }
  4992. }
  4993. if (board_config == ALC882_AUTO) {
  4994. /* automatic parse from the BIOS config */
  4995. err = alc882_parse_auto_config(codec);
  4996. if (err < 0) {
  4997. alc_free(codec);
  4998. return err;
  4999. } else if (!err) {
  5000. printk(KERN_INFO
  5001. "hda_codec: Cannot set up configuration "
  5002. "from BIOS. Using base mode...\n");
  5003. board_config = ALC882_3ST_DIG;
  5004. }
  5005. }
  5006. if (board_config != ALC882_AUTO)
  5007. setup_preset(spec, &alc882_presets[board_config]);
  5008. if (board_config == ALC885_MACPRO) {
  5009. alc882_gpio_mute(codec, 0, 0);
  5010. alc882_gpio_mute(codec, 1, 0);
  5011. }
  5012. spec->stream_name_analog = "ALC882 Analog";
  5013. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5014. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5015. spec->stream_name_digital = "ALC882 Digital";
  5016. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5017. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5018. if (!spec->adc_nids && spec->input_mux) {
  5019. /* check whether NID 0x07 is valid */
  5020. unsigned int wcap = get_wcaps(codec, 0x07);
  5021. /* get type */
  5022. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5023. if (wcap != AC_WID_AUD_IN) {
  5024. spec->adc_nids = alc882_adc_nids_alt;
  5025. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5026. spec->mixers[spec->num_mixers] =
  5027. alc882_capture_alt_mixer;
  5028. spec->num_mixers++;
  5029. } else {
  5030. spec->adc_nids = alc882_adc_nids;
  5031. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5032. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5033. spec->num_mixers++;
  5034. }
  5035. }
  5036. codec->patch_ops = alc_patch_ops;
  5037. if (board_config == ALC882_AUTO)
  5038. spec->init_hook = alc882_auto_init;
  5039. return 0;
  5040. }
  5041. /*
  5042. * ALC883 support
  5043. *
  5044. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5045. * configuration. Each pin widget can choose any input DACs and a mixer.
  5046. * Each ADC is connected from a mixer of all inputs. This makes possible
  5047. * 6-channel independent captures.
  5048. *
  5049. * In addition, an independent DAC for the multi-playback (not used in this
  5050. * driver yet).
  5051. */
  5052. #define ALC883_DIGOUT_NID 0x06
  5053. #define ALC883_DIGIN_NID 0x0a
  5054. static hda_nid_t alc883_dac_nids[4] = {
  5055. /* front, rear, clfe, rear_surr */
  5056. 0x02, 0x04, 0x03, 0x05
  5057. };
  5058. static hda_nid_t alc883_adc_nids[2] = {
  5059. /* ADC1-2 */
  5060. 0x08, 0x09,
  5061. };
  5062. /* input MUX */
  5063. /* FIXME: should be a matrix-type input source selection */
  5064. static struct hda_input_mux alc883_capture_source = {
  5065. .num_items = 4,
  5066. .items = {
  5067. { "Mic", 0x0 },
  5068. { "Front Mic", 0x1 },
  5069. { "Line", 0x2 },
  5070. { "CD", 0x4 },
  5071. },
  5072. };
  5073. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5074. .num_items = 2,
  5075. .items = {
  5076. { "Mic", 0x1 },
  5077. { "Line", 0x2 },
  5078. },
  5079. };
  5080. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5081. .num_items = 4,
  5082. .items = {
  5083. { "Mic", 0x0 },
  5084. { "iMic", 0x1 },
  5085. { "Line", 0x2 },
  5086. { "CD", 0x4 },
  5087. },
  5088. };
  5089. #define alc883_mux_enum_info alc_mux_enum_info
  5090. #define alc883_mux_enum_get alc_mux_enum_get
  5091. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5092. struct snd_ctl_elem_value *ucontrol)
  5093. {
  5094. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5095. struct alc_spec *spec = codec->spec;
  5096. const struct hda_input_mux *imux = spec->input_mux;
  5097. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5098. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5099. hda_nid_t nid = capture_mixers[adc_idx];
  5100. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5101. unsigned int i, idx;
  5102. idx = ucontrol->value.enumerated.item[0];
  5103. if (idx >= imux->num_items)
  5104. idx = imux->num_items - 1;
  5105. if (*cur_val == idx && !codec->in_resume)
  5106. return 0;
  5107. for (i = 0; i < imux->num_items; i++) {
  5108. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5109. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5110. v | (imux->items[i].index << 8));
  5111. }
  5112. *cur_val = idx;
  5113. return 1;
  5114. }
  5115. /*
  5116. * 2ch mode
  5117. */
  5118. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5119. { 2, NULL }
  5120. };
  5121. /*
  5122. * 2ch mode
  5123. */
  5124. static struct hda_verb alc883_3ST_ch2_init[] = {
  5125. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5126. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5127. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5128. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5129. { } /* end */
  5130. };
  5131. /*
  5132. * 6ch mode
  5133. */
  5134. static struct hda_verb alc883_3ST_ch6_init[] = {
  5135. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5136. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5137. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5138. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5139. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5140. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5141. { } /* end */
  5142. };
  5143. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5144. { 2, alc883_3ST_ch2_init },
  5145. { 6, alc883_3ST_ch6_init },
  5146. };
  5147. /*
  5148. * 6ch mode
  5149. */
  5150. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5151. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5152. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5153. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5154. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5155. { } /* end */
  5156. };
  5157. /*
  5158. * 8ch mode
  5159. */
  5160. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5161. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5162. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5163. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5164. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5165. { } /* end */
  5166. };
  5167. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5168. { 6, alc883_sixstack_ch6_init },
  5169. { 8, alc883_sixstack_ch8_init },
  5170. };
  5171. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5172. /* eanable EAPD on medion laptop */
  5173. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5174. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5175. { }
  5176. };
  5177. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5178. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5179. */
  5180. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5181. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5182. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5183. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5184. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5185. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5186. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5187. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5188. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5189. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5190. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5191. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5192. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5193. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5194. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5195. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5196. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5197. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5198. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5199. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5200. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5201. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5202. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5203. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5204. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5205. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5206. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5207. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5208. {
  5209. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5210. /* .name = "Capture Source", */
  5211. .name = "Input Source",
  5212. .count = 2,
  5213. .info = alc883_mux_enum_info,
  5214. .get = alc883_mux_enum_get,
  5215. .put = alc883_mux_enum_put,
  5216. },
  5217. { } /* end */
  5218. };
  5219. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5220. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5221. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5222. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5223. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5224. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5225. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5226. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5227. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5228. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5229. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5230. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5231. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5232. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5233. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5234. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5235. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5236. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5237. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5238. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5239. {
  5240. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5241. /* .name = "Capture Source", */
  5242. .name = "Input Source",
  5243. .count = 2,
  5244. .info = alc883_mux_enum_info,
  5245. .get = alc883_mux_enum_get,
  5246. .put = alc883_mux_enum_put,
  5247. },
  5248. { } /* end */
  5249. };
  5250. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5251. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5252. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5253. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5254. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5255. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5256. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5257. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5258. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5259. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5260. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5261. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5262. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5263. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5265. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5266. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5267. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5269. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5270. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5271. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5272. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5273. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5274. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5275. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5276. {
  5277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5278. /* .name = "Capture Source", */
  5279. .name = "Input Source",
  5280. .count = 2,
  5281. .info = alc883_mux_enum_info,
  5282. .get = alc883_mux_enum_get,
  5283. .put = alc883_mux_enum_put,
  5284. },
  5285. { } /* end */
  5286. };
  5287. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5288. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5289. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5292. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5294. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5295. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5296. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5297. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5298. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5299. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5300. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5302. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5303. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5304. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5306. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5307. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5308. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5309. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5310. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5311. {
  5312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5313. /* .name = "Capture Source", */
  5314. .name = "Input Source",
  5315. .count = 1,
  5316. .info = alc883_mux_enum_info,
  5317. .get = alc883_mux_enum_get,
  5318. .put = alc883_mux_enum_put,
  5319. },
  5320. { } /* end */
  5321. };
  5322. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5323. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5324. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5325. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5327. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5328. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5329. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5330. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5331. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5333. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5335. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5338. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5339. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5340. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5341. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5342. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5343. {
  5344. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5345. /* .name = "Capture Source", */
  5346. .name = "Input Source",
  5347. .count = 2,
  5348. .info = alc883_mux_enum_info,
  5349. .get = alc883_mux_enum_get,
  5350. .put = alc883_mux_enum_put,
  5351. },
  5352. { } /* end */
  5353. };
  5354. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5355. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5356. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5357. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5359. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5361. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5362. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5363. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5364. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5365. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5366. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5367. {
  5368. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5369. /* .name = "Capture Source", */
  5370. .name = "Input Source",
  5371. .count = 2,
  5372. .info = alc883_mux_enum_info,
  5373. .get = alc883_mux_enum_get,
  5374. .put = alc883_mux_enum_put,
  5375. },
  5376. { } /* end */
  5377. };
  5378. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5379. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5380. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5382. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5383. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5384. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5386. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5387. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5388. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5389. {
  5390. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5391. /* .name = "Capture Source", */
  5392. .name = "Input Source",
  5393. .count = 1,
  5394. .info = alc883_mux_enum_info,
  5395. .get = alc883_mux_enum_get,
  5396. .put = alc883_mux_enum_put,
  5397. },
  5398. { } /* end */
  5399. };
  5400. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5401. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5402. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5403. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5404. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5405. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5407. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5408. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5409. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5410. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5411. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5412. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5413. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5414. {
  5415. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5416. /* .name = "Capture Source", */
  5417. .name = "Input Source",
  5418. .count = 2,
  5419. .info = alc883_mux_enum_info,
  5420. .get = alc883_mux_enum_get,
  5421. .put = alc883_mux_enum_put,
  5422. },
  5423. { } /* end */
  5424. };
  5425. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5429. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5430. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5434. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5435. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5436. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5437. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5438. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5439. {
  5440. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5441. /* .name = "Capture Source", */
  5442. .name = "Input Source",
  5443. .count = 2,
  5444. .info = alc883_mux_enum_info,
  5445. .get = alc883_mux_enum_get,
  5446. .put = alc883_mux_enum_put,
  5447. },
  5448. { } /* end */
  5449. };
  5450. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5451. {
  5452. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5453. .name = "Channel Mode",
  5454. .info = alc_ch_mode_info,
  5455. .get = alc_ch_mode_get,
  5456. .put = alc_ch_mode_put,
  5457. },
  5458. { } /* end */
  5459. };
  5460. static struct hda_verb alc883_init_verbs[] = {
  5461. /* ADC1: mute amp left and right */
  5462. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5463. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5464. /* ADC2: mute amp left and right */
  5465. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5466. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5467. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5468. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5469. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5470. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5471. /* Rear mixer */
  5472. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5473. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5474. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5475. /* CLFE mixer */
  5476. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5477. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5478. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5479. /* Side mixer */
  5480. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5481. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5482. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5483. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5484. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5485. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5486. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5487. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5488. /* Front Pin: output 0 (0x0c) */
  5489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5491. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5492. /* Rear Pin: output 1 (0x0d) */
  5493. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5494. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5495. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5496. /* CLFE Pin: output 2 (0x0e) */
  5497. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5498. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5499. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5500. /* Side Pin: output 3 (0x0f) */
  5501. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5502. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5503. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5504. /* Mic (rear) pin: input vref at 80% */
  5505. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5506. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5507. /* Front Mic pin: input vref at 80% */
  5508. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5509. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5510. /* Line In pin: input */
  5511. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5512. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5513. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5514. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5515. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5516. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5517. /* CD pin widget for input */
  5518. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5519. /* FIXME: use matrix-type input source selection */
  5520. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5521. /* Input mixer2 */
  5522. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5523. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5524. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5525. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5526. /* Input mixer3 */
  5527. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5528. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5529. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5530. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5531. { }
  5532. };
  5533. static struct hda_verb alc883_tagra_verbs[] = {
  5534. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5535. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5536. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5537. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5538. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5539. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5540. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5541. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5542. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5543. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5544. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5545. { } /* end */
  5546. };
  5547. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5548. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5549. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5550. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5551. { } /* end */
  5552. };
  5553. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5554. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5555. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5556. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5557. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5558. { } /* end */
  5559. };
  5560. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5561. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5562. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5563. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5564. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5565. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5566. { } /* end */
  5567. };
  5568. /* toggle front-jack and RCA according to the hp-jack state */
  5569. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5570. {
  5571. unsigned int present;
  5572. present = snd_hda_codec_read(codec, 0x1b, 0,
  5573. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5574. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5575. 0x80, present ? 0x80 : 0);
  5576. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5577. 0x80, present ? 0x80 : 0);
  5578. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5579. 0x80, present ? 0x80 : 0);
  5580. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5581. 0x80, present ? 0x80 : 0);
  5582. }
  5583. /* toggle RCA according to the front-jack state */
  5584. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5585. {
  5586. unsigned int present;
  5587. present = snd_hda_codec_read(codec, 0x14, 0,
  5588. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5589. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5590. 0x80, present ? 0x80 : 0);
  5591. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5592. 0x80, present ? 0x80 : 0);
  5593. }
  5594. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5595. unsigned int res)
  5596. {
  5597. if ((res >> 26) == ALC880_HP_EVENT)
  5598. alc888_lenovo_ms7195_front_automute(codec);
  5599. if ((res >> 26) == ALC880_FRONT_EVENT)
  5600. alc888_lenovo_ms7195_rca_automute(codec);
  5601. }
  5602. static struct hda_verb alc883_medion_md2_verbs[] = {
  5603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5604. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5605. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5606. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5607. { } /* end */
  5608. };
  5609. /* toggle speaker-output according to the hp-jack state */
  5610. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5611. {
  5612. unsigned int present;
  5613. present = snd_hda_codec_read(codec, 0x14, 0,
  5614. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5615. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5616. 0x80, present ? 0x80 : 0);
  5617. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5618. 0x80, present ? 0x80 : 0);
  5619. }
  5620. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5621. unsigned int res)
  5622. {
  5623. if ((res >> 26) == ALC880_HP_EVENT)
  5624. alc883_medion_md2_automute(codec);
  5625. }
  5626. /* toggle speaker-output according to the hp-jack state */
  5627. static void alc883_tagra_automute(struct hda_codec *codec)
  5628. {
  5629. unsigned int present;
  5630. unsigned char bits;
  5631. present = snd_hda_codec_read(codec, 0x14, 0,
  5632. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5633. bits = present ? 0x80 : 0;
  5634. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5635. 0x80, bits);
  5636. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5637. 0x80, bits);
  5638. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5639. present ? 1 : 3);
  5640. }
  5641. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5642. {
  5643. if ((res >> 26) == ALC880_HP_EVENT)
  5644. alc883_tagra_automute(codec);
  5645. }
  5646. static void alc883_lenovo_101e_ispeaker_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, 0x15, 0, HDA_OUTPUT, 0,
  5654. 0x80, bits);
  5655. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5656. 0x80, bits);
  5657. }
  5658. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5659. {
  5660. unsigned int present;
  5661. unsigned char bits;
  5662. present = snd_hda_codec_read(codec, 0x1b, 0,
  5663. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5664. bits = present ? 0x80 : 0;
  5665. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5666. 0x80, bits);
  5667. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5668. 0x80, bits);
  5669. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5670. 0x80, bits);
  5671. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5672. 0x80, bits);
  5673. }
  5674. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5675. unsigned int res)
  5676. {
  5677. if ((res >> 26) == ALC880_HP_EVENT)
  5678. alc883_lenovo_101e_all_automute(codec);
  5679. if ((res >> 26) == ALC880_FRONT_EVENT)
  5680. alc883_lenovo_101e_ispeaker_automute(codec);
  5681. }
  5682. /*
  5683. * generic initialization of ADC, input mixers and output mixers
  5684. */
  5685. static struct hda_verb alc883_auto_init_verbs[] = {
  5686. /*
  5687. * Unmute ADC0-2 and set the default input to mic-in
  5688. */
  5689. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5690. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5691. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5692. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5693. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5694. * mixer widget
  5695. * Note: PASD motherboards uses the Line In 2 as the input for
  5696. * front panel mic (mic 2)
  5697. */
  5698. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5699. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5704. /*
  5705. * Set up output mixers (0x0c - 0x0f)
  5706. */
  5707. /* set vol=0 to output mixers */
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5709. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5710. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5711. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5712. /* set up input amps for analog loopback */
  5713. /* Amp Indices: DAC = 0, mixer = 1 */
  5714. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5715. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5716. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5717. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5718. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5719. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5720. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5721. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5722. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5723. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5724. /* FIXME: use matrix-type input source selection */
  5725. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5726. /* Input mixer1 */
  5727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5730. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5732. /* Input mixer2 */
  5733. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5736. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5737. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5738. { }
  5739. };
  5740. /* capture mixer elements */
  5741. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5742. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5743. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5744. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5745. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5746. {
  5747. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5748. /* The multiple "Capture Source" controls confuse alsamixer
  5749. * So call somewhat different..
  5750. * FIXME: the controls appear in the "playback" view!
  5751. */
  5752. /* .name = "Capture Source", */
  5753. .name = "Input Source",
  5754. .count = 2,
  5755. .info = alc882_mux_enum_info,
  5756. .get = alc882_mux_enum_get,
  5757. .put = alc882_mux_enum_put,
  5758. },
  5759. { } /* end */
  5760. };
  5761. /* pcm configuration: identiacal with ALC880 */
  5762. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5763. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5764. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5765. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5766. /*
  5767. * configuration and preset
  5768. */
  5769. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5770. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5771. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5772. [ALC883_3ST_6ch] = "3stack-6ch",
  5773. [ALC883_6ST_DIG] = "6stack-dig",
  5774. [ALC883_TARGA_DIG] = "targa-dig",
  5775. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5776. [ALC883_ACER] = "acer",
  5777. [ALC883_MEDION] = "medion",
  5778. [ALC883_MEDION_MD2] = "medion-md2",
  5779. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5780. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5781. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5782. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5783. [ALC883_AUTO] = "auto",
  5784. };
  5785. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5786. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5787. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5788. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5789. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5790. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5791. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5792. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5799. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5800. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5801. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5802. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5803. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5804. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5805. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5806. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5807. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5808. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5809. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5810. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5811. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5812. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5813. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5814. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5815. {}
  5816. };
  5817. static struct alc_config_preset alc883_presets[] = {
  5818. [ALC883_3ST_2ch_DIG] = {
  5819. .mixers = { alc883_3ST_2ch_mixer },
  5820. .init_verbs = { alc883_init_verbs },
  5821. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5822. .dac_nids = alc883_dac_nids,
  5823. .dig_out_nid = ALC883_DIGOUT_NID,
  5824. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5825. .adc_nids = alc883_adc_nids,
  5826. .dig_in_nid = ALC883_DIGIN_NID,
  5827. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5828. .channel_mode = alc883_3ST_2ch_modes,
  5829. .input_mux = &alc883_capture_source,
  5830. },
  5831. [ALC883_3ST_6ch_DIG] = {
  5832. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5833. .init_verbs = { alc883_init_verbs },
  5834. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5835. .dac_nids = alc883_dac_nids,
  5836. .dig_out_nid = ALC883_DIGOUT_NID,
  5837. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5838. .adc_nids = alc883_adc_nids,
  5839. .dig_in_nid = ALC883_DIGIN_NID,
  5840. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5841. .channel_mode = alc883_3ST_6ch_modes,
  5842. .need_dac_fix = 1,
  5843. .input_mux = &alc883_capture_source,
  5844. },
  5845. [ALC883_3ST_6ch] = {
  5846. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5847. .init_verbs = { alc883_init_verbs },
  5848. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5849. .dac_nids = alc883_dac_nids,
  5850. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5851. .adc_nids = alc883_adc_nids,
  5852. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5853. .channel_mode = alc883_3ST_6ch_modes,
  5854. .need_dac_fix = 1,
  5855. .input_mux = &alc883_capture_source,
  5856. },
  5857. [ALC883_6ST_DIG] = {
  5858. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5859. .init_verbs = { alc883_init_verbs },
  5860. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5861. .dac_nids = alc883_dac_nids,
  5862. .dig_out_nid = ALC883_DIGOUT_NID,
  5863. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5864. .adc_nids = alc883_adc_nids,
  5865. .dig_in_nid = ALC883_DIGIN_NID,
  5866. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5867. .channel_mode = alc883_sixstack_modes,
  5868. .input_mux = &alc883_capture_source,
  5869. },
  5870. [ALC883_TARGA_DIG] = {
  5871. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5872. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5873. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5874. .dac_nids = alc883_dac_nids,
  5875. .dig_out_nid = ALC883_DIGOUT_NID,
  5876. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5877. .adc_nids = alc883_adc_nids,
  5878. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5879. .channel_mode = alc883_3ST_6ch_modes,
  5880. .need_dac_fix = 1,
  5881. .input_mux = &alc883_capture_source,
  5882. .unsol_event = alc883_tagra_unsol_event,
  5883. .init_hook = alc883_tagra_automute,
  5884. },
  5885. [ALC883_TARGA_2ch_DIG] = {
  5886. .mixers = { alc883_tagra_2ch_mixer},
  5887. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5888. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5889. .dac_nids = alc883_dac_nids,
  5890. .dig_out_nid = ALC883_DIGOUT_NID,
  5891. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5892. .adc_nids = alc883_adc_nids,
  5893. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5894. .channel_mode = alc883_3ST_2ch_modes,
  5895. .input_mux = &alc883_capture_source,
  5896. .unsol_event = alc883_tagra_unsol_event,
  5897. .init_hook = alc883_tagra_automute,
  5898. },
  5899. [ALC883_ACER] = {
  5900. .mixers = { alc883_base_mixer,
  5901. alc883_chmode_mixer },
  5902. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5903. * and the headphone jack. Turn this on and rely on the
  5904. * standard mute methods whenever the user wants to turn
  5905. * these outputs off.
  5906. */
  5907. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5908. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5909. .dac_nids = alc883_dac_nids,
  5910. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5911. .adc_nids = alc883_adc_nids,
  5912. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5913. .channel_mode = alc883_3ST_2ch_modes,
  5914. .input_mux = &alc883_capture_source,
  5915. },
  5916. [ALC883_MEDION] = {
  5917. .mixers = { alc883_fivestack_mixer,
  5918. alc883_chmode_mixer },
  5919. .init_verbs = { alc883_init_verbs,
  5920. alc883_medion_eapd_verbs },
  5921. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5922. .dac_nids = alc883_dac_nids,
  5923. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5924. .adc_nids = alc883_adc_nids,
  5925. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5926. .channel_mode = alc883_sixstack_modes,
  5927. .input_mux = &alc883_capture_source,
  5928. },
  5929. [ALC883_MEDION_MD2] = {
  5930. .mixers = { alc883_medion_md2_mixer},
  5931. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5932. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5933. .dac_nids = alc883_dac_nids,
  5934. .dig_out_nid = ALC883_DIGOUT_NID,
  5935. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5936. .adc_nids = alc883_adc_nids,
  5937. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5938. .channel_mode = alc883_3ST_2ch_modes,
  5939. .input_mux = &alc883_capture_source,
  5940. .unsol_event = alc883_medion_md2_unsol_event,
  5941. .init_hook = alc883_medion_md2_automute,
  5942. },
  5943. [ALC883_LAPTOP_EAPD] = {
  5944. .mixers = { alc883_base_mixer,
  5945. alc883_chmode_mixer },
  5946. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5947. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5948. .dac_nids = alc883_dac_nids,
  5949. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5950. .adc_nids = alc883_adc_nids,
  5951. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5952. .channel_mode = alc883_3ST_2ch_modes,
  5953. .input_mux = &alc883_capture_source,
  5954. },
  5955. [ALC883_LENOVO_101E_2ch] = {
  5956. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5957. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5958. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5959. .dac_nids = alc883_dac_nids,
  5960. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5961. .adc_nids = alc883_adc_nids,
  5962. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5963. .channel_mode = alc883_3ST_2ch_modes,
  5964. .input_mux = &alc883_lenovo_101e_capture_source,
  5965. .unsol_event = alc883_lenovo_101e_unsol_event,
  5966. .init_hook = alc883_lenovo_101e_all_automute,
  5967. },
  5968. [ALC883_LENOVO_NB0763] = {
  5969. .mixers = { alc883_lenovo_nb0763_mixer },
  5970. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5971. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5972. .dac_nids = alc883_dac_nids,
  5973. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5974. .adc_nids = alc883_adc_nids,
  5975. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5976. .channel_mode = alc883_3ST_2ch_modes,
  5977. .need_dac_fix = 1,
  5978. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5979. .unsol_event = alc883_medion_md2_unsol_event,
  5980. .init_hook = alc883_medion_md2_automute,
  5981. },
  5982. [ALC888_LENOVO_MS7195_DIG] = {
  5983. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5984. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5985. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5986. .dac_nids = alc883_dac_nids,
  5987. .dig_out_nid = ALC883_DIGOUT_NID,
  5988. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5989. .adc_nids = alc883_adc_nids,
  5990. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5991. .channel_mode = alc883_3ST_6ch_modes,
  5992. .need_dac_fix = 1,
  5993. .input_mux = &alc883_capture_source,
  5994. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5995. .init_hook = alc888_lenovo_ms7195_front_automute,
  5996. },
  5997. };
  5998. /*
  5999. * BIOS auto configuration
  6000. */
  6001. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6002. hda_nid_t nid, int pin_type,
  6003. int dac_idx)
  6004. {
  6005. /* set as output */
  6006. struct alc_spec *spec = codec->spec;
  6007. int idx;
  6008. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6009. idx = 4;
  6010. else
  6011. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6012. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6013. pin_type);
  6014. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6015. AMP_OUT_UNMUTE);
  6016. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6017. }
  6018. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6019. {
  6020. struct alc_spec *spec = codec->spec;
  6021. int i;
  6022. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6023. for (i = 0; i <= HDA_SIDE; i++) {
  6024. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6025. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6026. if (nid)
  6027. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6028. i);
  6029. }
  6030. }
  6031. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6032. {
  6033. struct alc_spec *spec = codec->spec;
  6034. hda_nid_t pin;
  6035. pin = spec->autocfg.hp_pins[0];
  6036. if (pin) /* connect to front */
  6037. /* use dac 0 */
  6038. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6039. }
  6040. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6041. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6042. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6043. {
  6044. struct alc_spec *spec = codec->spec;
  6045. int i;
  6046. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6047. hda_nid_t nid = spec->autocfg.input_pins[i];
  6048. if (alc883_is_input_pin(nid)) {
  6049. snd_hda_codec_write(codec, nid, 0,
  6050. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6051. (i <= AUTO_PIN_FRONT_MIC ?
  6052. PIN_VREF80 : PIN_IN));
  6053. if (nid != ALC883_PIN_CD_NID)
  6054. snd_hda_codec_write(codec, nid, 0,
  6055. AC_VERB_SET_AMP_GAIN_MUTE,
  6056. AMP_OUT_MUTE);
  6057. }
  6058. }
  6059. }
  6060. /* almost identical with ALC880 parser... */
  6061. static int alc883_parse_auto_config(struct hda_codec *codec)
  6062. {
  6063. struct alc_spec *spec = codec->spec;
  6064. int err = alc880_parse_auto_config(codec);
  6065. if (err < 0)
  6066. return err;
  6067. else if (err > 0)
  6068. /* hack - override the init verbs */
  6069. spec->init_verbs[0] = alc883_auto_init_verbs;
  6070. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6071. spec->num_mixers++;
  6072. return err;
  6073. }
  6074. /* additional initialization for auto-configuration model */
  6075. static void alc883_auto_init(struct hda_codec *codec)
  6076. {
  6077. alc883_auto_init_multi_out(codec);
  6078. alc883_auto_init_hp_out(codec);
  6079. alc883_auto_init_analog_input(codec);
  6080. }
  6081. static int patch_alc883(struct hda_codec *codec)
  6082. {
  6083. struct alc_spec *spec;
  6084. int err, board_config;
  6085. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6086. if (spec == NULL)
  6087. return -ENOMEM;
  6088. codec->spec = spec;
  6089. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6090. alc883_models,
  6091. alc883_cfg_tbl);
  6092. if (board_config < 0) {
  6093. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6094. "trying auto-probe from BIOS...\n");
  6095. board_config = ALC883_AUTO;
  6096. }
  6097. if (board_config == ALC883_AUTO) {
  6098. /* automatic parse from the BIOS config */
  6099. err = alc883_parse_auto_config(codec);
  6100. if (err < 0) {
  6101. alc_free(codec);
  6102. return err;
  6103. } else if (!err) {
  6104. printk(KERN_INFO
  6105. "hda_codec: Cannot set up configuration "
  6106. "from BIOS. Using base mode...\n");
  6107. board_config = ALC883_3ST_2ch_DIG;
  6108. }
  6109. }
  6110. if (board_config != ALC883_AUTO)
  6111. setup_preset(spec, &alc883_presets[board_config]);
  6112. spec->stream_name_analog = "ALC883 Analog";
  6113. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6114. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6115. spec->stream_name_digital = "ALC883 Digital";
  6116. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6117. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6118. if (!spec->adc_nids && spec->input_mux) {
  6119. spec->adc_nids = alc883_adc_nids;
  6120. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6121. }
  6122. codec->patch_ops = alc_patch_ops;
  6123. if (board_config == ALC883_AUTO)
  6124. spec->init_hook = alc883_auto_init;
  6125. return 0;
  6126. }
  6127. /*
  6128. * ALC262 support
  6129. */
  6130. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6131. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6132. #define alc262_dac_nids alc260_dac_nids
  6133. #define alc262_adc_nids alc882_adc_nids
  6134. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6135. #define alc262_modes alc260_modes
  6136. #define alc262_capture_source alc882_capture_source
  6137. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6138. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6139. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6140. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6141. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6142. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6143. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6144. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6145. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6146. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6147. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6148. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6149. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6150. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6151. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6152. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6153. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6154. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6155. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6156. { } /* end */
  6157. };
  6158. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6159. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6160. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6161. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6162. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6163. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6164. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6165. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6166. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6167. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6168. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6169. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6170. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6171. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6172. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6173. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6174. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6175. { } /* end */
  6176. };
  6177. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6178. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6179. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6180. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6182. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6183. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6184. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6185. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6186. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6187. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6188. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6190. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6191. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6192. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6193. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6194. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6195. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6196. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6197. { } /* end */
  6198. };
  6199. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6200. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6201. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6202. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6203. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6204. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6205. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6207. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6208. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6209. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6210. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6211. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6212. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6213. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6214. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6215. { } /* end */
  6216. };
  6217. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6218. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6219. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6220. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6221. { } /* end */
  6222. };
  6223. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6224. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6225. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6226. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6227. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6228. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6229. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6230. { } /* end */
  6231. };
  6232. #define alc262_capture_mixer alc882_capture_mixer
  6233. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6234. /*
  6235. * generic initialization of ADC, input mixers and output mixers
  6236. */
  6237. static struct hda_verb alc262_init_verbs[] = {
  6238. /*
  6239. * Unmute ADC0-2 and set the default input to mic-in
  6240. */
  6241. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6242. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6243. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6244. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6245. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6246. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6247. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6248. * mixer widget
  6249. * Note: PASD motherboards uses the Line In 2 as the input for
  6250. * front panel mic (mic 2)
  6251. */
  6252. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6253. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6254. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6255. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6256. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6257. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6258. /*
  6259. * Set up output mixers (0x0c - 0x0e)
  6260. */
  6261. /* set vol=0 to output mixers */
  6262. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6263. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6265. /* set up input amps for analog loopback */
  6266. /* Amp Indices: DAC = 0, mixer = 1 */
  6267. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6268. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6269. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6270. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6271. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6272. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6273. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6274. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6275. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6276. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6277. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6278. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6279. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6280. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6281. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6282. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6283. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6284. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6285. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6286. /* FIXME: use matrix-type input source selection */
  6287. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6288. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6289. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6290. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6291. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6292. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6293. /* Input mixer2 */
  6294. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6295. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6298. /* Input mixer3 */
  6299. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6300. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6301. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6303. { }
  6304. };
  6305. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6306. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6307. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6308. {}
  6309. };
  6310. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6311. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6312. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6313. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6314. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6315. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6316. {}
  6317. };
  6318. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6319. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6320. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6321. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6322. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6323. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6324. };
  6325. /* mute/unmute internal speaker according to the hp jack and mute state */
  6326. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6327. {
  6328. struct alc_spec *spec = codec->spec;
  6329. unsigned int mute;
  6330. if (force || !spec->sense_updated) {
  6331. unsigned int present;
  6332. /* need to execute and sync at first */
  6333. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6334. present = snd_hda_codec_read(codec, 0x15, 0,
  6335. AC_VERB_GET_PIN_SENSE, 0);
  6336. spec->jack_present = (present & 0x80000000) != 0;
  6337. spec->sense_updated = 1;
  6338. }
  6339. if (spec->jack_present) {
  6340. /* mute internal speaker */
  6341. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6342. 0x80, 0x80);
  6343. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6344. 0x80, 0x80);
  6345. } else {
  6346. /* unmute internal speaker if necessary */
  6347. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6348. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6349. 0x80, mute & 0x80);
  6350. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6351. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6352. 0x80, mute & 0x80);
  6353. }
  6354. }
  6355. /* unsolicited event for HP jack sensing */
  6356. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6357. unsigned int res)
  6358. {
  6359. if ((res >> 26) != ALC880_HP_EVENT)
  6360. return;
  6361. alc262_hippo_automute(codec, 1);
  6362. }
  6363. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6364. {
  6365. struct alc_spec *spec = codec->spec;
  6366. unsigned int mute;
  6367. if (force || !spec->sense_updated) {
  6368. unsigned int present;
  6369. /* need to execute and sync at first */
  6370. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6371. present = snd_hda_codec_read(codec, 0x1b, 0,
  6372. AC_VERB_GET_PIN_SENSE, 0);
  6373. spec->jack_present = (present & 0x80000000) != 0;
  6374. spec->sense_updated = 1;
  6375. }
  6376. if (spec->jack_present) {
  6377. /* mute internal speaker */
  6378. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6379. 0x80, 0x80);
  6380. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6381. 0x80, 0x80);
  6382. } else {
  6383. /* unmute internal speaker if necessary */
  6384. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6385. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6386. 0x80, mute & 0x80);
  6387. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6388. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6389. 0x80, mute & 0x80);
  6390. }
  6391. }
  6392. /* unsolicited event for HP jack sensing */
  6393. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6394. unsigned int res)
  6395. {
  6396. if ((res >> 26) != ALC880_HP_EVENT)
  6397. return;
  6398. alc262_hippo1_automute(codec, 1);
  6399. }
  6400. /*
  6401. * fujitsu model
  6402. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6403. */
  6404. #define ALC_HP_EVENT 0x37
  6405. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6406. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6407. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6408. {}
  6409. };
  6410. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6411. .num_items = 2,
  6412. .items = {
  6413. { "Mic", 0x0 },
  6414. { "CD", 0x4 },
  6415. },
  6416. };
  6417. static struct hda_input_mux alc262_HP_capture_source = {
  6418. .num_items = 5,
  6419. .items = {
  6420. { "Mic", 0x0 },
  6421. { "Front Mic", 0x3 },
  6422. { "Line", 0x2 },
  6423. { "CD", 0x4 },
  6424. { "AUX IN", 0x6 },
  6425. },
  6426. };
  6427. /* mute/unmute internal speaker according to the hp jack and mute state */
  6428. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6429. {
  6430. struct alc_spec *spec = codec->spec;
  6431. unsigned int mute;
  6432. if (force || !spec->sense_updated) {
  6433. unsigned int present;
  6434. /* need to execute and sync at first */
  6435. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6436. present = snd_hda_codec_read(codec, 0x14, 0,
  6437. AC_VERB_GET_PIN_SENSE, 0);
  6438. spec->jack_present = (present & 0x80000000) != 0;
  6439. spec->sense_updated = 1;
  6440. }
  6441. if (spec->jack_present) {
  6442. /* mute internal speaker */
  6443. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6444. 0x80, 0x80);
  6445. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6446. 0x80, 0x80);
  6447. } else {
  6448. /* unmute internal speaker if necessary */
  6449. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6450. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6451. 0x80, mute & 0x80);
  6452. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6453. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6454. 0x80, mute & 0x80);
  6455. }
  6456. }
  6457. /* unsolicited event for HP jack sensing */
  6458. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6459. unsigned int res)
  6460. {
  6461. if ((res >> 26) != ALC_HP_EVENT)
  6462. return;
  6463. alc262_fujitsu_automute(codec, 1);
  6464. }
  6465. /* bind volumes of both NID 0x0c and 0x0d */
  6466. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6467. struct snd_ctl_elem_value *ucontrol)
  6468. {
  6469. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6470. long *valp = ucontrol->value.integer.value;
  6471. int change;
  6472. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6473. 0x7f, valp[0] & 0x7f);
  6474. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6475. 0x7f, valp[1] & 0x7f);
  6476. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6477. 0x7f, valp[0] & 0x7f);
  6478. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6479. 0x7f, valp[1] & 0x7f);
  6480. return change;
  6481. }
  6482. /* bind hp and internal speaker mute (with plug check) */
  6483. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6484. struct snd_ctl_elem_value *ucontrol)
  6485. {
  6486. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6487. long *valp = ucontrol->value.integer.value;
  6488. int change;
  6489. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6490. 0x80, valp[0] ? 0 : 0x80);
  6491. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6492. 0x80, valp[1] ? 0 : 0x80);
  6493. if (change || codec->in_resume)
  6494. alc262_fujitsu_automute(codec, codec->in_resume);
  6495. return change;
  6496. }
  6497. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6498. {
  6499. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6500. .name = "Master Playback Volume",
  6501. .info = snd_hda_mixer_amp_volume_info,
  6502. .get = snd_hda_mixer_amp_volume_get,
  6503. .put = alc262_fujitsu_master_vol_put,
  6504. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6505. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6506. },
  6507. {
  6508. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6509. .name = "Master Playback Switch",
  6510. .info = snd_hda_mixer_amp_switch_info,
  6511. .get = snd_hda_mixer_amp_switch_get,
  6512. .put = alc262_fujitsu_master_sw_put,
  6513. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6514. },
  6515. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6516. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6517. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6518. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6519. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6520. { } /* end */
  6521. };
  6522. /* additional init verbs for Benq laptops */
  6523. static struct hda_verb alc262_EAPD_verbs[] = {
  6524. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6525. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6526. {}
  6527. };
  6528. /* add playback controls from the parsed DAC table */
  6529. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6530. const struct auto_pin_cfg *cfg)
  6531. {
  6532. hda_nid_t nid;
  6533. int err;
  6534. spec->multiout.num_dacs = 1; /* only use one dac */
  6535. spec->multiout.dac_nids = spec->private_dac_nids;
  6536. spec->multiout.dac_nids[0] = 2;
  6537. nid = cfg->line_out_pins[0];
  6538. if (nid) {
  6539. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6540. "Front Playback Volume",
  6541. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6542. if (err < 0)
  6543. return err;
  6544. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6545. "Front Playback Switch",
  6546. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6547. if (err < 0)
  6548. return err;
  6549. }
  6550. nid = cfg->speaker_pins[0];
  6551. if (nid) {
  6552. if (nid == 0x16) {
  6553. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6554. "Speaker Playback Volume",
  6555. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6556. HDA_OUTPUT));
  6557. if (err < 0)
  6558. return err;
  6559. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6560. "Speaker Playback Switch",
  6561. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6562. HDA_OUTPUT));
  6563. if (err < 0)
  6564. return err;
  6565. } else {
  6566. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6567. "Speaker Playback Switch",
  6568. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6569. HDA_OUTPUT));
  6570. if (err < 0)
  6571. return err;
  6572. }
  6573. }
  6574. nid = cfg->hp_pins[0];
  6575. if (nid) {
  6576. /* spec->multiout.hp_nid = 2; */
  6577. if (nid == 0x16) {
  6578. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6579. "Headphone Playback Volume",
  6580. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6581. HDA_OUTPUT));
  6582. if (err < 0)
  6583. return err;
  6584. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6585. "Headphone Playback Switch",
  6586. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6587. HDA_OUTPUT));
  6588. if (err < 0)
  6589. return err;
  6590. } else {
  6591. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6592. "Headphone Playback Switch",
  6593. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6594. HDA_OUTPUT));
  6595. if (err < 0)
  6596. return err;
  6597. }
  6598. }
  6599. return 0;
  6600. }
  6601. /* identical with ALC880 */
  6602. #define alc262_auto_create_analog_input_ctls \
  6603. alc880_auto_create_analog_input_ctls
  6604. /*
  6605. * generic initialization of ADC, input mixers and output mixers
  6606. */
  6607. static struct hda_verb alc262_volume_init_verbs[] = {
  6608. /*
  6609. * Unmute ADC0-2 and set the default input to mic-in
  6610. */
  6611. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6612. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6613. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6614. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6615. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6616. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6617. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6618. * mixer widget
  6619. * Note: PASD motherboards uses the Line In 2 as the input for
  6620. * front panel mic (mic 2)
  6621. */
  6622. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6623. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6624. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6625. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6626. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6628. /*
  6629. * Set up output mixers (0x0c - 0x0f)
  6630. */
  6631. /* set vol=0 to output mixers */
  6632. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6633. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6634. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6635. /* set up input amps for analog loopback */
  6636. /* Amp Indices: DAC = 0, mixer = 1 */
  6637. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6638. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6639. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6640. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6641. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6642. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6643. /* FIXME: use matrix-type input source selection */
  6644. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6645. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6646. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6647. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6648. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6649. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6650. /* Input mixer2 */
  6651. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6652. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6653. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6654. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6655. /* Input mixer3 */
  6656. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6657. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6658. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6659. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6660. { }
  6661. };
  6662. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6663. /*
  6664. * Unmute ADC0-2 and set the default input to mic-in
  6665. */
  6666. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6667. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6668. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6669. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6670. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6671. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6672. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6673. * mixer widget
  6674. * Note: PASD motherboards uses the Line In 2 as the input for
  6675. * front panel mic (mic 2)
  6676. */
  6677. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6678. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6679. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6680. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6685. /*
  6686. * Set up output mixers (0x0c - 0x0e)
  6687. */
  6688. /* set vol=0 to output mixers */
  6689. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6690. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6692. /* set up input amps for analog loopback */
  6693. /* Amp Indices: DAC = 0, mixer = 1 */
  6694. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6695. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6696. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6697. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6698. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6699. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6700. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6701. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6702. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6703. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6704. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6705. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6706. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6707. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6708. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6709. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6710. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6711. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6712. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6713. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6714. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6715. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6716. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6717. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6718. /* FIXME: use matrix-type input source selection */
  6719. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6720. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6721. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6722. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6723. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6724. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6725. /* Input mixer2 */
  6726. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6730. /* Input mixer3 */
  6731. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6732. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6733. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6735. { }
  6736. };
  6737. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6738. /*
  6739. * Unmute ADC0-2 and set the default input to mic-in
  6740. */
  6741. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6742. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6743. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6744. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6745. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6746. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6747. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6748. * mixer widget
  6749. * Note: PASD motherboards uses the Line In 2 as the input for front
  6750. * panel mic (mic 2)
  6751. */
  6752. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6753. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6754. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6755. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6756. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6761. /*
  6762. * Set up output mixers (0x0c - 0x0e)
  6763. */
  6764. /* set vol=0 to output mixers */
  6765. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6766. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6767. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6768. /* set up input amps for analog loopback */
  6769. /* Amp Indices: DAC = 0, mixer = 1 */
  6770. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6771. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6772. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6773. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6774. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6775. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6776. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6777. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6778. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6779. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6780. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6781. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6782. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6783. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6784. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6785. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6786. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6787. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6788. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6789. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6790. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6791. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6792. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6793. /* FIXME: use matrix-type input source selection */
  6794. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6795. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6796. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6797. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6798. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6799. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6800. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6801. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6803. /* Input mixer2 */
  6804. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6805. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6806. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6809. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6810. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6811. /* Input mixer3 */
  6812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6814. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6816. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6817. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6818. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6819. { }
  6820. };
  6821. /* pcm configuration: identiacal with ALC880 */
  6822. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6823. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6824. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6825. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6826. /*
  6827. * BIOS auto configuration
  6828. */
  6829. static int alc262_parse_auto_config(struct hda_codec *codec)
  6830. {
  6831. struct alc_spec *spec = codec->spec;
  6832. int err;
  6833. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6834. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6835. alc262_ignore);
  6836. if (err < 0)
  6837. return err;
  6838. if (!spec->autocfg.line_outs)
  6839. return 0; /* can't find valid BIOS pin config */
  6840. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6841. if (err < 0)
  6842. return err;
  6843. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6844. if (err < 0)
  6845. return err;
  6846. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6847. if (spec->autocfg.dig_out_pin)
  6848. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6849. if (spec->autocfg.dig_in_pin)
  6850. spec->dig_in_nid = ALC262_DIGIN_NID;
  6851. if (spec->kctl_alloc)
  6852. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6853. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6854. spec->num_mux_defs = 1;
  6855. spec->input_mux = &spec->private_imux;
  6856. return 1;
  6857. }
  6858. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6859. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6860. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6861. /* init callback for auto-configuration model -- overriding the default init */
  6862. static void alc262_auto_init(struct hda_codec *codec)
  6863. {
  6864. alc262_auto_init_multi_out(codec);
  6865. alc262_auto_init_hp_out(codec);
  6866. alc262_auto_init_analog_input(codec);
  6867. }
  6868. /*
  6869. * configuration and preset
  6870. */
  6871. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6872. [ALC262_BASIC] = "basic",
  6873. [ALC262_HIPPO] = "hippo",
  6874. [ALC262_HIPPO_1] = "hippo_1",
  6875. [ALC262_FUJITSU] = "fujitsu",
  6876. [ALC262_HP_BPC] = "hp-bpc",
  6877. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6878. [ALC262_BENQ_ED8] = "benq",
  6879. [ALC262_BENQ_ED8] = "sony-assamd",
  6880. [ALC262_AUTO] = "auto",
  6881. };
  6882. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6883. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6884. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6885. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6886. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  6887. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  6888. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6889. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  6890. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6891. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  6892. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6893. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6894. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6895. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6896. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6897. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6898. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6899. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6900. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6901. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6902. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6903. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6904. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6905. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6906. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6907. {}
  6908. };
  6909. static struct alc_config_preset alc262_presets[] = {
  6910. [ALC262_BASIC] = {
  6911. .mixers = { alc262_base_mixer },
  6912. .init_verbs = { alc262_init_verbs },
  6913. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6914. .dac_nids = alc262_dac_nids,
  6915. .hp_nid = 0x03,
  6916. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6917. .channel_mode = alc262_modes,
  6918. .input_mux = &alc262_capture_source,
  6919. },
  6920. [ALC262_HIPPO] = {
  6921. .mixers = { alc262_base_mixer },
  6922. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6923. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6924. .dac_nids = alc262_dac_nids,
  6925. .hp_nid = 0x03,
  6926. .dig_out_nid = ALC262_DIGOUT_NID,
  6927. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6928. .channel_mode = alc262_modes,
  6929. .input_mux = &alc262_capture_source,
  6930. .unsol_event = alc262_hippo_unsol_event,
  6931. },
  6932. [ALC262_HIPPO_1] = {
  6933. .mixers = { alc262_hippo1_mixer },
  6934. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6935. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6936. .dac_nids = alc262_dac_nids,
  6937. .hp_nid = 0x02,
  6938. .dig_out_nid = ALC262_DIGOUT_NID,
  6939. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6940. .channel_mode = alc262_modes,
  6941. .input_mux = &alc262_capture_source,
  6942. .unsol_event = alc262_hippo1_unsol_event,
  6943. },
  6944. [ALC262_FUJITSU] = {
  6945. .mixers = { alc262_fujitsu_mixer },
  6946. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6947. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6948. .dac_nids = alc262_dac_nids,
  6949. .hp_nid = 0x03,
  6950. .dig_out_nid = ALC262_DIGOUT_NID,
  6951. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6952. .channel_mode = alc262_modes,
  6953. .input_mux = &alc262_fujitsu_capture_source,
  6954. .unsol_event = alc262_fujitsu_unsol_event,
  6955. },
  6956. [ALC262_HP_BPC] = {
  6957. .mixers = { alc262_HP_BPC_mixer },
  6958. .init_verbs = { alc262_HP_BPC_init_verbs },
  6959. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6960. .dac_nids = alc262_dac_nids,
  6961. .hp_nid = 0x03,
  6962. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6963. .channel_mode = alc262_modes,
  6964. .input_mux = &alc262_HP_capture_source,
  6965. },
  6966. [ALC262_HP_BPC_D7000_WF] = {
  6967. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6968. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6969. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6970. .dac_nids = alc262_dac_nids,
  6971. .hp_nid = 0x03,
  6972. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6973. .channel_mode = alc262_modes,
  6974. .input_mux = &alc262_HP_capture_source,
  6975. },
  6976. [ALC262_HP_BPC_D7000_WL] = {
  6977. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6978. alc262_HP_BPC_WildWest_option_mixer },
  6979. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6980. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6981. .dac_nids = alc262_dac_nids,
  6982. .hp_nid = 0x03,
  6983. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6984. .channel_mode = alc262_modes,
  6985. .input_mux = &alc262_HP_capture_source,
  6986. },
  6987. [ALC262_BENQ_ED8] = {
  6988. .mixers = { alc262_base_mixer },
  6989. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6990. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6991. .dac_nids = alc262_dac_nids,
  6992. .hp_nid = 0x03,
  6993. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6994. .channel_mode = alc262_modes,
  6995. .input_mux = &alc262_capture_source,
  6996. },
  6997. [ALC262_SONY_ASSAMD] = {
  6998. .mixers = { alc262_sony_mixer },
  6999. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7000. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7001. .dac_nids = alc262_dac_nids,
  7002. .hp_nid = 0x02,
  7003. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7004. .channel_mode = alc262_modes,
  7005. .input_mux = &alc262_capture_source,
  7006. .unsol_event = alc262_hippo_unsol_event,
  7007. },
  7008. };
  7009. static int patch_alc262(struct hda_codec *codec)
  7010. {
  7011. struct alc_spec *spec;
  7012. int board_config;
  7013. int err;
  7014. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7015. if (spec == NULL)
  7016. return -ENOMEM;
  7017. codec->spec = spec;
  7018. #if 0
  7019. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7020. * under-run
  7021. */
  7022. {
  7023. int tmp;
  7024. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7025. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7026. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7027. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7028. }
  7029. #endif
  7030. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7031. alc262_models,
  7032. alc262_cfg_tbl);
  7033. if (board_config < 0) {
  7034. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7035. "trying auto-probe from BIOS...\n");
  7036. board_config = ALC262_AUTO;
  7037. }
  7038. if (board_config == ALC262_AUTO) {
  7039. /* automatic parse from the BIOS config */
  7040. err = alc262_parse_auto_config(codec);
  7041. if (err < 0) {
  7042. alc_free(codec);
  7043. return err;
  7044. } else if (!err) {
  7045. printk(KERN_INFO
  7046. "hda_codec: Cannot set up configuration "
  7047. "from BIOS. Using base mode...\n");
  7048. board_config = ALC262_BASIC;
  7049. }
  7050. }
  7051. if (board_config != ALC262_AUTO)
  7052. setup_preset(spec, &alc262_presets[board_config]);
  7053. spec->stream_name_analog = "ALC262 Analog";
  7054. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7055. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7056. spec->stream_name_digital = "ALC262 Digital";
  7057. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7058. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7059. if (!spec->adc_nids && spec->input_mux) {
  7060. /* check whether NID 0x07 is valid */
  7061. unsigned int wcap = get_wcaps(codec, 0x07);
  7062. /* get type */
  7063. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7064. if (wcap != AC_WID_AUD_IN) {
  7065. spec->adc_nids = alc262_adc_nids_alt;
  7066. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7067. spec->mixers[spec->num_mixers] =
  7068. alc262_capture_alt_mixer;
  7069. spec->num_mixers++;
  7070. } else {
  7071. spec->adc_nids = alc262_adc_nids;
  7072. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7073. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7074. spec->num_mixers++;
  7075. }
  7076. }
  7077. codec->patch_ops = alc_patch_ops;
  7078. if (board_config == ALC262_AUTO)
  7079. spec->init_hook = alc262_auto_init;
  7080. return 0;
  7081. }
  7082. /*
  7083. * ALC268 channel source setting (2 channel)
  7084. */
  7085. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7086. #define alc268_modes alc260_modes
  7087. static hda_nid_t alc268_dac_nids[2] = {
  7088. /* front, hp */
  7089. 0x02, 0x03
  7090. };
  7091. static hda_nid_t alc268_adc_nids[2] = {
  7092. /* ADC0-1 */
  7093. 0x08, 0x07
  7094. };
  7095. static hda_nid_t alc268_adc_nids_alt[1] = {
  7096. /* ADC0 */
  7097. 0x08
  7098. };
  7099. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7100. /* output mixer control */
  7101. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7102. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7103. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7104. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7105. { }
  7106. };
  7107. /*
  7108. * generic initialization of ADC, input mixers and output mixers
  7109. */
  7110. static struct hda_verb alc268_base_init_verbs[] = {
  7111. /* Unmute DAC0-1 and set vol = 0 */
  7112. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7113. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7114. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7115. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7116. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7117. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7118. /*
  7119. * Set up output mixers (0x0c - 0x0e)
  7120. */
  7121. /* set vol=0 to output mixers */
  7122. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7123. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7124. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7125. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7126. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7127. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7128. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7129. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7130. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7131. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7132. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7133. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7134. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7135. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7136. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7137. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7138. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7139. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7140. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7141. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7142. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7143. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7144. /* FIXME: use matrix-type input source selection */
  7145. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7146. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7147. /* Input mixer2 */
  7148. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7149. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7150. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7151. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7152. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7153. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7154. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7155. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7156. { }
  7157. };
  7158. /*
  7159. * generic initialization of ADC, input mixers and output mixers
  7160. */
  7161. static struct hda_verb alc268_volume_init_verbs[] = {
  7162. /* set output DAC */
  7163. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7164. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7165. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7166. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7167. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7168. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7169. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7170. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7171. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7172. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7173. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7174. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7175. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7176. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7177. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7178. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7179. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7180. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7181. /* set PCBEEP vol = 0 */
  7182. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7183. { }
  7184. };
  7185. #define alc268_mux_enum_info alc_mux_enum_info
  7186. #define alc268_mux_enum_get alc_mux_enum_get
  7187. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7188. struct snd_ctl_elem_value *ucontrol)
  7189. {
  7190. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7191. struct alc_spec *spec = codec->spec;
  7192. const struct hda_input_mux *imux = spec->input_mux;
  7193. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7194. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7195. hda_nid_t nid = capture_mixers[adc_idx];
  7196. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7197. unsigned int i, idx;
  7198. idx = ucontrol->value.enumerated.item[0];
  7199. if (idx >= imux->num_items)
  7200. idx = imux->num_items - 1;
  7201. if (*cur_val == idx && !codec->in_resume)
  7202. return 0;
  7203. for (i = 0; i < imux->num_items; i++) {
  7204. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7205. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7206. v | (imux->items[i].index << 8));
  7207. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7208. idx );
  7209. }
  7210. *cur_val = idx;
  7211. return 1;
  7212. }
  7213. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7214. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7215. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7216. {
  7217. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7218. /* The multiple "Capture Source" controls confuse alsamixer
  7219. * So call somewhat different..
  7220. * FIXME: the controls appear in the "playback" view!
  7221. */
  7222. /* .name = "Capture Source", */
  7223. .name = "Input Source",
  7224. .count = 1,
  7225. .info = alc268_mux_enum_info,
  7226. .get = alc268_mux_enum_get,
  7227. .put = alc268_mux_enum_put,
  7228. },
  7229. { } /* end */
  7230. };
  7231. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7232. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7233. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7234. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7235. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7236. {
  7237. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7238. /* The multiple "Capture Source" controls confuse alsamixer
  7239. * So call somewhat different..
  7240. * FIXME: the controls appear in the "playback" view!
  7241. */
  7242. /* .name = "Capture Source", */
  7243. .name = "Input Source",
  7244. .count = 2,
  7245. .info = alc268_mux_enum_info,
  7246. .get = alc268_mux_enum_get,
  7247. .put = alc268_mux_enum_put,
  7248. },
  7249. { } /* end */
  7250. };
  7251. static struct hda_input_mux alc268_capture_source = {
  7252. .num_items = 4,
  7253. .items = {
  7254. { "Mic", 0x0 },
  7255. { "Front Mic", 0x1 },
  7256. { "Line", 0x2 },
  7257. { "CD", 0x3 },
  7258. },
  7259. };
  7260. /* create input playback/capture controls for the given pin */
  7261. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7262. const char *ctlname, int idx)
  7263. {
  7264. char name[32];
  7265. int err;
  7266. sprintf(name, "%s Playback Volume", ctlname);
  7267. if (nid == 0x14) {
  7268. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7269. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7270. HDA_OUTPUT));
  7271. if (err < 0)
  7272. return err;
  7273. } else if (nid == 0x15) {
  7274. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7275. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7276. HDA_OUTPUT));
  7277. if (err < 0)
  7278. return err;
  7279. } else
  7280. return -1;
  7281. sprintf(name, "%s Playback Switch", ctlname);
  7282. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7283. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7284. if (err < 0)
  7285. return err;
  7286. return 0;
  7287. }
  7288. /* add playback controls from the parsed DAC table */
  7289. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7290. const struct auto_pin_cfg *cfg)
  7291. {
  7292. hda_nid_t nid;
  7293. int err;
  7294. spec->multiout.num_dacs = 2; /* only use one dac */
  7295. spec->multiout.dac_nids = spec->private_dac_nids;
  7296. spec->multiout.dac_nids[0] = 2;
  7297. spec->multiout.dac_nids[1] = 3;
  7298. nid = cfg->line_out_pins[0];
  7299. if (nid)
  7300. alc268_new_analog_output(spec, nid, "Front", 0);
  7301. nid = cfg->speaker_pins[0];
  7302. if (nid == 0x1d) {
  7303. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7304. "Speaker Playback Volume",
  7305. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7306. if (err < 0)
  7307. return err;
  7308. }
  7309. nid = cfg->hp_pins[0];
  7310. if (nid)
  7311. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7312. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7313. if (nid == 0x16) {
  7314. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7315. "Mono Playback Switch",
  7316. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7317. if (err < 0)
  7318. return err;
  7319. }
  7320. return 0;
  7321. }
  7322. /* create playback/capture controls for input pins */
  7323. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7324. const struct auto_pin_cfg *cfg)
  7325. {
  7326. struct hda_input_mux *imux = &spec->private_imux;
  7327. int i, idx1;
  7328. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7329. switch(cfg->input_pins[i]) {
  7330. case 0x18:
  7331. idx1 = 0; /* Mic 1 */
  7332. break;
  7333. case 0x19:
  7334. idx1 = 1; /* Mic 2 */
  7335. break;
  7336. case 0x1a:
  7337. idx1 = 2; /* Line In */
  7338. break;
  7339. case 0x1c:
  7340. idx1 = 3; /* CD */
  7341. break;
  7342. default:
  7343. continue;
  7344. }
  7345. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7346. imux->items[imux->num_items].index = idx1;
  7347. imux->num_items++;
  7348. }
  7349. return 0;
  7350. }
  7351. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7352. {
  7353. struct alc_spec *spec = codec->spec;
  7354. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7355. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7356. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7357. unsigned int dac_vol1, dac_vol2;
  7358. if (speaker_nid) {
  7359. snd_hda_codec_write(codec, speaker_nid, 0,
  7360. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7361. snd_hda_codec_write(codec, 0x0f, 0,
  7362. AC_VERB_SET_AMP_GAIN_MUTE,
  7363. AMP_IN_UNMUTE(1));
  7364. snd_hda_codec_write(codec, 0x10, 0,
  7365. AC_VERB_SET_AMP_GAIN_MUTE,
  7366. AMP_IN_UNMUTE(1));
  7367. } else {
  7368. snd_hda_codec_write(codec, 0x0f, 0,
  7369. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7370. snd_hda_codec_write(codec, 0x10, 0,
  7371. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7372. }
  7373. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7374. if (line_nid == 0x14)
  7375. dac_vol2 = AMP_OUT_ZERO;
  7376. else if (line_nid == 0x15)
  7377. dac_vol1 = AMP_OUT_ZERO;
  7378. if (hp_nid == 0x14)
  7379. dac_vol2 = AMP_OUT_ZERO;
  7380. else if (hp_nid == 0x15)
  7381. dac_vol1 = AMP_OUT_ZERO;
  7382. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7383. spec->autocfg.line_out_pins[1] != 0x16 ||
  7384. spec->autocfg.line_out_pins[2] != 0x16)
  7385. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7386. snd_hda_codec_write(codec, 0x02, 0,
  7387. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7388. snd_hda_codec_write(codec, 0x03, 0,
  7389. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7390. }
  7391. /* pcm configuration: identiacal with ALC880 */
  7392. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7393. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7394. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7395. /*
  7396. * BIOS auto configuration
  7397. */
  7398. static int alc268_parse_auto_config(struct hda_codec *codec)
  7399. {
  7400. struct alc_spec *spec = codec->spec;
  7401. int err;
  7402. static hda_nid_t alc268_ignore[] = { 0 };
  7403. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7404. alc268_ignore);
  7405. if (err < 0)
  7406. return err;
  7407. if (!spec->autocfg.line_outs)
  7408. return 0; /* can't find valid BIOS pin config */
  7409. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7410. if (err < 0)
  7411. return err;
  7412. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7413. if (err < 0)
  7414. return err;
  7415. spec->multiout.max_channels = 2;
  7416. /* digital only support output */
  7417. if (spec->autocfg.dig_out_pin)
  7418. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7419. if (spec->kctl_alloc)
  7420. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7421. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7422. spec->num_mux_defs = 1;
  7423. spec->input_mux = &spec->private_imux;
  7424. return 1;
  7425. }
  7426. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7427. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7428. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7429. /* init callback for auto-configuration model -- overriding the default init */
  7430. static void alc268_auto_init(struct hda_codec *codec)
  7431. {
  7432. alc268_auto_init_multi_out(codec);
  7433. alc268_auto_init_hp_out(codec);
  7434. alc268_auto_init_mono_speaker_out(codec);
  7435. alc268_auto_init_analog_input(codec);
  7436. }
  7437. /*
  7438. * configuration and preset
  7439. */
  7440. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7441. [ALC268_3ST] = "3stack",
  7442. [ALC268_AUTO] = "auto",
  7443. };
  7444. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7445. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7446. {}
  7447. };
  7448. static struct alc_config_preset alc268_presets[] = {
  7449. [ALC268_3ST] = {
  7450. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7451. .init_verbs = { alc268_base_init_verbs },
  7452. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7453. .dac_nids = alc268_dac_nids,
  7454. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7455. .adc_nids = alc268_adc_nids_alt,
  7456. .hp_nid = 0x03,
  7457. .dig_out_nid = ALC268_DIGOUT_NID,
  7458. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7459. .channel_mode = alc268_modes,
  7460. .input_mux = &alc268_capture_source,
  7461. },
  7462. };
  7463. static int patch_alc268(struct hda_codec *codec)
  7464. {
  7465. struct alc_spec *spec;
  7466. int board_config;
  7467. int err;
  7468. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7469. if (spec == NULL)
  7470. return -ENOMEM;
  7471. codec->spec = spec;
  7472. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7473. alc268_models,
  7474. alc268_cfg_tbl);
  7475. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7476. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7477. "trying auto-probe from BIOS...\n");
  7478. board_config = ALC268_AUTO;
  7479. }
  7480. if (board_config == ALC268_AUTO) {
  7481. /* automatic parse from the BIOS config */
  7482. err = alc268_parse_auto_config(codec);
  7483. if (err < 0) {
  7484. alc_free(codec);
  7485. return err;
  7486. } else if (!err) {
  7487. printk(KERN_INFO
  7488. "hda_codec: Cannot set up configuration "
  7489. "from BIOS. Using base mode...\n");
  7490. board_config = ALC268_3ST;
  7491. }
  7492. }
  7493. if (board_config != ALC268_AUTO)
  7494. setup_preset(spec, &alc268_presets[board_config]);
  7495. spec->stream_name_analog = "ALC268 Analog";
  7496. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7497. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7498. spec->stream_name_digital = "ALC268 Digital";
  7499. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7500. if (board_config == ALC268_AUTO) {
  7501. if (!spec->adc_nids && spec->input_mux) {
  7502. /* check whether NID 0x07 is valid */
  7503. unsigned int wcap = get_wcaps(codec, 0x07);
  7504. /* get type */
  7505. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7506. if (wcap != AC_WID_AUD_IN) {
  7507. spec->adc_nids = alc268_adc_nids_alt;
  7508. spec->num_adc_nids =
  7509. ARRAY_SIZE(alc268_adc_nids_alt);
  7510. spec->mixers[spec->num_mixers] =
  7511. alc268_capture_alt_mixer;
  7512. spec->num_mixers++;
  7513. } else {
  7514. spec->adc_nids = alc268_adc_nids;
  7515. spec->num_adc_nids =
  7516. ARRAY_SIZE(alc268_adc_nids);
  7517. spec->mixers[spec->num_mixers] =
  7518. alc268_capture_mixer;
  7519. spec->num_mixers++;
  7520. }
  7521. }
  7522. }
  7523. codec->patch_ops = alc_patch_ops;
  7524. if (board_config == ALC268_AUTO)
  7525. spec->init_hook = alc268_auto_init;
  7526. return 0;
  7527. }
  7528. /*
  7529. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7530. */
  7531. /*
  7532. * set the path ways for 2 channel output
  7533. * need to set the codec line out and mic 1 pin widgets to inputs
  7534. */
  7535. static struct hda_verb alc861_threestack_ch2_init[] = {
  7536. /* set pin widget 1Ah (line in) for input */
  7537. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7538. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7539. * the vref
  7540. */
  7541. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7542. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7543. #if 0
  7544. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7545. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7546. #endif
  7547. { } /* end */
  7548. };
  7549. /*
  7550. * 6ch mode
  7551. * need to set the codec line out and mic 1 pin widgets to outputs
  7552. */
  7553. static struct hda_verb alc861_threestack_ch6_init[] = {
  7554. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7555. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7556. /* set pin widget 18h (mic1) for output (CLFE)*/
  7557. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7558. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7559. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7560. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7561. #if 0
  7562. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7563. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7564. #endif
  7565. { } /* end */
  7566. };
  7567. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7568. { 2, alc861_threestack_ch2_init },
  7569. { 6, alc861_threestack_ch6_init },
  7570. };
  7571. /* Set mic1 as input and unmute the mixer */
  7572. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7573. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7574. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7575. { } /* end */
  7576. };
  7577. /* Set mic1 as output and mute mixer */
  7578. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7579. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7580. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7581. { } /* end */
  7582. };
  7583. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7584. { 2, alc861_uniwill_m31_ch2_init },
  7585. { 4, alc861_uniwill_m31_ch4_init },
  7586. };
  7587. /* Set mic1 and line-in as input and unmute the mixer */
  7588. static struct hda_verb alc861_asus_ch2_init[] = {
  7589. /* set pin widget 1Ah (line in) for input */
  7590. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7591. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7592. * the vref
  7593. */
  7594. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7595. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7596. #if 0
  7597. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7598. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7599. #endif
  7600. { } /* end */
  7601. };
  7602. /* Set mic1 nad line-in as output and mute mixer */
  7603. static struct hda_verb alc861_asus_ch6_init[] = {
  7604. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7605. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7606. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7607. /* set pin widget 18h (mic1) for output (CLFE)*/
  7608. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7609. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7610. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7611. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7612. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7613. #if 0
  7614. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7615. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7616. #endif
  7617. { } /* end */
  7618. };
  7619. static struct hda_channel_mode alc861_asus_modes[2] = {
  7620. { 2, alc861_asus_ch2_init },
  7621. { 6, alc861_asus_ch6_init },
  7622. };
  7623. /* patch-ALC861 */
  7624. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7625. /* output mixer control */
  7626. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7627. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7628. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7629. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7630. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7631. /*Input mixer control */
  7632. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7633. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7634. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7635. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7636. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7637. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7638. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7639. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7640. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7641. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7642. /* Capture mixer control */
  7643. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7644. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7645. {
  7646. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7647. .name = "Capture Source",
  7648. .count = 1,
  7649. .info = alc_mux_enum_info,
  7650. .get = alc_mux_enum_get,
  7651. .put = alc_mux_enum_put,
  7652. },
  7653. { } /* end */
  7654. };
  7655. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7656. /* output mixer control */
  7657. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7658. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7659. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7660. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7661. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7662. /* Input mixer control */
  7663. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7664. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7665. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7666. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7667. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7668. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7670. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7671. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7672. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7673. /* Capture mixer control */
  7674. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7675. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7676. {
  7677. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7678. .name = "Capture Source",
  7679. .count = 1,
  7680. .info = alc_mux_enum_info,
  7681. .get = alc_mux_enum_get,
  7682. .put = alc_mux_enum_put,
  7683. },
  7684. {
  7685. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7686. .name = "Channel Mode",
  7687. .info = alc_ch_mode_info,
  7688. .get = alc_ch_mode_get,
  7689. .put = alc_ch_mode_put,
  7690. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7691. },
  7692. { } /* end */
  7693. };
  7694. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7695. /* output mixer control */
  7696. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7697. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7698. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7699. /*Capture mixer control */
  7700. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7701. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7702. {
  7703. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7704. .name = "Capture Source",
  7705. .count = 1,
  7706. .info = alc_mux_enum_info,
  7707. .get = alc_mux_enum_get,
  7708. .put = alc_mux_enum_put,
  7709. },
  7710. { } /* end */
  7711. };
  7712. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7713. /* output mixer control */
  7714. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7715. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7716. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7717. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7718. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7719. /* Input mixer control */
  7720. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7721. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7722. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7723. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7724. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7725. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7726. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7727. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7728. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7729. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7730. /* Capture mixer control */
  7731. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7732. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7733. {
  7734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7735. .name = "Capture Source",
  7736. .count = 1,
  7737. .info = alc_mux_enum_info,
  7738. .get = alc_mux_enum_get,
  7739. .put = alc_mux_enum_put,
  7740. },
  7741. {
  7742. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7743. .name = "Channel Mode",
  7744. .info = alc_ch_mode_info,
  7745. .get = alc_ch_mode_get,
  7746. .put = alc_ch_mode_put,
  7747. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7748. },
  7749. { } /* end */
  7750. };
  7751. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7752. /* output mixer control */
  7753. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7754. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7755. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7756. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7757. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7758. /* Input mixer control */
  7759. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7760. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7761. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7762. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7763. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7764. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7765. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7766. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7767. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7768. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7769. /* Capture mixer control */
  7770. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7771. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7772. {
  7773. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7774. .name = "Capture Source",
  7775. .count = 1,
  7776. .info = alc_mux_enum_info,
  7777. .get = alc_mux_enum_get,
  7778. .put = alc_mux_enum_put,
  7779. },
  7780. {
  7781. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7782. .name = "Channel Mode",
  7783. .info = alc_ch_mode_info,
  7784. .get = alc_ch_mode_get,
  7785. .put = alc_ch_mode_put,
  7786. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7787. },
  7788. { }
  7789. };
  7790. /* additional mixer */
  7791. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7792. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7793. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7794. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7795. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7796. { }
  7797. };
  7798. /*
  7799. * generic initialization of ADC, input mixers and output mixers
  7800. */
  7801. static struct hda_verb alc861_base_init_verbs[] = {
  7802. /*
  7803. * Unmute ADC0 and set the default input to mic-in
  7804. */
  7805. /* port-A for surround (rear panel) */
  7806. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7807. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7808. /* port-B for mic-in (rear panel) with vref */
  7809. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7810. /* port-C for line-in (rear panel) */
  7811. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7812. /* port-D for Front */
  7813. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7814. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7815. /* port-E for HP out (front panel) */
  7816. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7817. /* route front PCM to HP */
  7818. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7819. /* port-F for mic-in (front panel) with vref */
  7820. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7821. /* port-G for CLFE (rear panel) */
  7822. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7823. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7824. /* port-H for side (rear panel) */
  7825. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7826. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7827. /* CD-in */
  7828. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7829. /* route front mic to ADC1*/
  7830. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7832. /* Unmute DAC0~3 & spdif out*/
  7833. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7834. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7835. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7836. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7837. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7838. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7839. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7840. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7841. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7842. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7843. /* Unmute Stereo Mixer 15 */
  7844. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7845. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7846. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7847. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7848. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7849. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7850. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7851. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7852. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7853. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7854. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7855. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7856. /* hp used DAC 3 (Front) */
  7857. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7858. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7859. { }
  7860. };
  7861. static struct hda_verb alc861_threestack_init_verbs[] = {
  7862. /*
  7863. * Unmute ADC0 and set the default input to mic-in
  7864. */
  7865. /* port-A for surround (rear panel) */
  7866. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7867. /* port-B for mic-in (rear panel) with vref */
  7868. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7869. /* port-C for line-in (rear panel) */
  7870. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7871. /* port-D for Front */
  7872. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7873. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7874. /* port-E for HP out (front panel) */
  7875. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7876. /* route front PCM to HP */
  7877. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7878. /* port-F for mic-in (front panel) with vref */
  7879. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7880. /* port-G for CLFE (rear panel) */
  7881. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7882. /* port-H for side (rear panel) */
  7883. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7884. /* CD-in */
  7885. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7886. /* route front mic to ADC1*/
  7887. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7888. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7889. /* Unmute DAC0~3 & spdif out*/
  7890. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7891. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7892. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7893. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7894. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7895. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7896. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7897. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7898. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7899. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7900. /* Unmute Stereo Mixer 15 */
  7901. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7902. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7903. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7904. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7905. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7906. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7907. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7908. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7909. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7910. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7911. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7912. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7913. /* hp used DAC 3 (Front) */
  7914. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7915. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7916. { }
  7917. };
  7918. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7919. /*
  7920. * Unmute ADC0 and set the default input to mic-in
  7921. */
  7922. /* port-A for surround (rear panel) */
  7923. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7924. /* port-B for mic-in (rear panel) with vref */
  7925. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7926. /* port-C for line-in (rear panel) */
  7927. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7928. /* port-D for Front */
  7929. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7930. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7931. /* port-E for HP out (front panel) */
  7932. /* this has to be set to VREF80 */
  7933. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7934. /* route front PCM to HP */
  7935. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7936. /* port-F for mic-in (front panel) with vref */
  7937. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7938. /* port-G for CLFE (rear panel) */
  7939. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7940. /* port-H for side (rear panel) */
  7941. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7942. /* CD-in */
  7943. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7944. /* route front mic to ADC1*/
  7945. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7946. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7947. /* Unmute DAC0~3 & spdif out*/
  7948. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7949. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7950. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7951. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7952. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7953. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7954. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7955. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7956. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7957. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7958. /* Unmute Stereo Mixer 15 */
  7959. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7960. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7961. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7963. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7964. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7965. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7966. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7967. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7968. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7969. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7970. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7971. /* hp used DAC 3 (Front) */
  7972. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7973. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7974. { }
  7975. };
  7976. static struct hda_verb alc861_asus_init_verbs[] = {
  7977. /*
  7978. * Unmute ADC0 and set the default input to mic-in
  7979. */
  7980. /* port-A for surround (rear panel)
  7981. * according to codec#0 this is the HP jack
  7982. */
  7983. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7984. /* route front PCM to HP */
  7985. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7986. /* port-B for mic-in (rear panel) with vref */
  7987. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7988. /* port-C for line-in (rear panel) */
  7989. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7990. /* port-D for Front */
  7991. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7992. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7993. /* port-E for HP out (front panel) */
  7994. /* this has to be set to VREF80 */
  7995. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7996. /* route front PCM to HP */
  7997. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7998. /* port-F for mic-in (front panel) with vref */
  7999. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8000. /* port-G for CLFE (rear panel) */
  8001. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8002. /* port-H for side (rear panel) */
  8003. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8004. /* CD-in */
  8005. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8006. /* route front mic to ADC1*/
  8007. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8008. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8009. /* Unmute DAC0~3 & spdif out*/
  8010. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8011. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8012. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8013. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8014. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8015. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8016. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8017. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8018. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8019. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8020. /* Unmute Stereo Mixer 15 */
  8021. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8022. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8023. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8024. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8025. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8026. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8027. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8028. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8029. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8030. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8031. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8032. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8033. /* hp used DAC 3 (Front) */
  8034. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8035. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8036. { }
  8037. };
  8038. /* additional init verbs for ASUS laptops */
  8039. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8040. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8041. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8042. { }
  8043. };
  8044. /*
  8045. * generic initialization of ADC, input mixers and output mixers
  8046. */
  8047. static struct hda_verb alc861_auto_init_verbs[] = {
  8048. /*
  8049. * Unmute ADC0 and set the default input to mic-in
  8050. */
  8051. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8052. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8053. /* Unmute DAC0~3 & spdif out*/
  8054. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8055. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8056. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8057. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8059. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8060. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8061. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8062. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8063. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8064. /* Unmute Stereo Mixer 15 */
  8065. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8066. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8067. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8068. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8069. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8070. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8071. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8072. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8073. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8074. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8075. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8076. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8077. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8078. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8079. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8080. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8081. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8082. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8083. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8084. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8085. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8086. { }
  8087. };
  8088. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8089. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8090. { }
  8091. };
  8092. /* toggle speaker-output according to the hp-jack state */
  8093. static void alc861_toshiba_automute(struct hda_codec *codec)
  8094. {
  8095. unsigned int present;
  8096. present = snd_hda_codec_read(codec, 0x0f, 0,
  8097. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8098. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8099. 0x80, present ? 0x80 : 0);
  8100. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8101. 0x80, present ? 0x80 : 0);
  8102. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8103. 0x80, present ? 0 : 0x80);
  8104. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8105. 0x80, present ? 0 : 0x80);
  8106. }
  8107. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8108. unsigned int res)
  8109. {
  8110. if ((res >> 26) == ALC880_HP_EVENT)
  8111. alc861_toshiba_automute(codec);
  8112. }
  8113. /* pcm configuration: identiacal with ALC880 */
  8114. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8115. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8116. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8117. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8118. #define ALC861_DIGOUT_NID 0x07
  8119. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8120. { 8, NULL }
  8121. };
  8122. static hda_nid_t alc861_dac_nids[4] = {
  8123. /* front, surround, clfe, side */
  8124. 0x03, 0x06, 0x05, 0x04
  8125. };
  8126. static hda_nid_t alc660_dac_nids[3] = {
  8127. /* front, clfe, surround */
  8128. 0x03, 0x05, 0x06
  8129. };
  8130. static hda_nid_t alc861_adc_nids[1] = {
  8131. /* ADC0-2 */
  8132. 0x08,
  8133. };
  8134. static struct hda_input_mux alc861_capture_source = {
  8135. .num_items = 5,
  8136. .items = {
  8137. { "Mic", 0x0 },
  8138. { "Front Mic", 0x3 },
  8139. { "Line", 0x1 },
  8140. { "CD", 0x4 },
  8141. { "Mixer", 0x5 },
  8142. },
  8143. };
  8144. /* fill in the dac_nids table from the parsed pin configuration */
  8145. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8146. const struct auto_pin_cfg *cfg)
  8147. {
  8148. int i;
  8149. hda_nid_t nid;
  8150. spec->multiout.dac_nids = spec->private_dac_nids;
  8151. for (i = 0; i < cfg->line_outs; i++) {
  8152. nid = cfg->line_out_pins[i];
  8153. if (nid) {
  8154. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8155. continue;
  8156. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8157. }
  8158. }
  8159. spec->multiout.num_dacs = cfg->line_outs;
  8160. return 0;
  8161. }
  8162. /* add playback controls from the parsed DAC table */
  8163. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8164. const struct auto_pin_cfg *cfg)
  8165. {
  8166. char name[32];
  8167. static const char *chname[4] = {
  8168. "Front", "Surround", NULL /*CLFE*/, "Side"
  8169. };
  8170. hda_nid_t nid;
  8171. int i, idx, err;
  8172. for (i = 0; i < cfg->line_outs; i++) {
  8173. nid = spec->multiout.dac_nids[i];
  8174. if (!nid)
  8175. continue;
  8176. if (nid == 0x05) {
  8177. /* Center/LFE */
  8178. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8179. "Center Playback Switch",
  8180. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8181. HDA_OUTPUT));
  8182. if (err < 0)
  8183. return err;
  8184. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8185. "LFE Playback Switch",
  8186. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8187. HDA_OUTPUT));
  8188. if (err < 0)
  8189. return err;
  8190. } else {
  8191. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8192. idx++)
  8193. if (nid == alc861_dac_nids[idx])
  8194. break;
  8195. sprintf(name, "%s Playback Switch", chname[idx]);
  8196. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8197. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8198. HDA_OUTPUT));
  8199. if (err < 0)
  8200. return err;
  8201. }
  8202. }
  8203. return 0;
  8204. }
  8205. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8206. {
  8207. int err;
  8208. hda_nid_t nid;
  8209. if (!pin)
  8210. return 0;
  8211. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8212. nid = 0x03;
  8213. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8214. "Headphone Playback Switch",
  8215. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8216. if (err < 0)
  8217. return err;
  8218. spec->multiout.hp_nid = nid;
  8219. }
  8220. return 0;
  8221. }
  8222. /* create playback/capture controls for input pins */
  8223. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8224. const struct auto_pin_cfg *cfg)
  8225. {
  8226. struct hda_input_mux *imux = &spec->private_imux;
  8227. int i, err, idx, idx1;
  8228. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8229. switch (cfg->input_pins[i]) {
  8230. case 0x0c:
  8231. idx1 = 1;
  8232. idx = 2; /* Line In */
  8233. break;
  8234. case 0x0f:
  8235. idx1 = 2;
  8236. idx = 2; /* Line In */
  8237. break;
  8238. case 0x0d:
  8239. idx1 = 0;
  8240. idx = 1; /* Mic In */
  8241. break;
  8242. case 0x10:
  8243. idx1 = 3;
  8244. idx = 1; /* Mic In */
  8245. break;
  8246. case 0x11:
  8247. idx1 = 4;
  8248. idx = 0; /* CD */
  8249. break;
  8250. default:
  8251. continue;
  8252. }
  8253. err = new_analog_input(spec, cfg->input_pins[i],
  8254. auto_pin_cfg_labels[i], idx, 0x15);
  8255. if (err < 0)
  8256. return err;
  8257. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8258. imux->items[imux->num_items].index = idx1;
  8259. imux->num_items++;
  8260. }
  8261. return 0;
  8262. }
  8263. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8264. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8265. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8266. {
  8267. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8268. /* The multiple "Capture Source" controls confuse alsamixer
  8269. * So call somewhat different..
  8270. *FIXME: the controls appear in the "playback" view!
  8271. */
  8272. /* .name = "Capture Source", */
  8273. .name = "Input Source",
  8274. .count = 1,
  8275. .info = alc_mux_enum_info,
  8276. .get = alc_mux_enum_get,
  8277. .put = alc_mux_enum_put,
  8278. },
  8279. { } /* end */
  8280. };
  8281. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8282. hda_nid_t nid,
  8283. int pin_type, int dac_idx)
  8284. {
  8285. /* set as output */
  8286. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8287. pin_type);
  8288. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8289. AMP_OUT_UNMUTE);
  8290. }
  8291. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8292. {
  8293. struct alc_spec *spec = codec->spec;
  8294. int i;
  8295. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8296. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8297. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8298. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8299. if (nid)
  8300. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8301. spec->multiout.dac_nids[i]);
  8302. }
  8303. }
  8304. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8305. {
  8306. struct alc_spec *spec = codec->spec;
  8307. hda_nid_t pin;
  8308. pin = spec->autocfg.hp_pins[0];
  8309. if (pin) /* connect to front */
  8310. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8311. spec->multiout.dac_nids[0]);
  8312. }
  8313. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8314. {
  8315. struct alc_spec *spec = codec->spec;
  8316. int i;
  8317. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8318. hda_nid_t nid = spec->autocfg.input_pins[i];
  8319. if (nid >= 0x0c && nid <= 0x11) {
  8320. snd_hda_codec_write(codec, nid, 0,
  8321. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8322. i <= AUTO_PIN_FRONT_MIC ?
  8323. PIN_VREF80 : PIN_IN);
  8324. }
  8325. }
  8326. }
  8327. /* parse the BIOS configuration and set up the alc_spec */
  8328. /* return 1 if successful, 0 if the proper config is not found,
  8329. * or a negative error code
  8330. */
  8331. static int alc861_parse_auto_config(struct hda_codec *codec)
  8332. {
  8333. struct alc_spec *spec = codec->spec;
  8334. int err;
  8335. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8336. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8337. alc861_ignore);
  8338. if (err < 0)
  8339. return err;
  8340. if (!spec->autocfg.line_outs)
  8341. return 0; /* can't find valid BIOS pin config */
  8342. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8343. if (err < 0)
  8344. return err;
  8345. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8346. if (err < 0)
  8347. return err;
  8348. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8349. if (err < 0)
  8350. return err;
  8351. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8352. if (err < 0)
  8353. return err;
  8354. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8355. if (spec->autocfg.dig_out_pin)
  8356. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8357. if (spec->kctl_alloc)
  8358. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8359. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8360. spec->num_mux_defs = 1;
  8361. spec->input_mux = &spec->private_imux;
  8362. spec->adc_nids = alc861_adc_nids;
  8363. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8364. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8365. spec->num_mixers++;
  8366. return 1;
  8367. }
  8368. /* additional initialization for auto-configuration model */
  8369. static void alc861_auto_init(struct hda_codec *codec)
  8370. {
  8371. alc861_auto_init_multi_out(codec);
  8372. alc861_auto_init_hp_out(codec);
  8373. alc861_auto_init_analog_input(codec);
  8374. }
  8375. /*
  8376. * configuration and preset
  8377. */
  8378. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8379. [ALC861_3ST] = "3stack",
  8380. [ALC660_3ST] = "3stack-660",
  8381. [ALC861_3ST_DIG] = "3stack-dig",
  8382. [ALC861_6ST_DIG] = "6stack-dig",
  8383. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8384. [ALC861_TOSHIBA] = "toshiba",
  8385. [ALC861_ASUS] = "asus",
  8386. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8387. [ALC861_AUTO] = "auto",
  8388. };
  8389. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8390. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8391. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8392. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8393. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8394. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8395. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8396. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  8397. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8398. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8399. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8400. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8401. {}
  8402. };
  8403. static struct alc_config_preset alc861_presets[] = {
  8404. [ALC861_3ST] = {
  8405. .mixers = { alc861_3ST_mixer },
  8406. .init_verbs = { alc861_threestack_init_verbs },
  8407. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8408. .dac_nids = alc861_dac_nids,
  8409. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8410. .channel_mode = alc861_threestack_modes,
  8411. .need_dac_fix = 1,
  8412. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8413. .adc_nids = alc861_adc_nids,
  8414. .input_mux = &alc861_capture_source,
  8415. },
  8416. [ALC861_3ST_DIG] = {
  8417. .mixers = { alc861_base_mixer },
  8418. .init_verbs = { alc861_threestack_init_verbs },
  8419. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8420. .dac_nids = alc861_dac_nids,
  8421. .dig_out_nid = ALC861_DIGOUT_NID,
  8422. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8423. .channel_mode = alc861_threestack_modes,
  8424. .need_dac_fix = 1,
  8425. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8426. .adc_nids = alc861_adc_nids,
  8427. .input_mux = &alc861_capture_source,
  8428. },
  8429. [ALC861_6ST_DIG] = {
  8430. .mixers = { alc861_base_mixer },
  8431. .init_verbs = { alc861_base_init_verbs },
  8432. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8433. .dac_nids = alc861_dac_nids,
  8434. .dig_out_nid = ALC861_DIGOUT_NID,
  8435. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8436. .channel_mode = alc861_8ch_modes,
  8437. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8438. .adc_nids = alc861_adc_nids,
  8439. .input_mux = &alc861_capture_source,
  8440. },
  8441. [ALC660_3ST] = {
  8442. .mixers = { alc861_3ST_mixer },
  8443. .init_verbs = { alc861_threestack_init_verbs },
  8444. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8445. .dac_nids = alc660_dac_nids,
  8446. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8447. .channel_mode = alc861_threestack_modes,
  8448. .need_dac_fix = 1,
  8449. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8450. .adc_nids = alc861_adc_nids,
  8451. .input_mux = &alc861_capture_source,
  8452. },
  8453. [ALC861_UNIWILL_M31] = {
  8454. .mixers = { alc861_uniwill_m31_mixer },
  8455. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8456. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8457. .dac_nids = alc861_dac_nids,
  8458. .dig_out_nid = ALC861_DIGOUT_NID,
  8459. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8460. .channel_mode = alc861_uniwill_m31_modes,
  8461. .need_dac_fix = 1,
  8462. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8463. .adc_nids = alc861_adc_nids,
  8464. .input_mux = &alc861_capture_source,
  8465. },
  8466. [ALC861_TOSHIBA] = {
  8467. .mixers = { alc861_toshiba_mixer },
  8468. .init_verbs = { alc861_base_init_verbs,
  8469. alc861_toshiba_init_verbs },
  8470. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8471. .dac_nids = alc861_dac_nids,
  8472. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8473. .channel_mode = alc883_3ST_2ch_modes,
  8474. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8475. .adc_nids = alc861_adc_nids,
  8476. .input_mux = &alc861_capture_source,
  8477. .unsol_event = alc861_toshiba_unsol_event,
  8478. .init_hook = alc861_toshiba_automute,
  8479. },
  8480. [ALC861_ASUS] = {
  8481. .mixers = { alc861_asus_mixer },
  8482. .init_verbs = { alc861_asus_init_verbs },
  8483. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8484. .dac_nids = alc861_dac_nids,
  8485. .dig_out_nid = ALC861_DIGOUT_NID,
  8486. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8487. .channel_mode = alc861_asus_modes,
  8488. .need_dac_fix = 1,
  8489. .hp_nid = 0x06,
  8490. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8491. .adc_nids = alc861_adc_nids,
  8492. .input_mux = &alc861_capture_source,
  8493. },
  8494. [ALC861_ASUS_LAPTOP] = {
  8495. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8496. .init_verbs = { alc861_asus_init_verbs,
  8497. alc861_asus_laptop_init_verbs },
  8498. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8499. .dac_nids = alc861_dac_nids,
  8500. .dig_out_nid = ALC861_DIGOUT_NID,
  8501. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8502. .channel_mode = alc883_3ST_2ch_modes,
  8503. .need_dac_fix = 1,
  8504. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8505. .adc_nids = alc861_adc_nids,
  8506. .input_mux = &alc861_capture_source,
  8507. },
  8508. };
  8509. static int patch_alc861(struct hda_codec *codec)
  8510. {
  8511. struct alc_spec *spec;
  8512. int board_config;
  8513. int err;
  8514. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8515. if (spec == NULL)
  8516. return -ENOMEM;
  8517. codec->spec = spec;
  8518. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8519. alc861_models,
  8520. alc861_cfg_tbl);
  8521. if (board_config < 0) {
  8522. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8523. "trying auto-probe from BIOS...\n");
  8524. board_config = ALC861_AUTO;
  8525. }
  8526. if (board_config == ALC861_AUTO) {
  8527. /* automatic parse from the BIOS config */
  8528. err = alc861_parse_auto_config(codec);
  8529. if (err < 0) {
  8530. alc_free(codec);
  8531. return err;
  8532. } else if (!err) {
  8533. printk(KERN_INFO
  8534. "hda_codec: Cannot set up configuration "
  8535. "from BIOS. Using base mode...\n");
  8536. board_config = ALC861_3ST_DIG;
  8537. }
  8538. }
  8539. if (board_config != ALC861_AUTO)
  8540. setup_preset(spec, &alc861_presets[board_config]);
  8541. spec->stream_name_analog = "ALC861 Analog";
  8542. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8543. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8544. spec->stream_name_digital = "ALC861 Digital";
  8545. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8546. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8547. codec->patch_ops = alc_patch_ops;
  8548. if (board_config == ALC861_AUTO)
  8549. spec->init_hook = alc861_auto_init;
  8550. return 0;
  8551. }
  8552. /*
  8553. * ALC861-VD support
  8554. *
  8555. * Based on ALC882
  8556. *
  8557. * In addition, an independent DAC
  8558. */
  8559. #define ALC861VD_DIGOUT_NID 0x06
  8560. static hda_nid_t alc861vd_dac_nids[4] = {
  8561. /* front, surr, clfe, side surr */
  8562. 0x02, 0x03, 0x04, 0x05
  8563. };
  8564. /* dac_nids for ALC660vd are in a different order - according to
  8565. * Realtek's driver.
  8566. * This should probably tesult in a different mixer for 6stack models
  8567. * of ALC660vd codecs, but for now there is only 3stack mixer
  8568. * - and it is the same as in 861vd.
  8569. * adc_nids in ALC660vd are (is) the same as in 861vd
  8570. */
  8571. static hda_nid_t alc660vd_dac_nids[3] = {
  8572. /* front, rear, clfe, rear_surr */
  8573. 0x02, 0x04, 0x03
  8574. };
  8575. static hda_nid_t alc861vd_adc_nids[1] = {
  8576. /* ADC0 */
  8577. 0x09,
  8578. };
  8579. /* input MUX */
  8580. /* FIXME: should be a matrix-type input source selection */
  8581. static struct hda_input_mux alc861vd_capture_source = {
  8582. .num_items = 4,
  8583. .items = {
  8584. { "Mic", 0x0 },
  8585. { "Front Mic", 0x1 },
  8586. { "Line", 0x2 },
  8587. { "CD", 0x4 },
  8588. },
  8589. };
  8590. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8591. .num_items = 3,
  8592. .items = {
  8593. { "Front Mic", 0x0 },
  8594. { "ATAPI Mic", 0x1 },
  8595. { "Line In", 0x5 },
  8596. },
  8597. };
  8598. #define alc861vd_mux_enum_info alc_mux_enum_info
  8599. #define alc861vd_mux_enum_get alc_mux_enum_get
  8600. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8601. struct snd_ctl_elem_value *ucontrol)
  8602. {
  8603. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8604. struct alc_spec *spec = codec->spec;
  8605. const struct hda_input_mux *imux = spec->input_mux;
  8606. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8607. static hda_nid_t capture_mixers[1] = { 0x22 };
  8608. hda_nid_t nid = capture_mixers[adc_idx];
  8609. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8610. unsigned int i, idx;
  8611. idx = ucontrol->value.enumerated.item[0];
  8612. if (idx >= imux->num_items)
  8613. idx = imux->num_items - 1;
  8614. if (*cur_val == idx && !codec->in_resume)
  8615. return 0;
  8616. for (i = 0; i < imux->num_items; i++) {
  8617. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8618. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8619. v | (imux->items[i].index << 8));
  8620. }
  8621. *cur_val = idx;
  8622. return 1;
  8623. }
  8624. /*
  8625. * 2ch mode
  8626. */
  8627. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8628. { 2, NULL }
  8629. };
  8630. /*
  8631. * 6ch mode
  8632. */
  8633. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8634. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8635. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8636. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8637. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8638. { } /* end */
  8639. };
  8640. /*
  8641. * 8ch mode
  8642. */
  8643. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8644. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8645. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8646. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8647. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8648. { } /* end */
  8649. };
  8650. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8651. { 6, alc861vd_6stack_ch6_init },
  8652. { 8, alc861vd_6stack_ch8_init },
  8653. };
  8654. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8655. {
  8656. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8657. .name = "Channel Mode",
  8658. .info = alc_ch_mode_info,
  8659. .get = alc_ch_mode_get,
  8660. .put = alc_ch_mode_put,
  8661. },
  8662. { } /* end */
  8663. };
  8664. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8665. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8666. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8667. {
  8668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8669. /* The multiple "Capture Source" controls confuse alsamixer
  8670. * So call somewhat different..
  8671. *FIXME: the controls appear in the "playback" view!
  8672. */
  8673. /* .name = "Capture Source", */
  8674. .name = "Input Source",
  8675. .count = 1,
  8676. .info = alc861vd_mux_enum_info,
  8677. .get = alc861vd_mux_enum_get,
  8678. .put = alc861vd_mux_enum_put,
  8679. },
  8680. { } /* end */
  8681. };
  8682. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8683. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8684. */
  8685. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8686. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8687. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8688. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8689. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8690. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8691. HDA_OUTPUT),
  8692. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8693. HDA_OUTPUT),
  8694. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8695. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8696. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8697. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8698. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8699. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8700. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8701. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8702. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8703. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8704. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8705. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8706. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8707. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8708. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8709. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8710. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8711. { } /* end */
  8712. };
  8713. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8714. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8715. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8716. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8717. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8718. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8719. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8720. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8721. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8722. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8723. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8724. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8725. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8726. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8727. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8728. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8729. { } /* end */
  8730. };
  8731. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8732. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8733. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8734. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8735. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8736. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8737. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8738. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8739. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8740. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8741. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8742. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8743. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8744. { } /* end */
  8745. };
  8746. /* Pin assignment: Front=0x14, HP = 0x15,
  8747. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8748. */
  8749. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8750. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8751. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8752. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8753. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8754. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8755. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8756. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8757. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8758. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8759. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8760. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8761. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8762. {
  8763. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8764. /* .name = "Capture Source", */
  8765. .name = "Input Source",
  8766. .count = 1,
  8767. .info = alc882_mux_enum_info,
  8768. .get = alc882_mux_enum_get,
  8769. .put = alc882_mux_enum_put,
  8770. },
  8771. { } /* end */
  8772. };
  8773. /*
  8774. * generic initialization of ADC, input mixers and output mixers
  8775. */
  8776. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8777. /*
  8778. * Unmute ADC0 and set the default input to mic-in
  8779. */
  8780. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8781. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8782. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8783. * the analog-loopback mixer widget
  8784. */
  8785. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8786. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8787. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8788. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8789. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8790. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8791. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8792. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8793. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8794. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8795. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8796. /*
  8797. * Set up output mixers (0x02 - 0x05)
  8798. */
  8799. /* set vol=0 to output mixers */
  8800. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8801. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8802. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8803. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8804. /* set up input amps for analog loopback */
  8805. /* Amp Indices: DAC = 0, mixer = 1 */
  8806. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8807. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8808. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8809. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8810. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8811. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8812. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8813. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8814. { }
  8815. };
  8816. /*
  8817. * 3-stack pin configuration:
  8818. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8819. */
  8820. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8821. /*
  8822. * Set pin mode and muting
  8823. */
  8824. /* set front pin widgets 0x14 for output */
  8825. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8826. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8827. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8828. /* Mic (rear) pin: input vref at 80% */
  8829. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8830. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8831. /* Front Mic pin: input vref at 80% */
  8832. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8833. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8834. /* Line In pin: input */
  8835. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8836. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8837. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8838. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8839. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8840. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8841. /* CD pin widget for input */
  8842. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8843. { }
  8844. };
  8845. /*
  8846. * 6-stack pin configuration:
  8847. */
  8848. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8849. /*
  8850. * Set pin mode and muting
  8851. */
  8852. /* set front pin widgets 0x14 for output */
  8853. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8854. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8855. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8856. /* Rear Pin: output 1 (0x0d) */
  8857. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8858. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8859. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8860. /* CLFE Pin: output 2 (0x0e) */
  8861. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8862. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8863. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8864. /* Side Pin: output 3 (0x0f) */
  8865. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8866. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8867. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8868. /* Mic (rear) pin: input vref at 80% */
  8869. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8870. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8871. /* Front Mic pin: input vref at 80% */
  8872. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8873. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8874. /* Line In pin: input */
  8875. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8876. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8877. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8878. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8879. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8880. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8881. /* CD pin widget for input */
  8882. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8883. { }
  8884. };
  8885. static struct hda_verb alc861vd_eapd_verbs[] = {
  8886. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8887. { }
  8888. };
  8889. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8890. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8891. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8892. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8893. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8894. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8895. {}
  8896. };
  8897. /* toggle speaker-output according to the hp-jack state */
  8898. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8899. {
  8900. unsigned int present;
  8901. unsigned char bits;
  8902. present = snd_hda_codec_read(codec, 0x1b, 0,
  8903. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8904. bits = present ? 0x80 : 0;
  8905. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8906. 0x80, bits);
  8907. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8908. 0x80, bits);
  8909. }
  8910. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8911. {
  8912. unsigned int present;
  8913. unsigned char bits;
  8914. present = snd_hda_codec_read(codec, 0x18, 0,
  8915. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8916. bits = present ? 0x80 : 0;
  8917. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8918. 0x80, bits);
  8919. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8920. 0x80, bits);
  8921. }
  8922. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8923. {
  8924. alc861vd_lenovo_hp_automute(codec);
  8925. alc861vd_lenovo_mic_automute(codec);
  8926. }
  8927. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8928. unsigned int res)
  8929. {
  8930. switch (res >> 26) {
  8931. case ALC880_HP_EVENT:
  8932. alc861vd_lenovo_hp_automute(codec);
  8933. break;
  8934. case ALC880_MIC_EVENT:
  8935. alc861vd_lenovo_mic_automute(codec);
  8936. break;
  8937. }
  8938. }
  8939. static struct hda_verb alc861vd_dallas_verbs[] = {
  8940. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8941. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8942. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8943. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8944. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8945. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8946. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8947. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8948. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8949. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8950. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8951. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8952. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8953. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8954. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8955. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8956. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8957. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8958. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8959. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8960. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8961. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8962. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8963. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8964. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8965. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8966. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8967. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8968. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8969. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8970. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8971. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8972. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8973. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8974. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8975. { } /* end */
  8976. };
  8977. /* toggle speaker-output according to the hp-jack state */
  8978. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8979. {
  8980. unsigned int present;
  8981. present = snd_hda_codec_read(codec, 0x15, 0,
  8982. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8983. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8984. 0x80, present ? 0x80 : 0);
  8985. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8986. 0x80, present ? 0x80 : 0);
  8987. }
  8988. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8989. {
  8990. if ((res >> 26) == ALC880_HP_EVENT)
  8991. alc861vd_dallas_automute(codec);
  8992. }
  8993. /* pcm configuration: identiacal with ALC880 */
  8994. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  8995. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  8996. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  8997. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  8998. /*
  8999. * configuration and preset
  9000. */
  9001. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9002. [ALC660VD_3ST] = "3stack-660",
  9003. [ALC861VD_3ST] = "3stack",
  9004. [ALC861VD_3ST_DIG] = "3stack-digout",
  9005. [ALC861VD_6ST_DIG] = "6stack-digout",
  9006. [ALC861VD_LENOVO] = "lenovo",
  9007. [ALC861VD_DALLAS] = "dallas",
  9008. [ALC861VD_AUTO] = "auto",
  9009. };
  9010. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9011. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9012. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9013. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
  9014. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9015. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9016. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9017. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9018. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9019. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9020. {}
  9021. };
  9022. static struct alc_config_preset alc861vd_presets[] = {
  9023. [ALC660VD_3ST] = {
  9024. .mixers = { alc861vd_3st_mixer },
  9025. .init_verbs = { alc861vd_volume_init_verbs,
  9026. alc861vd_3stack_init_verbs },
  9027. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9028. .dac_nids = alc660vd_dac_nids,
  9029. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9030. .adc_nids = alc861vd_adc_nids,
  9031. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9032. .channel_mode = alc861vd_3stack_2ch_modes,
  9033. .input_mux = &alc861vd_capture_source,
  9034. },
  9035. [ALC861VD_3ST] = {
  9036. .mixers = { alc861vd_3st_mixer },
  9037. .init_verbs = { alc861vd_volume_init_verbs,
  9038. alc861vd_3stack_init_verbs },
  9039. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9040. .dac_nids = alc861vd_dac_nids,
  9041. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9042. .channel_mode = alc861vd_3stack_2ch_modes,
  9043. .input_mux = &alc861vd_capture_source,
  9044. },
  9045. [ALC861VD_3ST_DIG] = {
  9046. .mixers = { alc861vd_3st_mixer },
  9047. .init_verbs = { alc861vd_volume_init_verbs,
  9048. alc861vd_3stack_init_verbs },
  9049. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9050. .dac_nids = alc861vd_dac_nids,
  9051. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9052. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9053. .channel_mode = alc861vd_3stack_2ch_modes,
  9054. .input_mux = &alc861vd_capture_source,
  9055. },
  9056. [ALC861VD_6ST_DIG] = {
  9057. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9058. .init_verbs = { alc861vd_volume_init_verbs,
  9059. alc861vd_6stack_init_verbs },
  9060. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9061. .dac_nids = alc861vd_dac_nids,
  9062. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9063. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9064. .channel_mode = alc861vd_6stack_modes,
  9065. .input_mux = &alc861vd_capture_source,
  9066. },
  9067. [ALC861VD_LENOVO] = {
  9068. .mixers = { alc861vd_lenovo_mixer },
  9069. .init_verbs = { alc861vd_volume_init_verbs,
  9070. alc861vd_3stack_init_verbs,
  9071. alc861vd_eapd_verbs,
  9072. alc861vd_lenovo_unsol_verbs },
  9073. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9074. .dac_nids = alc660vd_dac_nids,
  9075. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9076. .adc_nids = alc861vd_adc_nids,
  9077. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9078. .channel_mode = alc861vd_3stack_2ch_modes,
  9079. .input_mux = &alc861vd_capture_source,
  9080. .unsol_event = alc861vd_lenovo_unsol_event,
  9081. .init_hook = alc861vd_lenovo_automute,
  9082. },
  9083. [ALC861VD_DALLAS] = {
  9084. .mixers = { alc861vd_dallas_mixer },
  9085. .init_verbs = { alc861vd_dallas_verbs },
  9086. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9087. .dac_nids = alc861vd_dac_nids,
  9088. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9089. .adc_nids = alc861vd_adc_nids,
  9090. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9091. .channel_mode = alc861vd_3stack_2ch_modes,
  9092. .input_mux = &alc861vd_dallas_capture_source,
  9093. .unsol_event = alc861vd_dallas_unsol_event,
  9094. .init_hook = alc861vd_dallas_automute,
  9095. },
  9096. };
  9097. /*
  9098. * BIOS auto configuration
  9099. */
  9100. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9101. hda_nid_t nid, int pin_type, int dac_idx)
  9102. {
  9103. /* set as output */
  9104. snd_hda_codec_write(codec, nid, 0,
  9105. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9106. snd_hda_codec_write(codec, nid, 0,
  9107. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9108. }
  9109. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9110. {
  9111. struct alc_spec *spec = codec->spec;
  9112. int i;
  9113. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9114. for (i = 0; i <= HDA_SIDE; i++) {
  9115. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9116. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9117. if (nid)
  9118. alc861vd_auto_set_output_and_unmute(codec, nid,
  9119. pin_type, i);
  9120. }
  9121. }
  9122. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9123. {
  9124. struct alc_spec *spec = codec->spec;
  9125. hda_nid_t pin;
  9126. pin = spec->autocfg.hp_pins[0];
  9127. if (pin) /* connect to front and use dac 0 */
  9128. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9129. }
  9130. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9131. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9132. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9133. {
  9134. struct alc_spec *spec = codec->spec;
  9135. int i;
  9136. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9137. hda_nid_t nid = spec->autocfg.input_pins[i];
  9138. if (alc861vd_is_input_pin(nid)) {
  9139. snd_hda_codec_write(codec, nid, 0,
  9140. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9141. i <= AUTO_PIN_FRONT_MIC ?
  9142. PIN_VREF80 : PIN_IN);
  9143. if (nid != ALC861VD_PIN_CD_NID)
  9144. snd_hda_codec_write(codec, nid, 0,
  9145. AC_VERB_SET_AMP_GAIN_MUTE,
  9146. AMP_OUT_MUTE);
  9147. }
  9148. }
  9149. }
  9150. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9151. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9152. /* add playback controls from the parsed DAC table */
  9153. /* Based on ALC880 version. But ALC861VD has separate,
  9154. * different NIDs for mute/unmute switch and volume control */
  9155. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9156. const struct auto_pin_cfg *cfg)
  9157. {
  9158. char name[32];
  9159. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9160. hda_nid_t nid_v, nid_s;
  9161. int i, err;
  9162. for (i = 0; i < cfg->line_outs; i++) {
  9163. if (!spec->multiout.dac_nids[i])
  9164. continue;
  9165. nid_v = alc861vd_idx_to_mixer_vol(
  9166. alc880_dac_to_idx(
  9167. spec->multiout.dac_nids[i]));
  9168. nid_s = alc861vd_idx_to_mixer_switch(
  9169. alc880_dac_to_idx(
  9170. spec->multiout.dac_nids[i]));
  9171. if (i == 2) {
  9172. /* Center/LFE */
  9173. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9174. "Center Playback Volume",
  9175. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9176. HDA_OUTPUT));
  9177. if (err < 0)
  9178. return err;
  9179. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9180. "LFE Playback Volume",
  9181. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9182. HDA_OUTPUT));
  9183. if (err < 0)
  9184. return err;
  9185. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9186. "Center Playback Switch",
  9187. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9188. HDA_INPUT));
  9189. if (err < 0)
  9190. return err;
  9191. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9192. "LFE Playback Switch",
  9193. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9194. HDA_INPUT));
  9195. if (err < 0)
  9196. return err;
  9197. } else {
  9198. sprintf(name, "%s Playback Volume", chname[i]);
  9199. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9200. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9201. HDA_OUTPUT));
  9202. if (err < 0)
  9203. return err;
  9204. sprintf(name, "%s Playback Switch", chname[i]);
  9205. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9206. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9207. HDA_INPUT));
  9208. if (err < 0)
  9209. return err;
  9210. }
  9211. }
  9212. return 0;
  9213. }
  9214. /* add playback controls for speaker and HP outputs */
  9215. /* Based on ALC880 version. But ALC861VD has separate,
  9216. * different NIDs for mute/unmute switch and volume control */
  9217. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9218. hda_nid_t pin, const char *pfx)
  9219. {
  9220. hda_nid_t nid_v, nid_s;
  9221. int err;
  9222. char name[32];
  9223. if (!pin)
  9224. return 0;
  9225. if (alc880_is_fixed_pin(pin)) {
  9226. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9227. /* specify the DAC as the extra output */
  9228. if (!spec->multiout.hp_nid)
  9229. spec->multiout.hp_nid = nid_v;
  9230. else
  9231. spec->multiout.extra_out_nid[0] = nid_v;
  9232. /* control HP volume/switch on the output mixer amp */
  9233. nid_v = alc861vd_idx_to_mixer_vol(
  9234. alc880_fixed_pin_idx(pin));
  9235. nid_s = alc861vd_idx_to_mixer_switch(
  9236. alc880_fixed_pin_idx(pin));
  9237. sprintf(name, "%s Playback Volume", pfx);
  9238. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9239. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9240. if (err < 0)
  9241. return err;
  9242. sprintf(name, "%s Playback Switch", pfx);
  9243. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9244. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9245. if (err < 0)
  9246. return err;
  9247. } else if (alc880_is_multi_pin(pin)) {
  9248. /* set manual connection */
  9249. /* we have only a switch on HP-out PIN */
  9250. sprintf(name, "%s Playback Switch", pfx);
  9251. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9252. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9253. if (err < 0)
  9254. return err;
  9255. }
  9256. return 0;
  9257. }
  9258. /* parse the BIOS configuration and set up the alc_spec
  9259. * return 1 if successful, 0 if the proper config is not found,
  9260. * or a negative error code
  9261. * Based on ALC880 version - had to change it to override
  9262. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9263. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9264. {
  9265. struct alc_spec *spec = codec->spec;
  9266. int err;
  9267. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9268. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9269. alc861vd_ignore);
  9270. if (err < 0)
  9271. return err;
  9272. if (!spec->autocfg.line_outs)
  9273. return 0; /* can't find valid BIOS pin config */
  9274. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9275. if (err < 0)
  9276. return err;
  9277. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9278. if (err < 0)
  9279. return err;
  9280. err = alc861vd_auto_create_extra_out(spec,
  9281. spec->autocfg.speaker_pins[0],
  9282. "Speaker");
  9283. if (err < 0)
  9284. return err;
  9285. err = alc861vd_auto_create_extra_out(spec,
  9286. spec->autocfg.hp_pins[0],
  9287. "Headphone");
  9288. if (err < 0)
  9289. return err;
  9290. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9291. if (err < 0)
  9292. return err;
  9293. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9294. if (spec->autocfg.dig_out_pin)
  9295. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9296. if (spec->kctl_alloc)
  9297. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9298. spec->init_verbs[spec->num_init_verbs++]
  9299. = alc861vd_volume_init_verbs;
  9300. spec->num_mux_defs = 1;
  9301. spec->input_mux = &spec->private_imux;
  9302. return 1;
  9303. }
  9304. /* additional initialization for auto-configuration model */
  9305. static void alc861vd_auto_init(struct hda_codec *codec)
  9306. {
  9307. alc861vd_auto_init_multi_out(codec);
  9308. alc861vd_auto_init_hp_out(codec);
  9309. alc861vd_auto_init_analog_input(codec);
  9310. }
  9311. static int patch_alc861vd(struct hda_codec *codec)
  9312. {
  9313. struct alc_spec *spec;
  9314. int err, board_config;
  9315. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9316. if (spec == NULL)
  9317. return -ENOMEM;
  9318. codec->spec = spec;
  9319. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9320. alc861vd_models,
  9321. alc861vd_cfg_tbl);
  9322. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9323. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9324. "ALC861VD, trying auto-probe from BIOS...\n");
  9325. board_config = ALC861VD_AUTO;
  9326. }
  9327. if (board_config == ALC861VD_AUTO) {
  9328. /* automatic parse from the BIOS config */
  9329. err = alc861vd_parse_auto_config(codec);
  9330. if (err < 0) {
  9331. alc_free(codec);
  9332. return err;
  9333. } else if (!err) {
  9334. printk(KERN_INFO
  9335. "hda_codec: Cannot set up configuration "
  9336. "from BIOS. Using base mode...\n");
  9337. board_config = ALC861VD_3ST;
  9338. }
  9339. }
  9340. if (board_config != ALC861VD_AUTO)
  9341. setup_preset(spec, &alc861vd_presets[board_config]);
  9342. spec->stream_name_analog = "ALC861VD Analog";
  9343. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9344. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9345. spec->stream_name_digital = "ALC861VD Digital";
  9346. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9347. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9348. spec->adc_nids = alc861vd_adc_nids;
  9349. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9350. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9351. spec->num_mixers++;
  9352. codec->patch_ops = alc_patch_ops;
  9353. if (board_config == ALC861VD_AUTO)
  9354. spec->init_hook = alc861vd_auto_init;
  9355. return 0;
  9356. }
  9357. /*
  9358. * ALC662 support
  9359. *
  9360. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9361. * configuration. Each pin widget can choose any input DACs and a mixer.
  9362. * Each ADC is connected from a mixer of all inputs. This makes possible
  9363. * 6-channel independent captures.
  9364. *
  9365. * In addition, an independent DAC for the multi-playback (not used in this
  9366. * driver yet).
  9367. */
  9368. #define ALC662_DIGOUT_NID 0x06
  9369. #define ALC662_DIGIN_NID 0x0a
  9370. static hda_nid_t alc662_dac_nids[4] = {
  9371. /* front, rear, clfe, rear_surr */
  9372. 0x02, 0x03, 0x04
  9373. };
  9374. static hda_nid_t alc662_adc_nids[1] = {
  9375. /* ADC1-2 */
  9376. 0x09,
  9377. };
  9378. /* input MUX */
  9379. /* FIXME: should be a matrix-type input source selection */
  9380. static struct hda_input_mux alc662_capture_source = {
  9381. .num_items = 4,
  9382. .items = {
  9383. { "Mic", 0x0 },
  9384. { "Front Mic", 0x1 },
  9385. { "Line", 0x2 },
  9386. { "CD", 0x4 },
  9387. },
  9388. };
  9389. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9390. .num_items = 2,
  9391. .items = {
  9392. { "Mic", 0x1 },
  9393. { "Line", 0x2 },
  9394. },
  9395. };
  9396. #define alc662_mux_enum_info alc_mux_enum_info
  9397. #define alc662_mux_enum_get alc_mux_enum_get
  9398. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9399. struct snd_ctl_elem_value *ucontrol)
  9400. {
  9401. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9402. struct alc_spec *spec = codec->spec;
  9403. const struct hda_input_mux *imux = spec->input_mux;
  9404. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9405. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9406. hda_nid_t nid = capture_mixers[adc_idx];
  9407. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9408. unsigned int i, idx;
  9409. idx = ucontrol->value.enumerated.item[0];
  9410. if (idx >= imux->num_items)
  9411. idx = imux->num_items - 1;
  9412. if (*cur_val == idx && !codec->in_resume)
  9413. return 0;
  9414. for (i = 0; i < imux->num_items; i++) {
  9415. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9416. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9417. v | (imux->items[i].index << 8));
  9418. }
  9419. *cur_val = idx;
  9420. return 1;
  9421. }
  9422. /*
  9423. * 2ch mode
  9424. */
  9425. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9426. { 2, NULL }
  9427. };
  9428. /*
  9429. * 2ch mode
  9430. */
  9431. static struct hda_verb alc662_3ST_ch2_init[] = {
  9432. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9433. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9434. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9435. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9436. { } /* end */
  9437. };
  9438. /*
  9439. * 6ch mode
  9440. */
  9441. static struct hda_verb alc662_3ST_ch6_init[] = {
  9442. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9443. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9444. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9445. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9446. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9447. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9448. { } /* end */
  9449. };
  9450. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9451. { 2, alc662_3ST_ch2_init },
  9452. { 6, alc662_3ST_ch6_init },
  9453. };
  9454. /*
  9455. * 2ch mode
  9456. */
  9457. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9458. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9459. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9460. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9461. { } /* end */
  9462. };
  9463. /*
  9464. * 6ch mode
  9465. */
  9466. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9467. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9468. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9469. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9470. { } /* end */
  9471. };
  9472. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9473. { 2, alc662_sixstack_ch6_init },
  9474. { 6, alc662_sixstack_ch8_init },
  9475. };
  9476. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9477. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9478. */
  9479. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9480. /* output mixer control */
  9481. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9482. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9483. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9484. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9485. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9486. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9487. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9488. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9489. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9490. /*Input mixer control */
  9491. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9492. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9493. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9494. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9495. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9496. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9497. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9498. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9499. /* Capture mixer control */
  9500. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9501. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9502. {
  9503. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9504. .name = "Capture Source",
  9505. .count = 1,
  9506. .info = alc_mux_enum_info,
  9507. .get = alc_mux_enum_get,
  9508. .put = alc_mux_enum_put,
  9509. },
  9510. { } /* end */
  9511. };
  9512. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9513. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9514. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9515. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9516. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9517. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9518. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9519. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9520. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9521. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9522. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9523. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9524. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9525. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9526. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9527. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9528. {
  9529. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9530. /* .name = "Capture Source", */
  9531. .name = "Input Source",
  9532. .count = 1,
  9533. .info = alc662_mux_enum_info,
  9534. .get = alc662_mux_enum_get,
  9535. .put = alc662_mux_enum_put,
  9536. },
  9537. { } /* end */
  9538. };
  9539. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9540. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9541. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9542. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9543. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9544. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9545. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9546. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9547. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9548. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9549. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9550. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9551. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9552. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9553. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9554. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9555. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9556. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9557. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9558. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9559. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9560. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9561. {
  9562. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9563. /* .name = "Capture Source", */
  9564. .name = "Input Source",
  9565. .count = 1,
  9566. .info = alc662_mux_enum_info,
  9567. .get = alc662_mux_enum_get,
  9568. .put = alc662_mux_enum_put,
  9569. },
  9570. { } /* end */
  9571. };
  9572. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9573. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9574. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9575. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9576. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9577. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9578. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9579. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9580. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9581. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9582. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9583. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9584. {
  9585. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9586. /* .name = "Capture Source", */
  9587. .name = "Input Source",
  9588. .count = 1,
  9589. .info = alc662_mux_enum_info,
  9590. .get = alc662_mux_enum_get,
  9591. .put = alc662_mux_enum_put,
  9592. },
  9593. { } /* end */
  9594. };
  9595. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9596. {
  9597. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9598. .name = "Channel Mode",
  9599. .info = alc_ch_mode_info,
  9600. .get = alc_ch_mode_get,
  9601. .put = alc_ch_mode_put,
  9602. },
  9603. { } /* end */
  9604. };
  9605. static struct hda_verb alc662_init_verbs[] = {
  9606. /* ADC: mute amp left and right */
  9607. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9608. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9609. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9610. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9611. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9612. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9613. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9614. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9615. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9616. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9617. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9618. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9619. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9620. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9621. /* Front Pin: output 0 (0x0c) */
  9622. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9623. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9624. /* Rear Pin: output 1 (0x0d) */
  9625. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9626. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9627. /* CLFE Pin: output 2 (0x0e) */
  9628. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9629. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9630. /* Mic (rear) pin: input vref at 80% */
  9631. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9632. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9633. /* Front Mic pin: input vref at 80% */
  9634. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9635. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9636. /* Line In pin: input */
  9637. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9638. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9639. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9640. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9641. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9642. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9643. /* CD pin widget for input */
  9644. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9645. /* FIXME: use matrix-type input source selection */
  9646. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9647. /* Input mixer */
  9648. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9651. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9652. { }
  9653. };
  9654. static struct hda_verb alc662_sue_init_verbs[] = {
  9655. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9656. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9657. {}
  9658. };
  9659. /*
  9660. * generic initialization of ADC, input mixers and output mixers
  9661. */
  9662. static struct hda_verb alc662_auto_init_verbs[] = {
  9663. /*
  9664. * Unmute ADC and set the default input to mic-in
  9665. */
  9666. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9667. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9668. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9669. * mixer widget
  9670. * Note: PASD motherboards uses the Line In 2 as the input for front
  9671. * panel mic (mic 2)
  9672. */
  9673. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9674. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9675. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9676. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9677. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9678. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9679. /*
  9680. * Set up output mixers (0x0c - 0x0f)
  9681. */
  9682. /* set vol=0 to output mixers */
  9683. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9684. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9685. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9686. /* set up input amps for analog loopback */
  9687. /* Amp Indices: DAC = 0, mixer = 1 */
  9688. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9689. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9690. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9691. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9692. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9693. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9694. /* FIXME: use matrix-type input source selection */
  9695. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9696. /* Input mixer */
  9697. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9698. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9699. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9700. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9701. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9702. { }
  9703. };
  9704. /* capture mixer elements */
  9705. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9706. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9707. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9708. {
  9709. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9710. /* The multiple "Capture Source" controls confuse alsamixer
  9711. * So call somewhat different..
  9712. * FIXME: the controls appear in the "playback" view!
  9713. */
  9714. /* .name = "Capture Source", */
  9715. .name = "Input Source",
  9716. .count = 1,
  9717. .info = alc882_mux_enum_info,
  9718. .get = alc882_mux_enum_get,
  9719. .put = alc882_mux_enum_put,
  9720. },
  9721. { } /* end */
  9722. };
  9723. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9724. {
  9725. unsigned int present;
  9726. unsigned char bits;
  9727. present = snd_hda_codec_read(codec, 0x14, 0,
  9728. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9729. bits = present ? 0x80 : 0;
  9730. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9731. 0x80, bits);
  9732. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9733. 0x80, bits);
  9734. }
  9735. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9736. {
  9737. unsigned int present;
  9738. unsigned char bits;
  9739. present = snd_hda_codec_read(codec, 0x1b, 0,
  9740. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9741. bits = present ? 0x80 : 0;
  9742. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9743. 0x80, bits);
  9744. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9745. 0x80, bits);
  9746. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9747. 0x80, bits);
  9748. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9749. 0x80, bits);
  9750. }
  9751. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9752. unsigned int res)
  9753. {
  9754. if ((res >> 26) == ALC880_HP_EVENT)
  9755. alc662_lenovo_101e_all_automute(codec);
  9756. if ((res >> 26) == ALC880_FRONT_EVENT)
  9757. alc662_lenovo_101e_ispeaker_automute(codec);
  9758. }
  9759. /* pcm configuration: identiacal with ALC880 */
  9760. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9761. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9762. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9763. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9764. /*
  9765. * configuration and preset
  9766. */
  9767. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9768. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9769. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9770. [ALC662_3ST_6ch] = "3stack-6ch",
  9771. [ALC662_5ST_DIG] = "6stack-dig",
  9772. [ALC662_LENOVO_101E] = "lenovo-101e",
  9773. [ALC662_AUTO] = "auto",
  9774. };
  9775. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9776. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9777. {}
  9778. };
  9779. static struct alc_config_preset alc662_presets[] = {
  9780. [ALC662_3ST_2ch_DIG] = {
  9781. .mixers = { alc662_3ST_2ch_mixer },
  9782. .init_verbs = { alc662_init_verbs },
  9783. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9784. .dac_nids = alc662_dac_nids,
  9785. .dig_out_nid = ALC662_DIGOUT_NID,
  9786. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9787. .adc_nids = alc662_adc_nids,
  9788. .dig_in_nid = ALC662_DIGIN_NID,
  9789. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9790. .channel_mode = alc662_3ST_2ch_modes,
  9791. .input_mux = &alc662_capture_source,
  9792. },
  9793. [ALC662_3ST_6ch_DIG] = {
  9794. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9795. .init_verbs = { alc662_init_verbs },
  9796. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9797. .dac_nids = alc662_dac_nids,
  9798. .dig_out_nid = ALC662_DIGOUT_NID,
  9799. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9800. .adc_nids = alc662_adc_nids,
  9801. .dig_in_nid = ALC662_DIGIN_NID,
  9802. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9803. .channel_mode = alc662_3ST_6ch_modes,
  9804. .need_dac_fix = 1,
  9805. .input_mux = &alc662_capture_source,
  9806. },
  9807. [ALC662_3ST_6ch] = {
  9808. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9809. .init_verbs = { alc662_init_verbs },
  9810. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9811. .dac_nids = alc662_dac_nids,
  9812. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9813. .adc_nids = alc662_adc_nids,
  9814. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9815. .channel_mode = alc662_3ST_6ch_modes,
  9816. .need_dac_fix = 1,
  9817. .input_mux = &alc662_capture_source,
  9818. },
  9819. [ALC662_5ST_DIG] = {
  9820. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9821. .init_verbs = { alc662_init_verbs },
  9822. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9823. .dac_nids = alc662_dac_nids,
  9824. .dig_out_nid = ALC662_DIGOUT_NID,
  9825. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9826. .adc_nids = alc662_adc_nids,
  9827. .dig_in_nid = ALC662_DIGIN_NID,
  9828. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9829. .channel_mode = alc662_5stack_modes,
  9830. .input_mux = &alc662_capture_source,
  9831. },
  9832. [ALC662_LENOVO_101E] = {
  9833. .mixers = { alc662_lenovo_101e_mixer },
  9834. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9835. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9836. .dac_nids = alc662_dac_nids,
  9837. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9838. .adc_nids = alc662_adc_nids,
  9839. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9840. .channel_mode = alc662_3ST_2ch_modes,
  9841. .input_mux = &alc662_lenovo_101e_capture_source,
  9842. .unsol_event = alc662_lenovo_101e_unsol_event,
  9843. .init_hook = alc662_lenovo_101e_all_automute,
  9844. },
  9845. };
  9846. /*
  9847. * BIOS auto configuration
  9848. */
  9849. /* add playback controls from the parsed DAC table */
  9850. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9851. const struct auto_pin_cfg *cfg)
  9852. {
  9853. char name[32];
  9854. static const char *chname[4] = {
  9855. "Front", "Surround", NULL /*CLFE*/, "Side"
  9856. };
  9857. hda_nid_t nid;
  9858. int i, err;
  9859. for (i = 0; i < cfg->line_outs; i++) {
  9860. if (!spec->multiout.dac_nids[i])
  9861. continue;
  9862. nid = alc880_idx_to_dac(i);
  9863. if (i == 2) {
  9864. /* Center/LFE */
  9865. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9866. "Center Playback Volume",
  9867. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9868. HDA_OUTPUT));
  9869. if (err < 0)
  9870. return err;
  9871. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9872. "LFE Playback Volume",
  9873. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9874. HDA_OUTPUT));
  9875. if (err < 0)
  9876. return err;
  9877. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9878. "Center Playback Switch",
  9879. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9880. HDA_INPUT));
  9881. if (err < 0)
  9882. return err;
  9883. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9884. "LFE Playback Switch",
  9885. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9886. HDA_INPUT));
  9887. if (err < 0)
  9888. return err;
  9889. } else {
  9890. sprintf(name, "%s Playback Volume", chname[i]);
  9891. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9892. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9893. HDA_OUTPUT));
  9894. if (err < 0)
  9895. return err;
  9896. sprintf(name, "%s Playback Switch", chname[i]);
  9897. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9898. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9899. HDA_INPUT));
  9900. if (err < 0)
  9901. return err;
  9902. }
  9903. }
  9904. return 0;
  9905. }
  9906. /* add playback controls for speaker and HP outputs */
  9907. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9908. const char *pfx)
  9909. {
  9910. hda_nid_t nid;
  9911. int err;
  9912. char name[32];
  9913. if (!pin)
  9914. return 0;
  9915. if (alc880_is_fixed_pin(pin)) {
  9916. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9917. /* printk("DAC nid=%x\n",nid); */
  9918. /* specify the DAC as the extra output */
  9919. if (!spec->multiout.hp_nid)
  9920. spec->multiout.hp_nid = nid;
  9921. else
  9922. spec->multiout.extra_out_nid[0] = nid;
  9923. /* control HP volume/switch on the output mixer amp */
  9924. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9925. sprintf(name, "%s Playback Volume", pfx);
  9926. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9927. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9928. if (err < 0)
  9929. return err;
  9930. sprintf(name, "%s Playback Switch", pfx);
  9931. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9932. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9933. if (err < 0)
  9934. return err;
  9935. } else if (alc880_is_multi_pin(pin)) {
  9936. /* set manual connection */
  9937. /* we have only a switch on HP-out PIN */
  9938. sprintf(name, "%s Playback Switch", pfx);
  9939. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9940. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9941. if (err < 0)
  9942. return err;
  9943. }
  9944. return 0;
  9945. }
  9946. /* create playback/capture controls for input pins */
  9947. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9948. const struct auto_pin_cfg *cfg)
  9949. {
  9950. struct hda_input_mux *imux = &spec->private_imux;
  9951. int i, err, idx;
  9952. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9953. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9954. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9955. err = new_analog_input(spec, cfg->input_pins[i],
  9956. auto_pin_cfg_labels[i],
  9957. idx, 0x0b);
  9958. if (err < 0)
  9959. return err;
  9960. imux->items[imux->num_items].label =
  9961. auto_pin_cfg_labels[i];
  9962. imux->items[imux->num_items].index =
  9963. alc880_input_pin_idx(cfg->input_pins[i]);
  9964. imux->num_items++;
  9965. }
  9966. }
  9967. return 0;
  9968. }
  9969. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9970. hda_nid_t nid, int pin_type,
  9971. int dac_idx)
  9972. {
  9973. /* set as output */
  9974. snd_hda_codec_write(codec, nid, 0,
  9975. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9976. snd_hda_codec_write(codec, nid, 0,
  9977. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9978. /* need the manual connection? */
  9979. if (alc880_is_multi_pin(nid)) {
  9980. struct alc_spec *spec = codec->spec;
  9981. int idx = alc880_multi_pin_idx(nid);
  9982. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  9983. AC_VERB_SET_CONNECT_SEL,
  9984. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  9985. }
  9986. }
  9987. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  9988. {
  9989. struct alc_spec *spec = codec->spec;
  9990. int i;
  9991. for (i = 0; i <= HDA_SIDE; i++) {
  9992. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9993. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9994. if (nid)
  9995. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  9996. i);
  9997. }
  9998. }
  9999. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10000. {
  10001. struct alc_spec *spec = codec->spec;
  10002. hda_nid_t pin;
  10003. pin = spec->autocfg.hp_pins[0];
  10004. if (pin) /* connect to front */
  10005. /* use dac 0 */
  10006. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10007. }
  10008. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10009. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10010. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10011. {
  10012. struct alc_spec *spec = codec->spec;
  10013. int i;
  10014. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10015. hda_nid_t nid = spec->autocfg.input_pins[i];
  10016. if (alc662_is_input_pin(nid)) {
  10017. snd_hda_codec_write(codec, nid, 0,
  10018. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10019. (i <= AUTO_PIN_FRONT_MIC ?
  10020. PIN_VREF80 : PIN_IN));
  10021. if (nid != ALC662_PIN_CD_NID)
  10022. snd_hda_codec_write(codec, nid, 0,
  10023. AC_VERB_SET_AMP_GAIN_MUTE,
  10024. AMP_OUT_MUTE);
  10025. }
  10026. }
  10027. }
  10028. static int alc662_parse_auto_config(struct hda_codec *codec)
  10029. {
  10030. struct alc_spec *spec = codec->spec;
  10031. int err;
  10032. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10033. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10034. alc662_ignore);
  10035. if (err < 0)
  10036. return err;
  10037. if (!spec->autocfg.line_outs)
  10038. return 0; /* can't find valid BIOS pin config */
  10039. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10040. if (err < 0)
  10041. return err;
  10042. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10043. if (err < 0)
  10044. return err;
  10045. err = alc662_auto_create_extra_out(spec,
  10046. spec->autocfg.speaker_pins[0],
  10047. "Speaker");
  10048. if (err < 0)
  10049. return err;
  10050. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10051. "Headphone");
  10052. if (err < 0)
  10053. return err;
  10054. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10055. if (err < 0)
  10056. return err;
  10057. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10058. if (spec->autocfg.dig_out_pin)
  10059. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10060. if (spec->kctl_alloc)
  10061. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10062. spec->num_mux_defs = 1;
  10063. spec->input_mux = &spec->private_imux;
  10064. if (err < 0)
  10065. return err;
  10066. else if (err > 0)
  10067. /* hack - override the init verbs */
  10068. spec->init_verbs[0] = alc662_auto_init_verbs;
  10069. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10070. spec->num_mixers++;
  10071. return err;
  10072. }
  10073. /* additional initialization for auto-configuration model */
  10074. static void alc662_auto_init(struct hda_codec *codec)
  10075. {
  10076. alc662_auto_init_multi_out(codec);
  10077. alc662_auto_init_hp_out(codec);
  10078. alc662_auto_init_analog_input(codec);
  10079. }
  10080. static int patch_alc662(struct hda_codec *codec)
  10081. {
  10082. struct alc_spec *spec;
  10083. int err, board_config;
  10084. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10085. if (!spec)
  10086. return -ENOMEM;
  10087. codec->spec = spec;
  10088. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10089. alc662_models,
  10090. alc662_cfg_tbl);
  10091. if (board_config < 0) {
  10092. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10093. "trying auto-probe from BIOS...\n");
  10094. board_config = ALC662_AUTO;
  10095. }
  10096. if (board_config == ALC662_AUTO) {
  10097. /* automatic parse from the BIOS config */
  10098. err = alc662_parse_auto_config(codec);
  10099. if (err < 0) {
  10100. alc_free(codec);
  10101. return err;
  10102. } else if (err) {
  10103. printk(KERN_INFO
  10104. "hda_codec: Cannot set up configuration "
  10105. "from BIOS. Using base mode...\n");
  10106. board_config = ALC662_3ST_2ch_DIG;
  10107. }
  10108. }
  10109. if (board_config != ALC662_AUTO)
  10110. setup_preset(spec, &alc662_presets[board_config]);
  10111. spec->stream_name_analog = "ALC662 Analog";
  10112. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10113. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10114. spec->stream_name_digital = "ALC662 Digital";
  10115. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10116. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10117. if (!spec->adc_nids && spec->input_mux) {
  10118. spec->adc_nids = alc662_adc_nids;
  10119. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10120. }
  10121. codec->patch_ops = alc_patch_ops;
  10122. if (board_config == ALC662_AUTO)
  10123. spec->init_hook = alc662_auto_init;
  10124. return 0;
  10125. }
  10126. /*
  10127. * patch entries
  10128. */
  10129. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10130. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10131. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10132. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10133. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10134. .patch = patch_alc861 },
  10135. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10136. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10137. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10138. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10139. .patch = patch_alc883 },
  10140. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10141. .patch = patch_alc662 },
  10142. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10143. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10144. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10145. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10146. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10147. {} /* terminator */
  10148. };