patch_realtek.c 397 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC885_MACPRO,
  149. ALC885_MBP3,
  150. ALC885_IMAC24,
  151. ALC882_AUTO,
  152. ALC882_MODEL_LAST,
  153. };
  154. /* ALC883 models */
  155. enum {
  156. ALC883_3ST_2ch_DIG,
  157. ALC883_3ST_6ch_DIG,
  158. ALC883_3ST_6ch,
  159. ALC883_6ST_DIG,
  160. ALC883_TARGA_DIG,
  161. ALC883_TARGA_2ch_DIG,
  162. ALC883_ACER,
  163. ALC883_ACER_ASPIRE,
  164. ALC883_MEDION,
  165. ALC883_MEDION_MD2,
  166. ALC883_LAPTOP_EAPD,
  167. ALC883_LENOVO_101E_2ch,
  168. ALC883_LENOVO_NB0763,
  169. ALC888_LENOVO_MS7195_DIG,
  170. ALC888_6ST_HP,
  171. ALC888_3ST_HP,
  172. ALC883_AUTO,
  173. ALC883_MODEL_LAST,
  174. };
  175. /* for GPIO Poll */
  176. #define GPIO_MASK 0x03
  177. struct alc_spec {
  178. /* codec parameterization */
  179. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  180. unsigned int num_mixers;
  181. const struct hda_verb *init_verbs[5]; /* initialization verbs
  182. * don't forget NULL
  183. * termination!
  184. */
  185. unsigned int num_init_verbs;
  186. char *stream_name_analog; /* analog PCM stream */
  187. struct hda_pcm_stream *stream_analog_playback;
  188. struct hda_pcm_stream *stream_analog_capture;
  189. char *stream_name_digital; /* digital PCM stream */
  190. struct hda_pcm_stream *stream_digital_playback;
  191. struct hda_pcm_stream *stream_digital_capture;
  192. /* playback */
  193. struct hda_multi_out multiout; /* playback set-up
  194. * max_channels, dacs must be set
  195. * dig_out_nid and hp_nid are optional
  196. */
  197. /* capture */
  198. unsigned int num_adc_nids;
  199. hda_nid_t *adc_nids;
  200. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  201. /* capture source */
  202. unsigned int num_mux_defs;
  203. const struct hda_input_mux *input_mux;
  204. unsigned int cur_mux[3];
  205. /* channel model */
  206. const struct hda_channel_mode *channel_mode;
  207. int num_channel_mode;
  208. int need_dac_fix;
  209. /* PCM information */
  210. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  211. /* dynamic controls, init_verbs and input_mux */
  212. struct auto_pin_cfg autocfg;
  213. unsigned int num_kctl_alloc, num_kctl_used;
  214. struct snd_kcontrol_new *kctl_alloc;
  215. struct hda_input_mux private_imux;
  216. hda_nid_t private_dac_nids[5];
  217. /* hooks */
  218. void (*init_hook)(struct hda_codec *codec);
  219. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  220. /* for pin sensing */
  221. unsigned int sense_updated: 1;
  222. unsigned int jack_present: 1;
  223. #ifdef CONFIG_SND_HDA_POWER_SAVE
  224. struct hda_loopback_check loopback;
  225. #endif
  226. };
  227. /*
  228. * configuration template - to be copied to the spec instance
  229. */
  230. struct alc_config_preset {
  231. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  232. * with spec
  233. */
  234. const struct hda_verb *init_verbs[5];
  235. unsigned int num_dacs;
  236. hda_nid_t *dac_nids;
  237. hda_nid_t dig_out_nid; /* optional */
  238. hda_nid_t hp_nid; /* optional */
  239. unsigned int num_adc_nids;
  240. hda_nid_t *adc_nids;
  241. hda_nid_t dig_in_nid;
  242. unsigned int num_channel_mode;
  243. const struct hda_channel_mode *channel_mode;
  244. int need_dac_fix;
  245. unsigned int num_mux_defs;
  246. const struct hda_input_mux *input_mux;
  247. void (*unsol_event)(struct hda_codec *, unsigned int);
  248. void (*init_hook)(struct hda_codec *);
  249. #ifdef CONFIG_SND_HDA_POWER_SAVE
  250. struct hda_amp_list *loopbacks;
  251. #endif
  252. };
  253. /*
  254. * input MUX handling
  255. */
  256. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  257. struct snd_ctl_elem_info *uinfo)
  258. {
  259. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  260. struct alc_spec *spec = codec->spec;
  261. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  262. if (mux_idx >= spec->num_mux_defs)
  263. mux_idx = 0;
  264. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  265. }
  266. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  267. struct snd_ctl_elem_value *ucontrol)
  268. {
  269. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  270. struct alc_spec *spec = codec->spec;
  271. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  272. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  273. return 0;
  274. }
  275. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  276. struct snd_ctl_elem_value *ucontrol)
  277. {
  278. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  279. struct alc_spec *spec = codec->spec;
  280. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  281. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  282. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  283. spec->adc_nids[adc_idx],
  284. &spec->cur_mux[adc_idx]);
  285. }
  286. /*
  287. * channel mode setting
  288. */
  289. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  290. struct snd_ctl_elem_info *uinfo)
  291. {
  292. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  293. struct alc_spec *spec = codec->spec;
  294. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  295. spec->num_channel_mode);
  296. }
  297. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  298. struct snd_ctl_elem_value *ucontrol)
  299. {
  300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  301. struct alc_spec *spec = codec->spec;
  302. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  303. spec->num_channel_mode,
  304. spec->multiout.max_channels);
  305. }
  306. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  307. struct snd_ctl_elem_value *ucontrol)
  308. {
  309. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  310. struct alc_spec *spec = codec->spec;
  311. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  312. spec->num_channel_mode,
  313. &spec->multiout.max_channels);
  314. if (err >= 0 && spec->need_dac_fix)
  315. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  316. return err;
  317. }
  318. /*
  319. * Control the mode of pin widget settings via the mixer. "pc" is used
  320. * instead of "%" to avoid consequences of accidently treating the % as
  321. * being part of a format specifier. Maximum allowed length of a value is
  322. * 63 characters plus NULL terminator.
  323. *
  324. * Note: some retasking pin complexes seem to ignore requests for input
  325. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  326. * are requested. Therefore order this list so that this behaviour will not
  327. * cause problems when mixer clients move through the enum sequentially.
  328. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  329. * March 2006.
  330. */
  331. static char *alc_pin_mode_names[] = {
  332. "Mic 50pc bias", "Mic 80pc bias",
  333. "Line in", "Line out", "Headphone out",
  334. };
  335. static unsigned char alc_pin_mode_values[] = {
  336. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  337. };
  338. /* The control can present all 5 options, or it can limit the options based
  339. * in the pin being assumed to be exclusively an input or an output pin. In
  340. * addition, "input" pins may or may not process the mic bias option
  341. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  342. * accept requests for bias as of chip versions up to March 2006) and/or
  343. * wiring in the computer.
  344. */
  345. #define ALC_PIN_DIR_IN 0x00
  346. #define ALC_PIN_DIR_OUT 0x01
  347. #define ALC_PIN_DIR_INOUT 0x02
  348. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  349. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  350. /* Info about the pin modes supported by the different pin direction modes.
  351. * For each direction the minimum and maximum values are given.
  352. */
  353. static signed char alc_pin_mode_dir_info[5][2] = {
  354. { 0, 2 }, /* ALC_PIN_DIR_IN */
  355. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  356. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  357. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  358. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  359. };
  360. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  361. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  362. #define alc_pin_mode_n_items(_dir) \
  363. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  364. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  365. struct snd_ctl_elem_info *uinfo)
  366. {
  367. unsigned int item_num = uinfo->value.enumerated.item;
  368. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  369. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  370. uinfo->count = 1;
  371. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  372. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  373. item_num = alc_pin_mode_min(dir);
  374. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  375. return 0;
  376. }
  377. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  378. struct snd_ctl_elem_value *ucontrol)
  379. {
  380. unsigned int i;
  381. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  382. hda_nid_t nid = kcontrol->private_value & 0xffff;
  383. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  384. long *valp = ucontrol->value.integer.value;
  385. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  386. AC_VERB_GET_PIN_WIDGET_CONTROL,
  387. 0x00);
  388. /* Find enumerated value for current pinctl setting */
  389. i = alc_pin_mode_min(dir);
  390. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  391. i++;
  392. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  393. return 0;
  394. }
  395. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  396. struct snd_ctl_elem_value *ucontrol)
  397. {
  398. signed int change;
  399. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  400. hda_nid_t nid = kcontrol->private_value & 0xffff;
  401. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  402. long val = *ucontrol->value.integer.value;
  403. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  404. AC_VERB_GET_PIN_WIDGET_CONTROL,
  405. 0x00);
  406. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  407. val = alc_pin_mode_min(dir);
  408. change = pinctl != alc_pin_mode_values[val];
  409. if (change) {
  410. /* Set pin mode to that requested */
  411. snd_hda_codec_write_cache(codec, nid, 0,
  412. AC_VERB_SET_PIN_WIDGET_CONTROL,
  413. alc_pin_mode_values[val]);
  414. /* Also enable the retasking pin's input/output as required
  415. * for the requested pin mode. Enum values of 2 or less are
  416. * input modes.
  417. *
  418. * Dynamically switching the input/output buffers probably
  419. * reduces noise slightly (particularly on input) so we'll
  420. * do it. However, having both input and output buffers
  421. * enabled simultaneously doesn't seem to be problematic if
  422. * this turns out to be necessary in the future.
  423. */
  424. if (val <= 2) {
  425. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  426. HDA_AMP_MUTE, HDA_AMP_MUTE);
  427. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  428. HDA_AMP_MUTE, 0);
  429. } else {
  430. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  431. HDA_AMP_MUTE, HDA_AMP_MUTE);
  432. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  433. HDA_AMP_MUTE, 0);
  434. }
  435. }
  436. return change;
  437. }
  438. #define ALC_PIN_MODE(xname, nid, dir) \
  439. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  440. .info = alc_pin_mode_info, \
  441. .get = alc_pin_mode_get, \
  442. .put = alc_pin_mode_put, \
  443. .private_value = nid | (dir<<16) }
  444. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  445. * together using a mask with more than one bit set. This control is
  446. * currently used only by the ALC260 test model. At this stage they are not
  447. * needed for any "production" models.
  448. */
  449. #ifdef CONFIG_SND_DEBUG
  450. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  451. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  452. struct snd_ctl_elem_value *ucontrol)
  453. {
  454. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  455. hda_nid_t nid = kcontrol->private_value & 0xffff;
  456. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  457. long *valp = ucontrol->value.integer.value;
  458. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  459. AC_VERB_GET_GPIO_DATA, 0x00);
  460. *valp = (val & mask) != 0;
  461. return 0;
  462. }
  463. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  464. struct snd_ctl_elem_value *ucontrol)
  465. {
  466. signed int change;
  467. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  468. hda_nid_t nid = kcontrol->private_value & 0xffff;
  469. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  470. long val = *ucontrol->value.integer.value;
  471. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  472. AC_VERB_GET_GPIO_DATA,
  473. 0x00);
  474. /* Set/unset the masked GPIO bit(s) as needed */
  475. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  476. if (val == 0)
  477. gpio_data &= ~mask;
  478. else
  479. gpio_data |= mask;
  480. snd_hda_codec_write_cache(codec, nid, 0,
  481. AC_VERB_SET_GPIO_DATA, gpio_data);
  482. return change;
  483. }
  484. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  485. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  486. .info = alc_gpio_data_info, \
  487. .get = alc_gpio_data_get, \
  488. .put = alc_gpio_data_put, \
  489. .private_value = nid | (mask<<16) }
  490. #endif /* CONFIG_SND_DEBUG */
  491. /* A switch control to allow the enabling of the digital IO pins on the
  492. * ALC260. This is incredibly simplistic; the intention of this control is
  493. * to provide something in the test model allowing digital outputs to be
  494. * identified if present. If models are found which can utilise these
  495. * outputs a more complete mixer control can be devised for those models if
  496. * necessary.
  497. */
  498. #ifdef CONFIG_SND_DEBUG
  499. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  500. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  501. struct snd_ctl_elem_value *ucontrol)
  502. {
  503. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  504. hda_nid_t nid = kcontrol->private_value & 0xffff;
  505. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  506. long *valp = ucontrol->value.integer.value;
  507. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  508. AC_VERB_GET_DIGI_CONVERT, 0x00);
  509. *valp = (val & mask) != 0;
  510. return 0;
  511. }
  512. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  513. struct snd_ctl_elem_value *ucontrol)
  514. {
  515. signed int change;
  516. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  517. hda_nid_t nid = kcontrol->private_value & 0xffff;
  518. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  519. long val = *ucontrol->value.integer.value;
  520. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  521. AC_VERB_GET_DIGI_CONVERT,
  522. 0x00);
  523. /* Set/unset the masked control bit(s) as needed */
  524. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  525. if (val==0)
  526. ctrl_data &= ~mask;
  527. else
  528. ctrl_data |= mask;
  529. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  530. ctrl_data);
  531. return change;
  532. }
  533. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  534. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  535. .info = alc_spdif_ctrl_info, \
  536. .get = alc_spdif_ctrl_get, \
  537. .put = alc_spdif_ctrl_put, \
  538. .private_value = nid | (mask<<16) }
  539. #endif /* CONFIG_SND_DEBUG */
  540. /*
  541. * set up from the preset table
  542. */
  543. static void setup_preset(struct alc_spec *spec,
  544. const struct alc_config_preset *preset)
  545. {
  546. int i;
  547. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  548. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  549. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  550. i++)
  551. spec->init_verbs[spec->num_init_verbs++] =
  552. preset->init_verbs[i];
  553. spec->channel_mode = preset->channel_mode;
  554. spec->num_channel_mode = preset->num_channel_mode;
  555. spec->need_dac_fix = preset->need_dac_fix;
  556. spec->multiout.max_channels = spec->channel_mode[0].channels;
  557. spec->multiout.num_dacs = preset->num_dacs;
  558. spec->multiout.dac_nids = preset->dac_nids;
  559. spec->multiout.dig_out_nid = preset->dig_out_nid;
  560. spec->multiout.hp_nid = preset->hp_nid;
  561. spec->num_mux_defs = preset->num_mux_defs;
  562. if (!spec->num_mux_defs)
  563. spec->num_mux_defs = 1;
  564. spec->input_mux = preset->input_mux;
  565. spec->num_adc_nids = preset->num_adc_nids;
  566. spec->adc_nids = preset->adc_nids;
  567. spec->dig_in_nid = preset->dig_in_nid;
  568. spec->unsol_event = preset->unsol_event;
  569. spec->init_hook = preset->init_hook;
  570. #ifdef CONFIG_SND_HDA_POWER_SAVE
  571. spec->loopback.amplist = preset->loopbacks;
  572. #endif
  573. }
  574. /* Enable GPIO mask and set output */
  575. static struct hda_verb alc_gpio1_init_verbs[] = {
  576. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  579. { }
  580. };
  581. static struct hda_verb alc_gpio2_init_verbs[] = {
  582. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  585. { }
  586. };
  587. static struct hda_verb alc_gpio3_init_verbs[] = {
  588. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  591. { }
  592. };
  593. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  594. * 31 ~ 16 : Manufacture ID
  595. * 15 ~ 8 : SKU ID
  596. * 7 ~ 0 : Assembly ID
  597. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  598. */
  599. static void alc_subsystem_id(struct hda_codec *codec,
  600. unsigned int porta, unsigned int porte,
  601. unsigned int portd)
  602. {
  603. unsigned int ass, tmp;
  604. ass = codec->subsystem_id;
  605. if (!(ass & 1))
  606. return;
  607. /* Override */
  608. tmp = (ass & 0x38) >> 3; /* external Amp control */
  609. switch (tmp) {
  610. case 1:
  611. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  612. break;
  613. case 3:
  614. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  615. break;
  616. case 7:
  617. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  618. break;
  619. case 5:
  620. switch (codec->vendor_id) {
  621. case 0x10ec0862:
  622. case 0x10ec0660:
  623. case 0x10ec0662:
  624. case 0x10ec0267:
  625. case 0x10ec0268:
  626. snd_hda_codec_write(codec, 0x14, 0,
  627. AC_VERB_SET_EAPD_BTLENABLE, 2);
  628. snd_hda_codec_write(codec, 0x15, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. return;
  631. }
  632. case 6:
  633. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  634. hda_nid_t port = 0;
  635. tmp = (ass & 0x1800) >> 11;
  636. switch (tmp) {
  637. case 0: port = porta; break;
  638. case 1: port = porte; break;
  639. case 2: port = portd; break;
  640. }
  641. if (port)
  642. snd_hda_codec_write(codec, port, 0,
  643. AC_VERB_SET_EAPD_BTLENABLE,
  644. 2);
  645. }
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  648. (tmp == 5 ? 0x3040 : 0x3050));
  649. break;
  650. }
  651. }
  652. /*
  653. * Fix-up pin default configurations
  654. */
  655. struct alc_pincfg {
  656. hda_nid_t nid;
  657. u32 val;
  658. };
  659. static void alc_fix_pincfg(struct hda_codec *codec,
  660. const struct snd_pci_quirk *quirk,
  661. const struct alc_pincfg **pinfix)
  662. {
  663. const struct alc_pincfg *cfg;
  664. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  665. if (!quirk)
  666. return;
  667. cfg = pinfix[quirk->value];
  668. for (; cfg->nid; cfg++) {
  669. int i;
  670. u32 val = cfg->val;
  671. for (i = 0; i < 4; i++) {
  672. snd_hda_codec_write(codec, cfg->nid, 0,
  673. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  674. val & 0xff);
  675. val >>= 8;
  676. }
  677. }
  678. }
  679. /*
  680. * ALC880 3-stack model
  681. *
  682. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  683. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  684. * F-Mic = 0x1b, HP = 0x19
  685. */
  686. static hda_nid_t alc880_dac_nids[4] = {
  687. /* front, rear, clfe, rear_surr */
  688. 0x02, 0x05, 0x04, 0x03
  689. };
  690. static hda_nid_t alc880_adc_nids[3] = {
  691. /* ADC0-2 */
  692. 0x07, 0x08, 0x09,
  693. };
  694. /* The datasheet says the node 0x07 is connected from inputs,
  695. * but it shows zero connection in the real implementation on some devices.
  696. * Note: this is a 915GAV bug, fixed on 915GLV
  697. */
  698. static hda_nid_t alc880_adc_nids_alt[2] = {
  699. /* ADC1-2 */
  700. 0x08, 0x09,
  701. };
  702. #define ALC880_DIGOUT_NID 0x06
  703. #define ALC880_DIGIN_NID 0x0a
  704. static struct hda_input_mux alc880_capture_source = {
  705. .num_items = 4,
  706. .items = {
  707. { "Mic", 0x0 },
  708. { "Front Mic", 0x3 },
  709. { "Line", 0x2 },
  710. { "CD", 0x4 },
  711. },
  712. };
  713. /* channel source setting (2/6 channel selection for 3-stack) */
  714. /* 2ch mode */
  715. static struct hda_verb alc880_threestack_ch2_init[] = {
  716. /* set line-in to input, mute it */
  717. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  718. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  719. /* set mic-in to input vref 80%, mute it */
  720. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  721. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  722. { } /* end */
  723. };
  724. /* 6ch mode */
  725. static struct hda_verb alc880_threestack_ch6_init[] = {
  726. /* set line-in to output, unmute it */
  727. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  728. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  729. /* set mic-in to output, unmute it */
  730. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  731. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  732. { } /* end */
  733. };
  734. static struct hda_channel_mode alc880_threestack_modes[2] = {
  735. { 2, alc880_threestack_ch2_init },
  736. { 6, alc880_threestack_ch6_init },
  737. };
  738. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  739. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  740. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  741. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  742. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  743. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  744. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  745. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  746. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  747. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  748. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  750. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  752. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  754. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  755. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  756. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  757. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  758. {
  759. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  760. .name = "Channel Mode",
  761. .info = alc_ch_mode_info,
  762. .get = alc_ch_mode_get,
  763. .put = alc_ch_mode_put,
  764. },
  765. { } /* end */
  766. };
  767. /* capture mixer elements */
  768. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  769. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  770. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  771. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  772. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  773. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  774. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  775. {
  776. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  777. /* The multiple "Capture Source" controls confuse alsamixer
  778. * So call somewhat different..
  779. * FIXME: the controls appear in the "playback" view!
  780. */
  781. /* .name = "Capture Source", */
  782. .name = "Input Source",
  783. .count = 3,
  784. .info = alc_mux_enum_info,
  785. .get = alc_mux_enum_get,
  786. .put = alc_mux_enum_put,
  787. },
  788. { } /* end */
  789. };
  790. /* capture mixer elements (in case NID 0x07 not available) */
  791. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  792. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  793. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  794. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  795. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  796. {
  797. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  798. /* The multiple "Capture Source" controls confuse alsamixer
  799. * So call somewhat different..
  800. * FIXME: the controls appear in the "playback" view!
  801. */
  802. /* .name = "Capture Source", */
  803. .name = "Input Source",
  804. .count = 2,
  805. .info = alc_mux_enum_info,
  806. .get = alc_mux_enum_get,
  807. .put = alc_mux_enum_put,
  808. },
  809. { } /* end */
  810. };
  811. /*
  812. * ALC880 5-stack model
  813. *
  814. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  815. * Side = 0x02 (0xd)
  816. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  817. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  818. */
  819. /* additional mixers to alc880_three_stack_mixer */
  820. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  821. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  822. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  823. { } /* end */
  824. };
  825. /* channel source setting (6/8 channel selection for 5-stack) */
  826. /* 6ch mode */
  827. static struct hda_verb alc880_fivestack_ch6_init[] = {
  828. /* set line-in to input, mute it */
  829. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  830. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  831. { } /* end */
  832. };
  833. /* 8ch mode */
  834. static struct hda_verb alc880_fivestack_ch8_init[] = {
  835. /* set line-in to output, unmute it */
  836. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  837. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  838. { } /* end */
  839. };
  840. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  841. { 6, alc880_fivestack_ch6_init },
  842. { 8, alc880_fivestack_ch8_init },
  843. };
  844. /*
  845. * ALC880 6-stack model
  846. *
  847. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  848. * Side = 0x05 (0x0f)
  849. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  850. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  851. */
  852. static hda_nid_t alc880_6st_dac_nids[4] = {
  853. /* front, rear, clfe, rear_surr */
  854. 0x02, 0x03, 0x04, 0x05
  855. };
  856. static struct hda_input_mux alc880_6stack_capture_source = {
  857. .num_items = 4,
  858. .items = {
  859. { "Mic", 0x0 },
  860. { "Front Mic", 0x1 },
  861. { "Line", 0x2 },
  862. { "CD", 0x4 },
  863. },
  864. };
  865. /* fixed 8-channels */
  866. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  867. { 8, NULL },
  868. };
  869. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  870. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  871. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  878. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  879. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  880. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  881. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  882. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  883. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  884. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  885. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  886. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  887. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  888. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  889. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  890. {
  891. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  892. .name = "Channel Mode",
  893. .info = alc_ch_mode_info,
  894. .get = alc_ch_mode_get,
  895. .put = alc_ch_mode_put,
  896. },
  897. { } /* end */
  898. };
  899. /*
  900. * ALC880 W810 model
  901. *
  902. * W810 has rear IO for:
  903. * Front (DAC 02)
  904. * Surround (DAC 03)
  905. * Center/LFE (DAC 04)
  906. * Digital out (06)
  907. *
  908. * The system also has a pair of internal speakers, and a headphone jack.
  909. * These are both connected to Line2 on the codec, hence to DAC 02.
  910. *
  911. * There is a variable resistor to control the speaker or headphone
  912. * volume. This is a hardware-only device without a software API.
  913. *
  914. * Plugging headphones in will disable the internal speakers. This is
  915. * implemented in hardware, not via the driver using jack sense. In
  916. * a similar fashion, plugging into the rear socket marked "front" will
  917. * disable both the speakers and headphones.
  918. *
  919. * For input, there's a microphone jack, and an "audio in" jack.
  920. * These may not do anything useful with this driver yet, because I
  921. * haven't setup any initialization verbs for these yet...
  922. */
  923. static hda_nid_t alc880_w810_dac_nids[3] = {
  924. /* front, rear/surround, clfe */
  925. 0x02, 0x03, 0x04
  926. };
  927. /* fixed 6 channels */
  928. static struct hda_channel_mode alc880_w810_modes[1] = {
  929. { 6, NULL }
  930. };
  931. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  932. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  933. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  934. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  935. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  938. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  939. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  940. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  941. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  942. { } /* end */
  943. };
  944. /*
  945. * Z710V model
  946. *
  947. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  948. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  949. * Line = 0x1a
  950. */
  951. static hda_nid_t alc880_z71v_dac_nids[1] = {
  952. 0x02
  953. };
  954. #define ALC880_Z71V_HP_DAC 0x03
  955. /* fixed 2 channels */
  956. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  957. { 2, NULL }
  958. };
  959. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  960. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  961. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  962. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  963. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  964. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  965. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  966. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  967. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  968. { } /* end */
  969. };
  970. /* FIXME! */
  971. /*
  972. * ALC880 F1734 model
  973. *
  974. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  975. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  976. */
  977. static hda_nid_t alc880_f1734_dac_nids[1] = {
  978. 0x03
  979. };
  980. #define ALC880_F1734_HP_DAC 0x02
  981. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  982. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  983. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  986. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  987. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  988. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  989. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  990. { } /* end */
  991. };
  992. /* FIXME! */
  993. /*
  994. * ALC880 ASUS model
  995. *
  996. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  997. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  998. * Mic = 0x18, Line = 0x1a
  999. */
  1000. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1001. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1002. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1003. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1004. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1005. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1006. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1007. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1008. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1010. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1011. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1012. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1013. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1014. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1015. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1016. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1017. {
  1018. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1019. .name = "Channel Mode",
  1020. .info = alc_ch_mode_info,
  1021. .get = alc_ch_mode_get,
  1022. .put = alc_ch_mode_put,
  1023. },
  1024. { } /* end */
  1025. };
  1026. /* FIXME! */
  1027. /*
  1028. * ALC880 ASUS W1V model
  1029. *
  1030. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1031. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1032. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1033. */
  1034. /* additional mixers to alc880_asus_mixer */
  1035. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1036. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1037. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1038. { } /* end */
  1039. };
  1040. /* additional mixers to alc880_asus_mixer */
  1041. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1042. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1043. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1044. { } /* end */
  1045. };
  1046. /* TCL S700 */
  1047. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1048. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1049. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1050. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1052. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1053. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1054. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1056. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1057. {
  1058. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1059. /* The multiple "Capture Source" controls confuse alsamixer
  1060. * So call somewhat different..
  1061. * FIXME: the controls appear in the "playback" view!
  1062. */
  1063. /* .name = "Capture Source", */
  1064. .name = "Input Source",
  1065. .count = 1,
  1066. .info = alc_mux_enum_info,
  1067. .get = alc_mux_enum_get,
  1068. .put = alc_mux_enum_put,
  1069. },
  1070. { } /* end */
  1071. };
  1072. /* Uniwill */
  1073. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1074. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1075. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1079. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1080. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1081. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1082. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1083. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1085. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1088. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1089. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1091. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1092. {
  1093. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1094. .name = "Channel Mode",
  1095. .info = alc_ch_mode_info,
  1096. .get = alc_ch_mode_get,
  1097. .put = alc_ch_mode_put,
  1098. },
  1099. { } /* end */
  1100. };
  1101. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1102. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1103. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1104. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1105. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1107. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1109. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1110. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1111. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1112. { } /* end */
  1113. };
  1114. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1115. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1116. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1117. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1118. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1119. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1120. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1121. { } /* end */
  1122. };
  1123. /*
  1124. * build control elements
  1125. */
  1126. static int alc_build_controls(struct hda_codec *codec)
  1127. {
  1128. struct alc_spec *spec = codec->spec;
  1129. int err;
  1130. int i;
  1131. for (i = 0; i < spec->num_mixers; i++) {
  1132. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1133. if (err < 0)
  1134. return err;
  1135. }
  1136. if (spec->multiout.dig_out_nid) {
  1137. err = snd_hda_create_spdif_out_ctls(codec,
  1138. spec->multiout.dig_out_nid);
  1139. if (err < 0)
  1140. return err;
  1141. }
  1142. if (spec->dig_in_nid) {
  1143. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1144. if (err < 0)
  1145. return err;
  1146. }
  1147. return 0;
  1148. }
  1149. /*
  1150. * initialize the codec volumes, etc
  1151. */
  1152. /*
  1153. * generic initialization of ADC, input mixers and output mixers
  1154. */
  1155. static struct hda_verb alc880_volume_init_verbs[] = {
  1156. /*
  1157. * Unmute ADC0-2 and set the default input to mic-in
  1158. */
  1159. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1160. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1161. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1162. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1163. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1164. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1165. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1166. * mixer widget
  1167. * Note: PASD motherboards uses the Line In 2 as the input for front
  1168. * panel mic (mic 2)
  1169. */
  1170. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1171. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1178. /*
  1179. * Set up output mixers (0x0c - 0x0f)
  1180. */
  1181. /* set vol=0 to output mixers */
  1182. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1183. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. /* set up input amps for analog loopback */
  1187. /* Amp Indices: DAC = 0, mixer = 1 */
  1188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1194. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1196. { }
  1197. };
  1198. /*
  1199. * 3-stack pin configuration:
  1200. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1201. */
  1202. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1203. /*
  1204. * preset connection lists of input pins
  1205. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1206. */
  1207. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1208. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1209. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1210. /*
  1211. * Set pin mode and muting
  1212. */
  1213. /* set front pin widgets 0x14 for output */
  1214. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1215. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1216. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1217. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1218. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1219. /* Mic2 (as headphone out) for HP output */
  1220. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1221. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1222. /* Line In pin widget for input */
  1223. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1224. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1225. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1226. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1227. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1228. /* CD pin widget for input */
  1229. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1230. { }
  1231. };
  1232. /*
  1233. * 5-stack pin configuration:
  1234. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1235. * line-in/side = 0x1a, f-mic = 0x1b
  1236. */
  1237. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1238. /*
  1239. * preset connection lists of input pins
  1240. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1241. */
  1242. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1243. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1244. /*
  1245. * Set pin mode and muting
  1246. */
  1247. /* set pin widgets 0x14-0x17 for output */
  1248. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1249. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. /* unmute pins for output (no gain on this amp) */
  1253. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1254. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1258. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1259. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1260. /* Mic2 (as headphone out) for HP output */
  1261. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1262. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1263. /* Line In pin widget for input */
  1264. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1265. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1266. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1267. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1268. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1269. /* CD pin widget for input */
  1270. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1271. { }
  1272. };
  1273. /*
  1274. * W810 pin configuration:
  1275. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1276. */
  1277. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1278. /* hphone/speaker input selector: front DAC */
  1279. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1280. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1281. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1282. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1285. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1287. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1288. { }
  1289. };
  1290. /*
  1291. * Z71V pin configuration:
  1292. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1293. */
  1294. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1295. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1296. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1297. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1298. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1300. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1301. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1302. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1303. { }
  1304. };
  1305. /*
  1306. * 6-stack pin configuration:
  1307. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1308. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1309. */
  1310. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1311. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1312. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1313. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1317. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1319. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1321. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1323. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1325. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1326. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1327. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1328. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1329. { }
  1330. };
  1331. /*
  1332. * Uniwill pin configuration:
  1333. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1334. * line = 0x1a
  1335. */
  1336. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1337. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1338. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1339. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1341. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1342. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1345. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1348. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1353. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1354. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1357. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1359. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1360. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1361. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1362. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1363. { }
  1364. };
  1365. /*
  1366. * Uniwill P53
  1367. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1368. */
  1369. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1370. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1371. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1372. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1373. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1376. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1383. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1384. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1385. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1386. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1387. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1388. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1389. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1390. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1391. { }
  1392. };
  1393. static struct hda_verb alc880_beep_init_verbs[] = {
  1394. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1395. { }
  1396. };
  1397. /* toggle speaker-output according to the hp-jack state */
  1398. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1399. {
  1400. unsigned int present;
  1401. unsigned char bits;
  1402. present = snd_hda_codec_read(codec, 0x14, 0,
  1403. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1404. bits = present ? HDA_AMP_MUTE : 0;
  1405. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1406. HDA_AMP_MUTE, bits);
  1407. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1408. HDA_AMP_MUTE, bits);
  1409. }
  1410. /* auto-toggle front mic */
  1411. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1412. {
  1413. unsigned int present;
  1414. unsigned char bits;
  1415. present = snd_hda_codec_read(codec, 0x18, 0,
  1416. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1417. bits = present ? HDA_AMP_MUTE : 0;
  1418. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1419. }
  1420. static void alc880_uniwill_automute(struct hda_codec *codec)
  1421. {
  1422. alc880_uniwill_hp_automute(codec);
  1423. alc880_uniwill_mic_automute(codec);
  1424. }
  1425. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1426. unsigned int res)
  1427. {
  1428. /* Looks like the unsol event is incompatible with the standard
  1429. * definition. 4bit tag is placed at 28 bit!
  1430. */
  1431. switch (res >> 28) {
  1432. case ALC880_HP_EVENT:
  1433. alc880_uniwill_hp_automute(codec);
  1434. break;
  1435. case ALC880_MIC_EVENT:
  1436. alc880_uniwill_mic_automute(codec);
  1437. break;
  1438. }
  1439. }
  1440. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1441. {
  1442. unsigned int present;
  1443. unsigned char bits;
  1444. present = snd_hda_codec_read(codec, 0x14, 0,
  1445. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1446. bits = present ? HDA_AMP_MUTE : 0;
  1447. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1448. }
  1449. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1450. {
  1451. unsigned int present;
  1452. present = snd_hda_codec_read(codec, 0x21, 0,
  1453. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1454. present &= HDA_AMP_VOLMASK;
  1455. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1456. HDA_AMP_VOLMASK, present);
  1457. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1458. HDA_AMP_VOLMASK, present);
  1459. }
  1460. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1461. unsigned int res)
  1462. {
  1463. /* Looks like the unsol event is incompatible with the standard
  1464. * definition. 4bit tag is placed at 28 bit!
  1465. */
  1466. if ((res >> 28) == ALC880_HP_EVENT)
  1467. alc880_uniwill_p53_hp_automute(codec);
  1468. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1469. alc880_uniwill_p53_dcvol_automute(codec);
  1470. }
  1471. /* FIXME! */
  1472. /*
  1473. * F1734 pin configuration:
  1474. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1475. */
  1476. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1477. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1478. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1479. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1480. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1482. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1483. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1486. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1487. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1488. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1489. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1490. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1494. { }
  1495. };
  1496. /* FIXME! */
  1497. /*
  1498. * ASUS pin configuration:
  1499. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1500. */
  1501. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1502. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1503. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1504. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1505. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1506. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1507. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1508. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1510. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1513. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1514. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1515. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1516. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1518. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1519. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1520. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1523. { }
  1524. };
  1525. /* Enable GPIO mask and set output */
  1526. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1527. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1528. /* Clevo m520g init */
  1529. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1530. /* headphone output */
  1531. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1532. /* line-out */
  1533. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1534. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1535. /* Line-in */
  1536. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1537. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1538. /* CD */
  1539. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1540. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1541. /* Mic1 (rear panel) */
  1542. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1543. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1544. /* Mic2 (front panel) */
  1545. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1546. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1547. /* headphone */
  1548. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1549. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1550. /* change to EAPD mode */
  1551. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1552. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1553. { }
  1554. };
  1555. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1556. /* change to EAPD mode */
  1557. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1558. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1559. /* Headphone output */
  1560. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1561. /* Front output*/
  1562. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1563. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1564. /* Line In pin widget for input */
  1565. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1566. /* CD pin widget for input */
  1567. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1568. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1569. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1570. /* change to EAPD mode */
  1571. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1572. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1573. { }
  1574. };
  1575. /*
  1576. * LG m1 express dual
  1577. *
  1578. * Pin assignment:
  1579. * Rear Line-In/Out (blue): 0x14
  1580. * Build-in Mic-In: 0x15
  1581. * Speaker-out: 0x17
  1582. * HP-Out (green): 0x1b
  1583. * Mic-In/Out (red): 0x19
  1584. * SPDIF-Out: 0x1e
  1585. */
  1586. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1587. static hda_nid_t alc880_lg_dac_nids[3] = {
  1588. 0x05, 0x02, 0x03
  1589. };
  1590. /* seems analog CD is not working */
  1591. static struct hda_input_mux alc880_lg_capture_source = {
  1592. .num_items = 3,
  1593. .items = {
  1594. { "Mic", 0x1 },
  1595. { "Line", 0x5 },
  1596. { "Internal Mic", 0x6 },
  1597. },
  1598. };
  1599. /* 2,4,6 channel modes */
  1600. static struct hda_verb alc880_lg_ch2_init[] = {
  1601. /* set line-in and mic-in to input */
  1602. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1603. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1604. { }
  1605. };
  1606. static struct hda_verb alc880_lg_ch4_init[] = {
  1607. /* set line-in to out and mic-in to input */
  1608. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1609. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1610. { }
  1611. };
  1612. static struct hda_verb alc880_lg_ch6_init[] = {
  1613. /* set line-in and mic-in to output */
  1614. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1615. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1616. { }
  1617. };
  1618. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1619. { 2, alc880_lg_ch2_init },
  1620. { 4, alc880_lg_ch4_init },
  1621. { 6, alc880_lg_ch6_init },
  1622. };
  1623. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1624. /* FIXME: it's not really "master" but front channels */
  1625. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1626. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1627. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1628. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1629. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1630. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1631. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1632. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1633. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1634. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1635. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1636. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1637. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1638. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1639. {
  1640. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1641. .name = "Channel Mode",
  1642. .info = alc_ch_mode_info,
  1643. .get = alc_ch_mode_get,
  1644. .put = alc_ch_mode_put,
  1645. },
  1646. { } /* end */
  1647. };
  1648. static struct hda_verb alc880_lg_init_verbs[] = {
  1649. /* set capture source to mic-in */
  1650. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1651. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. /* mute all amp mixer inputs */
  1654. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1657. /* line-in to input */
  1658. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1660. /* built-in mic */
  1661. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1662. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1663. /* speaker-out */
  1664. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1665. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1666. /* mic-in to input */
  1667. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1668. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1669. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1670. /* HP-out */
  1671. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1672. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1673. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* jack sense */
  1675. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1676. { }
  1677. };
  1678. /* toggle speaker-output according to the hp-jack state */
  1679. static void alc880_lg_automute(struct hda_codec *codec)
  1680. {
  1681. unsigned int present;
  1682. unsigned char bits;
  1683. present = snd_hda_codec_read(codec, 0x1b, 0,
  1684. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1685. bits = present ? HDA_AMP_MUTE : 0;
  1686. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1687. HDA_AMP_MUTE, bits);
  1688. }
  1689. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1690. {
  1691. /* Looks like the unsol event is incompatible with the standard
  1692. * definition. 4bit tag is placed at 28 bit!
  1693. */
  1694. if ((res >> 28) == 0x01)
  1695. alc880_lg_automute(codec);
  1696. }
  1697. /*
  1698. * LG LW20
  1699. *
  1700. * Pin assignment:
  1701. * Speaker-out: 0x14
  1702. * Mic-In: 0x18
  1703. * Built-in Mic-In: 0x19
  1704. * Line-In: 0x1b
  1705. * HP-Out: 0x1a
  1706. * SPDIF-Out: 0x1e
  1707. */
  1708. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1709. .num_items = 3,
  1710. .items = {
  1711. { "Mic", 0x0 },
  1712. { "Internal Mic", 0x1 },
  1713. { "Line In", 0x2 },
  1714. },
  1715. };
  1716. #define alc880_lg_lw_modes alc880_threestack_modes
  1717. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1718. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1719. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1720. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1721. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1722. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1723. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1724. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1725. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1726. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1727. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1728. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1729. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1730. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1731. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1732. {
  1733. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1734. .name = "Channel Mode",
  1735. .info = alc_ch_mode_info,
  1736. .get = alc_ch_mode_get,
  1737. .put = alc_ch_mode_put,
  1738. },
  1739. { } /* end */
  1740. };
  1741. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1742. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1743. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1744. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1745. /* set capture source to mic-in */
  1746. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1747. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1748. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1750. /* speaker-out */
  1751. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1752. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1753. /* HP-out */
  1754. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1755. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1756. /* mic-in to input */
  1757. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1758. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1759. /* built-in mic */
  1760. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1761. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1762. /* jack sense */
  1763. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1764. { }
  1765. };
  1766. /* toggle speaker-output according to the hp-jack state */
  1767. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1768. {
  1769. unsigned int present;
  1770. unsigned char bits;
  1771. present = snd_hda_codec_read(codec, 0x1b, 0,
  1772. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1773. bits = present ? HDA_AMP_MUTE : 0;
  1774. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1775. HDA_AMP_MUTE, bits);
  1776. }
  1777. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1778. {
  1779. /* Looks like the unsol event is incompatible with the standard
  1780. * definition. 4bit tag is placed at 28 bit!
  1781. */
  1782. if ((res >> 28) == 0x01)
  1783. alc880_lg_lw_automute(codec);
  1784. }
  1785. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1786. static struct hda_amp_list alc880_loopbacks[] = {
  1787. { 0x0b, HDA_INPUT, 0 },
  1788. { 0x0b, HDA_INPUT, 1 },
  1789. { 0x0b, HDA_INPUT, 2 },
  1790. { 0x0b, HDA_INPUT, 3 },
  1791. { 0x0b, HDA_INPUT, 4 },
  1792. { } /* end */
  1793. };
  1794. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1795. { 0x0b, HDA_INPUT, 1 },
  1796. { 0x0b, HDA_INPUT, 6 },
  1797. { 0x0b, HDA_INPUT, 7 },
  1798. { } /* end */
  1799. };
  1800. #endif
  1801. /*
  1802. * Common callbacks
  1803. */
  1804. static int alc_init(struct hda_codec *codec)
  1805. {
  1806. struct alc_spec *spec = codec->spec;
  1807. unsigned int i;
  1808. for (i = 0; i < spec->num_init_verbs; i++)
  1809. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1810. if (spec->init_hook)
  1811. spec->init_hook(codec);
  1812. return 0;
  1813. }
  1814. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1815. {
  1816. struct alc_spec *spec = codec->spec;
  1817. if (spec->unsol_event)
  1818. spec->unsol_event(codec, res);
  1819. }
  1820. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1821. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1822. {
  1823. struct alc_spec *spec = codec->spec;
  1824. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1825. }
  1826. #endif
  1827. /*
  1828. * Analog playback callbacks
  1829. */
  1830. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1831. struct hda_codec *codec,
  1832. struct snd_pcm_substream *substream)
  1833. {
  1834. struct alc_spec *spec = codec->spec;
  1835. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1836. }
  1837. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1838. struct hda_codec *codec,
  1839. unsigned int stream_tag,
  1840. unsigned int format,
  1841. struct snd_pcm_substream *substream)
  1842. {
  1843. struct alc_spec *spec = codec->spec;
  1844. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1845. stream_tag, format, substream);
  1846. }
  1847. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1848. struct hda_codec *codec,
  1849. struct snd_pcm_substream *substream)
  1850. {
  1851. struct alc_spec *spec = codec->spec;
  1852. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1853. }
  1854. /*
  1855. * Digital out
  1856. */
  1857. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1858. struct hda_codec *codec,
  1859. struct snd_pcm_substream *substream)
  1860. {
  1861. struct alc_spec *spec = codec->spec;
  1862. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1863. }
  1864. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1865. struct hda_codec *codec,
  1866. unsigned int stream_tag,
  1867. unsigned int format,
  1868. struct snd_pcm_substream *substream)
  1869. {
  1870. struct alc_spec *spec = codec->spec;
  1871. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1872. stream_tag, format, substream);
  1873. }
  1874. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1875. struct hda_codec *codec,
  1876. struct snd_pcm_substream *substream)
  1877. {
  1878. struct alc_spec *spec = codec->spec;
  1879. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1880. }
  1881. /*
  1882. * Analog capture
  1883. */
  1884. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1885. struct hda_codec *codec,
  1886. unsigned int stream_tag,
  1887. unsigned int format,
  1888. struct snd_pcm_substream *substream)
  1889. {
  1890. struct alc_spec *spec = codec->spec;
  1891. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1892. stream_tag, 0, format);
  1893. return 0;
  1894. }
  1895. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1896. struct hda_codec *codec,
  1897. struct snd_pcm_substream *substream)
  1898. {
  1899. struct alc_spec *spec = codec->spec;
  1900. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1901. 0, 0, 0);
  1902. return 0;
  1903. }
  1904. /*
  1905. */
  1906. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1907. .substreams = 1,
  1908. .channels_min = 2,
  1909. .channels_max = 8,
  1910. /* NID is set in alc_build_pcms */
  1911. .ops = {
  1912. .open = alc880_playback_pcm_open,
  1913. .prepare = alc880_playback_pcm_prepare,
  1914. .cleanup = alc880_playback_pcm_cleanup
  1915. },
  1916. };
  1917. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1918. .substreams = 2,
  1919. .channels_min = 2,
  1920. .channels_max = 2,
  1921. /* NID is set in alc_build_pcms */
  1922. .ops = {
  1923. .prepare = alc880_capture_pcm_prepare,
  1924. .cleanup = alc880_capture_pcm_cleanup
  1925. },
  1926. };
  1927. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1928. .substreams = 1,
  1929. .channels_min = 2,
  1930. .channels_max = 2,
  1931. /* NID is set in alc_build_pcms */
  1932. .ops = {
  1933. .open = alc880_dig_playback_pcm_open,
  1934. .close = alc880_dig_playback_pcm_close,
  1935. .prepare = alc880_dig_playback_pcm_prepare
  1936. },
  1937. };
  1938. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1939. .substreams = 1,
  1940. .channels_min = 2,
  1941. .channels_max = 2,
  1942. /* NID is set in alc_build_pcms */
  1943. };
  1944. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1945. static struct hda_pcm_stream alc_pcm_null_playback = {
  1946. .substreams = 0,
  1947. .channels_min = 0,
  1948. .channels_max = 0,
  1949. };
  1950. static int alc_build_pcms(struct hda_codec *codec)
  1951. {
  1952. struct alc_spec *spec = codec->spec;
  1953. struct hda_pcm *info = spec->pcm_rec;
  1954. int i;
  1955. codec->num_pcms = 1;
  1956. codec->pcm_info = info;
  1957. info->name = spec->stream_name_analog;
  1958. if (spec->stream_analog_playback) {
  1959. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1960. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1961. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1962. }
  1963. if (spec->stream_analog_capture) {
  1964. snd_assert(spec->adc_nids, return -EINVAL);
  1965. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1966. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1967. }
  1968. if (spec->channel_mode) {
  1969. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1970. for (i = 0; i < spec->num_channel_mode; i++) {
  1971. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1972. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1973. }
  1974. }
  1975. }
  1976. /* SPDIF for stream index #1 */
  1977. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1978. codec->num_pcms = 2;
  1979. info = spec->pcm_rec + 1;
  1980. info->name = spec->stream_name_digital;
  1981. if (spec->multiout.dig_out_nid &&
  1982. spec->stream_digital_playback) {
  1983. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1985. }
  1986. if (spec->dig_in_nid &&
  1987. spec->stream_digital_capture) {
  1988. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1989. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1990. }
  1991. }
  1992. /* If the use of more than one ADC is requested for the current
  1993. * model, configure a second analog capture-only PCM.
  1994. */
  1995. /* Additional Analaog capture for index #2 */
  1996. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1997. spec->adc_nids) {
  1998. codec->num_pcms = 3;
  1999. info = spec->pcm_rec + 2;
  2000. info->name = spec->stream_name_analog;
  2001. /* No playback stream for second PCM */
  2002. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2003. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2004. if (spec->stream_analog_capture) {
  2005. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2006. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2007. }
  2008. }
  2009. return 0;
  2010. }
  2011. static void alc_free(struct hda_codec *codec)
  2012. {
  2013. struct alc_spec *spec = codec->spec;
  2014. unsigned int i;
  2015. if (!spec)
  2016. return;
  2017. if (spec->kctl_alloc) {
  2018. for (i = 0; i < spec->num_kctl_used; i++)
  2019. kfree(spec->kctl_alloc[i].name);
  2020. kfree(spec->kctl_alloc);
  2021. }
  2022. kfree(spec);
  2023. }
  2024. /*
  2025. */
  2026. static struct hda_codec_ops alc_patch_ops = {
  2027. .build_controls = alc_build_controls,
  2028. .build_pcms = alc_build_pcms,
  2029. .init = alc_init,
  2030. .free = alc_free,
  2031. .unsol_event = alc_unsol_event,
  2032. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2033. .check_power_status = alc_check_power_status,
  2034. #endif
  2035. };
  2036. /*
  2037. * Test configuration for debugging
  2038. *
  2039. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2040. * enum controls.
  2041. */
  2042. #ifdef CONFIG_SND_DEBUG
  2043. static hda_nid_t alc880_test_dac_nids[4] = {
  2044. 0x02, 0x03, 0x04, 0x05
  2045. };
  2046. static struct hda_input_mux alc880_test_capture_source = {
  2047. .num_items = 7,
  2048. .items = {
  2049. { "In-1", 0x0 },
  2050. { "In-2", 0x1 },
  2051. { "In-3", 0x2 },
  2052. { "In-4", 0x3 },
  2053. { "CD", 0x4 },
  2054. { "Front", 0x5 },
  2055. { "Surround", 0x6 },
  2056. },
  2057. };
  2058. static struct hda_channel_mode alc880_test_modes[4] = {
  2059. { 2, NULL },
  2060. { 4, NULL },
  2061. { 6, NULL },
  2062. { 8, NULL },
  2063. };
  2064. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2065. struct snd_ctl_elem_info *uinfo)
  2066. {
  2067. static char *texts[] = {
  2068. "N/A", "Line Out", "HP Out",
  2069. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2070. };
  2071. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2072. uinfo->count = 1;
  2073. uinfo->value.enumerated.items = 8;
  2074. if (uinfo->value.enumerated.item >= 8)
  2075. uinfo->value.enumerated.item = 7;
  2076. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2077. return 0;
  2078. }
  2079. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2080. struct snd_ctl_elem_value *ucontrol)
  2081. {
  2082. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2083. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2084. unsigned int pin_ctl, item = 0;
  2085. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2086. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2087. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2088. if (pin_ctl & AC_PINCTL_HP_EN)
  2089. item = 2;
  2090. else
  2091. item = 1;
  2092. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2093. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2094. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2095. case AC_PINCTL_VREF_50: item = 4; break;
  2096. case AC_PINCTL_VREF_GRD: item = 5; break;
  2097. case AC_PINCTL_VREF_80: item = 6; break;
  2098. case AC_PINCTL_VREF_100: item = 7; break;
  2099. }
  2100. }
  2101. ucontrol->value.enumerated.item[0] = item;
  2102. return 0;
  2103. }
  2104. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2105. struct snd_ctl_elem_value *ucontrol)
  2106. {
  2107. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2108. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2109. static unsigned int ctls[] = {
  2110. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2111. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2116. };
  2117. unsigned int old_ctl, new_ctl;
  2118. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2119. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2120. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2121. if (old_ctl != new_ctl) {
  2122. int val;
  2123. snd_hda_codec_write_cache(codec, nid, 0,
  2124. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2125. new_ctl);
  2126. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2127. HDA_AMP_MUTE : 0;
  2128. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2129. HDA_AMP_MUTE, val);
  2130. return 1;
  2131. }
  2132. return 0;
  2133. }
  2134. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2135. struct snd_ctl_elem_info *uinfo)
  2136. {
  2137. static char *texts[] = {
  2138. "Front", "Surround", "CLFE", "Side"
  2139. };
  2140. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2141. uinfo->count = 1;
  2142. uinfo->value.enumerated.items = 4;
  2143. if (uinfo->value.enumerated.item >= 4)
  2144. uinfo->value.enumerated.item = 3;
  2145. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2146. return 0;
  2147. }
  2148. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2149. struct snd_ctl_elem_value *ucontrol)
  2150. {
  2151. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2152. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2153. unsigned int sel;
  2154. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2155. ucontrol->value.enumerated.item[0] = sel & 3;
  2156. return 0;
  2157. }
  2158. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2162. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2163. unsigned int sel;
  2164. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2165. if (ucontrol->value.enumerated.item[0] != sel) {
  2166. sel = ucontrol->value.enumerated.item[0] & 3;
  2167. snd_hda_codec_write_cache(codec, nid, 0,
  2168. AC_VERB_SET_CONNECT_SEL, sel);
  2169. return 1;
  2170. }
  2171. return 0;
  2172. }
  2173. #define PIN_CTL_TEST(xname,nid) { \
  2174. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2175. .name = xname, \
  2176. .info = alc_test_pin_ctl_info, \
  2177. .get = alc_test_pin_ctl_get, \
  2178. .put = alc_test_pin_ctl_put, \
  2179. .private_value = nid \
  2180. }
  2181. #define PIN_SRC_TEST(xname,nid) { \
  2182. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2183. .name = xname, \
  2184. .info = alc_test_pin_src_info, \
  2185. .get = alc_test_pin_src_get, \
  2186. .put = alc_test_pin_src_put, \
  2187. .private_value = nid \
  2188. }
  2189. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2190. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2191. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2194. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2195. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2196. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2198. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2199. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2200. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2201. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2202. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2203. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2204. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2205. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2206. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2207. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2208. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2209. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2210. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2211. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2212. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2213. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2214. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2215. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2216. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2217. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2218. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2219. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2220. {
  2221. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2222. .name = "Channel Mode",
  2223. .info = alc_ch_mode_info,
  2224. .get = alc_ch_mode_get,
  2225. .put = alc_ch_mode_put,
  2226. },
  2227. { } /* end */
  2228. };
  2229. static struct hda_verb alc880_test_init_verbs[] = {
  2230. /* Unmute inputs of 0x0c - 0x0f */
  2231. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2232. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2233. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2234. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2235. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2237. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2239. /* Vol output for 0x0c-0x0f */
  2240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2241. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2242. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. /* Set output pins 0x14-0x17 */
  2245. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2246. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2247. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. /* Unmute output pins 0x14-0x17 */
  2250. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2251. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2252. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. /* Set input pins 0x18-0x1c */
  2255. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2256. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2257. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2258. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2259. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. /* Mute input pins 0x18-0x1b */
  2261. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2262. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2263. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. /* ADC set up */
  2266. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2267. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2268. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2269. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2270. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2271. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2272. /* Analog input/passthru */
  2273. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2278. { }
  2279. };
  2280. #endif
  2281. /*
  2282. */
  2283. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2284. [ALC880_3ST] = "3stack",
  2285. [ALC880_TCL_S700] = "tcl",
  2286. [ALC880_3ST_DIG] = "3stack-digout",
  2287. [ALC880_CLEVO] = "clevo",
  2288. [ALC880_5ST] = "5stack",
  2289. [ALC880_5ST_DIG] = "5stack-digout",
  2290. [ALC880_W810] = "w810",
  2291. [ALC880_Z71V] = "z71v",
  2292. [ALC880_6ST] = "6stack",
  2293. [ALC880_6ST_DIG] = "6stack-digout",
  2294. [ALC880_ASUS] = "asus",
  2295. [ALC880_ASUS_W1V] = "asus-w1v",
  2296. [ALC880_ASUS_DIG] = "asus-dig",
  2297. [ALC880_ASUS_DIG2] = "asus-dig2",
  2298. [ALC880_UNIWILL_DIG] = "uniwill",
  2299. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2300. [ALC880_FUJITSU] = "fujitsu",
  2301. [ALC880_F1734] = "F1734",
  2302. [ALC880_LG] = "lg",
  2303. [ALC880_LG_LW] = "lg-lw",
  2304. #ifdef CONFIG_SND_DEBUG
  2305. [ALC880_TEST] = "test",
  2306. #endif
  2307. [ALC880_AUTO] = "auto",
  2308. };
  2309. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2310. /* Broken BIOS configuration */
  2311. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2314. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2315. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2316. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2317. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2318. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2322. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2323. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2324. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2325. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2326. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2331. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2332. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2333. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2334. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2335. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2337. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2338. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2339. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2340. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2341. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2342. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2343. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2345. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2346. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2347. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2348. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2349. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2350. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2351. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2352. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2353. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2357. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2358. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2359. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2360. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2361. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2362. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2363. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2364. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2365. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2366. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2367. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2368. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2369. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2370. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2380. {}
  2381. };
  2382. /*
  2383. * ALC880 codec presets
  2384. */
  2385. static struct alc_config_preset alc880_presets[] = {
  2386. [ALC880_3ST] = {
  2387. .mixers = { alc880_three_stack_mixer },
  2388. .init_verbs = { alc880_volume_init_verbs,
  2389. alc880_pin_3stack_init_verbs },
  2390. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2391. .dac_nids = alc880_dac_nids,
  2392. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2393. .channel_mode = alc880_threestack_modes,
  2394. .need_dac_fix = 1,
  2395. .input_mux = &alc880_capture_source,
  2396. },
  2397. [ALC880_3ST_DIG] = {
  2398. .mixers = { alc880_three_stack_mixer },
  2399. .init_verbs = { alc880_volume_init_verbs,
  2400. alc880_pin_3stack_init_verbs },
  2401. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2402. .dac_nids = alc880_dac_nids,
  2403. .dig_out_nid = ALC880_DIGOUT_NID,
  2404. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2405. .channel_mode = alc880_threestack_modes,
  2406. .need_dac_fix = 1,
  2407. .input_mux = &alc880_capture_source,
  2408. },
  2409. [ALC880_TCL_S700] = {
  2410. .mixers = { alc880_tcl_s700_mixer },
  2411. .init_verbs = { alc880_volume_init_verbs,
  2412. alc880_pin_tcl_S700_init_verbs,
  2413. alc880_gpio2_init_verbs },
  2414. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2415. .dac_nids = alc880_dac_nids,
  2416. .hp_nid = 0x03,
  2417. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2418. .channel_mode = alc880_2_jack_modes,
  2419. .input_mux = &alc880_capture_source,
  2420. },
  2421. [ALC880_5ST] = {
  2422. .mixers = { alc880_three_stack_mixer,
  2423. alc880_five_stack_mixer},
  2424. .init_verbs = { alc880_volume_init_verbs,
  2425. alc880_pin_5stack_init_verbs },
  2426. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2427. .dac_nids = alc880_dac_nids,
  2428. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2429. .channel_mode = alc880_fivestack_modes,
  2430. .input_mux = &alc880_capture_source,
  2431. },
  2432. [ALC880_5ST_DIG] = {
  2433. .mixers = { alc880_three_stack_mixer,
  2434. alc880_five_stack_mixer },
  2435. .init_verbs = { alc880_volume_init_verbs,
  2436. alc880_pin_5stack_init_verbs },
  2437. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2438. .dac_nids = alc880_dac_nids,
  2439. .dig_out_nid = ALC880_DIGOUT_NID,
  2440. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2441. .channel_mode = alc880_fivestack_modes,
  2442. .input_mux = &alc880_capture_source,
  2443. },
  2444. [ALC880_6ST] = {
  2445. .mixers = { alc880_six_stack_mixer },
  2446. .init_verbs = { alc880_volume_init_verbs,
  2447. alc880_pin_6stack_init_verbs },
  2448. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2449. .dac_nids = alc880_6st_dac_nids,
  2450. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2451. .channel_mode = alc880_sixstack_modes,
  2452. .input_mux = &alc880_6stack_capture_source,
  2453. },
  2454. [ALC880_6ST_DIG] = {
  2455. .mixers = { alc880_six_stack_mixer },
  2456. .init_verbs = { alc880_volume_init_verbs,
  2457. alc880_pin_6stack_init_verbs },
  2458. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2459. .dac_nids = alc880_6st_dac_nids,
  2460. .dig_out_nid = ALC880_DIGOUT_NID,
  2461. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2462. .channel_mode = alc880_sixstack_modes,
  2463. .input_mux = &alc880_6stack_capture_source,
  2464. },
  2465. [ALC880_W810] = {
  2466. .mixers = { alc880_w810_base_mixer },
  2467. .init_verbs = { alc880_volume_init_verbs,
  2468. alc880_pin_w810_init_verbs,
  2469. alc880_gpio2_init_verbs },
  2470. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2471. .dac_nids = alc880_w810_dac_nids,
  2472. .dig_out_nid = ALC880_DIGOUT_NID,
  2473. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2474. .channel_mode = alc880_w810_modes,
  2475. .input_mux = &alc880_capture_source,
  2476. },
  2477. [ALC880_Z71V] = {
  2478. .mixers = { alc880_z71v_mixer },
  2479. .init_verbs = { alc880_volume_init_verbs,
  2480. alc880_pin_z71v_init_verbs },
  2481. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2482. .dac_nids = alc880_z71v_dac_nids,
  2483. .dig_out_nid = ALC880_DIGOUT_NID,
  2484. .hp_nid = 0x03,
  2485. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2486. .channel_mode = alc880_2_jack_modes,
  2487. .input_mux = &alc880_capture_source,
  2488. },
  2489. [ALC880_F1734] = {
  2490. .mixers = { alc880_f1734_mixer },
  2491. .init_verbs = { alc880_volume_init_verbs,
  2492. alc880_pin_f1734_init_verbs },
  2493. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2494. .dac_nids = alc880_f1734_dac_nids,
  2495. .hp_nid = 0x02,
  2496. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2497. .channel_mode = alc880_2_jack_modes,
  2498. .input_mux = &alc880_capture_source,
  2499. },
  2500. [ALC880_ASUS] = {
  2501. .mixers = { alc880_asus_mixer },
  2502. .init_verbs = { alc880_volume_init_verbs,
  2503. alc880_pin_asus_init_verbs,
  2504. alc880_gpio1_init_verbs },
  2505. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2506. .dac_nids = alc880_asus_dac_nids,
  2507. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2508. .channel_mode = alc880_asus_modes,
  2509. .need_dac_fix = 1,
  2510. .input_mux = &alc880_capture_source,
  2511. },
  2512. [ALC880_ASUS_DIG] = {
  2513. .mixers = { alc880_asus_mixer },
  2514. .init_verbs = { alc880_volume_init_verbs,
  2515. alc880_pin_asus_init_verbs,
  2516. alc880_gpio1_init_verbs },
  2517. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2518. .dac_nids = alc880_asus_dac_nids,
  2519. .dig_out_nid = ALC880_DIGOUT_NID,
  2520. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2521. .channel_mode = alc880_asus_modes,
  2522. .need_dac_fix = 1,
  2523. .input_mux = &alc880_capture_source,
  2524. },
  2525. [ALC880_ASUS_DIG2] = {
  2526. .mixers = { alc880_asus_mixer },
  2527. .init_verbs = { alc880_volume_init_verbs,
  2528. alc880_pin_asus_init_verbs,
  2529. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2530. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2531. .dac_nids = alc880_asus_dac_nids,
  2532. .dig_out_nid = ALC880_DIGOUT_NID,
  2533. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2534. .channel_mode = alc880_asus_modes,
  2535. .need_dac_fix = 1,
  2536. .input_mux = &alc880_capture_source,
  2537. },
  2538. [ALC880_ASUS_W1V] = {
  2539. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2540. .init_verbs = { alc880_volume_init_verbs,
  2541. alc880_pin_asus_init_verbs,
  2542. alc880_gpio1_init_verbs },
  2543. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2544. .dac_nids = alc880_asus_dac_nids,
  2545. .dig_out_nid = ALC880_DIGOUT_NID,
  2546. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2547. .channel_mode = alc880_asus_modes,
  2548. .need_dac_fix = 1,
  2549. .input_mux = &alc880_capture_source,
  2550. },
  2551. [ALC880_UNIWILL_DIG] = {
  2552. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2553. .init_verbs = { alc880_volume_init_verbs,
  2554. alc880_pin_asus_init_verbs },
  2555. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2556. .dac_nids = alc880_asus_dac_nids,
  2557. .dig_out_nid = ALC880_DIGOUT_NID,
  2558. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2559. .channel_mode = alc880_asus_modes,
  2560. .need_dac_fix = 1,
  2561. .input_mux = &alc880_capture_source,
  2562. },
  2563. [ALC880_UNIWILL] = {
  2564. .mixers = { alc880_uniwill_mixer },
  2565. .init_verbs = { alc880_volume_init_verbs,
  2566. alc880_uniwill_init_verbs },
  2567. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2568. .dac_nids = alc880_asus_dac_nids,
  2569. .dig_out_nid = ALC880_DIGOUT_NID,
  2570. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2571. .channel_mode = alc880_threestack_modes,
  2572. .need_dac_fix = 1,
  2573. .input_mux = &alc880_capture_source,
  2574. .unsol_event = alc880_uniwill_unsol_event,
  2575. .init_hook = alc880_uniwill_automute,
  2576. },
  2577. [ALC880_UNIWILL_P53] = {
  2578. .mixers = { alc880_uniwill_p53_mixer },
  2579. .init_verbs = { alc880_volume_init_verbs,
  2580. alc880_uniwill_p53_init_verbs },
  2581. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2582. .dac_nids = alc880_asus_dac_nids,
  2583. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2584. .channel_mode = alc880_threestack_modes,
  2585. .input_mux = &alc880_capture_source,
  2586. .unsol_event = alc880_uniwill_p53_unsol_event,
  2587. .init_hook = alc880_uniwill_p53_hp_automute,
  2588. },
  2589. [ALC880_FUJITSU] = {
  2590. .mixers = { alc880_fujitsu_mixer,
  2591. alc880_pcbeep_mixer, },
  2592. .init_verbs = { alc880_volume_init_verbs,
  2593. alc880_uniwill_p53_init_verbs,
  2594. alc880_beep_init_verbs },
  2595. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2596. .dac_nids = alc880_dac_nids,
  2597. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2598. .channel_mode = alc880_2_jack_modes,
  2599. .input_mux = &alc880_capture_source,
  2600. .unsol_event = alc880_uniwill_p53_unsol_event,
  2601. .init_hook = alc880_uniwill_p53_hp_automute,
  2602. },
  2603. [ALC880_CLEVO] = {
  2604. .mixers = { alc880_three_stack_mixer },
  2605. .init_verbs = { alc880_volume_init_verbs,
  2606. alc880_pin_clevo_init_verbs },
  2607. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2608. .dac_nids = alc880_dac_nids,
  2609. .hp_nid = 0x03,
  2610. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2611. .channel_mode = alc880_threestack_modes,
  2612. .need_dac_fix = 1,
  2613. .input_mux = &alc880_capture_source,
  2614. },
  2615. [ALC880_LG] = {
  2616. .mixers = { alc880_lg_mixer },
  2617. .init_verbs = { alc880_volume_init_verbs,
  2618. alc880_lg_init_verbs },
  2619. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2620. .dac_nids = alc880_lg_dac_nids,
  2621. .dig_out_nid = ALC880_DIGOUT_NID,
  2622. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2623. .channel_mode = alc880_lg_ch_modes,
  2624. .need_dac_fix = 1,
  2625. .input_mux = &alc880_lg_capture_source,
  2626. .unsol_event = alc880_lg_unsol_event,
  2627. .init_hook = alc880_lg_automute,
  2628. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2629. .loopbacks = alc880_lg_loopbacks,
  2630. #endif
  2631. },
  2632. [ALC880_LG_LW] = {
  2633. .mixers = { alc880_lg_lw_mixer },
  2634. .init_verbs = { alc880_volume_init_verbs,
  2635. alc880_lg_lw_init_verbs },
  2636. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2637. .dac_nids = alc880_dac_nids,
  2638. .dig_out_nid = ALC880_DIGOUT_NID,
  2639. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2640. .channel_mode = alc880_lg_lw_modes,
  2641. .input_mux = &alc880_lg_lw_capture_source,
  2642. .unsol_event = alc880_lg_lw_unsol_event,
  2643. .init_hook = alc880_lg_lw_automute,
  2644. },
  2645. #ifdef CONFIG_SND_DEBUG
  2646. [ALC880_TEST] = {
  2647. .mixers = { alc880_test_mixer },
  2648. .init_verbs = { alc880_test_init_verbs },
  2649. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2650. .dac_nids = alc880_test_dac_nids,
  2651. .dig_out_nid = ALC880_DIGOUT_NID,
  2652. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2653. .channel_mode = alc880_test_modes,
  2654. .input_mux = &alc880_test_capture_source,
  2655. },
  2656. #endif
  2657. };
  2658. /*
  2659. * Automatic parse of I/O pins from the BIOS configuration
  2660. */
  2661. #define NUM_CONTROL_ALLOC 32
  2662. #define NUM_VERB_ALLOC 32
  2663. enum {
  2664. ALC_CTL_WIDGET_VOL,
  2665. ALC_CTL_WIDGET_MUTE,
  2666. ALC_CTL_BIND_MUTE,
  2667. };
  2668. static struct snd_kcontrol_new alc880_control_templates[] = {
  2669. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2670. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2671. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2672. };
  2673. /* add dynamic controls */
  2674. static int add_control(struct alc_spec *spec, int type, const char *name,
  2675. unsigned long val)
  2676. {
  2677. struct snd_kcontrol_new *knew;
  2678. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2679. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2680. /* array + terminator */
  2681. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2682. if (!knew)
  2683. return -ENOMEM;
  2684. if (spec->kctl_alloc) {
  2685. memcpy(knew, spec->kctl_alloc,
  2686. sizeof(*knew) * spec->num_kctl_alloc);
  2687. kfree(spec->kctl_alloc);
  2688. }
  2689. spec->kctl_alloc = knew;
  2690. spec->num_kctl_alloc = num;
  2691. }
  2692. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2693. *knew = alc880_control_templates[type];
  2694. knew->name = kstrdup(name, GFP_KERNEL);
  2695. if (!knew->name)
  2696. return -ENOMEM;
  2697. knew->private_value = val;
  2698. spec->num_kctl_used++;
  2699. return 0;
  2700. }
  2701. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2702. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2703. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2704. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2705. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2706. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2707. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2708. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2709. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2710. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2711. #define ALC880_PIN_CD_NID 0x1c
  2712. /* fill in the dac_nids table from the parsed pin configuration */
  2713. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2714. const struct auto_pin_cfg *cfg)
  2715. {
  2716. hda_nid_t nid;
  2717. int assigned[4];
  2718. int i, j;
  2719. memset(assigned, 0, sizeof(assigned));
  2720. spec->multiout.dac_nids = spec->private_dac_nids;
  2721. /* check the pins hardwired to audio widget */
  2722. for (i = 0; i < cfg->line_outs; i++) {
  2723. nid = cfg->line_out_pins[i];
  2724. if (alc880_is_fixed_pin(nid)) {
  2725. int idx = alc880_fixed_pin_idx(nid);
  2726. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2727. assigned[idx] = 1;
  2728. }
  2729. }
  2730. /* left pins can be connect to any audio widget */
  2731. for (i = 0; i < cfg->line_outs; i++) {
  2732. nid = cfg->line_out_pins[i];
  2733. if (alc880_is_fixed_pin(nid))
  2734. continue;
  2735. /* search for an empty channel */
  2736. for (j = 0; j < cfg->line_outs; j++) {
  2737. if (!assigned[j]) {
  2738. spec->multiout.dac_nids[i] =
  2739. alc880_idx_to_dac(j);
  2740. assigned[j] = 1;
  2741. break;
  2742. }
  2743. }
  2744. }
  2745. spec->multiout.num_dacs = cfg->line_outs;
  2746. return 0;
  2747. }
  2748. /* add playback controls from the parsed DAC table */
  2749. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2750. const struct auto_pin_cfg *cfg)
  2751. {
  2752. char name[32];
  2753. static const char *chname[4] = {
  2754. "Front", "Surround", NULL /*CLFE*/, "Side"
  2755. };
  2756. hda_nid_t nid;
  2757. int i, err;
  2758. for (i = 0; i < cfg->line_outs; i++) {
  2759. if (!spec->multiout.dac_nids[i])
  2760. continue;
  2761. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2762. if (i == 2) {
  2763. /* Center/LFE */
  2764. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2765. "Center Playback Volume",
  2766. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2767. HDA_OUTPUT));
  2768. if (err < 0)
  2769. return err;
  2770. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2771. "LFE Playback Volume",
  2772. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2773. HDA_OUTPUT));
  2774. if (err < 0)
  2775. return err;
  2776. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2777. "Center Playback Switch",
  2778. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2779. HDA_INPUT));
  2780. if (err < 0)
  2781. return err;
  2782. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2783. "LFE Playback Switch",
  2784. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2785. HDA_INPUT));
  2786. if (err < 0)
  2787. return err;
  2788. } else {
  2789. sprintf(name, "%s Playback Volume", chname[i]);
  2790. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2791. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2792. HDA_OUTPUT));
  2793. if (err < 0)
  2794. return err;
  2795. sprintf(name, "%s Playback Switch", chname[i]);
  2796. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2797. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2798. HDA_INPUT));
  2799. if (err < 0)
  2800. return err;
  2801. }
  2802. }
  2803. return 0;
  2804. }
  2805. /* add playback controls for speaker and HP outputs */
  2806. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2807. const char *pfx)
  2808. {
  2809. hda_nid_t nid;
  2810. int err;
  2811. char name[32];
  2812. if (!pin)
  2813. return 0;
  2814. if (alc880_is_fixed_pin(pin)) {
  2815. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2816. /* specify the DAC as the extra output */
  2817. if (!spec->multiout.hp_nid)
  2818. spec->multiout.hp_nid = nid;
  2819. else
  2820. spec->multiout.extra_out_nid[0] = nid;
  2821. /* control HP volume/switch on the output mixer amp */
  2822. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2823. sprintf(name, "%s Playback Volume", pfx);
  2824. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2825. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2826. if (err < 0)
  2827. return err;
  2828. sprintf(name, "%s Playback Switch", pfx);
  2829. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2830. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2831. if (err < 0)
  2832. return err;
  2833. } else if (alc880_is_multi_pin(pin)) {
  2834. /* set manual connection */
  2835. /* we have only a switch on HP-out PIN */
  2836. sprintf(name, "%s Playback Switch", pfx);
  2837. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2838. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2839. if (err < 0)
  2840. return err;
  2841. }
  2842. return 0;
  2843. }
  2844. /* create input playback/capture controls for the given pin */
  2845. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2846. const char *ctlname,
  2847. int idx, hda_nid_t mix_nid)
  2848. {
  2849. char name[32];
  2850. int err;
  2851. sprintf(name, "%s Playback Volume", ctlname);
  2852. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2853. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2854. if (err < 0)
  2855. return err;
  2856. sprintf(name, "%s Playback Switch", ctlname);
  2857. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2858. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2859. if (err < 0)
  2860. return err;
  2861. return 0;
  2862. }
  2863. /* create playback/capture controls for input pins */
  2864. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2865. const struct auto_pin_cfg *cfg)
  2866. {
  2867. struct hda_input_mux *imux = &spec->private_imux;
  2868. int i, err, idx;
  2869. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2870. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2871. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2872. err = new_analog_input(spec, cfg->input_pins[i],
  2873. auto_pin_cfg_labels[i],
  2874. idx, 0x0b);
  2875. if (err < 0)
  2876. return err;
  2877. imux->items[imux->num_items].label =
  2878. auto_pin_cfg_labels[i];
  2879. imux->items[imux->num_items].index =
  2880. alc880_input_pin_idx(cfg->input_pins[i]);
  2881. imux->num_items++;
  2882. }
  2883. }
  2884. return 0;
  2885. }
  2886. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2887. hda_nid_t nid, int pin_type,
  2888. int dac_idx)
  2889. {
  2890. /* set as output */
  2891. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2892. pin_type);
  2893. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2894. AMP_OUT_UNMUTE);
  2895. /* need the manual connection? */
  2896. if (alc880_is_multi_pin(nid)) {
  2897. struct alc_spec *spec = codec->spec;
  2898. int idx = alc880_multi_pin_idx(nid);
  2899. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2900. AC_VERB_SET_CONNECT_SEL,
  2901. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2902. }
  2903. }
  2904. static int get_pin_type(int line_out_type)
  2905. {
  2906. if (line_out_type == AUTO_PIN_HP_OUT)
  2907. return PIN_HP;
  2908. else
  2909. return PIN_OUT;
  2910. }
  2911. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2912. {
  2913. struct alc_spec *spec = codec->spec;
  2914. int i;
  2915. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2916. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2917. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2918. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2919. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2920. }
  2921. }
  2922. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2923. {
  2924. struct alc_spec *spec = codec->spec;
  2925. hda_nid_t pin;
  2926. pin = spec->autocfg.speaker_pins[0];
  2927. if (pin) /* connect to front */
  2928. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2929. pin = spec->autocfg.hp_pins[0];
  2930. if (pin) /* connect to front */
  2931. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2932. }
  2933. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2934. {
  2935. struct alc_spec *spec = codec->spec;
  2936. int i;
  2937. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2938. hda_nid_t nid = spec->autocfg.input_pins[i];
  2939. if (alc880_is_input_pin(nid)) {
  2940. snd_hda_codec_write(codec, nid, 0,
  2941. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2942. i <= AUTO_PIN_FRONT_MIC ?
  2943. PIN_VREF80 : PIN_IN);
  2944. if (nid != ALC880_PIN_CD_NID)
  2945. snd_hda_codec_write(codec, nid, 0,
  2946. AC_VERB_SET_AMP_GAIN_MUTE,
  2947. AMP_OUT_MUTE);
  2948. }
  2949. }
  2950. }
  2951. /* parse the BIOS configuration and set up the alc_spec */
  2952. /* return 1 if successful, 0 if the proper config is not found,
  2953. * or a negative error code
  2954. */
  2955. static int alc880_parse_auto_config(struct hda_codec *codec)
  2956. {
  2957. struct alc_spec *spec = codec->spec;
  2958. int err;
  2959. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2960. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2961. alc880_ignore);
  2962. if (err < 0)
  2963. return err;
  2964. if (!spec->autocfg.line_outs)
  2965. return 0; /* can't find valid BIOS pin config */
  2966. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2967. if (err < 0)
  2968. return err;
  2969. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2970. if (err < 0)
  2971. return err;
  2972. err = alc880_auto_create_extra_out(spec,
  2973. spec->autocfg.speaker_pins[0],
  2974. "Speaker");
  2975. if (err < 0)
  2976. return err;
  2977. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2978. "Headphone");
  2979. if (err < 0)
  2980. return err;
  2981. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2982. if (err < 0)
  2983. return err;
  2984. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2985. if (spec->autocfg.dig_out_pin)
  2986. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2987. if (spec->autocfg.dig_in_pin)
  2988. spec->dig_in_nid = ALC880_DIGIN_NID;
  2989. if (spec->kctl_alloc)
  2990. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2991. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2992. spec->num_mux_defs = 1;
  2993. spec->input_mux = &spec->private_imux;
  2994. return 1;
  2995. }
  2996. /* additional initialization for auto-configuration model */
  2997. static void alc880_auto_init(struct hda_codec *codec)
  2998. {
  2999. alc880_auto_init_multi_out(codec);
  3000. alc880_auto_init_extra_out(codec);
  3001. alc880_auto_init_analog_input(codec);
  3002. }
  3003. /*
  3004. * OK, here we have finally the patch for ALC880
  3005. */
  3006. static int patch_alc880(struct hda_codec *codec)
  3007. {
  3008. struct alc_spec *spec;
  3009. int board_config;
  3010. int err;
  3011. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3012. if (spec == NULL)
  3013. return -ENOMEM;
  3014. codec->spec = spec;
  3015. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3016. alc880_models,
  3017. alc880_cfg_tbl);
  3018. if (board_config < 0) {
  3019. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3020. "trying auto-probe from BIOS...\n");
  3021. board_config = ALC880_AUTO;
  3022. }
  3023. if (board_config == ALC880_AUTO) {
  3024. /* automatic parse from the BIOS config */
  3025. err = alc880_parse_auto_config(codec);
  3026. if (err < 0) {
  3027. alc_free(codec);
  3028. return err;
  3029. } else if (!err) {
  3030. printk(KERN_INFO
  3031. "hda_codec: Cannot set up configuration "
  3032. "from BIOS. Using 3-stack mode...\n");
  3033. board_config = ALC880_3ST;
  3034. }
  3035. }
  3036. if (board_config != ALC880_AUTO)
  3037. setup_preset(spec, &alc880_presets[board_config]);
  3038. spec->stream_name_analog = "ALC880 Analog";
  3039. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3040. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3041. spec->stream_name_digital = "ALC880 Digital";
  3042. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3043. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3044. if (!spec->adc_nids && spec->input_mux) {
  3045. /* check whether NID 0x07 is valid */
  3046. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3047. /* get type */
  3048. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3049. if (wcap != AC_WID_AUD_IN) {
  3050. spec->adc_nids = alc880_adc_nids_alt;
  3051. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3052. spec->mixers[spec->num_mixers] =
  3053. alc880_capture_alt_mixer;
  3054. spec->num_mixers++;
  3055. } else {
  3056. spec->adc_nids = alc880_adc_nids;
  3057. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3058. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3059. spec->num_mixers++;
  3060. }
  3061. }
  3062. codec->patch_ops = alc_patch_ops;
  3063. if (board_config == ALC880_AUTO)
  3064. spec->init_hook = alc880_auto_init;
  3065. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3066. if (!spec->loopback.amplist)
  3067. spec->loopback.amplist = alc880_loopbacks;
  3068. #endif
  3069. return 0;
  3070. }
  3071. /*
  3072. * ALC260 support
  3073. */
  3074. static hda_nid_t alc260_dac_nids[1] = {
  3075. /* front */
  3076. 0x02,
  3077. };
  3078. static hda_nid_t alc260_adc_nids[1] = {
  3079. /* ADC0 */
  3080. 0x04,
  3081. };
  3082. static hda_nid_t alc260_adc_nids_alt[1] = {
  3083. /* ADC1 */
  3084. 0x05,
  3085. };
  3086. static hda_nid_t alc260_hp_adc_nids[2] = {
  3087. /* ADC1, 0 */
  3088. 0x05, 0x04
  3089. };
  3090. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3091. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3092. */
  3093. static hda_nid_t alc260_dual_adc_nids[2] = {
  3094. /* ADC0, ADC1 */
  3095. 0x04, 0x05
  3096. };
  3097. #define ALC260_DIGOUT_NID 0x03
  3098. #define ALC260_DIGIN_NID 0x06
  3099. static struct hda_input_mux alc260_capture_source = {
  3100. .num_items = 4,
  3101. .items = {
  3102. { "Mic", 0x0 },
  3103. { "Front Mic", 0x1 },
  3104. { "Line", 0x2 },
  3105. { "CD", 0x4 },
  3106. },
  3107. };
  3108. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3109. * headphone jack and the internal CD lines since these are the only pins at
  3110. * which audio can appear. For flexibility, also allow the option of
  3111. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3112. * connection to the mixer output).
  3113. */
  3114. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3115. {
  3116. .num_items = 3,
  3117. .items = {
  3118. { "Mic/Line", 0x0 },
  3119. { "CD", 0x4 },
  3120. { "Headphone", 0x2 },
  3121. },
  3122. },
  3123. {
  3124. .num_items = 4,
  3125. .items = {
  3126. { "Mic/Line", 0x0 },
  3127. { "CD", 0x4 },
  3128. { "Headphone", 0x2 },
  3129. { "Mixer", 0x5 },
  3130. },
  3131. },
  3132. };
  3133. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3134. * the Fujitsu S702x, but jacks are marked differently.
  3135. */
  3136. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3137. {
  3138. .num_items = 4,
  3139. .items = {
  3140. { "Mic", 0x0 },
  3141. { "Line", 0x2 },
  3142. { "CD", 0x4 },
  3143. { "Headphone", 0x5 },
  3144. },
  3145. },
  3146. {
  3147. .num_items = 5,
  3148. .items = {
  3149. { "Mic", 0x0 },
  3150. { "Line", 0x2 },
  3151. { "CD", 0x4 },
  3152. { "Headphone", 0x6 },
  3153. { "Mixer", 0x5 },
  3154. },
  3155. },
  3156. };
  3157. /*
  3158. * This is just place-holder, so there's something for alc_build_pcms to look
  3159. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3160. * element which allows changing the channel mode, so the verb list is
  3161. * never used.
  3162. */
  3163. static struct hda_channel_mode alc260_modes[1] = {
  3164. { 2, NULL },
  3165. };
  3166. /* Mixer combinations
  3167. *
  3168. * basic: base_output + input + pc_beep + capture
  3169. * HP: base_output + input + capture_alt
  3170. * HP_3013: hp_3013 + input + capture
  3171. * fujitsu: fujitsu + capture
  3172. * acer: acer + capture
  3173. */
  3174. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3175. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3176. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3177. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3181. { } /* end */
  3182. };
  3183. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3184. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3185. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3186. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3187. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3192. { } /* end */
  3193. };
  3194. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3195. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3196. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3197. { } /* end */
  3198. };
  3199. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3200. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3201. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3202. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3203. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3204. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3206. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3208. { } /* end */
  3209. };
  3210. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3211. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3212. */
  3213. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3214. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3215. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3216. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3217. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3218. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3219. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3220. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3221. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3222. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3223. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3224. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3225. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3226. { } /* end */
  3227. };
  3228. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3229. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3230. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3231. * datasheet doesn't mention this restriction. At this stage it's not clear
  3232. * whether this behaviour is intentional or is a hardware bug in chip
  3233. * revisions available in early 2006. Therefore for now allow the
  3234. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3235. * that the lack of mic bias for this NID is intentional we could change the
  3236. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3237. *
  3238. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3239. * don't appear to make the mic bias available from the "line" jack, even
  3240. * though the NID used for this jack (0x14) can supply it. The theory is
  3241. * that perhaps Acer have included blocking capacitors between the ALC260
  3242. * and the output jack. If this turns out to be the case for all such
  3243. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3244. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3245. *
  3246. * The C20x Tablet series have a mono internal speaker which is controlled
  3247. * via the chip's Mono sum widget and pin complex, so include the necessary
  3248. * controls for such models. On models without a "mono speaker" the control
  3249. * won't do anything.
  3250. */
  3251. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3252. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3253. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3254. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3255. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3256. HDA_OUTPUT),
  3257. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3258. HDA_INPUT),
  3259. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3260. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3261. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3262. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3263. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3264. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3265. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3266. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3267. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3268. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3269. { } /* end */
  3270. };
  3271. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3272. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3273. */
  3274. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3275. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3276. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3277. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3278. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3279. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3280. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3282. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3283. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3284. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3285. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3286. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3287. { } /* end */
  3288. };
  3289. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3290. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3291. */
  3292. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3293. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3294. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3295. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3296. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3297. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3298. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3299. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3300. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3301. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3302. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3303. { } /* end */
  3304. };
  3305. /* capture mixer elements */
  3306. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3307. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3308. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3309. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3311. {
  3312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3313. /* The multiple "Capture Source" controls confuse alsamixer
  3314. * So call somewhat different..
  3315. * FIXME: the controls appear in the "playback" view!
  3316. */
  3317. /* .name = "Capture Source", */
  3318. .name = "Input Source",
  3319. .count = 2,
  3320. .info = alc_mux_enum_info,
  3321. .get = alc_mux_enum_get,
  3322. .put = alc_mux_enum_put,
  3323. },
  3324. { } /* end */
  3325. };
  3326. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3327. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3328. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3329. {
  3330. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3331. /* The multiple "Capture Source" controls confuse alsamixer
  3332. * So call somewhat different..
  3333. * FIXME: the controls appear in the "playback" view!
  3334. */
  3335. /* .name = "Capture Source", */
  3336. .name = "Input Source",
  3337. .count = 1,
  3338. .info = alc_mux_enum_info,
  3339. .get = alc_mux_enum_get,
  3340. .put = alc_mux_enum_put,
  3341. },
  3342. { } /* end */
  3343. };
  3344. /*
  3345. * initialization verbs
  3346. */
  3347. static struct hda_verb alc260_init_verbs[] = {
  3348. /* Line In pin widget for input */
  3349. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3350. /* CD pin widget for input */
  3351. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3353. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3354. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3355. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* LINE-2 is used for line-out in rear */
  3357. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3358. /* select line-out */
  3359. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3360. /* LINE-OUT pin */
  3361. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3362. /* enable HP */
  3363. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3364. /* enable Mono */
  3365. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3366. /* mute capture amp left and right */
  3367. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3368. /* set connection select to line in (default select for this ADC) */
  3369. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3370. /* mute capture amp left and right */
  3371. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3372. /* set connection select to line in (default select for this ADC) */
  3373. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3374. /* set vol=0 Line-Out mixer amp left and right */
  3375. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3376. /* unmute pin widget amp left and right (no gain on this amp) */
  3377. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3378. /* set vol=0 HP mixer amp left and right */
  3379. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3380. /* unmute pin widget amp left and right (no gain on this amp) */
  3381. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3382. /* set vol=0 Mono mixer amp left and right */
  3383. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3384. /* unmute pin widget amp left and right (no gain on this amp) */
  3385. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3386. /* unmute LINE-2 out pin */
  3387. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3389. * Line In 2 = 0x03
  3390. */
  3391. /* mute analog inputs */
  3392. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3397. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3398. /* mute Front out path */
  3399. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3400. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3401. /* mute Headphone out path */
  3402. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3403. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3404. /* mute Mono out path */
  3405. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3406. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3407. { }
  3408. };
  3409. #if 0 /* should be identical with alc260_init_verbs? */
  3410. static struct hda_verb alc260_hp_init_verbs[] = {
  3411. /* Headphone and output */
  3412. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3413. /* mono output */
  3414. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3415. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3416. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3417. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3418. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Line In pin widget for input */
  3420. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3421. /* Line-2 pin widget for output */
  3422. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3423. /* CD pin widget for input */
  3424. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3425. /* unmute amp left and right */
  3426. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3427. /* set connection select to line in (default select for this ADC) */
  3428. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3429. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3430. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3431. /* mute pin widget amp left and right (no gain on this amp) */
  3432. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3433. /* unmute HP mixer amp left and right (volume = 0) */
  3434. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3435. /* mute pin widget amp left and right (no gain on this amp) */
  3436. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3437. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3438. * Line In 2 = 0x03
  3439. */
  3440. /* mute analog inputs */
  3441. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3442. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3446. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3447. /* Unmute Front out path */
  3448. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3449. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3450. /* Unmute Headphone out path */
  3451. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3452. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3453. /* Unmute Mono out path */
  3454. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3455. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3456. { }
  3457. };
  3458. #endif
  3459. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3460. /* Line out and output */
  3461. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3462. /* mono output */
  3463. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3465. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3466. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3467. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Line In pin widget for input */
  3469. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3470. /* Headphone pin widget for output */
  3471. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3472. /* CD pin widget for input */
  3473. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3474. /* unmute amp left and right */
  3475. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3476. /* set connection select to line in (default select for this ADC) */
  3477. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3478. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3479. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3480. /* mute pin widget amp left and right (no gain on this amp) */
  3481. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3482. /* unmute HP mixer amp left and right (volume = 0) */
  3483. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3484. /* mute pin widget amp left and right (no gain on this amp) */
  3485. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3486. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3487. * Line In 2 = 0x03
  3488. */
  3489. /* mute analog inputs */
  3490. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3491. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3495. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3496. /* Unmute Front out path */
  3497. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3498. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3499. /* Unmute Headphone out path */
  3500. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3501. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3502. /* Unmute Mono out path */
  3503. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3504. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3505. { }
  3506. };
  3507. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3508. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3509. * audio = 0x16, internal speaker = 0x10.
  3510. */
  3511. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3512. /* Disable all GPIOs */
  3513. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3514. /* Internal speaker is connected to headphone pin */
  3515. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3516. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3517. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3518. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3519. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3520. /* Ensure all other unused pins are disabled and muted. */
  3521. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3522. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3523. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. /* Disable digital (SPDIF) pins */
  3530. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3531. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3532. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3533. * when acting as an output.
  3534. */
  3535. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3536. /* Start with output sum widgets muted and their output gains at min */
  3537. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3538. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3540. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3541. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3543. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3544. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3546. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3547. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3548. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3549. * If the pin mode is changed by the user the pin mode control will
  3550. * take care of enabling the pin's input/output buffers as needed.
  3551. * Therefore there's no need to enable the input buffer at this
  3552. * stage.
  3553. */
  3554. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3555. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3556. * mixer ctrl)
  3557. */
  3558. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3559. /* Mute capture amp left and right */
  3560. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3561. /* Set ADC connection select to match default mixer setting - line
  3562. * in (on mic1 pin)
  3563. */
  3564. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3565. /* Do the same for the second ADC: mute capture input amp and
  3566. * set ADC connection to line in (on mic1 pin)
  3567. */
  3568. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3569. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3570. /* Mute all inputs to mixer widget (even unconnected ones) */
  3571. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3579. { }
  3580. };
  3581. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3582. * similar laptops (adapted from Fujitsu init verbs).
  3583. */
  3584. static struct hda_verb alc260_acer_init_verbs[] = {
  3585. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3586. * the headphone jack. Turn this on and rely on the standard mute
  3587. * methods whenever the user wants to turn these outputs off.
  3588. */
  3589. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3590. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3591. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3592. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3593. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3594. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3595. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3596. /* Line In jack is connected to Line1 pin */
  3597. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3598. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3599. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3600. /* Ensure all other unused pins are disabled and muted. */
  3601. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3602. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3603. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. /* Disable digital (SPDIF) pins */
  3608. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3609. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3610. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3611. * bus when acting as outputs.
  3612. */
  3613. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3614. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3615. /* Start with output sum widgets muted and their output gains at min */
  3616. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3617. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3619. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3620. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3622. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3623. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3625. /* Unmute Line-out pin widget amp left and right
  3626. * (no equiv mixer ctrl)
  3627. */
  3628. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3629. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3630. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3632. * inputs. If the pin mode is changed by the user the pin mode control
  3633. * will take care of enabling the pin's input/output buffers as needed.
  3634. * Therefore there's no need to enable the input buffer at this
  3635. * stage.
  3636. */
  3637. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3638. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3639. /* Mute capture amp left and right */
  3640. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3641. /* Set ADC connection select to match default mixer setting - mic
  3642. * (on mic1 pin)
  3643. */
  3644. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3645. /* Do similar with the second ADC: mute capture input amp and
  3646. * set ADC connection to mic to match ALSA's default state.
  3647. */
  3648. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3649. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3650. /* Mute all inputs to mixer widget (even unconnected ones) */
  3651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3659. { }
  3660. };
  3661. static struct hda_verb alc260_will_verbs[] = {
  3662. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3663. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3664. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3665. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3666. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3667. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3668. {}
  3669. };
  3670. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3671. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3672. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3673. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3674. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3675. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3676. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3677. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3678. {}
  3679. };
  3680. /* toggle speaker-output according to the hp-jack state */
  3681. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3682. {
  3683. unsigned int present;
  3684. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3685. present = snd_hda_codec_read(codec, 0x0f, 0,
  3686. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3687. if (present) {
  3688. snd_hda_codec_write_cache(codec, 0x01, 0,
  3689. AC_VERB_SET_GPIO_DATA, 1);
  3690. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3691. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3692. PIN_HP);
  3693. } else {
  3694. snd_hda_codec_write_cache(codec, 0x01, 0,
  3695. AC_VERB_SET_GPIO_DATA, 0);
  3696. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3697. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3698. PIN_OUT);
  3699. }
  3700. }
  3701. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3702. unsigned int res)
  3703. {
  3704. if ((res >> 26) == ALC880_HP_EVENT)
  3705. alc260_replacer_672v_automute(codec);
  3706. }
  3707. /* Test configuration for debugging, modelled after the ALC880 test
  3708. * configuration.
  3709. */
  3710. #ifdef CONFIG_SND_DEBUG
  3711. static hda_nid_t alc260_test_dac_nids[1] = {
  3712. 0x02,
  3713. };
  3714. static hda_nid_t alc260_test_adc_nids[2] = {
  3715. 0x04, 0x05,
  3716. };
  3717. /* For testing the ALC260, each input MUX needs its own definition since
  3718. * the signal assignments are different. This assumes that the first ADC
  3719. * is NID 0x04.
  3720. */
  3721. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3722. {
  3723. .num_items = 7,
  3724. .items = {
  3725. { "MIC1 pin", 0x0 },
  3726. { "MIC2 pin", 0x1 },
  3727. { "LINE1 pin", 0x2 },
  3728. { "LINE2 pin", 0x3 },
  3729. { "CD pin", 0x4 },
  3730. { "LINE-OUT pin", 0x5 },
  3731. { "HP-OUT pin", 0x6 },
  3732. },
  3733. },
  3734. {
  3735. .num_items = 8,
  3736. .items = {
  3737. { "MIC1 pin", 0x0 },
  3738. { "MIC2 pin", 0x1 },
  3739. { "LINE1 pin", 0x2 },
  3740. { "LINE2 pin", 0x3 },
  3741. { "CD pin", 0x4 },
  3742. { "Mixer", 0x5 },
  3743. { "LINE-OUT pin", 0x6 },
  3744. { "HP-OUT pin", 0x7 },
  3745. },
  3746. },
  3747. };
  3748. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3749. /* Output driver widgets */
  3750. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3751. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3752. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3754. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3755. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3756. /* Modes for retasking pin widgets
  3757. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3758. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3759. * mention this restriction. At this stage it's not clear whether
  3760. * this behaviour is intentional or is a hardware bug in chip
  3761. * revisions available at least up until early 2006. Therefore for
  3762. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3763. * choices, but if it turns out that the lack of mic bias for these
  3764. * NIDs is intentional we could change their modes from
  3765. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3766. */
  3767. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3773. /* Loopback mixer controls */
  3774. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3775. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3776. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3777. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3779. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3781. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3783. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3785. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3787. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3788. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3789. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3790. /* Controls for GPIO pins, assuming they are configured as outputs */
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3792. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3795. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3796. * is ambigious as to which NID is which; testing on laptops which
  3797. * make this output available should provide clarification.
  3798. */
  3799. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3800. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3801. { } /* end */
  3802. };
  3803. static struct hda_verb alc260_test_init_verbs[] = {
  3804. /* Enable all GPIOs as outputs with an initial value of 0 */
  3805. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3806. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3807. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3808. /* Enable retasking pins as output, initially without power amp */
  3809. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. /* Disable digital (SPDIF) pins initially, but users can enable
  3816. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3817. * payload also sets the generation to 0, output to be in "consumer"
  3818. * PCM format, copyright asserted, no pre-emphasis and no validity
  3819. * control.
  3820. */
  3821. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3822. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3823. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3824. * OUT1 sum bus when acting as an output.
  3825. */
  3826. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3827. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3828. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3829. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3830. /* Start with output sum widgets muted and their output gains at min */
  3831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3832. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3833. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3835. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3836. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3837. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3838. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3839. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3840. /* Unmute retasking pin widget output buffers since the default
  3841. * state appears to be output. As the pin mode is changed by the
  3842. * user the pin mode control will take care of enabling the pin's
  3843. * input/output buffers as needed.
  3844. */
  3845. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. /* Also unmute the mono-out pin widget */
  3852. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. /* Mute capture amp left and right */
  3854. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3855. /* Set ADC connection select to match default mixer setting (mic1
  3856. * pin)
  3857. */
  3858. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3859. /* Do the same for the second ADC: mute capture input amp and
  3860. * set ADC connection to mic1 pin
  3861. */
  3862. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3863. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3864. /* Mute all inputs to mixer widget (even unconnected ones) */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3873. { }
  3874. };
  3875. #endif
  3876. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3877. .substreams = 1,
  3878. .channels_min = 2,
  3879. .channels_max = 2,
  3880. };
  3881. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3882. .substreams = 1,
  3883. .channels_min = 2,
  3884. .channels_max = 2,
  3885. };
  3886. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3887. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3888. /*
  3889. * for BIOS auto-configuration
  3890. */
  3891. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3892. const char *pfx)
  3893. {
  3894. hda_nid_t nid_vol;
  3895. unsigned long vol_val, sw_val;
  3896. char name[32];
  3897. int err;
  3898. if (nid >= 0x0f && nid < 0x11) {
  3899. nid_vol = nid - 0x7;
  3900. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3901. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3902. } else if (nid == 0x11) {
  3903. nid_vol = nid - 0x7;
  3904. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3905. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3906. } else if (nid >= 0x12 && nid <= 0x15) {
  3907. nid_vol = 0x08;
  3908. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3909. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3910. } else
  3911. return 0; /* N/A */
  3912. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3913. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3914. if (err < 0)
  3915. return err;
  3916. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3917. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3918. if (err < 0)
  3919. return err;
  3920. return 1;
  3921. }
  3922. /* add playback controls from the parsed DAC table */
  3923. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3924. const struct auto_pin_cfg *cfg)
  3925. {
  3926. hda_nid_t nid;
  3927. int err;
  3928. spec->multiout.num_dacs = 1;
  3929. spec->multiout.dac_nids = spec->private_dac_nids;
  3930. spec->multiout.dac_nids[0] = 0x02;
  3931. nid = cfg->line_out_pins[0];
  3932. if (nid) {
  3933. err = alc260_add_playback_controls(spec, nid, "Front");
  3934. if (err < 0)
  3935. return err;
  3936. }
  3937. nid = cfg->speaker_pins[0];
  3938. if (nid) {
  3939. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3940. if (err < 0)
  3941. return err;
  3942. }
  3943. nid = cfg->hp_pins[0];
  3944. if (nid) {
  3945. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3946. if (err < 0)
  3947. return err;
  3948. }
  3949. return 0;
  3950. }
  3951. /* create playback/capture controls for input pins */
  3952. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3953. const struct auto_pin_cfg *cfg)
  3954. {
  3955. struct hda_input_mux *imux = &spec->private_imux;
  3956. int i, err, idx;
  3957. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3958. if (cfg->input_pins[i] >= 0x12) {
  3959. idx = cfg->input_pins[i] - 0x12;
  3960. err = new_analog_input(spec, cfg->input_pins[i],
  3961. auto_pin_cfg_labels[i], idx,
  3962. 0x07);
  3963. if (err < 0)
  3964. return err;
  3965. imux->items[imux->num_items].label =
  3966. auto_pin_cfg_labels[i];
  3967. imux->items[imux->num_items].index = idx;
  3968. imux->num_items++;
  3969. }
  3970. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3971. idx = cfg->input_pins[i] - 0x09;
  3972. err = new_analog_input(spec, cfg->input_pins[i],
  3973. auto_pin_cfg_labels[i], idx,
  3974. 0x07);
  3975. if (err < 0)
  3976. return err;
  3977. imux->items[imux->num_items].label =
  3978. auto_pin_cfg_labels[i];
  3979. imux->items[imux->num_items].index = idx;
  3980. imux->num_items++;
  3981. }
  3982. }
  3983. return 0;
  3984. }
  3985. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3986. hda_nid_t nid, int pin_type,
  3987. int sel_idx)
  3988. {
  3989. /* set as output */
  3990. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3991. pin_type);
  3992. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3993. AMP_OUT_UNMUTE);
  3994. /* need the manual connection? */
  3995. if (nid >= 0x12) {
  3996. int idx = nid - 0x12;
  3997. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3998. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3999. }
  4000. }
  4001. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4002. {
  4003. struct alc_spec *spec = codec->spec;
  4004. hda_nid_t nid;
  4005. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4006. nid = spec->autocfg.line_out_pins[0];
  4007. if (nid) {
  4008. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4009. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4010. }
  4011. nid = spec->autocfg.speaker_pins[0];
  4012. if (nid)
  4013. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4014. nid = spec->autocfg.hp_pins[0];
  4015. if (nid)
  4016. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4017. }
  4018. #define ALC260_PIN_CD_NID 0x16
  4019. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4020. {
  4021. struct alc_spec *spec = codec->spec;
  4022. int i;
  4023. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4024. hda_nid_t nid = spec->autocfg.input_pins[i];
  4025. if (nid >= 0x12) {
  4026. snd_hda_codec_write(codec, nid, 0,
  4027. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4028. i <= AUTO_PIN_FRONT_MIC ?
  4029. PIN_VREF80 : PIN_IN);
  4030. if (nid != ALC260_PIN_CD_NID)
  4031. snd_hda_codec_write(codec, nid, 0,
  4032. AC_VERB_SET_AMP_GAIN_MUTE,
  4033. AMP_OUT_MUTE);
  4034. }
  4035. }
  4036. }
  4037. /*
  4038. * generic initialization of ADC, input mixers and output mixers
  4039. */
  4040. static struct hda_verb alc260_volume_init_verbs[] = {
  4041. /*
  4042. * Unmute ADC0-1 and set the default input to mic-in
  4043. */
  4044. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4045. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4046. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4047. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4048. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4049. * mixer widget
  4050. * Note: PASD motherboards uses the Line In 2 as the input for
  4051. * front panel mic (mic 2)
  4052. */
  4053. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4054. /* mute analog inputs */
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4060. /*
  4061. * Set up output mixers (0x08 - 0x0a)
  4062. */
  4063. /* set vol=0 to output mixers */
  4064. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4065. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4066. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4067. /* set up input amps for analog loopback */
  4068. /* Amp Indices: DAC = 0, mixer = 1 */
  4069. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4070. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4071. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4072. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4073. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4074. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4075. { }
  4076. };
  4077. static int alc260_parse_auto_config(struct hda_codec *codec)
  4078. {
  4079. struct alc_spec *spec = codec->spec;
  4080. unsigned int wcap;
  4081. int err;
  4082. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4083. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4084. alc260_ignore);
  4085. if (err < 0)
  4086. return err;
  4087. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4088. if (err < 0)
  4089. return err;
  4090. if (!spec->kctl_alloc)
  4091. return 0; /* can't find valid BIOS pin config */
  4092. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4093. if (err < 0)
  4094. return err;
  4095. spec->multiout.max_channels = 2;
  4096. if (spec->autocfg.dig_out_pin)
  4097. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4098. if (spec->kctl_alloc)
  4099. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4100. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4101. spec->num_mux_defs = 1;
  4102. spec->input_mux = &spec->private_imux;
  4103. /* check whether NID 0x04 is valid */
  4104. wcap = get_wcaps(codec, 0x04);
  4105. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4106. if (wcap != AC_WID_AUD_IN) {
  4107. spec->adc_nids = alc260_adc_nids_alt;
  4108. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4109. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4110. } else {
  4111. spec->adc_nids = alc260_adc_nids;
  4112. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4113. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4114. }
  4115. spec->num_mixers++;
  4116. return 1;
  4117. }
  4118. /* additional initialization for auto-configuration model */
  4119. static void alc260_auto_init(struct hda_codec *codec)
  4120. {
  4121. alc260_auto_init_multi_out(codec);
  4122. alc260_auto_init_analog_input(codec);
  4123. }
  4124. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4125. static struct hda_amp_list alc260_loopbacks[] = {
  4126. { 0x07, HDA_INPUT, 0 },
  4127. { 0x07, HDA_INPUT, 1 },
  4128. { 0x07, HDA_INPUT, 2 },
  4129. { 0x07, HDA_INPUT, 3 },
  4130. { 0x07, HDA_INPUT, 4 },
  4131. { } /* end */
  4132. };
  4133. #endif
  4134. /*
  4135. * ALC260 configurations
  4136. */
  4137. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4138. [ALC260_BASIC] = "basic",
  4139. [ALC260_HP] = "hp",
  4140. [ALC260_HP_3013] = "hp-3013",
  4141. [ALC260_FUJITSU_S702X] = "fujitsu",
  4142. [ALC260_ACER] = "acer",
  4143. [ALC260_WILL] = "will",
  4144. [ALC260_REPLACER_672V] = "replacer",
  4145. #ifdef CONFIG_SND_DEBUG
  4146. [ALC260_TEST] = "test",
  4147. #endif
  4148. [ALC260_AUTO] = "auto",
  4149. };
  4150. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4151. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4152. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4153. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4154. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4155. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4156. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4157. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4159. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4160. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4161. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4162. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4163. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4164. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4165. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4166. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4168. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4169. {}
  4170. };
  4171. static struct alc_config_preset alc260_presets[] = {
  4172. [ALC260_BASIC] = {
  4173. .mixers = { alc260_base_output_mixer,
  4174. alc260_input_mixer,
  4175. alc260_pc_beep_mixer,
  4176. alc260_capture_mixer },
  4177. .init_verbs = { alc260_init_verbs },
  4178. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4179. .dac_nids = alc260_dac_nids,
  4180. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4181. .adc_nids = alc260_adc_nids,
  4182. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4183. .channel_mode = alc260_modes,
  4184. .input_mux = &alc260_capture_source,
  4185. },
  4186. [ALC260_HP] = {
  4187. .mixers = { alc260_base_output_mixer,
  4188. alc260_input_mixer,
  4189. alc260_capture_alt_mixer },
  4190. .init_verbs = { alc260_init_verbs },
  4191. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4192. .dac_nids = alc260_dac_nids,
  4193. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4194. .adc_nids = alc260_hp_adc_nids,
  4195. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4196. .channel_mode = alc260_modes,
  4197. .input_mux = &alc260_capture_source,
  4198. },
  4199. [ALC260_HP_3013] = {
  4200. .mixers = { alc260_hp_3013_mixer,
  4201. alc260_input_mixer,
  4202. alc260_capture_alt_mixer },
  4203. .init_verbs = { alc260_hp_3013_init_verbs },
  4204. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4205. .dac_nids = alc260_dac_nids,
  4206. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4207. .adc_nids = alc260_hp_adc_nids,
  4208. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4209. .channel_mode = alc260_modes,
  4210. .input_mux = &alc260_capture_source,
  4211. },
  4212. [ALC260_FUJITSU_S702X] = {
  4213. .mixers = { alc260_fujitsu_mixer,
  4214. alc260_capture_mixer },
  4215. .init_verbs = { alc260_fujitsu_init_verbs },
  4216. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4217. .dac_nids = alc260_dac_nids,
  4218. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4219. .adc_nids = alc260_dual_adc_nids,
  4220. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4221. .channel_mode = alc260_modes,
  4222. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4223. .input_mux = alc260_fujitsu_capture_sources,
  4224. },
  4225. [ALC260_ACER] = {
  4226. .mixers = { alc260_acer_mixer,
  4227. alc260_capture_mixer },
  4228. .init_verbs = { alc260_acer_init_verbs },
  4229. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4230. .dac_nids = alc260_dac_nids,
  4231. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4232. .adc_nids = alc260_dual_adc_nids,
  4233. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4234. .channel_mode = alc260_modes,
  4235. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4236. .input_mux = alc260_acer_capture_sources,
  4237. },
  4238. [ALC260_WILL] = {
  4239. .mixers = { alc260_will_mixer,
  4240. alc260_capture_mixer },
  4241. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4242. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4243. .dac_nids = alc260_dac_nids,
  4244. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4245. .adc_nids = alc260_adc_nids,
  4246. .dig_out_nid = ALC260_DIGOUT_NID,
  4247. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4248. .channel_mode = alc260_modes,
  4249. .input_mux = &alc260_capture_source,
  4250. },
  4251. [ALC260_REPLACER_672V] = {
  4252. .mixers = { alc260_replacer_672v_mixer,
  4253. alc260_capture_mixer },
  4254. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4255. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4256. .dac_nids = alc260_dac_nids,
  4257. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4258. .adc_nids = alc260_adc_nids,
  4259. .dig_out_nid = ALC260_DIGOUT_NID,
  4260. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4261. .channel_mode = alc260_modes,
  4262. .input_mux = &alc260_capture_source,
  4263. .unsol_event = alc260_replacer_672v_unsol_event,
  4264. .init_hook = alc260_replacer_672v_automute,
  4265. },
  4266. #ifdef CONFIG_SND_DEBUG
  4267. [ALC260_TEST] = {
  4268. .mixers = { alc260_test_mixer,
  4269. alc260_capture_mixer },
  4270. .init_verbs = { alc260_test_init_verbs },
  4271. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4272. .dac_nids = alc260_test_dac_nids,
  4273. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4274. .adc_nids = alc260_test_adc_nids,
  4275. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4276. .channel_mode = alc260_modes,
  4277. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4278. .input_mux = alc260_test_capture_sources,
  4279. },
  4280. #endif
  4281. };
  4282. static int patch_alc260(struct hda_codec *codec)
  4283. {
  4284. struct alc_spec *spec;
  4285. int err, board_config;
  4286. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4287. if (spec == NULL)
  4288. return -ENOMEM;
  4289. codec->spec = spec;
  4290. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4291. alc260_models,
  4292. alc260_cfg_tbl);
  4293. if (board_config < 0) {
  4294. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4295. "trying auto-probe from BIOS...\n");
  4296. board_config = ALC260_AUTO;
  4297. }
  4298. if (board_config == ALC260_AUTO) {
  4299. /* automatic parse from the BIOS config */
  4300. err = alc260_parse_auto_config(codec);
  4301. if (err < 0) {
  4302. alc_free(codec);
  4303. return err;
  4304. } else if (!err) {
  4305. printk(KERN_INFO
  4306. "hda_codec: Cannot set up configuration "
  4307. "from BIOS. Using base mode...\n");
  4308. board_config = ALC260_BASIC;
  4309. }
  4310. }
  4311. if (board_config != ALC260_AUTO)
  4312. setup_preset(spec, &alc260_presets[board_config]);
  4313. spec->stream_name_analog = "ALC260 Analog";
  4314. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4315. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4316. spec->stream_name_digital = "ALC260 Digital";
  4317. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4318. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4319. codec->patch_ops = alc_patch_ops;
  4320. if (board_config == ALC260_AUTO)
  4321. spec->init_hook = alc260_auto_init;
  4322. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4323. if (!spec->loopback.amplist)
  4324. spec->loopback.amplist = alc260_loopbacks;
  4325. #endif
  4326. return 0;
  4327. }
  4328. /*
  4329. * ALC882 support
  4330. *
  4331. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4332. * configuration. Each pin widget can choose any input DACs and a mixer.
  4333. * Each ADC is connected from a mixer of all inputs. This makes possible
  4334. * 6-channel independent captures.
  4335. *
  4336. * In addition, an independent DAC for the multi-playback (not used in this
  4337. * driver yet).
  4338. */
  4339. #define ALC882_DIGOUT_NID 0x06
  4340. #define ALC882_DIGIN_NID 0x0a
  4341. static struct hda_channel_mode alc882_ch_modes[1] = {
  4342. { 8, NULL }
  4343. };
  4344. static hda_nid_t alc882_dac_nids[4] = {
  4345. /* front, rear, clfe, rear_surr */
  4346. 0x02, 0x03, 0x04, 0x05
  4347. };
  4348. /* identical with ALC880 */
  4349. #define alc882_adc_nids alc880_adc_nids
  4350. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4351. /* input MUX */
  4352. /* FIXME: should be a matrix-type input source selection */
  4353. static struct hda_input_mux alc882_capture_source = {
  4354. .num_items = 4,
  4355. .items = {
  4356. { "Mic", 0x0 },
  4357. { "Front Mic", 0x1 },
  4358. { "Line", 0x2 },
  4359. { "CD", 0x4 },
  4360. },
  4361. };
  4362. #define alc882_mux_enum_info alc_mux_enum_info
  4363. #define alc882_mux_enum_get alc_mux_enum_get
  4364. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4365. struct snd_ctl_elem_value *ucontrol)
  4366. {
  4367. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4368. struct alc_spec *spec = codec->spec;
  4369. const struct hda_input_mux *imux = spec->input_mux;
  4370. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4371. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4372. hda_nid_t nid = capture_mixers[adc_idx];
  4373. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4374. unsigned int i, idx;
  4375. idx = ucontrol->value.enumerated.item[0];
  4376. if (idx >= imux->num_items)
  4377. idx = imux->num_items - 1;
  4378. if (*cur_val == idx)
  4379. return 0;
  4380. for (i = 0; i < imux->num_items; i++) {
  4381. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4382. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4383. imux->items[i].index,
  4384. HDA_AMP_MUTE, v);
  4385. }
  4386. *cur_val = idx;
  4387. return 1;
  4388. }
  4389. /*
  4390. * 2ch mode
  4391. */
  4392. static struct hda_verb alc882_3ST_ch2_init[] = {
  4393. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4394. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4395. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4396. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4397. { } /* end */
  4398. };
  4399. /*
  4400. * 6ch mode
  4401. */
  4402. static struct hda_verb alc882_3ST_ch6_init[] = {
  4403. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4404. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4405. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4406. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4407. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4408. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4409. { } /* end */
  4410. };
  4411. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4412. { 2, alc882_3ST_ch2_init },
  4413. { 6, alc882_3ST_ch6_init },
  4414. };
  4415. /*
  4416. * 6ch mode
  4417. */
  4418. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4419. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4420. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4421. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4422. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4423. { } /* end */
  4424. };
  4425. /*
  4426. * 8ch mode
  4427. */
  4428. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4429. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4430. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4431. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4432. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { } /* end */
  4434. };
  4435. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4436. { 6, alc882_sixstack_ch6_init },
  4437. { 8, alc882_sixstack_ch8_init },
  4438. };
  4439. /*
  4440. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4441. */
  4442. /*
  4443. * 2ch mode
  4444. */
  4445. static struct hda_verb alc885_mbp_ch2_init[] = {
  4446. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4447. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4448. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4449. { } /* end */
  4450. };
  4451. /*
  4452. * 6ch mode
  4453. */
  4454. static struct hda_verb alc885_mbp_ch6_init[] = {
  4455. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4456. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4457. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4458. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4459. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4460. { } /* end */
  4461. };
  4462. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4463. { 2, alc885_mbp_ch2_init },
  4464. { 6, alc885_mbp_ch6_init },
  4465. };
  4466. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4467. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4468. */
  4469. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4470. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4471. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4472. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4473. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4474. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4475. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4476. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4477. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4478. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4479. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4480. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4481. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4482. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4483. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4484. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4485. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4486. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4487. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4490. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4492. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4493. { } /* end */
  4494. };
  4495. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4496. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4497. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4498. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4499. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4500. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4501. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4502. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4503. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4504. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4505. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4506. { } /* end */
  4507. };
  4508. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4509. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4510. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4511. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4512. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4513. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4514. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4515. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4516. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4517. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4519. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4520. { } /* end */
  4521. };
  4522. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4523. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4524. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4525. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4526. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4527. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4528. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4529. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4530. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4531. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4532. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4533. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4534. { } /* end */
  4535. };
  4536. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4537. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4538. */
  4539. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4540. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4541. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4542. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4545. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4546. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4547. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4548. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4549. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4550. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4552. { } /* end */
  4553. };
  4554. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4555. {
  4556. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4557. .name = "Channel Mode",
  4558. .info = alc_ch_mode_info,
  4559. .get = alc_ch_mode_get,
  4560. .put = alc_ch_mode_put,
  4561. },
  4562. { } /* end */
  4563. };
  4564. static struct hda_verb alc882_init_verbs[] = {
  4565. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4566. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4567. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4569. /* Rear mixer */
  4570. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4571. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4573. /* CLFE mixer */
  4574. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4575. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4577. /* Side mixer */
  4578. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4579. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4581. /* Front Pin: output 0 (0x0c) */
  4582. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4583. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4584. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4585. /* Rear Pin: output 1 (0x0d) */
  4586. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4587. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4588. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4589. /* CLFE Pin: output 2 (0x0e) */
  4590. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4591. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4592. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4593. /* Side Pin: output 3 (0x0f) */
  4594. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4595. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4596. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4597. /* Mic (rear) pin: input vref at 80% */
  4598. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4599. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4600. /* Front Mic pin: input vref at 80% */
  4601. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4602. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4603. /* Line In pin: input */
  4604. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4605. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4606. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4607. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4608. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4609. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4610. /* CD pin widget for input */
  4611. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4612. /* FIXME: use matrix-type input source selection */
  4613. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4614. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4615. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4616. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4617. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4618. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4619. /* Input mixer2 */
  4620. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4621. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4623. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4624. /* Input mixer3 */
  4625. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4626. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4629. /* ADC1: mute amp left and right */
  4630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4631. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4632. /* ADC2: mute amp left and right */
  4633. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4634. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4635. /* ADC3: mute amp left and right */
  4636. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4637. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4638. { }
  4639. };
  4640. static struct hda_verb alc882_eapd_verbs[] = {
  4641. /* change to EAPD mode */
  4642. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4643. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4644. { }
  4645. };
  4646. /* Mac Pro test */
  4647. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4648. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4649. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4650. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4651. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4652. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4653. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4654. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4655. { } /* end */
  4656. };
  4657. static struct hda_verb alc882_macpro_init_verbs[] = {
  4658. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4659. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4660. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4661. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4662. /* Front Pin: output 0 (0x0c) */
  4663. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4664. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4665. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4666. /* Front Mic pin: input vref at 80% */
  4667. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4668. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4669. /* Speaker: output */
  4670. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4671. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4672. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4673. /* Headphone output (output 0 - 0x0c) */
  4674. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4675. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4676. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4677. /* FIXME: use matrix-type input source selection */
  4678. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4679. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4680. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4681. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4682. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4683. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4684. /* Input mixer2 */
  4685. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4686. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4687. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4688. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4689. /* Input mixer3 */
  4690. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4691. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4692. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4693. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4694. /* ADC1: mute amp left and right */
  4695. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4696. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4697. /* ADC2: mute amp left and right */
  4698. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4699. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4700. /* ADC3: mute amp left and right */
  4701. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4702. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4703. { }
  4704. };
  4705. /* Macbook Pro rev3 */
  4706. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4707. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4711. /* Rear mixer */
  4712. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4713. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4715. /* Front Pin: output 0 (0x0c) */
  4716. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4717. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4718. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4719. /* HP Pin: output 0 (0x0d) */
  4720. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4721. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4722. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4723. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4724. /* Mic (rear) pin: input vref at 80% */
  4725. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4726. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4727. /* Front Mic pin: input vref at 80% */
  4728. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4729. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4730. /* Line In pin: use output 1 when in LineOut mode */
  4731. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4732. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4733. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4734. /* FIXME: use matrix-type input source selection */
  4735. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4736. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4737. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4738. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4741. /* Input mixer2 */
  4742. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4743. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4746. /* Input mixer3 */
  4747. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4748. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4749. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4751. /* ADC1: mute amp left and right */
  4752. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4753. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4754. /* ADC2: mute amp left and right */
  4755. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4756. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4757. /* ADC3: mute amp left and right */
  4758. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4759. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4760. { }
  4761. };
  4762. /* iMac 24 mixer. */
  4763. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4764. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4765. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4766. { } /* end */
  4767. };
  4768. /* iMac 24 init verbs. */
  4769. static struct hda_verb alc885_imac24_init_verbs[] = {
  4770. /* Internal speakers: output 0 (0x0c) */
  4771. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4772. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4773. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4774. /* Internal speakers: output 0 (0x0c) */
  4775. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4776. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4777. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4778. /* Headphone: output 0 (0x0c) */
  4779. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4780. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4781. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4782. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4783. /* Front Mic: input vref at 80% */
  4784. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4785. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4786. { }
  4787. };
  4788. /* Toggle speaker-output according to the hp-jack state */
  4789. static void alc885_imac24_automute(struct hda_codec *codec)
  4790. {
  4791. unsigned int present;
  4792. present = snd_hda_codec_read(codec, 0x14, 0,
  4793. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4794. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4795. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4796. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4797. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4798. }
  4799. /* Processes unsolicited events. */
  4800. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4801. unsigned int res)
  4802. {
  4803. /* Headphone insertion or removal. */
  4804. if ((res >> 26) == ALC880_HP_EVENT)
  4805. alc885_imac24_automute(codec);
  4806. }
  4807. static void alc885_mbp3_automute(struct hda_codec *codec)
  4808. {
  4809. unsigned int present;
  4810. present = snd_hda_codec_read(codec, 0x15, 0,
  4811. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4812. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4813. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4814. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4815. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4816. }
  4817. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4818. unsigned int res)
  4819. {
  4820. /* Headphone insertion or removal. */
  4821. if ((res >> 26) == ALC880_HP_EVENT)
  4822. alc885_mbp3_automute(codec);
  4823. }
  4824. static struct hda_verb alc882_targa_verbs[] = {
  4825. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4826. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4827. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4828. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4829. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4830. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4831. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4832. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4833. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4834. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4835. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4836. { } /* end */
  4837. };
  4838. /* toggle speaker-output according to the hp-jack state */
  4839. static void alc882_targa_automute(struct hda_codec *codec)
  4840. {
  4841. unsigned int present;
  4842. present = snd_hda_codec_read(codec, 0x14, 0,
  4843. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4844. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4845. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4846. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4847. present ? 1 : 3);
  4848. }
  4849. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4850. {
  4851. /* Looks like the unsol event is incompatible with the standard
  4852. * definition. 4bit tag is placed at 26 bit!
  4853. */
  4854. if (((res >> 26) == ALC880_HP_EVENT)) {
  4855. alc882_targa_automute(codec);
  4856. }
  4857. }
  4858. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4859. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4860. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4861. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4862. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4863. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4864. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4865. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4866. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4867. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4868. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4869. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4870. { } /* end */
  4871. };
  4872. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4873. {
  4874. unsigned int gpiostate, gpiomask, gpiodir;
  4875. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4876. AC_VERB_GET_GPIO_DATA, 0);
  4877. if (!muted)
  4878. gpiostate |= (1 << pin);
  4879. else
  4880. gpiostate &= ~(1 << pin);
  4881. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4882. AC_VERB_GET_GPIO_MASK, 0);
  4883. gpiomask |= (1 << pin);
  4884. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4885. AC_VERB_GET_GPIO_DIRECTION, 0);
  4886. gpiodir |= (1 << pin);
  4887. snd_hda_codec_write(codec, codec->afg, 0,
  4888. AC_VERB_SET_GPIO_MASK, gpiomask);
  4889. snd_hda_codec_write(codec, codec->afg, 0,
  4890. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4891. msleep(1);
  4892. snd_hda_codec_write(codec, codec->afg, 0,
  4893. AC_VERB_SET_GPIO_DATA, gpiostate);
  4894. }
  4895. /* set up GPIO at initialization */
  4896. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4897. {
  4898. alc882_gpio_mute(codec, 0, 0);
  4899. alc882_gpio_mute(codec, 1, 0);
  4900. }
  4901. /* set up GPIO and update auto-muting at initialization */
  4902. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4903. {
  4904. alc885_macpro_init_hook(codec);
  4905. alc885_imac24_automute(codec);
  4906. }
  4907. /*
  4908. * generic initialization of ADC, input mixers and output mixers
  4909. */
  4910. static struct hda_verb alc882_auto_init_verbs[] = {
  4911. /*
  4912. * Unmute ADC0-2 and set the default input to mic-in
  4913. */
  4914. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4915. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4916. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4918. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4920. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4921. * mixer widget
  4922. * Note: PASD motherboards uses the Line In 2 as the input for
  4923. * front panel mic (mic 2)
  4924. */
  4925. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4926. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4927. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4928. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4929. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4931. /*
  4932. * Set up output mixers (0x0c - 0x0f)
  4933. */
  4934. /* set vol=0 to output mixers */
  4935. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4936. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4937. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4938. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4939. /* set up input amps for analog loopback */
  4940. /* Amp Indices: DAC = 0, mixer = 1 */
  4941. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4942. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4943. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4944. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4945. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4946. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4947. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4948. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4949. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4950. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4951. /* FIXME: use matrix-type input source selection */
  4952. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4953. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4954. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4955. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4956. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4957. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4958. /* Input mixer2 */
  4959. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4960. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4962. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4963. /* Input mixer3 */
  4964. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4965. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4967. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4968. { }
  4969. };
  4970. /* capture mixer elements */
  4971. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4972. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4973. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4974. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4975. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4976. {
  4977. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4978. /* The multiple "Capture Source" controls confuse alsamixer
  4979. * So call somewhat different..
  4980. * FIXME: the controls appear in the "playback" view!
  4981. */
  4982. /* .name = "Capture Source", */
  4983. .name = "Input Source",
  4984. .count = 2,
  4985. .info = alc882_mux_enum_info,
  4986. .get = alc882_mux_enum_get,
  4987. .put = alc882_mux_enum_put,
  4988. },
  4989. { } /* end */
  4990. };
  4991. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4992. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4993. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4994. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4995. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4996. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4997. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4998. {
  4999. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5000. /* The multiple "Capture Source" controls confuse alsamixer
  5001. * So call somewhat different..
  5002. * FIXME: the controls appear in the "playback" view!
  5003. */
  5004. /* .name = "Capture Source", */
  5005. .name = "Input Source",
  5006. .count = 3,
  5007. .info = alc882_mux_enum_info,
  5008. .get = alc882_mux_enum_get,
  5009. .put = alc882_mux_enum_put,
  5010. },
  5011. { } /* end */
  5012. };
  5013. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5014. #define alc882_loopbacks alc880_loopbacks
  5015. #endif
  5016. /* pcm configuration: identiacal with ALC880 */
  5017. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5018. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5019. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5020. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5021. /*
  5022. * configuration and preset
  5023. */
  5024. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5025. [ALC882_3ST_DIG] = "3stack-dig",
  5026. [ALC882_6ST_DIG] = "6stack-dig",
  5027. [ALC882_ARIMA] = "arima",
  5028. [ALC882_W2JC] = "w2jc",
  5029. [ALC885_MACPRO] = "macpro",
  5030. [ALC885_MBP3] = "mbp3",
  5031. [ALC885_IMAC24] = "imac24",
  5032. [ALC882_AUTO] = "auto",
  5033. };
  5034. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5035. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5036. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5037. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5038. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5039. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5040. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5041. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5042. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5043. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5044. {}
  5045. };
  5046. static struct alc_config_preset alc882_presets[] = {
  5047. [ALC882_3ST_DIG] = {
  5048. .mixers = { alc882_base_mixer },
  5049. .init_verbs = { alc882_init_verbs },
  5050. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5051. .dac_nids = alc882_dac_nids,
  5052. .dig_out_nid = ALC882_DIGOUT_NID,
  5053. .dig_in_nid = ALC882_DIGIN_NID,
  5054. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5055. .channel_mode = alc882_ch_modes,
  5056. .need_dac_fix = 1,
  5057. .input_mux = &alc882_capture_source,
  5058. },
  5059. [ALC882_6ST_DIG] = {
  5060. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5061. .init_verbs = { alc882_init_verbs },
  5062. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5063. .dac_nids = alc882_dac_nids,
  5064. .dig_out_nid = ALC882_DIGOUT_NID,
  5065. .dig_in_nid = ALC882_DIGIN_NID,
  5066. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5067. .channel_mode = alc882_sixstack_modes,
  5068. .input_mux = &alc882_capture_source,
  5069. },
  5070. [ALC882_ARIMA] = {
  5071. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5072. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5073. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5074. .dac_nids = alc882_dac_nids,
  5075. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5076. .channel_mode = alc882_sixstack_modes,
  5077. .input_mux = &alc882_capture_source,
  5078. },
  5079. [ALC882_W2JC] = {
  5080. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5081. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5082. alc880_gpio1_init_verbs },
  5083. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5084. .dac_nids = alc882_dac_nids,
  5085. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5086. .channel_mode = alc880_threestack_modes,
  5087. .need_dac_fix = 1,
  5088. .input_mux = &alc882_capture_source,
  5089. .dig_out_nid = ALC882_DIGOUT_NID,
  5090. },
  5091. [ALC885_MBP3] = {
  5092. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5093. .init_verbs = { alc885_mbp3_init_verbs,
  5094. alc880_gpio1_init_verbs },
  5095. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5096. .dac_nids = alc882_dac_nids,
  5097. .channel_mode = alc885_mbp_6ch_modes,
  5098. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5099. .input_mux = &alc882_capture_source,
  5100. .dig_out_nid = ALC882_DIGOUT_NID,
  5101. .dig_in_nid = ALC882_DIGIN_NID,
  5102. .unsol_event = alc885_mbp3_unsol_event,
  5103. .init_hook = alc885_mbp3_automute,
  5104. },
  5105. [ALC885_MACPRO] = {
  5106. .mixers = { alc882_macpro_mixer },
  5107. .init_verbs = { alc882_macpro_init_verbs },
  5108. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5109. .dac_nids = alc882_dac_nids,
  5110. .dig_out_nid = ALC882_DIGOUT_NID,
  5111. .dig_in_nid = ALC882_DIGIN_NID,
  5112. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5113. .channel_mode = alc882_ch_modes,
  5114. .input_mux = &alc882_capture_source,
  5115. .init_hook = alc885_macpro_init_hook,
  5116. },
  5117. [ALC885_IMAC24] = {
  5118. .mixers = { alc885_imac24_mixer },
  5119. .init_verbs = { alc885_imac24_init_verbs },
  5120. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5121. .dac_nids = alc882_dac_nids,
  5122. .dig_out_nid = ALC882_DIGOUT_NID,
  5123. .dig_in_nid = ALC882_DIGIN_NID,
  5124. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5125. .channel_mode = alc882_ch_modes,
  5126. .input_mux = &alc882_capture_source,
  5127. .unsol_event = alc885_imac24_unsol_event,
  5128. .init_hook = alc885_imac24_init_hook,
  5129. },
  5130. [ALC882_TARGA] = {
  5131. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5132. alc882_capture_mixer },
  5133. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5134. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5135. .dac_nids = alc882_dac_nids,
  5136. .dig_out_nid = ALC882_DIGOUT_NID,
  5137. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5138. .adc_nids = alc882_adc_nids,
  5139. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5140. .channel_mode = alc882_3ST_6ch_modes,
  5141. .need_dac_fix = 1,
  5142. .input_mux = &alc882_capture_source,
  5143. .unsol_event = alc882_targa_unsol_event,
  5144. .init_hook = alc882_targa_automute,
  5145. },
  5146. [ALC882_ASUS_A7J] = {
  5147. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5148. alc882_capture_mixer },
  5149. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5150. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5151. .dac_nids = alc882_dac_nids,
  5152. .dig_out_nid = ALC882_DIGOUT_NID,
  5153. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5154. .adc_nids = alc882_adc_nids,
  5155. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5156. .channel_mode = alc882_3ST_6ch_modes,
  5157. .need_dac_fix = 1,
  5158. .input_mux = &alc882_capture_source,
  5159. },
  5160. };
  5161. /*
  5162. * Pin config fixes
  5163. */
  5164. enum {
  5165. PINFIX_ABIT_AW9D_MAX
  5166. };
  5167. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5168. { 0x15, 0x01080104 }, /* side */
  5169. { 0x16, 0x01011012 }, /* rear */
  5170. { 0x17, 0x01016011 }, /* clfe */
  5171. { }
  5172. };
  5173. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5174. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5175. };
  5176. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5177. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5178. {}
  5179. };
  5180. /*
  5181. * BIOS auto configuration
  5182. */
  5183. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5184. hda_nid_t nid, int pin_type,
  5185. int dac_idx)
  5186. {
  5187. /* set as output */
  5188. struct alc_spec *spec = codec->spec;
  5189. int idx;
  5190. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5191. idx = 4;
  5192. else
  5193. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5194. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5195. pin_type);
  5196. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5197. AMP_OUT_UNMUTE);
  5198. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5199. }
  5200. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5201. {
  5202. struct alc_spec *spec = codec->spec;
  5203. int i;
  5204. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5205. for (i = 0; i <= HDA_SIDE; i++) {
  5206. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5207. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5208. if (nid)
  5209. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5210. i);
  5211. }
  5212. }
  5213. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5214. {
  5215. struct alc_spec *spec = codec->spec;
  5216. hda_nid_t pin;
  5217. pin = spec->autocfg.hp_pins[0];
  5218. if (pin) /* connect to front */
  5219. /* use dac 0 */
  5220. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5221. }
  5222. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5223. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5224. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5225. {
  5226. struct alc_spec *spec = codec->spec;
  5227. int i;
  5228. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5229. hda_nid_t nid = spec->autocfg.input_pins[i];
  5230. if (alc882_is_input_pin(nid)) {
  5231. snd_hda_codec_write(codec, nid, 0,
  5232. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5233. i <= AUTO_PIN_FRONT_MIC ?
  5234. PIN_VREF80 : PIN_IN);
  5235. if (nid != ALC882_PIN_CD_NID)
  5236. snd_hda_codec_write(codec, nid, 0,
  5237. AC_VERB_SET_AMP_GAIN_MUTE,
  5238. AMP_OUT_MUTE);
  5239. }
  5240. }
  5241. }
  5242. /* almost identical with ALC880 parser... */
  5243. static int alc882_parse_auto_config(struct hda_codec *codec)
  5244. {
  5245. struct alc_spec *spec = codec->spec;
  5246. int err = alc880_parse_auto_config(codec);
  5247. if (err < 0)
  5248. return err;
  5249. else if (err > 0)
  5250. /* hack - override the init verbs */
  5251. spec->init_verbs[0] = alc882_auto_init_verbs;
  5252. return err;
  5253. }
  5254. /* additional initialization for auto-configuration model */
  5255. static void alc882_auto_init(struct hda_codec *codec)
  5256. {
  5257. alc882_auto_init_multi_out(codec);
  5258. alc882_auto_init_hp_out(codec);
  5259. alc882_auto_init_analog_input(codec);
  5260. }
  5261. static int patch_alc882(struct hda_codec *codec)
  5262. {
  5263. struct alc_spec *spec;
  5264. int err, board_config;
  5265. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5266. if (spec == NULL)
  5267. return -ENOMEM;
  5268. codec->spec = spec;
  5269. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5270. alc882_models,
  5271. alc882_cfg_tbl);
  5272. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5273. /* Pick up systems that don't supply PCI SSID */
  5274. switch (codec->subsystem_id) {
  5275. case 0x106b0c00: /* Mac Pro */
  5276. board_config = ALC885_MACPRO;
  5277. break;
  5278. case 0x106b1000: /* iMac 24 */
  5279. board_config = ALC885_IMAC24;
  5280. break;
  5281. case 0x106b2c00: /* Macbook Pro rev3 */
  5282. board_config = ALC885_MBP3;
  5283. break;
  5284. default:
  5285. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5286. "trying auto-probe from BIOS...\n");
  5287. board_config = ALC882_AUTO;
  5288. }
  5289. }
  5290. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5291. if (board_config == ALC882_AUTO) {
  5292. /* automatic parse from the BIOS config */
  5293. err = alc882_parse_auto_config(codec);
  5294. if (err < 0) {
  5295. alc_free(codec);
  5296. return err;
  5297. } else if (!err) {
  5298. printk(KERN_INFO
  5299. "hda_codec: Cannot set up configuration "
  5300. "from BIOS. Using base mode...\n");
  5301. board_config = ALC882_3ST_DIG;
  5302. }
  5303. }
  5304. if (board_config != ALC882_AUTO)
  5305. setup_preset(spec, &alc882_presets[board_config]);
  5306. spec->stream_name_analog = "ALC882 Analog";
  5307. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5308. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5309. spec->stream_name_digital = "ALC882 Digital";
  5310. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5311. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5312. if (!spec->adc_nids && spec->input_mux) {
  5313. /* check whether NID 0x07 is valid */
  5314. unsigned int wcap = get_wcaps(codec, 0x07);
  5315. /* get type */
  5316. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5317. if (wcap != AC_WID_AUD_IN) {
  5318. spec->adc_nids = alc882_adc_nids_alt;
  5319. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5320. spec->mixers[spec->num_mixers] =
  5321. alc882_capture_alt_mixer;
  5322. spec->num_mixers++;
  5323. } else {
  5324. spec->adc_nids = alc882_adc_nids;
  5325. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5326. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5327. spec->num_mixers++;
  5328. }
  5329. }
  5330. codec->patch_ops = alc_patch_ops;
  5331. if (board_config == ALC882_AUTO)
  5332. spec->init_hook = alc882_auto_init;
  5333. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5334. if (!spec->loopback.amplist)
  5335. spec->loopback.amplist = alc882_loopbacks;
  5336. #endif
  5337. return 0;
  5338. }
  5339. /*
  5340. * ALC883 support
  5341. *
  5342. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5343. * configuration. Each pin widget can choose any input DACs and a mixer.
  5344. * Each ADC is connected from a mixer of all inputs. This makes possible
  5345. * 6-channel independent captures.
  5346. *
  5347. * In addition, an independent DAC for the multi-playback (not used in this
  5348. * driver yet).
  5349. */
  5350. #define ALC883_DIGOUT_NID 0x06
  5351. #define ALC883_DIGIN_NID 0x0a
  5352. static hda_nid_t alc883_dac_nids[4] = {
  5353. /* front, rear, clfe, rear_surr */
  5354. 0x02, 0x04, 0x03, 0x05
  5355. };
  5356. static hda_nid_t alc883_adc_nids[2] = {
  5357. /* ADC1-2 */
  5358. 0x08, 0x09,
  5359. };
  5360. /* input MUX */
  5361. /* FIXME: should be a matrix-type input source selection */
  5362. static struct hda_input_mux alc883_capture_source = {
  5363. .num_items = 4,
  5364. .items = {
  5365. { "Mic", 0x0 },
  5366. { "Front Mic", 0x1 },
  5367. { "Line", 0x2 },
  5368. { "CD", 0x4 },
  5369. },
  5370. };
  5371. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5372. .num_items = 2,
  5373. .items = {
  5374. { "Mic", 0x1 },
  5375. { "Line", 0x2 },
  5376. },
  5377. };
  5378. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5379. .num_items = 4,
  5380. .items = {
  5381. { "Mic", 0x0 },
  5382. { "iMic", 0x1 },
  5383. { "Line", 0x2 },
  5384. { "CD", 0x4 },
  5385. },
  5386. };
  5387. #define alc883_mux_enum_info alc_mux_enum_info
  5388. #define alc883_mux_enum_get alc_mux_enum_get
  5389. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5390. struct snd_ctl_elem_value *ucontrol)
  5391. {
  5392. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5393. struct alc_spec *spec = codec->spec;
  5394. const struct hda_input_mux *imux = spec->input_mux;
  5395. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5396. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5397. hda_nid_t nid = capture_mixers[adc_idx];
  5398. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5399. unsigned int i, idx;
  5400. idx = ucontrol->value.enumerated.item[0];
  5401. if (idx >= imux->num_items)
  5402. idx = imux->num_items - 1;
  5403. if (*cur_val == idx)
  5404. return 0;
  5405. for (i = 0; i < imux->num_items; i++) {
  5406. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5407. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5408. imux->items[i].index,
  5409. HDA_AMP_MUTE, v);
  5410. }
  5411. *cur_val = idx;
  5412. return 1;
  5413. }
  5414. /*
  5415. * 2ch mode
  5416. */
  5417. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5418. { 2, NULL }
  5419. };
  5420. /*
  5421. * 2ch mode
  5422. */
  5423. static struct hda_verb alc883_3ST_ch2_init[] = {
  5424. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5425. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5426. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5427. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5428. { } /* end */
  5429. };
  5430. /*
  5431. * 6ch mode
  5432. */
  5433. static struct hda_verb alc883_3ST_ch6_init[] = {
  5434. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5435. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5436. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5437. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5438. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5439. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5440. { } /* end */
  5441. };
  5442. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5443. { 2, alc883_3ST_ch2_init },
  5444. { 6, alc883_3ST_ch6_init },
  5445. };
  5446. /*
  5447. * 6ch mode
  5448. */
  5449. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5450. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5451. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5452. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5453. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5454. { } /* end */
  5455. };
  5456. /*
  5457. * 8ch mode
  5458. */
  5459. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5460. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5461. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5462. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5463. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5464. { } /* end */
  5465. };
  5466. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5467. { 6, alc883_sixstack_ch6_init },
  5468. { 8, alc883_sixstack_ch8_init },
  5469. };
  5470. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5471. /* eanable EAPD on medion laptop */
  5472. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5473. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5474. { }
  5475. };
  5476. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5477. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5478. */
  5479. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5480. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5481. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5482. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5483. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5484. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5485. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5486. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5487. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5488. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5489. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5490. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5491. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5492. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5493. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5494. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5495. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5496. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5497. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5498. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5499. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5500. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5501. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5502. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5504. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5505. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5506. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5507. {
  5508. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5509. /* .name = "Capture Source", */
  5510. .name = "Input Source",
  5511. .count = 2,
  5512. .info = alc883_mux_enum_info,
  5513. .get = alc883_mux_enum_get,
  5514. .put = alc883_mux_enum_put,
  5515. },
  5516. { } /* end */
  5517. };
  5518. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5519. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5520. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5521. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5522. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5523. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5524. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5525. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5527. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5528. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5530. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5531. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5532. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5533. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5534. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5535. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5536. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5537. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5538. {
  5539. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5540. /* .name = "Capture Source", */
  5541. .name = "Input Source",
  5542. .count = 2,
  5543. .info = alc883_mux_enum_info,
  5544. .get = alc883_mux_enum_get,
  5545. .put = alc883_mux_enum_put,
  5546. },
  5547. { } /* end */
  5548. };
  5549. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5550. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5551. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5552. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5553. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5554. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5555. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5556. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5557. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5558. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5559. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5560. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5561. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5562. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5563. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5564. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5565. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5566. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5567. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5568. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5569. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5570. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5571. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5572. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5573. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5574. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5575. {
  5576. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5577. /* .name = "Capture Source", */
  5578. .name = "Input Source",
  5579. .count = 2,
  5580. .info = alc883_mux_enum_info,
  5581. .get = alc883_mux_enum_get,
  5582. .put = alc883_mux_enum_put,
  5583. },
  5584. { } /* end */
  5585. };
  5586. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5587. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5588. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5589. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5590. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5591. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5592. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5593. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5594. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5595. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5596. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5597. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5598. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5599. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5600. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5601. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5602. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5603. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5604. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5605. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5606. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5607. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5608. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5609. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5610. {
  5611. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5612. /* .name = "Capture Source", */
  5613. .name = "Input Source",
  5614. .count = 1,
  5615. .info = alc883_mux_enum_info,
  5616. .get = alc883_mux_enum_get,
  5617. .put = alc883_mux_enum_put,
  5618. },
  5619. { } /* end */
  5620. };
  5621. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5622. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5623. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5624. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5625. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5626. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5627. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5628. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5629. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5630. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5631. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5632. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5634. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5635. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5636. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5637. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5638. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5639. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5640. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5641. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5642. {
  5643. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5644. /* .name = "Capture Source", */
  5645. .name = "Input Source",
  5646. .count = 2,
  5647. .info = alc883_mux_enum_info,
  5648. .get = alc883_mux_enum_get,
  5649. .put = alc883_mux_enum_put,
  5650. },
  5651. { } /* end */
  5652. };
  5653. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5654. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5655. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5656. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5657. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5658. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5659. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5660. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5661. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5662. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5663. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5664. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5665. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5666. {
  5667. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5668. /* .name = "Capture Source", */
  5669. .name = "Input Source",
  5670. .count = 2,
  5671. .info = alc883_mux_enum_info,
  5672. .get = alc883_mux_enum_get,
  5673. .put = alc883_mux_enum_put,
  5674. },
  5675. { } /* end */
  5676. };
  5677. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5678. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5679. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5680. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5681. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5682. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5683. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5684. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5685. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5686. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5687. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5688. {
  5689. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5690. /* .name = "Capture Source", */
  5691. .name = "Input Source",
  5692. .count = 1,
  5693. .info = alc883_mux_enum_info,
  5694. .get = alc883_mux_enum_get,
  5695. .put = alc883_mux_enum_put,
  5696. },
  5697. { } /* end */
  5698. };
  5699. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5700. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5701. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5702. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5703. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5704. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5705. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5706. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5707. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5708. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5709. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5710. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5711. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5712. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5713. {
  5714. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5715. /* .name = "Capture Source", */
  5716. .name = "Input Source",
  5717. .count = 2,
  5718. .info = alc883_mux_enum_info,
  5719. .get = alc883_mux_enum_get,
  5720. .put = alc883_mux_enum_put,
  5721. },
  5722. { } /* end */
  5723. };
  5724. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5725. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5726. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5727. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5728. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5729. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5733. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5734. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5735. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5736. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5737. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5738. {
  5739. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5740. /* .name = "Capture Source", */
  5741. .name = "Input Source",
  5742. .count = 2,
  5743. .info = alc883_mux_enum_info,
  5744. .get = alc883_mux_enum_get,
  5745. .put = alc883_mux_enum_put,
  5746. },
  5747. { } /* end */
  5748. };
  5749. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5750. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5751. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5752. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5753. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5754. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5755. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5756. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5757. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5758. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5759. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5760. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5761. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5762. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5763. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5764. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5765. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5766. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5767. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5768. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5769. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5770. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5771. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5772. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5773. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5774. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5775. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5776. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5777. {
  5778. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5779. /* .name = "Capture Source", */
  5780. .name = "Input Source",
  5781. .count = 2,
  5782. .info = alc883_mux_enum_info,
  5783. .get = alc883_mux_enum_get,
  5784. .put = alc883_mux_enum_put,
  5785. },
  5786. { } /* end */
  5787. };
  5788. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5789. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5790. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5791. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5792. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5793. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5794. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5795. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5796. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5797. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5798. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5799. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5801. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5802. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5803. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5804. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5805. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5806. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5807. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5808. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5809. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5810. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5811. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5812. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5813. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5814. {
  5815. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5816. /* .name = "Capture Source", */
  5817. .name = "Input Source",
  5818. .count = 2,
  5819. .info = alc883_mux_enum_info,
  5820. .get = alc883_mux_enum_get,
  5821. .put = alc883_mux_enum_put,
  5822. },
  5823. { } /* end */
  5824. };
  5825. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5826. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5827. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5828. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5829. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5830. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5831. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5833. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5834. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5835. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5836. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5837. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5838. {
  5839. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5840. /* .name = "Capture Source", */
  5841. .name = "Input Source",
  5842. .count = 2,
  5843. .info = alc883_mux_enum_info,
  5844. .get = alc883_mux_enum_get,
  5845. .put = alc883_mux_enum_put,
  5846. },
  5847. { } /* end */
  5848. };
  5849. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5850. {
  5851. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5852. .name = "Channel Mode",
  5853. .info = alc_ch_mode_info,
  5854. .get = alc_ch_mode_get,
  5855. .put = alc_ch_mode_put,
  5856. },
  5857. { } /* end */
  5858. };
  5859. static struct hda_verb alc883_init_verbs[] = {
  5860. /* ADC1: mute amp left and right */
  5861. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5862. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5863. /* ADC2: mute amp left and right */
  5864. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5865. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5866. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5868. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5869. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5870. /* Rear mixer */
  5871. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5872. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5873. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5874. /* CLFE mixer */
  5875. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5876. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5877. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5878. /* Side mixer */
  5879. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5880. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5881. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5882. /* mute analog input loopbacks */
  5883. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5884. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5885. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5886. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5887. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5888. /* Front Pin: output 0 (0x0c) */
  5889. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5891. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5892. /* Rear Pin: output 1 (0x0d) */
  5893. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5894. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5895. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5896. /* CLFE Pin: output 2 (0x0e) */
  5897. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5898. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5899. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5900. /* Side Pin: output 3 (0x0f) */
  5901. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5902. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5903. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5904. /* Mic (rear) pin: input vref at 80% */
  5905. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5906. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5907. /* Front Mic pin: input vref at 80% */
  5908. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5909. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5910. /* Line In pin: input */
  5911. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5912. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5913. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5914. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5915. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5916. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5917. /* CD pin widget for input */
  5918. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5919. /* FIXME: use matrix-type input source selection */
  5920. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5921. /* Input mixer2 */
  5922. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5923. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5924. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5925. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5926. /* Input mixer3 */
  5927. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5928. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5929. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5930. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5931. { }
  5932. };
  5933. static struct hda_verb alc883_tagra_verbs[] = {
  5934. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5935. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5936. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5937. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5938. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5939. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5940. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5941. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5942. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5943. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5944. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5945. { } /* end */
  5946. };
  5947. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5948. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5949. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5950. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5951. { } /* end */
  5952. };
  5953. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5954. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5955. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5956. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5957. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5958. { } /* end */
  5959. };
  5960. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5962. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5963. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5964. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5965. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5966. { } /* end */
  5967. };
  5968. static struct hda_verb alc888_6st_hp_verbs[] = {
  5969. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5970. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5971. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5972. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5973. { }
  5974. };
  5975. static struct hda_verb alc888_3st_hp_verbs[] = {
  5976. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5977. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5978. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5979. { }
  5980. };
  5981. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5982. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5983. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5984. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5985. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5986. { }
  5987. };
  5988. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5989. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5990. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5991. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5992. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5993. { }
  5994. };
  5995. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5996. { 2, alc888_3st_hp_2ch_init },
  5997. { 6, alc888_3st_hp_6ch_init },
  5998. };
  5999. /* toggle front-jack and RCA according to the hp-jack state */
  6000. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6001. {
  6002. unsigned int present;
  6003. present = snd_hda_codec_read(codec, 0x1b, 0,
  6004. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6005. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6006. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6007. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6008. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6009. }
  6010. /* toggle RCA according to the front-jack state */
  6011. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6012. {
  6013. unsigned int present;
  6014. present = snd_hda_codec_read(codec, 0x14, 0,
  6015. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6016. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6017. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6018. }
  6019. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6020. unsigned int res)
  6021. {
  6022. if ((res >> 26) == ALC880_HP_EVENT)
  6023. alc888_lenovo_ms7195_front_automute(codec);
  6024. if ((res >> 26) == ALC880_FRONT_EVENT)
  6025. alc888_lenovo_ms7195_rca_automute(codec);
  6026. }
  6027. static struct hda_verb alc883_medion_md2_verbs[] = {
  6028. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6030. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6031. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6032. { } /* end */
  6033. };
  6034. /* toggle speaker-output according to the hp-jack state */
  6035. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6036. {
  6037. unsigned int present;
  6038. present = snd_hda_codec_read(codec, 0x14, 0,
  6039. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6040. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6041. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6042. }
  6043. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6044. unsigned int res)
  6045. {
  6046. if ((res >> 26) == ALC880_HP_EVENT)
  6047. alc883_medion_md2_automute(codec);
  6048. }
  6049. /* toggle speaker-output according to the hp-jack state */
  6050. static void alc883_tagra_automute(struct hda_codec *codec)
  6051. {
  6052. unsigned int present;
  6053. unsigned char bits;
  6054. present = snd_hda_codec_read(codec, 0x14, 0,
  6055. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6056. bits = present ? HDA_AMP_MUTE : 0;
  6057. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6058. HDA_AMP_MUTE, bits);
  6059. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6060. present ? 1 : 3);
  6061. }
  6062. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6063. {
  6064. if ((res >> 26) == ALC880_HP_EVENT)
  6065. alc883_tagra_automute(codec);
  6066. }
  6067. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6068. {
  6069. unsigned int present;
  6070. unsigned char bits;
  6071. present = snd_hda_codec_read(codec, 0x14, 0,
  6072. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6073. bits = present ? HDA_AMP_MUTE : 0;
  6074. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6075. HDA_AMP_MUTE, bits);
  6076. }
  6077. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6078. {
  6079. unsigned int present;
  6080. unsigned char bits;
  6081. present = snd_hda_codec_read(codec, 0x1b, 0,
  6082. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6083. bits = present ? HDA_AMP_MUTE : 0;
  6084. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6085. HDA_AMP_MUTE, bits);
  6086. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6087. HDA_AMP_MUTE, bits);
  6088. }
  6089. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6090. unsigned int res)
  6091. {
  6092. if ((res >> 26) == ALC880_HP_EVENT)
  6093. alc883_lenovo_101e_all_automute(codec);
  6094. if ((res >> 26) == ALC880_FRONT_EVENT)
  6095. alc883_lenovo_101e_ispeaker_automute(codec);
  6096. }
  6097. /* toggle speaker-output according to the hp-jack state */
  6098. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6099. {
  6100. unsigned int present;
  6101. present = snd_hda_codec_read(codec, 0x14, 0,
  6102. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6103. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6104. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6105. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6106. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6107. }
  6108. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6109. unsigned int res)
  6110. {
  6111. if ((res >> 26) == ALC880_HP_EVENT)
  6112. alc883_acer_aspire_automute(codec);
  6113. }
  6114. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6115. /* HP Pin: output 0 (0x0c) */
  6116. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6117. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6118. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6119. /* Front Pin: output 0 (0x0c) */
  6120. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6121. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6122. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6123. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6124. /* eanable EAPD on medion laptop */
  6125. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6126. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6127. /* enable unsolicited event */
  6128. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6129. { }
  6130. };
  6131. /*
  6132. * generic initialization of ADC, input mixers and output mixers
  6133. */
  6134. static struct hda_verb alc883_auto_init_verbs[] = {
  6135. /*
  6136. * Unmute ADC0-2 and set the default input to mic-in
  6137. */
  6138. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6139. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6140. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6141. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6142. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6143. * mixer widget
  6144. * Note: PASD motherboards uses the Line In 2 as the input for
  6145. * front panel mic (mic 2)
  6146. */
  6147. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6149. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6150. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6151. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6152. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6153. /*
  6154. * Set up output mixers (0x0c - 0x0f)
  6155. */
  6156. /* set vol=0 to output mixers */
  6157. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6158. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6159. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6160. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6161. /* set up input amps for analog loopback */
  6162. /* Amp Indices: DAC = 0, mixer = 1 */
  6163. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6165. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6166. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6167. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6168. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6169. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6170. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6171. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6172. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6173. /* FIXME: use matrix-type input source selection */
  6174. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6175. /* Input mixer1 */
  6176. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6177. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6178. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6179. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6180. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6181. /* Input mixer2 */
  6182. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6183. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6184. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6185. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6186. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6187. { }
  6188. };
  6189. /* capture mixer elements */
  6190. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6191. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6192. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6193. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6194. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6195. {
  6196. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6197. /* The multiple "Capture Source" controls confuse alsamixer
  6198. * So call somewhat different..
  6199. * FIXME: the controls appear in the "playback" view!
  6200. */
  6201. /* .name = "Capture Source", */
  6202. .name = "Input Source",
  6203. .count = 2,
  6204. .info = alc882_mux_enum_info,
  6205. .get = alc882_mux_enum_get,
  6206. .put = alc882_mux_enum_put,
  6207. },
  6208. { } /* end */
  6209. };
  6210. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6211. #define alc883_loopbacks alc880_loopbacks
  6212. #endif
  6213. /* pcm configuration: identiacal with ALC880 */
  6214. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6215. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6216. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6217. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6218. /*
  6219. * configuration and preset
  6220. */
  6221. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6222. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6223. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6224. [ALC883_3ST_6ch] = "3stack-6ch",
  6225. [ALC883_6ST_DIG] = "6stack-dig",
  6226. [ALC883_TARGA_DIG] = "targa-dig",
  6227. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6228. [ALC883_ACER] = "acer",
  6229. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6230. [ALC883_MEDION] = "medion",
  6231. [ALC883_MEDION_MD2] = "medion-md2",
  6232. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6233. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6234. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6235. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6236. [ALC888_6ST_HP] = "6stack-hp",
  6237. [ALC888_3ST_HP] = "3stack-hp",
  6238. [ALC883_AUTO] = "auto",
  6239. };
  6240. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6241. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6242. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6243. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6244. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6245. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6246. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6247. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6248. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6249. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6250. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6251. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6252. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6253. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6254. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6255. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6256. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6257. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6258. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6259. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6260. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6261. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6262. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6263. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6264. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6265. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6266. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6267. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6268. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6269. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6270. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6271. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6272. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6273. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6274. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6275. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6276. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6277. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6278. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6279. {}
  6280. };
  6281. static struct alc_config_preset alc883_presets[] = {
  6282. [ALC883_3ST_2ch_DIG] = {
  6283. .mixers = { alc883_3ST_2ch_mixer },
  6284. .init_verbs = { alc883_init_verbs },
  6285. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6286. .dac_nids = alc883_dac_nids,
  6287. .dig_out_nid = ALC883_DIGOUT_NID,
  6288. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6289. .adc_nids = alc883_adc_nids,
  6290. .dig_in_nid = ALC883_DIGIN_NID,
  6291. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6292. .channel_mode = alc883_3ST_2ch_modes,
  6293. .input_mux = &alc883_capture_source,
  6294. },
  6295. [ALC883_3ST_6ch_DIG] = {
  6296. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6297. .init_verbs = { alc883_init_verbs },
  6298. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6299. .dac_nids = alc883_dac_nids,
  6300. .dig_out_nid = ALC883_DIGOUT_NID,
  6301. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6302. .adc_nids = alc883_adc_nids,
  6303. .dig_in_nid = ALC883_DIGIN_NID,
  6304. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6305. .channel_mode = alc883_3ST_6ch_modes,
  6306. .need_dac_fix = 1,
  6307. .input_mux = &alc883_capture_source,
  6308. },
  6309. [ALC883_3ST_6ch] = {
  6310. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6311. .init_verbs = { alc883_init_verbs },
  6312. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6313. .dac_nids = alc883_dac_nids,
  6314. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6315. .adc_nids = alc883_adc_nids,
  6316. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6317. .channel_mode = alc883_3ST_6ch_modes,
  6318. .need_dac_fix = 1,
  6319. .input_mux = &alc883_capture_source,
  6320. },
  6321. [ALC883_6ST_DIG] = {
  6322. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6323. .init_verbs = { alc883_init_verbs },
  6324. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6325. .dac_nids = alc883_dac_nids,
  6326. .dig_out_nid = ALC883_DIGOUT_NID,
  6327. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6328. .adc_nids = alc883_adc_nids,
  6329. .dig_in_nid = ALC883_DIGIN_NID,
  6330. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6331. .channel_mode = alc883_sixstack_modes,
  6332. .input_mux = &alc883_capture_source,
  6333. },
  6334. [ALC883_TARGA_DIG] = {
  6335. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6336. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6337. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6338. .dac_nids = alc883_dac_nids,
  6339. .dig_out_nid = ALC883_DIGOUT_NID,
  6340. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6341. .adc_nids = alc883_adc_nids,
  6342. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6343. .channel_mode = alc883_3ST_6ch_modes,
  6344. .need_dac_fix = 1,
  6345. .input_mux = &alc883_capture_source,
  6346. .unsol_event = alc883_tagra_unsol_event,
  6347. .init_hook = alc883_tagra_automute,
  6348. },
  6349. [ALC883_TARGA_2ch_DIG] = {
  6350. .mixers = { alc883_tagra_2ch_mixer},
  6351. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6352. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6353. .dac_nids = alc883_dac_nids,
  6354. .dig_out_nid = ALC883_DIGOUT_NID,
  6355. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6356. .adc_nids = alc883_adc_nids,
  6357. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6358. .channel_mode = alc883_3ST_2ch_modes,
  6359. .input_mux = &alc883_capture_source,
  6360. .unsol_event = alc883_tagra_unsol_event,
  6361. .init_hook = alc883_tagra_automute,
  6362. },
  6363. [ALC883_ACER] = {
  6364. .mixers = { alc883_base_mixer },
  6365. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6366. * and the headphone jack. Turn this on and rely on the
  6367. * standard mute methods whenever the user wants to turn
  6368. * these outputs off.
  6369. */
  6370. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6371. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6372. .dac_nids = alc883_dac_nids,
  6373. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6374. .adc_nids = alc883_adc_nids,
  6375. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6376. .channel_mode = alc883_3ST_2ch_modes,
  6377. .input_mux = &alc883_capture_source,
  6378. },
  6379. [ALC883_ACER_ASPIRE] = {
  6380. .mixers = { alc883_acer_aspire_mixer },
  6381. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6382. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6383. .dac_nids = alc883_dac_nids,
  6384. .dig_out_nid = ALC883_DIGOUT_NID,
  6385. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6386. .adc_nids = alc883_adc_nids,
  6387. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6388. .channel_mode = alc883_3ST_2ch_modes,
  6389. .input_mux = &alc883_capture_source,
  6390. .unsol_event = alc883_acer_aspire_unsol_event,
  6391. .init_hook = alc883_acer_aspire_automute,
  6392. },
  6393. [ALC883_MEDION] = {
  6394. .mixers = { alc883_fivestack_mixer,
  6395. alc883_chmode_mixer },
  6396. .init_verbs = { alc883_init_verbs,
  6397. alc883_medion_eapd_verbs },
  6398. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6399. .dac_nids = alc883_dac_nids,
  6400. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6401. .adc_nids = alc883_adc_nids,
  6402. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6403. .channel_mode = alc883_sixstack_modes,
  6404. .input_mux = &alc883_capture_source,
  6405. },
  6406. [ALC883_MEDION_MD2] = {
  6407. .mixers = { alc883_medion_md2_mixer},
  6408. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6409. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6410. .dac_nids = alc883_dac_nids,
  6411. .dig_out_nid = ALC883_DIGOUT_NID,
  6412. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6413. .adc_nids = alc883_adc_nids,
  6414. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6415. .channel_mode = alc883_3ST_2ch_modes,
  6416. .input_mux = &alc883_capture_source,
  6417. .unsol_event = alc883_medion_md2_unsol_event,
  6418. .init_hook = alc883_medion_md2_automute,
  6419. },
  6420. [ALC883_LAPTOP_EAPD] = {
  6421. .mixers = { alc883_base_mixer },
  6422. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6423. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6424. .dac_nids = alc883_dac_nids,
  6425. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6426. .adc_nids = alc883_adc_nids,
  6427. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6428. .channel_mode = alc883_3ST_2ch_modes,
  6429. .input_mux = &alc883_capture_source,
  6430. },
  6431. [ALC883_LENOVO_101E_2ch] = {
  6432. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6433. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6434. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6435. .dac_nids = alc883_dac_nids,
  6436. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6437. .adc_nids = alc883_adc_nids,
  6438. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6439. .channel_mode = alc883_3ST_2ch_modes,
  6440. .input_mux = &alc883_lenovo_101e_capture_source,
  6441. .unsol_event = alc883_lenovo_101e_unsol_event,
  6442. .init_hook = alc883_lenovo_101e_all_automute,
  6443. },
  6444. [ALC883_LENOVO_NB0763] = {
  6445. .mixers = { alc883_lenovo_nb0763_mixer },
  6446. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6447. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6448. .dac_nids = alc883_dac_nids,
  6449. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6450. .adc_nids = alc883_adc_nids,
  6451. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6452. .channel_mode = alc883_3ST_2ch_modes,
  6453. .need_dac_fix = 1,
  6454. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6455. .unsol_event = alc883_medion_md2_unsol_event,
  6456. .init_hook = alc883_medion_md2_automute,
  6457. },
  6458. [ALC888_LENOVO_MS7195_DIG] = {
  6459. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6460. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6461. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6462. .dac_nids = alc883_dac_nids,
  6463. .dig_out_nid = ALC883_DIGOUT_NID,
  6464. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6465. .adc_nids = alc883_adc_nids,
  6466. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6467. .channel_mode = alc883_3ST_6ch_modes,
  6468. .need_dac_fix = 1,
  6469. .input_mux = &alc883_capture_source,
  6470. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6471. .init_hook = alc888_lenovo_ms7195_front_automute,
  6472. },
  6473. [ALC888_6ST_HP] = {
  6474. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6475. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6476. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6477. .dac_nids = alc883_dac_nids,
  6478. .dig_out_nid = ALC883_DIGOUT_NID,
  6479. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6480. .adc_nids = alc883_adc_nids,
  6481. .dig_in_nid = ALC883_DIGIN_NID,
  6482. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6483. .channel_mode = alc883_sixstack_modes,
  6484. .input_mux = &alc883_capture_source,
  6485. },
  6486. [ALC888_3ST_HP] = {
  6487. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6488. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6489. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6490. .dac_nids = alc883_dac_nids,
  6491. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6492. .adc_nids = alc883_adc_nids,
  6493. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6494. .channel_mode = alc888_3st_hp_modes,
  6495. .need_dac_fix = 1,
  6496. .input_mux = &alc883_capture_source,
  6497. },
  6498. };
  6499. /*
  6500. * BIOS auto configuration
  6501. */
  6502. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6503. hda_nid_t nid, int pin_type,
  6504. int dac_idx)
  6505. {
  6506. /* set as output */
  6507. struct alc_spec *spec = codec->spec;
  6508. int idx;
  6509. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6510. idx = 4;
  6511. else
  6512. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6513. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6514. pin_type);
  6515. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6516. AMP_OUT_UNMUTE);
  6517. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6518. }
  6519. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6520. {
  6521. struct alc_spec *spec = codec->spec;
  6522. int i;
  6523. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6524. for (i = 0; i <= HDA_SIDE; i++) {
  6525. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6526. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6527. if (nid)
  6528. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6529. i);
  6530. }
  6531. }
  6532. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6533. {
  6534. struct alc_spec *spec = codec->spec;
  6535. hda_nid_t pin;
  6536. pin = spec->autocfg.hp_pins[0];
  6537. if (pin) /* connect to front */
  6538. /* use dac 0 */
  6539. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6540. }
  6541. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6542. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6543. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6544. {
  6545. struct alc_spec *spec = codec->spec;
  6546. int i;
  6547. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6548. hda_nid_t nid = spec->autocfg.input_pins[i];
  6549. if (alc883_is_input_pin(nid)) {
  6550. snd_hda_codec_write(codec, nid, 0,
  6551. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6552. (i <= AUTO_PIN_FRONT_MIC ?
  6553. PIN_VREF80 : PIN_IN));
  6554. if (nid != ALC883_PIN_CD_NID)
  6555. snd_hda_codec_write(codec, nid, 0,
  6556. AC_VERB_SET_AMP_GAIN_MUTE,
  6557. AMP_OUT_MUTE);
  6558. }
  6559. }
  6560. }
  6561. /* almost identical with ALC880 parser... */
  6562. static int alc883_parse_auto_config(struct hda_codec *codec)
  6563. {
  6564. struct alc_spec *spec = codec->spec;
  6565. int err = alc880_parse_auto_config(codec);
  6566. if (err < 0)
  6567. return err;
  6568. else if (err > 0)
  6569. /* hack - override the init verbs */
  6570. spec->init_verbs[0] = alc883_auto_init_verbs;
  6571. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6572. spec->num_mixers++;
  6573. return err;
  6574. }
  6575. /* additional initialization for auto-configuration model */
  6576. static void alc883_auto_init(struct hda_codec *codec)
  6577. {
  6578. alc883_auto_init_multi_out(codec);
  6579. alc883_auto_init_hp_out(codec);
  6580. alc883_auto_init_analog_input(codec);
  6581. }
  6582. static int patch_alc883(struct hda_codec *codec)
  6583. {
  6584. struct alc_spec *spec;
  6585. int err, board_config;
  6586. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6587. if (spec == NULL)
  6588. return -ENOMEM;
  6589. codec->spec = spec;
  6590. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6591. alc883_models,
  6592. alc883_cfg_tbl);
  6593. if (board_config < 0) {
  6594. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6595. "trying auto-probe from BIOS...\n");
  6596. board_config = ALC883_AUTO;
  6597. }
  6598. if (board_config == ALC883_AUTO) {
  6599. /* automatic parse from the BIOS config */
  6600. err = alc883_parse_auto_config(codec);
  6601. if (err < 0) {
  6602. alc_free(codec);
  6603. return err;
  6604. } else if (!err) {
  6605. printk(KERN_INFO
  6606. "hda_codec: Cannot set up configuration "
  6607. "from BIOS. Using base mode...\n");
  6608. board_config = ALC883_3ST_2ch_DIG;
  6609. }
  6610. }
  6611. if (board_config != ALC883_AUTO)
  6612. setup_preset(spec, &alc883_presets[board_config]);
  6613. spec->stream_name_analog = "ALC883 Analog";
  6614. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6615. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6616. spec->stream_name_digital = "ALC883 Digital";
  6617. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6618. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6619. if (!spec->adc_nids && spec->input_mux) {
  6620. spec->adc_nids = alc883_adc_nids;
  6621. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6622. }
  6623. codec->patch_ops = alc_patch_ops;
  6624. if (board_config == ALC883_AUTO)
  6625. spec->init_hook = alc883_auto_init;
  6626. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6627. if (!spec->loopback.amplist)
  6628. spec->loopback.amplist = alc883_loopbacks;
  6629. #endif
  6630. return 0;
  6631. }
  6632. /*
  6633. * ALC262 support
  6634. */
  6635. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6636. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6637. #define alc262_dac_nids alc260_dac_nids
  6638. #define alc262_adc_nids alc882_adc_nids
  6639. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6640. #define alc262_modes alc260_modes
  6641. #define alc262_capture_source alc882_capture_source
  6642. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6643. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6644. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6645. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6646. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6647. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6648. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6649. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6650. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6651. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6652. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6653. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6654. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6655. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6656. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6657. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6658. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6659. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6660. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6661. { } /* end */
  6662. };
  6663. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6664. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6665. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6666. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6667. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6668. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6669. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6670. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6671. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6672. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6673. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6674. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6675. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6676. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6677. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6678. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6679. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6680. { } /* end */
  6681. };
  6682. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6683. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6684. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6685. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6686. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6687. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6688. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6689. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6690. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6691. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6692. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6693. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6694. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6695. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6696. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6697. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6698. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6699. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6700. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6701. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6702. { } /* end */
  6703. };
  6704. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6705. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6706. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6707. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6708. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6709. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6710. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6711. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6712. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6713. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6714. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6715. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6716. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6717. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6718. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6719. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6720. { } /* end */
  6721. };
  6722. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6723. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6724. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6725. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6726. { } /* end */
  6727. };
  6728. static struct hda_bind_ctls alc262_sony_bind_sw = {
  6729. .ops = &snd_hda_bind_sw,
  6730. .values = {
  6731. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6732. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6733. 0,
  6734. },
  6735. };
  6736. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6737. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6738. HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
  6739. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6740. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6741. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6742. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6743. { } /* end */
  6744. };
  6745. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6746. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6747. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6748. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6749. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6750. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6751. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6752. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6753. { } /* end */
  6754. };
  6755. #define alc262_capture_mixer alc882_capture_mixer
  6756. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6757. /*
  6758. * generic initialization of ADC, input mixers and output mixers
  6759. */
  6760. static struct hda_verb alc262_init_verbs[] = {
  6761. /*
  6762. * Unmute ADC0-2 and set the default input to mic-in
  6763. */
  6764. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6765. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6766. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6767. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6768. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6769. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6770. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6771. * mixer widget
  6772. * Note: PASD motherboards uses the Line In 2 as the input for
  6773. * front panel mic (mic 2)
  6774. */
  6775. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6776. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6777. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6778. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6779. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6780. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6781. /*
  6782. * Set up output mixers (0x0c - 0x0e)
  6783. */
  6784. /* set vol=0 to output mixers */
  6785. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6786. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6787. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6788. /* set up input amps for analog loopback */
  6789. /* Amp Indices: DAC = 0, mixer = 1 */
  6790. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6791. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6792. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6793. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6794. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6795. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6796. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6797. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6798. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6799. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6800. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6801. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6802. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6804. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6805. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6806. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6807. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6808. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6809. /* FIXME: use matrix-type input source selection */
  6810. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6811. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6812. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6813. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6814. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6815. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6816. /* Input mixer2 */
  6817. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6818. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6819. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6820. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6821. /* Input mixer3 */
  6822. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6823. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6824. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6825. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6826. { }
  6827. };
  6828. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6829. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6830. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6831. {}
  6832. };
  6833. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6834. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6835. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6836. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6837. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6838. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6839. {}
  6840. };
  6841. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6842. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6843. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6844. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6845. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6846. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6847. };
  6848. /* mute/unmute internal speaker according to the hp jack and mute state */
  6849. static void alc262_hippo_automute(struct hda_codec *codec)
  6850. {
  6851. struct alc_spec *spec = codec->spec;
  6852. unsigned int mute;
  6853. unsigned int present;
  6854. /* need to execute and sync at first */
  6855. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6856. present = snd_hda_codec_read(codec, 0x15, 0,
  6857. AC_VERB_GET_PIN_SENSE, 0);
  6858. spec->jack_present = (present & 0x80000000) != 0;
  6859. if (spec->jack_present) {
  6860. /* mute internal speaker */
  6861. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6862. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6863. } else {
  6864. /* unmute internal speaker if necessary */
  6865. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6866. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6867. HDA_AMP_MUTE, mute);
  6868. }
  6869. }
  6870. /* unsolicited event for HP jack sensing */
  6871. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6872. unsigned int res)
  6873. {
  6874. if ((res >> 26) != ALC880_HP_EVENT)
  6875. return;
  6876. alc262_hippo_automute(codec);
  6877. }
  6878. static void alc262_hippo1_automute(struct hda_codec *codec)
  6879. {
  6880. unsigned int mute;
  6881. unsigned int present;
  6882. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6883. present = snd_hda_codec_read(codec, 0x1b, 0,
  6884. AC_VERB_GET_PIN_SENSE, 0);
  6885. present = (present & 0x80000000) != 0;
  6886. if (present) {
  6887. /* mute internal speaker */
  6888. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6889. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6890. } else {
  6891. /* unmute internal speaker if necessary */
  6892. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6893. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6894. HDA_AMP_MUTE, mute);
  6895. }
  6896. }
  6897. /* unsolicited event for HP jack sensing */
  6898. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6899. unsigned int res)
  6900. {
  6901. if ((res >> 26) != ALC880_HP_EVENT)
  6902. return;
  6903. alc262_hippo1_automute(codec);
  6904. }
  6905. /*
  6906. * fujitsu model
  6907. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6908. */
  6909. #define ALC_HP_EVENT 0x37
  6910. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6911. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6912. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6913. {}
  6914. };
  6915. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6916. .num_items = 2,
  6917. .items = {
  6918. { "Mic", 0x0 },
  6919. { "CD", 0x4 },
  6920. },
  6921. };
  6922. static struct hda_input_mux alc262_HP_capture_source = {
  6923. .num_items = 5,
  6924. .items = {
  6925. { "Mic", 0x0 },
  6926. { "Front Mic", 0x3 },
  6927. { "Line", 0x2 },
  6928. { "CD", 0x4 },
  6929. { "AUX IN", 0x6 },
  6930. },
  6931. };
  6932. /* mute/unmute internal speaker according to the hp jack and mute state */
  6933. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6934. {
  6935. struct alc_spec *spec = codec->spec;
  6936. unsigned int mute;
  6937. if (force || !spec->sense_updated) {
  6938. unsigned int present;
  6939. /* need to execute and sync at first */
  6940. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6941. present = snd_hda_codec_read(codec, 0x14, 0,
  6942. AC_VERB_GET_PIN_SENSE, 0);
  6943. spec->jack_present = (present & 0x80000000) != 0;
  6944. spec->sense_updated = 1;
  6945. }
  6946. if (spec->jack_present) {
  6947. /* mute internal speaker */
  6948. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6949. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6950. } else {
  6951. /* unmute internal speaker if necessary */
  6952. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6953. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6954. HDA_AMP_MUTE, mute);
  6955. }
  6956. }
  6957. /* unsolicited event for HP jack sensing */
  6958. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6959. unsigned int res)
  6960. {
  6961. if ((res >> 26) != ALC_HP_EVENT)
  6962. return;
  6963. alc262_fujitsu_automute(codec, 1);
  6964. }
  6965. /* bind volumes of both NID 0x0c and 0x0d */
  6966. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  6967. .ops = &snd_hda_bind_vol,
  6968. .values = {
  6969. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6970. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  6971. 0
  6972. },
  6973. };
  6974. /* bind hp and internal speaker mute (with plug check) */
  6975. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6976. struct snd_ctl_elem_value *ucontrol)
  6977. {
  6978. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6979. long *valp = ucontrol->value.integer.value;
  6980. int change;
  6981. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6982. HDA_AMP_MUTE,
  6983. valp[0] ? 0 : HDA_AMP_MUTE);
  6984. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6985. HDA_AMP_MUTE,
  6986. valp[1] ? 0 : HDA_AMP_MUTE);
  6987. if (change)
  6988. alc262_fujitsu_automute(codec, 0);
  6989. return change;
  6990. }
  6991. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6992. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  6993. {
  6994. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6995. .name = "Master Playback Switch",
  6996. .info = snd_hda_mixer_amp_switch_info,
  6997. .get = snd_hda_mixer_amp_switch_get,
  6998. .put = alc262_fujitsu_master_sw_put,
  6999. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7000. },
  7001. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7002. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7003. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7004. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7005. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7006. { } /* end */
  7007. };
  7008. /* additional init verbs for Benq laptops */
  7009. static struct hda_verb alc262_EAPD_verbs[] = {
  7010. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7011. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7012. {}
  7013. };
  7014. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7015. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7016. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7017. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7018. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7019. {}
  7020. };
  7021. /* add playback controls from the parsed DAC table */
  7022. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7023. const struct auto_pin_cfg *cfg)
  7024. {
  7025. hda_nid_t nid;
  7026. int err;
  7027. spec->multiout.num_dacs = 1; /* only use one dac */
  7028. spec->multiout.dac_nids = spec->private_dac_nids;
  7029. spec->multiout.dac_nids[0] = 2;
  7030. nid = cfg->line_out_pins[0];
  7031. if (nid) {
  7032. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7033. "Front Playback Volume",
  7034. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7035. if (err < 0)
  7036. return err;
  7037. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7038. "Front Playback Switch",
  7039. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7040. if (err < 0)
  7041. return err;
  7042. }
  7043. nid = cfg->speaker_pins[0];
  7044. if (nid) {
  7045. if (nid == 0x16) {
  7046. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7047. "Speaker Playback Volume",
  7048. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7049. HDA_OUTPUT));
  7050. if (err < 0)
  7051. return err;
  7052. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7053. "Speaker Playback Switch",
  7054. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7055. HDA_OUTPUT));
  7056. if (err < 0)
  7057. return err;
  7058. } else {
  7059. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7060. "Speaker Playback Switch",
  7061. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7062. HDA_OUTPUT));
  7063. if (err < 0)
  7064. return err;
  7065. }
  7066. }
  7067. nid = cfg->hp_pins[0];
  7068. if (nid) {
  7069. /* spec->multiout.hp_nid = 2; */
  7070. if (nid == 0x16) {
  7071. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7072. "Headphone Playback Volume",
  7073. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7074. HDA_OUTPUT));
  7075. if (err < 0)
  7076. return err;
  7077. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7078. "Headphone Playback Switch",
  7079. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7080. HDA_OUTPUT));
  7081. if (err < 0)
  7082. return err;
  7083. } else {
  7084. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7085. "Headphone Playback Switch",
  7086. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7087. HDA_OUTPUT));
  7088. if (err < 0)
  7089. return err;
  7090. }
  7091. }
  7092. return 0;
  7093. }
  7094. /* identical with ALC880 */
  7095. #define alc262_auto_create_analog_input_ctls \
  7096. alc880_auto_create_analog_input_ctls
  7097. /*
  7098. * generic initialization of ADC, input mixers and output mixers
  7099. */
  7100. static struct hda_verb alc262_volume_init_verbs[] = {
  7101. /*
  7102. * Unmute ADC0-2 and set the default input to mic-in
  7103. */
  7104. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7105. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7106. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7107. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7108. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7109. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7110. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7111. * mixer widget
  7112. * Note: PASD motherboards uses the Line In 2 as the input for
  7113. * front panel mic (mic 2)
  7114. */
  7115. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7117. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7118. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7119. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7120. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7121. /*
  7122. * Set up output mixers (0x0c - 0x0f)
  7123. */
  7124. /* set vol=0 to output mixers */
  7125. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7126. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7128. /* set up input amps for analog loopback */
  7129. /* Amp Indices: DAC = 0, mixer = 1 */
  7130. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7131. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7132. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7133. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7134. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7135. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7136. /* FIXME: use matrix-type input source selection */
  7137. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7138. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7139. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7140. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7141. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7142. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7143. /* Input mixer2 */
  7144. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7145. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7146. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7147. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7148. /* Input mixer3 */
  7149. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7150. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7151. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7152. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7153. { }
  7154. };
  7155. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7156. /*
  7157. * Unmute ADC0-2 and set the default input to mic-in
  7158. */
  7159. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7160. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7161. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7162. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7163. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7164. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7165. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7166. * mixer widget
  7167. * Note: PASD motherboards uses the Line In 2 as the input for
  7168. * front panel mic (mic 2)
  7169. */
  7170. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7171. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7178. /*
  7179. * Set up output mixers (0x0c - 0x0e)
  7180. */
  7181. /* set vol=0 to output mixers */
  7182. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7183. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7184. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7185. /* set up input amps for analog loopback */
  7186. /* Amp Indices: DAC = 0, mixer = 1 */
  7187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7193. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7194. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7195. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7196. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7197. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7198. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7199. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7200. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7201. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7202. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7203. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7204. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7205. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7206. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7207. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7208. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7209. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7210. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7211. /* FIXME: use matrix-type input source selection */
  7212. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7213. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7214. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7215. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7216. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7217. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7218. /* Input mixer2 */
  7219. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7220. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7221. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7222. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7223. /* Input mixer3 */
  7224. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7225. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7226. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7227. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7228. { }
  7229. };
  7230. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7231. /*
  7232. * Unmute ADC0-2 and set the default input to mic-in
  7233. */
  7234. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7235. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7236. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7237. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7238. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7239. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7240. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7241. * mixer widget
  7242. * Note: PASD motherboards uses the Line In 2 as the input for front
  7243. * panel mic (mic 2)
  7244. */
  7245. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7246. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7247. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7248. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7249. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7250. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7251. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7252. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7253. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7254. /*
  7255. * Set up output mixers (0x0c - 0x0e)
  7256. */
  7257. /* set vol=0 to output mixers */
  7258. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7259. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7260. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7261. /* set up input amps for analog loopback */
  7262. /* Amp Indices: DAC = 0, mixer = 1 */
  7263. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7264. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7265. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7266. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7267. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7268. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7269. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7270. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7271. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7272. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7273. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7274. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7275. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7276. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7277. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7278. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7279. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7280. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7281. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7282. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7283. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7284. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7285. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7286. /* FIXME: use matrix-type input source selection */
  7287. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7288. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7289. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7290. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7291. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7292. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7293. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7294. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7295. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7296. /* Input mixer2 */
  7297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7299. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7300. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7301. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7302. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7303. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7304. /* Input mixer3 */
  7305. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7306. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7307. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7308. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7309. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7310. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7311. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7312. { }
  7313. };
  7314. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7315. #define alc262_loopbacks alc880_loopbacks
  7316. #endif
  7317. /* pcm configuration: identiacal with ALC880 */
  7318. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7319. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7320. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7321. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7322. /*
  7323. * BIOS auto configuration
  7324. */
  7325. static int alc262_parse_auto_config(struct hda_codec *codec)
  7326. {
  7327. struct alc_spec *spec = codec->spec;
  7328. int err;
  7329. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7330. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7331. alc262_ignore);
  7332. if (err < 0)
  7333. return err;
  7334. if (!spec->autocfg.line_outs)
  7335. return 0; /* can't find valid BIOS pin config */
  7336. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7337. if (err < 0)
  7338. return err;
  7339. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7340. if (err < 0)
  7341. return err;
  7342. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7343. if (spec->autocfg.dig_out_pin)
  7344. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7345. if (spec->autocfg.dig_in_pin)
  7346. spec->dig_in_nid = ALC262_DIGIN_NID;
  7347. if (spec->kctl_alloc)
  7348. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7349. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7350. spec->num_mux_defs = 1;
  7351. spec->input_mux = &spec->private_imux;
  7352. return 1;
  7353. }
  7354. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7355. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7356. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7357. /* init callback for auto-configuration model -- overriding the default init */
  7358. static void alc262_auto_init(struct hda_codec *codec)
  7359. {
  7360. alc262_auto_init_multi_out(codec);
  7361. alc262_auto_init_hp_out(codec);
  7362. alc262_auto_init_analog_input(codec);
  7363. }
  7364. /*
  7365. * configuration and preset
  7366. */
  7367. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7368. [ALC262_BASIC] = "basic",
  7369. [ALC262_HIPPO] = "hippo",
  7370. [ALC262_HIPPO_1] = "hippo_1",
  7371. [ALC262_FUJITSU] = "fujitsu",
  7372. [ALC262_HP_BPC] = "hp-bpc",
  7373. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7374. [ALC262_BENQ_ED8] = "benq",
  7375. [ALC262_BENQ_T31] = "benq-t31",
  7376. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7377. [ALC262_AUTO] = "auto",
  7378. };
  7379. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7380. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7381. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7382. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7383. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7384. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7385. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7386. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7387. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7388. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7389. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7390. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7391. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7392. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7393. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7394. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7395. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7396. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7397. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7398. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7399. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7400. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7401. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7402. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7403. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7404. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7405. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7406. {}
  7407. };
  7408. static struct alc_config_preset alc262_presets[] = {
  7409. [ALC262_BASIC] = {
  7410. .mixers = { alc262_base_mixer },
  7411. .init_verbs = { alc262_init_verbs },
  7412. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7413. .dac_nids = alc262_dac_nids,
  7414. .hp_nid = 0x03,
  7415. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7416. .channel_mode = alc262_modes,
  7417. .input_mux = &alc262_capture_source,
  7418. },
  7419. [ALC262_HIPPO] = {
  7420. .mixers = { alc262_base_mixer },
  7421. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7422. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7423. .dac_nids = alc262_dac_nids,
  7424. .hp_nid = 0x03,
  7425. .dig_out_nid = ALC262_DIGOUT_NID,
  7426. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7427. .channel_mode = alc262_modes,
  7428. .input_mux = &alc262_capture_source,
  7429. .unsol_event = alc262_hippo_unsol_event,
  7430. .init_hook = alc262_hippo_automute,
  7431. },
  7432. [ALC262_HIPPO_1] = {
  7433. .mixers = { alc262_hippo1_mixer },
  7434. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7435. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7436. .dac_nids = alc262_dac_nids,
  7437. .hp_nid = 0x02,
  7438. .dig_out_nid = ALC262_DIGOUT_NID,
  7439. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7440. .channel_mode = alc262_modes,
  7441. .input_mux = &alc262_capture_source,
  7442. .unsol_event = alc262_hippo1_unsol_event,
  7443. .init_hook = alc262_hippo1_automute,
  7444. },
  7445. [ALC262_FUJITSU] = {
  7446. .mixers = { alc262_fujitsu_mixer },
  7447. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7448. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7449. .dac_nids = alc262_dac_nids,
  7450. .hp_nid = 0x03,
  7451. .dig_out_nid = ALC262_DIGOUT_NID,
  7452. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7453. .channel_mode = alc262_modes,
  7454. .input_mux = &alc262_fujitsu_capture_source,
  7455. .unsol_event = alc262_fujitsu_unsol_event,
  7456. },
  7457. [ALC262_HP_BPC] = {
  7458. .mixers = { alc262_HP_BPC_mixer },
  7459. .init_verbs = { alc262_HP_BPC_init_verbs },
  7460. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7461. .dac_nids = alc262_dac_nids,
  7462. .hp_nid = 0x03,
  7463. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7464. .channel_mode = alc262_modes,
  7465. .input_mux = &alc262_HP_capture_source,
  7466. },
  7467. [ALC262_HP_BPC_D7000_WF] = {
  7468. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7469. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7470. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7471. .dac_nids = alc262_dac_nids,
  7472. .hp_nid = 0x03,
  7473. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7474. .channel_mode = alc262_modes,
  7475. .input_mux = &alc262_HP_capture_source,
  7476. },
  7477. [ALC262_HP_BPC_D7000_WL] = {
  7478. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7479. alc262_HP_BPC_WildWest_option_mixer },
  7480. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7481. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7482. .dac_nids = alc262_dac_nids,
  7483. .hp_nid = 0x03,
  7484. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7485. .channel_mode = alc262_modes,
  7486. .input_mux = &alc262_HP_capture_source,
  7487. },
  7488. [ALC262_BENQ_ED8] = {
  7489. .mixers = { alc262_base_mixer },
  7490. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7491. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7492. .dac_nids = alc262_dac_nids,
  7493. .hp_nid = 0x03,
  7494. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7495. .channel_mode = alc262_modes,
  7496. .input_mux = &alc262_capture_source,
  7497. },
  7498. [ALC262_SONY_ASSAMD] = {
  7499. .mixers = { alc262_sony_mixer },
  7500. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7501. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7502. .dac_nids = alc262_dac_nids,
  7503. .hp_nid = 0x02,
  7504. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7505. .channel_mode = alc262_modes,
  7506. .input_mux = &alc262_capture_source,
  7507. .unsol_event = alc262_hippo_unsol_event,
  7508. .init_hook = alc262_hippo_automute,
  7509. },
  7510. [ALC262_BENQ_T31] = {
  7511. .mixers = { alc262_benq_t31_mixer },
  7512. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7513. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7514. .dac_nids = alc262_dac_nids,
  7515. .hp_nid = 0x03,
  7516. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7517. .channel_mode = alc262_modes,
  7518. .input_mux = &alc262_capture_source,
  7519. .unsol_event = alc262_hippo_unsol_event,
  7520. .init_hook = alc262_hippo_automute,
  7521. },
  7522. };
  7523. static int patch_alc262(struct hda_codec *codec)
  7524. {
  7525. struct alc_spec *spec;
  7526. int board_config;
  7527. int err;
  7528. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7529. if (spec == NULL)
  7530. return -ENOMEM;
  7531. codec->spec = spec;
  7532. #if 0
  7533. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7534. * under-run
  7535. */
  7536. {
  7537. int tmp;
  7538. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7539. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7540. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7541. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7542. }
  7543. #endif
  7544. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7545. alc262_models,
  7546. alc262_cfg_tbl);
  7547. if (board_config < 0) {
  7548. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7549. "trying auto-probe from BIOS...\n");
  7550. board_config = ALC262_AUTO;
  7551. }
  7552. if (board_config == ALC262_AUTO) {
  7553. /* automatic parse from the BIOS config */
  7554. err = alc262_parse_auto_config(codec);
  7555. if (err < 0) {
  7556. alc_free(codec);
  7557. return err;
  7558. } else if (!err) {
  7559. printk(KERN_INFO
  7560. "hda_codec: Cannot set up configuration "
  7561. "from BIOS. Using base mode...\n");
  7562. board_config = ALC262_BASIC;
  7563. }
  7564. }
  7565. if (board_config != ALC262_AUTO)
  7566. setup_preset(spec, &alc262_presets[board_config]);
  7567. spec->stream_name_analog = "ALC262 Analog";
  7568. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7569. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7570. spec->stream_name_digital = "ALC262 Digital";
  7571. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7572. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7573. if (!spec->adc_nids && spec->input_mux) {
  7574. /* check whether NID 0x07 is valid */
  7575. unsigned int wcap = get_wcaps(codec, 0x07);
  7576. /* get type */
  7577. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7578. if (wcap != AC_WID_AUD_IN) {
  7579. spec->adc_nids = alc262_adc_nids_alt;
  7580. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7581. spec->mixers[spec->num_mixers] =
  7582. alc262_capture_alt_mixer;
  7583. spec->num_mixers++;
  7584. } else {
  7585. spec->adc_nids = alc262_adc_nids;
  7586. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7587. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7588. spec->num_mixers++;
  7589. }
  7590. }
  7591. codec->patch_ops = alc_patch_ops;
  7592. if (board_config == ALC262_AUTO)
  7593. spec->init_hook = alc262_auto_init;
  7594. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7595. if (!spec->loopback.amplist)
  7596. spec->loopback.amplist = alc262_loopbacks;
  7597. #endif
  7598. return 0;
  7599. }
  7600. /*
  7601. * ALC268 channel source setting (2 channel)
  7602. */
  7603. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7604. #define alc268_modes alc260_modes
  7605. static hda_nid_t alc268_dac_nids[2] = {
  7606. /* front, hp */
  7607. 0x02, 0x03
  7608. };
  7609. static hda_nid_t alc268_adc_nids[2] = {
  7610. /* ADC0-1 */
  7611. 0x08, 0x07
  7612. };
  7613. static hda_nid_t alc268_adc_nids_alt[1] = {
  7614. /* ADC0 */
  7615. 0x08
  7616. };
  7617. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7618. /* output mixer control */
  7619. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7620. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7621. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7622. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7623. { }
  7624. };
  7625. static struct hda_verb alc268_eapd_verbs[] = {
  7626. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7627. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7628. { }
  7629. };
  7630. /* Toshiba specific */
  7631. #define alc268_toshiba_automute alc262_hippo_automute
  7632. static struct hda_verb alc268_toshiba_verbs[] = {
  7633. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7634. { } /* end */
  7635. };
  7636. /* Acer specific */
  7637. #define alc268_acer_bind_master_vol alc262_fujitsu_bind_master_vol
  7638. #define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
  7639. #define alc268_acer_automute alc262_fujitsu_automute
  7640. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7641. /* output mixer control */
  7642. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7643. {
  7644. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7645. .name = "Master Playback Switch",
  7646. .info = snd_hda_mixer_amp_switch_info,
  7647. .get = snd_hda_mixer_amp_switch_get,
  7648. .put = alc268_acer_master_sw_put,
  7649. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7650. },
  7651. { }
  7652. };
  7653. static struct hda_verb alc268_acer_verbs[] = {
  7654. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7655. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7656. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7657. { }
  7658. };
  7659. /* unsolicited event for HP jack sensing */
  7660. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7661. unsigned int res)
  7662. {
  7663. if ((res >> 28) != ALC880_HP_EVENT)
  7664. return;
  7665. alc268_toshiba_automute(codec);
  7666. }
  7667. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7668. unsigned int res)
  7669. {
  7670. if ((res >> 28) != ALC880_HP_EVENT)
  7671. return;
  7672. alc268_acer_automute(codec, 1);
  7673. }
  7674. /*
  7675. * generic initialization of ADC, input mixers and output mixers
  7676. */
  7677. static struct hda_verb alc268_base_init_verbs[] = {
  7678. /* Unmute DAC0-1 and set vol = 0 */
  7679. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7680. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7681. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7682. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7683. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7684. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7685. /*
  7686. * Set up output mixers (0x0c - 0x0e)
  7687. */
  7688. /* set vol=0 to output mixers */
  7689. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7690. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7692. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7693. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7694. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7696. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7697. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7698. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7699. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7700. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7701. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7702. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7703. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7704. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7705. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7706. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7707. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7708. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7709. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7710. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7711. /* FIXME: use matrix-type input source selection */
  7712. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7713. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7714. /* Input mixer2 */
  7715. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7716. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7717. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7718. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7719. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7720. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7721. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7722. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7723. { }
  7724. };
  7725. /*
  7726. * generic initialization of ADC, input mixers and output mixers
  7727. */
  7728. static struct hda_verb alc268_volume_init_verbs[] = {
  7729. /* set output DAC */
  7730. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7731. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7732. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7733. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7734. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7735. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7736. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7737. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7738. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7739. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7740. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7741. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7742. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7743. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7744. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7745. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7746. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7747. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7748. /* set PCBEEP vol = 0 */
  7749. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7750. { }
  7751. };
  7752. #define alc268_mux_enum_info alc_mux_enum_info
  7753. #define alc268_mux_enum_get alc_mux_enum_get
  7754. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7755. struct snd_ctl_elem_value *ucontrol)
  7756. {
  7757. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7758. struct alc_spec *spec = codec->spec;
  7759. const struct hda_input_mux *imux = spec->input_mux;
  7760. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7761. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7762. hda_nid_t nid = capture_mixers[adc_idx];
  7763. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7764. unsigned int i, idx;
  7765. idx = ucontrol->value.enumerated.item[0];
  7766. if (idx >= imux->num_items)
  7767. idx = imux->num_items - 1;
  7768. if (*cur_val == idx)
  7769. return 0;
  7770. for (i = 0; i < imux->num_items; i++) {
  7771. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7772. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7773. imux->items[i].index,
  7774. HDA_AMP_MUTE, v);
  7775. snd_hda_codec_write_cache(codec, nid, 0,
  7776. AC_VERB_SET_CONNECT_SEL,
  7777. idx );
  7778. }
  7779. *cur_val = idx;
  7780. return 1;
  7781. }
  7782. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7783. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7784. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7785. {
  7786. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7787. /* The multiple "Capture Source" controls confuse alsamixer
  7788. * So call somewhat different..
  7789. * FIXME: the controls appear in the "playback" view!
  7790. */
  7791. /* .name = "Capture Source", */
  7792. .name = "Input Source",
  7793. .count = 1,
  7794. .info = alc268_mux_enum_info,
  7795. .get = alc268_mux_enum_get,
  7796. .put = alc268_mux_enum_put,
  7797. },
  7798. { } /* end */
  7799. };
  7800. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7801. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7802. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7803. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7804. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7805. {
  7806. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7807. /* The multiple "Capture Source" controls confuse alsamixer
  7808. * So call somewhat different..
  7809. * FIXME: the controls appear in the "playback" view!
  7810. */
  7811. /* .name = "Capture Source", */
  7812. .name = "Input Source",
  7813. .count = 2,
  7814. .info = alc268_mux_enum_info,
  7815. .get = alc268_mux_enum_get,
  7816. .put = alc268_mux_enum_put,
  7817. },
  7818. { } /* end */
  7819. };
  7820. static struct hda_input_mux alc268_capture_source = {
  7821. .num_items = 4,
  7822. .items = {
  7823. { "Mic", 0x0 },
  7824. { "Front Mic", 0x1 },
  7825. { "Line", 0x2 },
  7826. { "CD", 0x3 },
  7827. },
  7828. };
  7829. /* create input playback/capture controls for the given pin */
  7830. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7831. const char *ctlname, int idx)
  7832. {
  7833. char name[32];
  7834. int err;
  7835. sprintf(name, "%s Playback Volume", ctlname);
  7836. if (nid == 0x14) {
  7837. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7838. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7839. HDA_OUTPUT));
  7840. if (err < 0)
  7841. return err;
  7842. } else if (nid == 0x15) {
  7843. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7844. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7845. HDA_OUTPUT));
  7846. if (err < 0)
  7847. return err;
  7848. } else
  7849. return -1;
  7850. sprintf(name, "%s Playback Switch", ctlname);
  7851. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7852. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7853. if (err < 0)
  7854. return err;
  7855. return 0;
  7856. }
  7857. /* add playback controls from the parsed DAC table */
  7858. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7859. const struct auto_pin_cfg *cfg)
  7860. {
  7861. hda_nid_t nid;
  7862. int err;
  7863. spec->multiout.num_dacs = 2; /* only use one dac */
  7864. spec->multiout.dac_nids = spec->private_dac_nids;
  7865. spec->multiout.dac_nids[0] = 2;
  7866. spec->multiout.dac_nids[1] = 3;
  7867. nid = cfg->line_out_pins[0];
  7868. if (nid)
  7869. alc268_new_analog_output(spec, nid, "Front", 0);
  7870. nid = cfg->speaker_pins[0];
  7871. if (nid == 0x1d) {
  7872. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7873. "Speaker Playback Volume",
  7874. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7875. if (err < 0)
  7876. return err;
  7877. }
  7878. nid = cfg->hp_pins[0];
  7879. if (nid)
  7880. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7881. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7882. if (nid == 0x16) {
  7883. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7884. "Mono Playback Switch",
  7885. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7886. if (err < 0)
  7887. return err;
  7888. }
  7889. return 0;
  7890. }
  7891. /* create playback/capture controls for input pins */
  7892. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7893. const struct auto_pin_cfg *cfg)
  7894. {
  7895. struct hda_input_mux *imux = &spec->private_imux;
  7896. int i, idx1;
  7897. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7898. switch(cfg->input_pins[i]) {
  7899. case 0x18:
  7900. idx1 = 0; /* Mic 1 */
  7901. break;
  7902. case 0x19:
  7903. idx1 = 1; /* Mic 2 */
  7904. break;
  7905. case 0x1a:
  7906. idx1 = 2; /* Line In */
  7907. break;
  7908. case 0x1c:
  7909. idx1 = 3; /* CD */
  7910. break;
  7911. default:
  7912. continue;
  7913. }
  7914. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7915. imux->items[imux->num_items].index = idx1;
  7916. imux->num_items++;
  7917. }
  7918. return 0;
  7919. }
  7920. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7921. {
  7922. struct alc_spec *spec = codec->spec;
  7923. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7924. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7925. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7926. unsigned int dac_vol1, dac_vol2;
  7927. if (speaker_nid) {
  7928. snd_hda_codec_write(codec, speaker_nid, 0,
  7929. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7930. snd_hda_codec_write(codec, 0x0f, 0,
  7931. AC_VERB_SET_AMP_GAIN_MUTE,
  7932. AMP_IN_UNMUTE(1));
  7933. snd_hda_codec_write(codec, 0x10, 0,
  7934. AC_VERB_SET_AMP_GAIN_MUTE,
  7935. AMP_IN_UNMUTE(1));
  7936. } else {
  7937. snd_hda_codec_write(codec, 0x0f, 0,
  7938. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7939. snd_hda_codec_write(codec, 0x10, 0,
  7940. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7941. }
  7942. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7943. if (line_nid == 0x14)
  7944. dac_vol2 = AMP_OUT_ZERO;
  7945. else if (line_nid == 0x15)
  7946. dac_vol1 = AMP_OUT_ZERO;
  7947. if (hp_nid == 0x14)
  7948. dac_vol2 = AMP_OUT_ZERO;
  7949. else if (hp_nid == 0x15)
  7950. dac_vol1 = AMP_OUT_ZERO;
  7951. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7952. spec->autocfg.line_out_pins[1] != 0x16 ||
  7953. spec->autocfg.line_out_pins[2] != 0x16)
  7954. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7955. snd_hda_codec_write(codec, 0x02, 0,
  7956. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7957. snd_hda_codec_write(codec, 0x03, 0,
  7958. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7959. }
  7960. /* pcm configuration: identiacal with ALC880 */
  7961. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7962. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7963. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7964. /*
  7965. * BIOS auto configuration
  7966. */
  7967. static int alc268_parse_auto_config(struct hda_codec *codec)
  7968. {
  7969. struct alc_spec *spec = codec->spec;
  7970. int err;
  7971. static hda_nid_t alc268_ignore[] = { 0 };
  7972. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7973. alc268_ignore);
  7974. if (err < 0)
  7975. return err;
  7976. if (!spec->autocfg.line_outs)
  7977. return 0; /* can't find valid BIOS pin config */
  7978. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7979. if (err < 0)
  7980. return err;
  7981. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7982. if (err < 0)
  7983. return err;
  7984. spec->multiout.max_channels = 2;
  7985. /* digital only support output */
  7986. if (spec->autocfg.dig_out_pin)
  7987. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7988. if (spec->kctl_alloc)
  7989. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7990. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7991. spec->num_mux_defs = 1;
  7992. spec->input_mux = &spec->private_imux;
  7993. return 1;
  7994. }
  7995. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7996. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7997. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7998. /* init callback for auto-configuration model -- overriding the default init */
  7999. static void alc268_auto_init(struct hda_codec *codec)
  8000. {
  8001. alc268_auto_init_multi_out(codec);
  8002. alc268_auto_init_hp_out(codec);
  8003. alc268_auto_init_mono_speaker_out(codec);
  8004. alc268_auto_init_analog_input(codec);
  8005. }
  8006. /*
  8007. * configuration and preset
  8008. */
  8009. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8010. [ALC268_3ST] = "3stack",
  8011. [ALC268_TOSHIBA] = "toshiba",
  8012. [ALC268_ACER] = "acer",
  8013. [ALC268_AUTO] = "auto",
  8014. };
  8015. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8016. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8017. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8018. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8019. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8020. {}
  8021. };
  8022. static struct alc_config_preset alc268_presets[] = {
  8023. [ALC268_3ST] = {
  8024. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8025. .init_verbs = { alc268_base_init_verbs },
  8026. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8027. .dac_nids = alc268_dac_nids,
  8028. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8029. .adc_nids = alc268_adc_nids_alt,
  8030. .hp_nid = 0x03,
  8031. .dig_out_nid = ALC268_DIGOUT_NID,
  8032. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8033. .channel_mode = alc268_modes,
  8034. .input_mux = &alc268_capture_source,
  8035. },
  8036. [ALC268_TOSHIBA] = {
  8037. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8038. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8039. alc268_toshiba_verbs },
  8040. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8041. .dac_nids = alc268_dac_nids,
  8042. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8043. .adc_nids = alc268_adc_nids_alt,
  8044. .hp_nid = 0x03,
  8045. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8046. .channel_mode = alc268_modes,
  8047. .input_mux = &alc268_capture_source,
  8048. .input_mux = &alc268_capture_source,
  8049. .unsol_event = alc268_toshiba_unsol_event,
  8050. .init_hook = alc268_toshiba_automute,
  8051. },
  8052. [ALC268_ACER] = {
  8053. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8054. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8055. alc268_acer_verbs },
  8056. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8057. .dac_nids = alc268_dac_nids,
  8058. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8059. .adc_nids = alc268_adc_nids_alt,
  8060. .hp_nid = 0x02,
  8061. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8062. .channel_mode = alc268_modes,
  8063. .input_mux = &alc268_capture_source,
  8064. .unsol_event = alc268_acer_unsol_event,
  8065. },
  8066. };
  8067. static int patch_alc268(struct hda_codec *codec)
  8068. {
  8069. struct alc_spec *spec;
  8070. int board_config;
  8071. int err;
  8072. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8073. if (spec == NULL)
  8074. return -ENOMEM;
  8075. codec->spec = spec;
  8076. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8077. alc268_models,
  8078. alc268_cfg_tbl);
  8079. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8080. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8081. "trying auto-probe from BIOS...\n");
  8082. board_config = ALC268_AUTO;
  8083. }
  8084. if (board_config == ALC268_AUTO) {
  8085. /* automatic parse from the BIOS config */
  8086. err = alc268_parse_auto_config(codec);
  8087. if (err < 0) {
  8088. alc_free(codec);
  8089. return err;
  8090. } else if (!err) {
  8091. printk(KERN_INFO
  8092. "hda_codec: Cannot set up configuration "
  8093. "from BIOS. Using base mode...\n");
  8094. board_config = ALC268_3ST;
  8095. }
  8096. }
  8097. if (board_config != ALC268_AUTO)
  8098. setup_preset(spec, &alc268_presets[board_config]);
  8099. spec->stream_name_analog = "ALC268 Analog";
  8100. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8101. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8102. spec->stream_name_digital = "ALC268 Digital";
  8103. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8104. if (board_config == ALC268_AUTO) {
  8105. if (!spec->adc_nids && spec->input_mux) {
  8106. /* check whether NID 0x07 is valid */
  8107. unsigned int wcap = get_wcaps(codec, 0x07);
  8108. /* get type */
  8109. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8110. if (wcap != AC_WID_AUD_IN) {
  8111. spec->adc_nids = alc268_adc_nids_alt;
  8112. spec->num_adc_nids =
  8113. ARRAY_SIZE(alc268_adc_nids_alt);
  8114. spec->mixers[spec->num_mixers] =
  8115. alc268_capture_alt_mixer;
  8116. spec->num_mixers++;
  8117. } else {
  8118. spec->adc_nids = alc268_adc_nids;
  8119. spec->num_adc_nids =
  8120. ARRAY_SIZE(alc268_adc_nids);
  8121. spec->mixers[spec->num_mixers] =
  8122. alc268_capture_mixer;
  8123. spec->num_mixers++;
  8124. }
  8125. }
  8126. }
  8127. codec->patch_ops = alc_patch_ops;
  8128. if (board_config == ALC268_AUTO)
  8129. spec->init_hook = alc268_auto_init;
  8130. return 0;
  8131. }
  8132. /*
  8133. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8134. */
  8135. /*
  8136. * set the path ways for 2 channel output
  8137. * need to set the codec line out and mic 1 pin widgets to inputs
  8138. */
  8139. static struct hda_verb alc861_threestack_ch2_init[] = {
  8140. /* set pin widget 1Ah (line in) for input */
  8141. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8142. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8143. * the vref
  8144. */
  8145. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8146. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8147. #if 0
  8148. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8149. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8150. #endif
  8151. { } /* end */
  8152. };
  8153. /*
  8154. * 6ch mode
  8155. * need to set the codec line out and mic 1 pin widgets to outputs
  8156. */
  8157. static struct hda_verb alc861_threestack_ch6_init[] = {
  8158. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8159. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8160. /* set pin widget 18h (mic1) for output (CLFE)*/
  8161. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8162. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8163. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8164. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8165. #if 0
  8166. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8167. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8168. #endif
  8169. { } /* end */
  8170. };
  8171. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8172. { 2, alc861_threestack_ch2_init },
  8173. { 6, alc861_threestack_ch6_init },
  8174. };
  8175. /* Set mic1 as input and unmute the mixer */
  8176. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8177. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8178. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8179. { } /* end */
  8180. };
  8181. /* Set mic1 as output and mute mixer */
  8182. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8183. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8184. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8185. { } /* end */
  8186. };
  8187. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8188. { 2, alc861_uniwill_m31_ch2_init },
  8189. { 4, alc861_uniwill_m31_ch4_init },
  8190. };
  8191. /* Set mic1 and line-in as input and unmute the mixer */
  8192. static struct hda_verb alc861_asus_ch2_init[] = {
  8193. /* set pin widget 1Ah (line in) for input */
  8194. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8195. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8196. * the vref
  8197. */
  8198. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8199. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8200. #if 0
  8201. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8202. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8203. #endif
  8204. { } /* end */
  8205. };
  8206. /* Set mic1 nad line-in as output and mute mixer */
  8207. static struct hda_verb alc861_asus_ch6_init[] = {
  8208. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8209. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8210. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8211. /* set pin widget 18h (mic1) for output (CLFE)*/
  8212. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8213. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8214. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8215. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8216. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8217. #if 0
  8218. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8219. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8220. #endif
  8221. { } /* end */
  8222. };
  8223. static struct hda_channel_mode alc861_asus_modes[2] = {
  8224. { 2, alc861_asus_ch2_init },
  8225. { 6, alc861_asus_ch6_init },
  8226. };
  8227. /* patch-ALC861 */
  8228. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8229. /* output mixer control */
  8230. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8231. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8232. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8233. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8234. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8235. /*Input mixer control */
  8236. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8237. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8238. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8239. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8240. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8241. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8242. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8243. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8244. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8245. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8246. /* Capture mixer control */
  8247. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8248. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8249. {
  8250. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8251. .name = "Capture Source",
  8252. .count = 1,
  8253. .info = alc_mux_enum_info,
  8254. .get = alc_mux_enum_get,
  8255. .put = alc_mux_enum_put,
  8256. },
  8257. { } /* end */
  8258. };
  8259. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8260. /* output mixer control */
  8261. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8262. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8263. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8264. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8265. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8266. /* Input mixer control */
  8267. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8268. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8269. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8270. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8271. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8272. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8273. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8274. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8275. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8276. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8277. /* Capture mixer control */
  8278. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8279. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8280. {
  8281. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8282. .name = "Capture Source",
  8283. .count = 1,
  8284. .info = alc_mux_enum_info,
  8285. .get = alc_mux_enum_get,
  8286. .put = alc_mux_enum_put,
  8287. },
  8288. {
  8289. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8290. .name = "Channel Mode",
  8291. .info = alc_ch_mode_info,
  8292. .get = alc_ch_mode_get,
  8293. .put = alc_ch_mode_put,
  8294. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8295. },
  8296. { } /* end */
  8297. };
  8298. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8299. /* output mixer control */
  8300. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8301. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8302. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8303. /*Capture mixer control */
  8304. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8305. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8306. {
  8307. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8308. .name = "Capture Source",
  8309. .count = 1,
  8310. .info = alc_mux_enum_info,
  8311. .get = alc_mux_enum_get,
  8312. .put = alc_mux_enum_put,
  8313. },
  8314. { } /* end */
  8315. };
  8316. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8317. /* output mixer control */
  8318. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8319. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8320. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8321. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8322. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8323. /* Input mixer control */
  8324. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8325. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8326. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8327. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8328. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8329. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8330. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8331. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8332. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8333. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8334. /* Capture mixer control */
  8335. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8336. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8337. {
  8338. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8339. .name = "Capture Source",
  8340. .count = 1,
  8341. .info = alc_mux_enum_info,
  8342. .get = alc_mux_enum_get,
  8343. .put = alc_mux_enum_put,
  8344. },
  8345. {
  8346. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8347. .name = "Channel Mode",
  8348. .info = alc_ch_mode_info,
  8349. .get = alc_ch_mode_get,
  8350. .put = alc_ch_mode_put,
  8351. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8352. },
  8353. { } /* end */
  8354. };
  8355. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8356. /* output mixer control */
  8357. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8358. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8359. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8360. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8361. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8362. /* Input mixer control */
  8363. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8364. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8365. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8366. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8367. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8368. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8369. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8370. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8371. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8372. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8373. /* Capture mixer control */
  8374. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8375. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8376. {
  8377. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8378. .name = "Capture Source",
  8379. .count = 1,
  8380. .info = alc_mux_enum_info,
  8381. .get = alc_mux_enum_get,
  8382. .put = alc_mux_enum_put,
  8383. },
  8384. {
  8385. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8386. .name = "Channel Mode",
  8387. .info = alc_ch_mode_info,
  8388. .get = alc_ch_mode_get,
  8389. .put = alc_ch_mode_put,
  8390. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8391. },
  8392. { }
  8393. };
  8394. /* additional mixer */
  8395. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8396. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8397. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8398. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8399. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8400. { }
  8401. };
  8402. /*
  8403. * generic initialization of ADC, input mixers and output mixers
  8404. */
  8405. static struct hda_verb alc861_base_init_verbs[] = {
  8406. /*
  8407. * Unmute ADC0 and set the default input to mic-in
  8408. */
  8409. /* port-A for surround (rear panel) */
  8410. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8411. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8412. /* port-B for mic-in (rear panel) with vref */
  8413. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8414. /* port-C for line-in (rear panel) */
  8415. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8416. /* port-D for Front */
  8417. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8418. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8419. /* port-E for HP out (front panel) */
  8420. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8421. /* route front PCM to HP */
  8422. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8423. /* port-F for mic-in (front panel) with vref */
  8424. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8425. /* port-G for CLFE (rear panel) */
  8426. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8427. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8428. /* port-H for side (rear panel) */
  8429. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8430. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8431. /* CD-in */
  8432. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8433. /* route front mic to ADC1*/
  8434. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8435. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8436. /* Unmute DAC0~3 & spdif out*/
  8437. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8438. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8439. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8440. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8441. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8442. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8443. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8444. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8445. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8446. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8447. /* Unmute Stereo Mixer 15 */
  8448. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8449. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8450. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8451. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8452. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8453. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8454. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8455. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8456. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8457. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8458. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8459. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8460. /* hp used DAC 3 (Front) */
  8461. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8462. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8463. { }
  8464. };
  8465. static struct hda_verb alc861_threestack_init_verbs[] = {
  8466. /*
  8467. * Unmute ADC0 and set the default input to mic-in
  8468. */
  8469. /* port-A for surround (rear panel) */
  8470. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8471. /* port-B for mic-in (rear panel) with vref */
  8472. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8473. /* port-C for line-in (rear panel) */
  8474. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8475. /* port-D for Front */
  8476. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8477. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8478. /* port-E for HP out (front panel) */
  8479. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8480. /* route front PCM to HP */
  8481. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8482. /* port-F for mic-in (front panel) with vref */
  8483. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8484. /* port-G for CLFE (rear panel) */
  8485. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8486. /* port-H for side (rear panel) */
  8487. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8488. /* CD-in */
  8489. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8490. /* route front mic to ADC1*/
  8491. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8492. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8493. /* Unmute DAC0~3 & spdif out*/
  8494. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8495. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8496. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8497. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8498. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8499. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8500. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8501. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8502. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8503. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8504. /* Unmute Stereo Mixer 15 */
  8505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8506. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8507. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8508. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8509. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8510. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8511. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8512. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8513. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8514. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8515. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8516. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8517. /* hp used DAC 3 (Front) */
  8518. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8519. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8520. { }
  8521. };
  8522. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8523. /*
  8524. * Unmute ADC0 and set the default input to mic-in
  8525. */
  8526. /* port-A for surround (rear panel) */
  8527. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8528. /* port-B for mic-in (rear panel) with vref */
  8529. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8530. /* port-C for line-in (rear panel) */
  8531. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8532. /* port-D for Front */
  8533. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8534. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8535. /* port-E for HP out (front panel) */
  8536. /* this has to be set to VREF80 */
  8537. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8538. /* route front PCM to HP */
  8539. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8540. /* port-F for mic-in (front panel) with vref */
  8541. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8542. /* port-G for CLFE (rear panel) */
  8543. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8544. /* port-H for side (rear panel) */
  8545. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8546. /* CD-in */
  8547. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8548. /* route front mic to ADC1*/
  8549. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8550. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8551. /* Unmute DAC0~3 & spdif out*/
  8552. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8553. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8554. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8555. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8556. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8557. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8558. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8559. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8560. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8561. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8562. /* Unmute Stereo Mixer 15 */
  8563. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8564. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8565. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8566. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8567. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8568. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8569. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8570. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8571. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8572. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8573. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8574. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8575. /* hp used DAC 3 (Front) */
  8576. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8577. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8578. { }
  8579. };
  8580. static struct hda_verb alc861_asus_init_verbs[] = {
  8581. /*
  8582. * Unmute ADC0 and set the default input to mic-in
  8583. */
  8584. /* port-A for surround (rear panel)
  8585. * according to codec#0 this is the HP jack
  8586. */
  8587. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8588. /* route front PCM to HP */
  8589. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8590. /* port-B for mic-in (rear panel) with vref */
  8591. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8592. /* port-C for line-in (rear panel) */
  8593. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8594. /* port-D for Front */
  8595. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8596. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8597. /* port-E for HP out (front panel) */
  8598. /* this has to be set to VREF80 */
  8599. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8600. /* route front PCM to HP */
  8601. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8602. /* port-F for mic-in (front panel) with vref */
  8603. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8604. /* port-G for CLFE (rear panel) */
  8605. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8606. /* port-H for side (rear panel) */
  8607. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8608. /* CD-in */
  8609. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8610. /* route front mic to ADC1*/
  8611. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8612. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8613. /* Unmute DAC0~3 & spdif out*/
  8614. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8615. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8616. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8617. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8618. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8619. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8620. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8621. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8622. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8623. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8624. /* Unmute Stereo Mixer 15 */
  8625. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8626. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8627. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8628. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8629. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8630. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8631. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8632. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8633. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8634. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8635. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8636. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8637. /* hp used DAC 3 (Front) */
  8638. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8639. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8640. { }
  8641. };
  8642. /* additional init verbs for ASUS laptops */
  8643. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8644. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8645. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8646. { }
  8647. };
  8648. /*
  8649. * generic initialization of ADC, input mixers and output mixers
  8650. */
  8651. static struct hda_verb alc861_auto_init_verbs[] = {
  8652. /*
  8653. * Unmute ADC0 and set the default input to mic-in
  8654. */
  8655. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8656. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8657. /* Unmute DAC0~3 & spdif out*/
  8658. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8659. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8660. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8661. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8662. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8663. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8664. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8665. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8666. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8667. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8668. /* Unmute Stereo Mixer 15 */
  8669. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8670. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8671. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8672. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8673. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8674. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8675. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8676. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8677. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8678. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8679. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8680. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8681. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8682. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8683. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8684. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8685. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8686. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8687. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8688. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8689. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8690. { }
  8691. };
  8692. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8693. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8694. { }
  8695. };
  8696. /* toggle speaker-output according to the hp-jack state */
  8697. static void alc861_toshiba_automute(struct hda_codec *codec)
  8698. {
  8699. unsigned int present;
  8700. present = snd_hda_codec_read(codec, 0x0f, 0,
  8701. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8702. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8703. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8704. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8705. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8706. }
  8707. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8708. unsigned int res)
  8709. {
  8710. if ((res >> 26) == ALC880_HP_EVENT)
  8711. alc861_toshiba_automute(codec);
  8712. }
  8713. /* pcm configuration: identiacal with ALC880 */
  8714. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8715. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8716. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8717. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8718. #define ALC861_DIGOUT_NID 0x07
  8719. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8720. { 8, NULL }
  8721. };
  8722. static hda_nid_t alc861_dac_nids[4] = {
  8723. /* front, surround, clfe, side */
  8724. 0x03, 0x06, 0x05, 0x04
  8725. };
  8726. static hda_nid_t alc660_dac_nids[3] = {
  8727. /* front, clfe, surround */
  8728. 0x03, 0x05, 0x06
  8729. };
  8730. static hda_nid_t alc861_adc_nids[1] = {
  8731. /* ADC0-2 */
  8732. 0x08,
  8733. };
  8734. static struct hda_input_mux alc861_capture_source = {
  8735. .num_items = 5,
  8736. .items = {
  8737. { "Mic", 0x0 },
  8738. { "Front Mic", 0x3 },
  8739. { "Line", 0x1 },
  8740. { "CD", 0x4 },
  8741. { "Mixer", 0x5 },
  8742. },
  8743. };
  8744. /* fill in the dac_nids table from the parsed pin configuration */
  8745. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8746. const struct auto_pin_cfg *cfg)
  8747. {
  8748. int i;
  8749. hda_nid_t nid;
  8750. spec->multiout.dac_nids = spec->private_dac_nids;
  8751. for (i = 0; i < cfg->line_outs; i++) {
  8752. nid = cfg->line_out_pins[i];
  8753. if (nid) {
  8754. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8755. continue;
  8756. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8757. }
  8758. }
  8759. spec->multiout.num_dacs = cfg->line_outs;
  8760. return 0;
  8761. }
  8762. /* add playback controls from the parsed DAC table */
  8763. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8764. const struct auto_pin_cfg *cfg)
  8765. {
  8766. char name[32];
  8767. static const char *chname[4] = {
  8768. "Front", "Surround", NULL /*CLFE*/, "Side"
  8769. };
  8770. hda_nid_t nid;
  8771. int i, idx, err;
  8772. for (i = 0; i < cfg->line_outs; i++) {
  8773. nid = spec->multiout.dac_nids[i];
  8774. if (!nid)
  8775. continue;
  8776. if (nid == 0x05) {
  8777. /* Center/LFE */
  8778. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8779. "Center Playback Switch",
  8780. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8781. HDA_OUTPUT));
  8782. if (err < 0)
  8783. return err;
  8784. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8785. "LFE Playback Switch",
  8786. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8787. HDA_OUTPUT));
  8788. if (err < 0)
  8789. return err;
  8790. } else {
  8791. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8792. idx++)
  8793. if (nid == alc861_dac_nids[idx])
  8794. break;
  8795. sprintf(name, "%s Playback Switch", chname[idx]);
  8796. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8797. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8798. HDA_OUTPUT));
  8799. if (err < 0)
  8800. return err;
  8801. }
  8802. }
  8803. return 0;
  8804. }
  8805. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8806. {
  8807. int err;
  8808. hda_nid_t nid;
  8809. if (!pin)
  8810. return 0;
  8811. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8812. nid = 0x03;
  8813. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8814. "Headphone Playback Switch",
  8815. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8816. if (err < 0)
  8817. return err;
  8818. spec->multiout.hp_nid = nid;
  8819. }
  8820. return 0;
  8821. }
  8822. /* create playback/capture controls for input pins */
  8823. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8824. const struct auto_pin_cfg *cfg)
  8825. {
  8826. struct hda_input_mux *imux = &spec->private_imux;
  8827. int i, err, idx, idx1;
  8828. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8829. switch (cfg->input_pins[i]) {
  8830. case 0x0c:
  8831. idx1 = 1;
  8832. idx = 2; /* Line In */
  8833. break;
  8834. case 0x0f:
  8835. idx1 = 2;
  8836. idx = 2; /* Line In */
  8837. break;
  8838. case 0x0d:
  8839. idx1 = 0;
  8840. idx = 1; /* Mic In */
  8841. break;
  8842. case 0x10:
  8843. idx1 = 3;
  8844. idx = 1; /* Mic In */
  8845. break;
  8846. case 0x11:
  8847. idx1 = 4;
  8848. idx = 0; /* CD */
  8849. break;
  8850. default:
  8851. continue;
  8852. }
  8853. err = new_analog_input(spec, cfg->input_pins[i],
  8854. auto_pin_cfg_labels[i], idx, 0x15);
  8855. if (err < 0)
  8856. return err;
  8857. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8858. imux->items[imux->num_items].index = idx1;
  8859. imux->num_items++;
  8860. }
  8861. return 0;
  8862. }
  8863. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8864. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8865. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8866. {
  8867. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8868. /* The multiple "Capture Source" controls confuse alsamixer
  8869. * So call somewhat different..
  8870. *FIXME: the controls appear in the "playback" view!
  8871. */
  8872. /* .name = "Capture Source", */
  8873. .name = "Input Source",
  8874. .count = 1,
  8875. .info = alc_mux_enum_info,
  8876. .get = alc_mux_enum_get,
  8877. .put = alc_mux_enum_put,
  8878. },
  8879. { } /* end */
  8880. };
  8881. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8882. hda_nid_t nid,
  8883. int pin_type, int dac_idx)
  8884. {
  8885. /* set as output */
  8886. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8887. pin_type);
  8888. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8889. AMP_OUT_UNMUTE);
  8890. }
  8891. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8892. {
  8893. struct alc_spec *spec = codec->spec;
  8894. int i;
  8895. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8896. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8897. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8898. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8899. if (nid)
  8900. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8901. spec->multiout.dac_nids[i]);
  8902. }
  8903. }
  8904. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8905. {
  8906. struct alc_spec *spec = codec->spec;
  8907. hda_nid_t pin;
  8908. pin = spec->autocfg.hp_pins[0];
  8909. if (pin) /* connect to front */
  8910. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8911. spec->multiout.dac_nids[0]);
  8912. }
  8913. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8914. {
  8915. struct alc_spec *spec = codec->spec;
  8916. int i;
  8917. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8918. hda_nid_t nid = spec->autocfg.input_pins[i];
  8919. if (nid >= 0x0c && nid <= 0x11) {
  8920. snd_hda_codec_write(codec, nid, 0,
  8921. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8922. i <= AUTO_PIN_FRONT_MIC ?
  8923. PIN_VREF80 : PIN_IN);
  8924. }
  8925. }
  8926. }
  8927. /* parse the BIOS configuration and set up the alc_spec */
  8928. /* return 1 if successful, 0 if the proper config is not found,
  8929. * or a negative error code
  8930. */
  8931. static int alc861_parse_auto_config(struct hda_codec *codec)
  8932. {
  8933. struct alc_spec *spec = codec->spec;
  8934. int err;
  8935. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8936. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8937. alc861_ignore);
  8938. if (err < 0)
  8939. return err;
  8940. if (!spec->autocfg.line_outs)
  8941. return 0; /* can't find valid BIOS pin config */
  8942. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8943. if (err < 0)
  8944. return err;
  8945. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8946. if (err < 0)
  8947. return err;
  8948. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8949. if (err < 0)
  8950. return err;
  8951. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8952. if (err < 0)
  8953. return err;
  8954. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8955. if (spec->autocfg.dig_out_pin)
  8956. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8957. if (spec->kctl_alloc)
  8958. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8959. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8960. spec->num_mux_defs = 1;
  8961. spec->input_mux = &spec->private_imux;
  8962. spec->adc_nids = alc861_adc_nids;
  8963. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8964. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8965. spec->num_mixers++;
  8966. return 1;
  8967. }
  8968. /* additional initialization for auto-configuration model */
  8969. static void alc861_auto_init(struct hda_codec *codec)
  8970. {
  8971. alc861_auto_init_multi_out(codec);
  8972. alc861_auto_init_hp_out(codec);
  8973. alc861_auto_init_analog_input(codec);
  8974. }
  8975. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8976. static struct hda_amp_list alc861_loopbacks[] = {
  8977. { 0x15, HDA_INPUT, 0 },
  8978. { 0x15, HDA_INPUT, 1 },
  8979. { 0x15, HDA_INPUT, 2 },
  8980. { 0x15, HDA_INPUT, 3 },
  8981. { } /* end */
  8982. };
  8983. #endif
  8984. /*
  8985. * configuration and preset
  8986. */
  8987. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8988. [ALC861_3ST] = "3stack",
  8989. [ALC660_3ST] = "3stack-660",
  8990. [ALC861_3ST_DIG] = "3stack-dig",
  8991. [ALC861_6ST_DIG] = "6stack-dig",
  8992. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8993. [ALC861_TOSHIBA] = "toshiba",
  8994. [ALC861_ASUS] = "asus",
  8995. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8996. [ALC861_AUTO] = "auto",
  8997. };
  8998. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8999. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9000. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9001. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9002. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9003. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9004. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9005. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9006. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9007. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9008. * Any other models that need this preset?
  9009. */
  9010. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9011. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9012. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9013. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9014. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9015. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9016. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9017. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9018. {}
  9019. };
  9020. static struct alc_config_preset alc861_presets[] = {
  9021. [ALC861_3ST] = {
  9022. .mixers = { alc861_3ST_mixer },
  9023. .init_verbs = { alc861_threestack_init_verbs },
  9024. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9025. .dac_nids = alc861_dac_nids,
  9026. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9027. .channel_mode = alc861_threestack_modes,
  9028. .need_dac_fix = 1,
  9029. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9030. .adc_nids = alc861_adc_nids,
  9031. .input_mux = &alc861_capture_source,
  9032. },
  9033. [ALC861_3ST_DIG] = {
  9034. .mixers = { alc861_base_mixer },
  9035. .init_verbs = { alc861_threestack_init_verbs },
  9036. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9037. .dac_nids = alc861_dac_nids,
  9038. .dig_out_nid = ALC861_DIGOUT_NID,
  9039. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9040. .channel_mode = alc861_threestack_modes,
  9041. .need_dac_fix = 1,
  9042. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9043. .adc_nids = alc861_adc_nids,
  9044. .input_mux = &alc861_capture_source,
  9045. },
  9046. [ALC861_6ST_DIG] = {
  9047. .mixers = { alc861_base_mixer },
  9048. .init_verbs = { alc861_base_init_verbs },
  9049. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9050. .dac_nids = alc861_dac_nids,
  9051. .dig_out_nid = ALC861_DIGOUT_NID,
  9052. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9053. .channel_mode = alc861_8ch_modes,
  9054. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9055. .adc_nids = alc861_adc_nids,
  9056. .input_mux = &alc861_capture_source,
  9057. },
  9058. [ALC660_3ST] = {
  9059. .mixers = { alc861_3ST_mixer },
  9060. .init_verbs = { alc861_threestack_init_verbs },
  9061. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9062. .dac_nids = alc660_dac_nids,
  9063. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9064. .channel_mode = alc861_threestack_modes,
  9065. .need_dac_fix = 1,
  9066. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9067. .adc_nids = alc861_adc_nids,
  9068. .input_mux = &alc861_capture_source,
  9069. },
  9070. [ALC861_UNIWILL_M31] = {
  9071. .mixers = { alc861_uniwill_m31_mixer },
  9072. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9073. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9074. .dac_nids = alc861_dac_nids,
  9075. .dig_out_nid = ALC861_DIGOUT_NID,
  9076. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9077. .channel_mode = alc861_uniwill_m31_modes,
  9078. .need_dac_fix = 1,
  9079. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9080. .adc_nids = alc861_adc_nids,
  9081. .input_mux = &alc861_capture_source,
  9082. },
  9083. [ALC861_TOSHIBA] = {
  9084. .mixers = { alc861_toshiba_mixer },
  9085. .init_verbs = { alc861_base_init_verbs,
  9086. alc861_toshiba_init_verbs },
  9087. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9088. .dac_nids = alc861_dac_nids,
  9089. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9090. .channel_mode = alc883_3ST_2ch_modes,
  9091. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9092. .adc_nids = alc861_adc_nids,
  9093. .input_mux = &alc861_capture_source,
  9094. .unsol_event = alc861_toshiba_unsol_event,
  9095. .init_hook = alc861_toshiba_automute,
  9096. },
  9097. [ALC861_ASUS] = {
  9098. .mixers = { alc861_asus_mixer },
  9099. .init_verbs = { alc861_asus_init_verbs },
  9100. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9101. .dac_nids = alc861_dac_nids,
  9102. .dig_out_nid = ALC861_DIGOUT_NID,
  9103. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9104. .channel_mode = alc861_asus_modes,
  9105. .need_dac_fix = 1,
  9106. .hp_nid = 0x06,
  9107. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9108. .adc_nids = alc861_adc_nids,
  9109. .input_mux = &alc861_capture_source,
  9110. },
  9111. [ALC861_ASUS_LAPTOP] = {
  9112. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9113. .init_verbs = { alc861_asus_init_verbs,
  9114. alc861_asus_laptop_init_verbs },
  9115. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9116. .dac_nids = alc861_dac_nids,
  9117. .dig_out_nid = ALC861_DIGOUT_NID,
  9118. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9119. .channel_mode = alc883_3ST_2ch_modes,
  9120. .need_dac_fix = 1,
  9121. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9122. .adc_nids = alc861_adc_nids,
  9123. .input_mux = &alc861_capture_source,
  9124. },
  9125. };
  9126. static int patch_alc861(struct hda_codec *codec)
  9127. {
  9128. struct alc_spec *spec;
  9129. int board_config;
  9130. int err;
  9131. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9132. if (spec == NULL)
  9133. return -ENOMEM;
  9134. codec->spec = spec;
  9135. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9136. alc861_models,
  9137. alc861_cfg_tbl);
  9138. if (board_config < 0) {
  9139. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9140. "trying auto-probe from BIOS...\n");
  9141. board_config = ALC861_AUTO;
  9142. }
  9143. if (board_config == ALC861_AUTO) {
  9144. /* automatic parse from the BIOS config */
  9145. err = alc861_parse_auto_config(codec);
  9146. if (err < 0) {
  9147. alc_free(codec);
  9148. return err;
  9149. } else if (!err) {
  9150. printk(KERN_INFO
  9151. "hda_codec: Cannot set up configuration "
  9152. "from BIOS. Using base mode...\n");
  9153. board_config = ALC861_3ST_DIG;
  9154. }
  9155. }
  9156. if (board_config != ALC861_AUTO)
  9157. setup_preset(spec, &alc861_presets[board_config]);
  9158. spec->stream_name_analog = "ALC861 Analog";
  9159. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9160. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9161. spec->stream_name_digital = "ALC861 Digital";
  9162. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9163. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9164. codec->patch_ops = alc_patch_ops;
  9165. if (board_config == ALC861_AUTO)
  9166. spec->init_hook = alc861_auto_init;
  9167. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9168. if (!spec->loopback.amplist)
  9169. spec->loopback.amplist = alc861_loopbacks;
  9170. #endif
  9171. return 0;
  9172. }
  9173. /*
  9174. * ALC861-VD support
  9175. *
  9176. * Based on ALC882
  9177. *
  9178. * In addition, an independent DAC
  9179. */
  9180. #define ALC861VD_DIGOUT_NID 0x06
  9181. static hda_nid_t alc861vd_dac_nids[4] = {
  9182. /* front, surr, clfe, side surr */
  9183. 0x02, 0x03, 0x04, 0x05
  9184. };
  9185. /* dac_nids for ALC660vd are in a different order - according to
  9186. * Realtek's driver.
  9187. * This should probably tesult in a different mixer for 6stack models
  9188. * of ALC660vd codecs, but for now there is only 3stack mixer
  9189. * - and it is the same as in 861vd.
  9190. * adc_nids in ALC660vd are (is) the same as in 861vd
  9191. */
  9192. static hda_nid_t alc660vd_dac_nids[3] = {
  9193. /* front, rear, clfe, rear_surr */
  9194. 0x02, 0x04, 0x03
  9195. };
  9196. static hda_nid_t alc861vd_adc_nids[1] = {
  9197. /* ADC0 */
  9198. 0x09,
  9199. };
  9200. /* input MUX */
  9201. /* FIXME: should be a matrix-type input source selection */
  9202. static struct hda_input_mux alc861vd_capture_source = {
  9203. .num_items = 4,
  9204. .items = {
  9205. { "Mic", 0x0 },
  9206. { "Front Mic", 0x1 },
  9207. { "Line", 0x2 },
  9208. { "CD", 0x4 },
  9209. },
  9210. };
  9211. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9212. .num_items = 3,
  9213. .items = {
  9214. { "Front Mic", 0x0 },
  9215. { "ATAPI Mic", 0x1 },
  9216. { "Line In", 0x5 },
  9217. },
  9218. };
  9219. static struct hda_input_mux alc861vd_hp_capture_source = {
  9220. .num_items = 2,
  9221. .items = {
  9222. { "Front Mic", 0x0 },
  9223. { "ATAPI Mic", 0x1 },
  9224. },
  9225. };
  9226. #define alc861vd_mux_enum_info alc_mux_enum_info
  9227. #define alc861vd_mux_enum_get alc_mux_enum_get
  9228. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9229. struct snd_ctl_elem_value *ucontrol)
  9230. {
  9231. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9232. struct alc_spec *spec = codec->spec;
  9233. const struct hda_input_mux *imux = spec->input_mux;
  9234. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9235. static hda_nid_t capture_mixers[1] = { 0x22 };
  9236. hda_nid_t nid = capture_mixers[adc_idx];
  9237. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9238. unsigned int i, idx;
  9239. idx = ucontrol->value.enumerated.item[0];
  9240. if (idx >= imux->num_items)
  9241. idx = imux->num_items - 1;
  9242. if (*cur_val == idx)
  9243. return 0;
  9244. for (i = 0; i < imux->num_items; i++) {
  9245. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9246. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9247. imux->items[i].index,
  9248. HDA_AMP_MUTE, v);
  9249. }
  9250. *cur_val = idx;
  9251. return 1;
  9252. }
  9253. /*
  9254. * 2ch mode
  9255. */
  9256. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9257. { 2, NULL }
  9258. };
  9259. /*
  9260. * 6ch mode
  9261. */
  9262. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9263. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9264. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9265. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9266. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9267. { } /* end */
  9268. };
  9269. /*
  9270. * 8ch mode
  9271. */
  9272. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9273. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9274. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9275. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9276. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9277. { } /* end */
  9278. };
  9279. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9280. { 6, alc861vd_6stack_ch6_init },
  9281. { 8, alc861vd_6stack_ch8_init },
  9282. };
  9283. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9284. {
  9285. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9286. .name = "Channel Mode",
  9287. .info = alc_ch_mode_info,
  9288. .get = alc_ch_mode_get,
  9289. .put = alc_ch_mode_put,
  9290. },
  9291. { } /* end */
  9292. };
  9293. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9294. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9295. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9296. {
  9297. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9298. /* The multiple "Capture Source" controls confuse alsamixer
  9299. * So call somewhat different..
  9300. *FIXME: the controls appear in the "playback" view!
  9301. */
  9302. /* .name = "Capture Source", */
  9303. .name = "Input Source",
  9304. .count = 1,
  9305. .info = alc861vd_mux_enum_info,
  9306. .get = alc861vd_mux_enum_get,
  9307. .put = alc861vd_mux_enum_put,
  9308. },
  9309. { } /* end */
  9310. };
  9311. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9312. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9313. */
  9314. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9315. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9316. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9317. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9318. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9319. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9320. HDA_OUTPUT),
  9321. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9322. HDA_OUTPUT),
  9323. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9324. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9325. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9326. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9327. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9328. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9329. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9330. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9331. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9332. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9333. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9334. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9335. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9336. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9337. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9338. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9339. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9340. { } /* end */
  9341. };
  9342. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9343. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9344. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9345. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9346. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9347. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9348. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9349. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9350. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9351. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9352. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9353. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9354. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9355. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9356. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9357. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9358. { } /* end */
  9359. };
  9360. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9361. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9362. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9363. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9364. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9365. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9366. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9367. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9368. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9369. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9370. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9371. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9372. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9373. { } /* end */
  9374. };
  9375. /* Pin assignment: Front=0x14, HP = 0x15,
  9376. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9377. */
  9378. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9379. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9380. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9381. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9382. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9383. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9384. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9385. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9386. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9387. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9388. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9389. { } /* end */
  9390. };
  9391. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9392. * Front Mic=0x18, ATAPI Mic = 0x19,
  9393. */
  9394. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9395. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9396. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9397. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9398. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9399. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9400. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9401. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9402. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9403. { } /* end */
  9404. };
  9405. /*
  9406. * generic initialization of ADC, input mixers and output mixers
  9407. */
  9408. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9409. /*
  9410. * Unmute ADC0 and set the default input to mic-in
  9411. */
  9412. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9413. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9414. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9415. * the analog-loopback mixer widget
  9416. */
  9417. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9418. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9419. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9420. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9421. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9422. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9423. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9424. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9425. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9426. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9427. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9428. /*
  9429. * Set up output mixers (0x02 - 0x05)
  9430. */
  9431. /* set vol=0 to output mixers */
  9432. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9433. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9434. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9435. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9436. /* set up input amps for analog loopback */
  9437. /* Amp Indices: DAC = 0, mixer = 1 */
  9438. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9439. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9440. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9441. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9442. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9443. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9444. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9445. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9446. { }
  9447. };
  9448. /*
  9449. * 3-stack pin configuration:
  9450. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9451. */
  9452. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9453. /*
  9454. * Set pin mode and muting
  9455. */
  9456. /* set front pin widgets 0x14 for output */
  9457. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9458. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9459. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9460. /* Mic (rear) pin: input vref at 80% */
  9461. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9462. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9463. /* Front Mic pin: input vref at 80% */
  9464. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9465. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9466. /* Line In pin: input */
  9467. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9468. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9469. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9470. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9471. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9472. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9473. /* CD pin widget for input */
  9474. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9475. { }
  9476. };
  9477. /*
  9478. * 6-stack pin configuration:
  9479. */
  9480. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9481. /*
  9482. * Set pin mode and muting
  9483. */
  9484. /* set front pin widgets 0x14 for output */
  9485. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9486. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9487. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9488. /* Rear Pin: output 1 (0x0d) */
  9489. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9490. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9491. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9492. /* CLFE Pin: output 2 (0x0e) */
  9493. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9494. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9495. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9496. /* Side Pin: output 3 (0x0f) */
  9497. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9498. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9499. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9500. /* Mic (rear) pin: input vref at 80% */
  9501. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9502. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9503. /* Front Mic pin: input vref at 80% */
  9504. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9505. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9506. /* Line In pin: input */
  9507. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9508. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9509. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9510. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9511. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9512. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9513. /* CD pin widget for input */
  9514. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9515. { }
  9516. };
  9517. static struct hda_verb alc861vd_eapd_verbs[] = {
  9518. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9519. { }
  9520. };
  9521. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9522. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9523. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9524. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9525. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9526. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9527. {}
  9528. };
  9529. /* toggle speaker-output according to the hp-jack state */
  9530. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9531. {
  9532. unsigned int present;
  9533. unsigned char bits;
  9534. present = snd_hda_codec_read(codec, 0x1b, 0,
  9535. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9536. bits = present ? HDA_AMP_MUTE : 0;
  9537. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9538. HDA_AMP_MUTE, bits);
  9539. }
  9540. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9541. {
  9542. unsigned int present;
  9543. unsigned char bits;
  9544. present = snd_hda_codec_read(codec, 0x18, 0,
  9545. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9546. bits = present ? HDA_AMP_MUTE : 0;
  9547. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9548. HDA_AMP_MUTE, bits);
  9549. }
  9550. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9551. {
  9552. alc861vd_lenovo_hp_automute(codec);
  9553. alc861vd_lenovo_mic_automute(codec);
  9554. }
  9555. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9556. unsigned int res)
  9557. {
  9558. switch (res >> 26) {
  9559. case ALC880_HP_EVENT:
  9560. alc861vd_lenovo_hp_automute(codec);
  9561. break;
  9562. case ALC880_MIC_EVENT:
  9563. alc861vd_lenovo_mic_automute(codec);
  9564. break;
  9565. }
  9566. }
  9567. static struct hda_verb alc861vd_dallas_verbs[] = {
  9568. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9569. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9570. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9571. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9572. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9573. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9574. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9575. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9577. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9578. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9579. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9580. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9581. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9582. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9583. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9584. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9585. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9586. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9587. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9588. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9589. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9590. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9591. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9592. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9593. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9594. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9595. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9596. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9597. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9598. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9599. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9600. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9601. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9602. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9603. { } /* end */
  9604. };
  9605. /* toggle speaker-output according to the hp-jack state */
  9606. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9607. {
  9608. unsigned int present;
  9609. present = snd_hda_codec_read(codec, 0x15, 0,
  9610. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9611. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9612. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9613. }
  9614. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9615. {
  9616. if ((res >> 26) == ALC880_HP_EVENT)
  9617. alc861vd_dallas_automute(codec);
  9618. }
  9619. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9620. #define alc861vd_loopbacks alc880_loopbacks
  9621. #endif
  9622. /* pcm configuration: identiacal with ALC880 */
  9623. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9624. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9625. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9626. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9627. /*
  9628. * configuration and preset
  9629. */
  9630. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9631. [ALC660VD_3ST] = "3stack-660",
  9632. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9633. [ALC861VD_3ST] = "3stack",
  9634. [ALC861VD_3ST_DIG] = "3stack-digout",
  9635. [ALC861VD_6ST_DIG] = "6stack-digout",
  9636. [ALC861VD_LENOVO] = "lenovo",
  9637. [ALC861VD_DALLAS] = "dallas",
  9638. [ALC861VD_HP] = "hp",
  9639. [ALC861VD_AUTO] = "auto",
  9640. };
  9641. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9642. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9643. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9644. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9645. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9646. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9647. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9648. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9649. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9650. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9651. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9652. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9653. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9654. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9655. {}
  9656. };
  9657. static struct alc_config_preset alc861vd_presets[] = {
  9658. [ALC660VD_3ST] = {
  9659. .mixers = { alc861vd_3st_mixer },
  9660. .init_verbs = { alc861vd_volume_init_verbs,
  9661. alc861vd_3stack_init_verbs },
  9662. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9663. .dac_nids = alc660vd_dac_nids,
  9664. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9665. .adc_nids = alc861vd_adc_nids,
  9666. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9667. .channel_mode = alc861vd_3stack_2ch_modes,
  9668. .input_mux = &alc861vd_capture_source,
  9669. },
  9670. [ALC660VD_3ST_DIG] = {
  9671. .mixers = { alc861vd_3st_mixer },
  9672. .init_verbs = { alc861vd_volume_init_verbs,
  9673. alc861vd_3stack_init_verbs },
  9674. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9675. .dac_nids = alc660vd_dac_nids,
  9676. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9677. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9678. .adc_nids = alc861vd_adc_nids,
  9679. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9680. .channel_mode = alc861vd_3stack_2ch_modes,
  9681. .input_mux = &alc861vd_capture_source,
  9682. },
  9683. [ALC861VD_3ST] = {
  9684. .mixers = { alc861vd_3st_mixer },
  9685. .init_verbs = { alc861vd_volume_init_verbs,
  9686. alc861vd_3stack_init_verbs },
  9687. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9688. .dac_nids = alc861vd_dac_nids,
  9689. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9690. .channel_mode = alc861vd_3stack_2ch_modes,
  9691. .input_mux = &alc861vd_capture_source,
  9692. },
  9693. [ALC861VD_3ST_DIG] = {
  9694. .mixers = { alc861vd_3st_mixer },
  9695. .init_verbs = { alc861vd_volume_init_verbs,
  9696. alc861vd_3stack_init_verbs },
  9697. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9698. .dac_nids = alc861vd_dac_nids,
  9699. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9700. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9701. .channel_mode = alc861vd_3stack_2ch_modes,
  9702. .input_mux = &alc861vd_capture_source,
  9703. },
  9704. [ALC861VD_6ST_DIG] = {
  9705. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9706. .init_verbs = { alc861vd_volume_init_verbs,
  9707. alc861vd_6stack_init_verbs },
  9708. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9709. .dac_nids = alc861vd_dac_nids,
  9710. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9711. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9712. .channel_mode = alc861vd_6stack_modes,
  9713. .input_mux = &alc861vd_capture_source,
  9714. },
  9715. [ALC861VD_LENOVO] = {
  9716. .mixers = { alc861vd_lenovo_mixer },
  9717. .init_verbs = { alc861vd_volume_init_verbs,
  9718. alc861vd_3stack_init_verbs,
  9719. alc861vd_eapd_verbs,
  9720. alc861vd_lenovo_unsol_verbs },
  9721. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9722. .dac_nids = alc660vd_dac_nids,
  9723. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9724. .adc_nids = alc861vd_adc_nids,
  9725. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9726. .channel_mode = alc861vd_3stack_2ch_modes,
  9727. .input_mux = &alc861vd_capture_source,
  9728. .unsol_event = alc861vd_lenovo_unsol_event,
  9729. .init_hook = alc861vd_lenovo_automute,
  9730. },
  9731. [ALC861VD_DALLAS] = {
  9732. .mixers = { alc861vd_dallas_mixer },
  9733. .init_verbs = { alc861vd_dallas_verbs },
  9734. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9735. .dac_nids = alc861vd_dac_nids,
  9736. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9737. .adc_nids = alc861vd_adc_nids,
  9738. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9739. .channel_mode = alc861vd_3stack_2ch_modes,
  9740. .input_mux = &alc861vd_dallas_capture_source,
  9741. .unsol_event = alc861vd_dallas_unsol_event,
  9742. .init_hook = alc861vd_dallas_automute,
  9743. },
  9744. [ALC861VD_HP] = {
  9745. .mixers = { alc861vd_hp_mixer },
  9746. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9747. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9748. .dac_nids = alc861vd_dac_nids,
  9749. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9750. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9751. .adc_nids = alc861vd_adc_nids,
  9752. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9753. .channel_mode = alc861vd_3stack_2ch_modes,
  9754. .input_mux = &alc861vd_hp_capture_source,
  9755. .unsol_event = alc861vd_dallas_unsol_event,
  9756. .init_hook = alc861vd_dallas_automute,
  9757. },
  9758. };
  9759. /*
  9760. * BIOS auto configuration
  9761. */
  9762. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9763. hda_nid_t nid, int pin_type, int dac_idx)
  9764. {
  9765. /* set as output */
  9766. snd_hda_codec_write(codec, nid, 0,
  9767. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9768. snd_hda_codec_write(codec, nid, 0,
  9769. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9770. }
  9771. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9772. {
  9773. struct alc_spec *spec = codec->spec;
  9774. int i;
  9775. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9776. for (i = 0; i <= HDA_SIDE; i++) {
  9777. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9778. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9779. if (nid)
  9780. alc861vd_auto_set_output_and_unmute(codec, nid,
  9781. pin_type, i);
  9782. }
  9783. }
  9784. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9785. {
  9786. struct alc_spec *spec = codec->spec;
  9787. hda_nid_t pin;
  9788. pin = spec->autocfg.hp_pins[0];
  9789. if (pin) /* connect to front and use dac 0 */
  9790. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9791. }
  9792. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9793. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9794. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9795. {
  9796. struct alc_spec *spec = codec->spec;
  9797. int i;
  9798. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9799. hda_nid_t nid = spec->autocfg.input_pins[i];
  9800. if (alc861vd_is_input_pin(nid)) {
  9801. snd_hda_codec_write(codec, nid, 0,
  9802. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9803. i <= AUTO_PIN_FRONT_MIC ?
  9804. PIN_VREF80 : PIN_IN);
  9805. if (nid != ALC861VD_PIN_CD_NID)
  9806. snd_hda_codec_write(codec, nid, 0,
  9807. AC_VERB_SET_AMP_GAIN_MUTE,
  9808. AMP_OUT_MUTE);
  9809. }
  9810. }
  9811. }
  9812. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9813. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9814. /* add playback controls from the parsed DAC table */
  9815. /* Based on ALC880 version. But ALC861VD has separate,
  9816. * different NIDs for mute/unmute switch and volume control */
  9817. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9818. const struct auto_pin_cfg *cfg)
  9819. {
  9820. char name[32];
  9821. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9822. hda_nid_t nid_v, nid_s;
  9823. int i, err;
  9824. for (i = 0; i < cfg->line_outs; i++) {
  9825. if (!spec->multiout.dac_nids[i])
  9826. continue;
  9827. nid_v = alc861vd_idx_to_mixer_vol(
  9828. alc880_dac_to_idx(
  9829. spec->multiout.dac_nids[i]));
  9830. nid_s = alc861vd_idx_to_mixer_switch(
  9831. alc880_dac_to_idx(
  9832. spec->multiout.dac_nids[i]));
  9833. if (i == 2) {
  9834. /* Center/LFE */
  9835. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9836. "Center Playback Volume",
  9837. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9838. HDA_OUTPUT));
  9839. if (err < 0)
  9840. return err;
  9841. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9842. "LFE Playback Volume",
  9843. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9844. HDA_OUTPUT));
  9845. if (err < 0)
  9846. return err;
  9847. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9848. "Center Playback Switch",
  9849. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9850. HDA_INPUT));
  9851. if (err < 0)
  9852. return err;
  9853. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9854. "LFE Playback Switch",
  9855. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9856. HDA_INPUT));
  9857. if (err < 0)
  9858. return err;
  9859. } else {
  9860. sprintf(name, "%s Playback Volume", chname[i]);
  9861. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9862. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9863. HDA_OUTPUT));
  9864. if (err < 0)
  9865. return err;
  9866. sprintf(name, "%s Playback Switch", chname[i]);
  9867. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9868. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9869. HDA_INPUT));
  9870. if (err < 0)
  9871. return err;
  9872. }
  9873. }
  9874. return 0;
  9875. }
  9876. /* add playback controls for speaker and HP outputs */
  9877. /* Based on ALC880 version. But ALC861VD has separate,
  9878. * different NIDs for mute/unmute switch and volume control */
  9879. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9880. hda_nid_t pin, const char *pfx)
  9881. {
  9882. hda_nid_t nid_v, nid_s;
  9883. int err;
  9884. char name[32];
  9885. if (!pin)
  9886. return 0;
  9887. if (alc880_is_fixed_pin(pin)) {
  9888. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9889. /* specify the DAC as the extra output */
  9890. if (!spec->multiout.hp_nid)
  9891. spec->multiout.hp_nid = nid_v;
  9892. else
  9893. spec->multiout.extra_out_nid[0] = nid_v;
  9894. /* control HP volume/switch on the output mixer amp */
  9895. nid_v = alc861vd_idx_to_mixer_vol(
  9896. alc880_fixed_pin_idx(pin));
  9897. nid_s = alc861vd_idx_to_mixer_switch(
  9898. alc880_fixed_pin_idx(pin));
  9899. sprintf(name, "%s Playback Volume", pfx);
  9900. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9901. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9902. if (err < 0)
  9903. return err;
  9904. sprintf(name, "%s Playback Switch", pfx);
  9905. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9906. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9907. if (err < 0)
  9908. return err;
  9909. } else if (alc880_is_multi_pin(pin)) {
  9910. /* set manual connection */
  9911. /* we have only a switch on HP-out PIN */
  9912. sprintf(name, "%s Playback Switch", pfx);
  9913. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9914. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9915. if (err < 0)
  9916. return err;
  9917. }
  9918. return 0;
  9919. }
  9920. /* parse the BIOS configuration and set up the alc_spec
  9921. * return 1 if successful, 0 if the proper config is not found,
  9922. * or a negative error code
  9923. * Based on ALC880 version - had to change it to override
  9924. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9925. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9926. {
  9927. struct alc_spec *spec = codec->spec;
  9928. int err;
  9929. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9930. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9931. alc861vd_ignore);
  9932. if (err < 0)
  9933. return err;
  9934. if (!spec->autocfg.line_outs)
  9935. return 0; /* can't find valid BIOS pin config */
  9936. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9937. if (err < 0)
  9938. return err;
  9939. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9940. if (err < 0)
  9941. return err;
  9942. err = alc861vd_auto_create_extra_out(spec,
  9943. spec->autocfg.speaker_pins[0],
  9944. "Speaker");
  9945. if (err < 0)
  9946. return err;
  9947. err = alc861vd_auto_create_extra_out(spec,
  9948. spec->autocfg.hp_pins[0],
  9949. "Headphone");
  9950. if (err < 0)
  9951. return err;
  9952. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9953. if (err < 0)
  9954. return err;
  9955. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9956. if (spec->autocfg.dig_out_pin)
  9957. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9958. if (spec->kctl_alloc)
  9959. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9960. spec->init_verbs[spec->num_init_verbs++]
  9961. = alc861vd_volume_init_verbs;
  9962. spec->num_mux_defs = 1;
  9963. spec->input_mux = &spec->private_imux;
  9964. return 1;
  9965. }
  9966. /* additional initialization for auto-configuration model */
  9967. static void alc861vd_auto_init(struct hda_codec *codec)
  9968. {
  9969. alc861vd_auto_init_multi_out(codec);
  9970. alc861vd_auto_init_hp_out(codec);
  9971. alc861vd_auto_init_analog_input(codec);
  9972. }
  9973. static int patch_alc861vd(struct hda_codec *codec)
  9974. {
  9975. struct alc_spec *spec;
  9976. int err, board_config;
  9977. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9978. if (spec == NULL)
  9979. return -ENOMEM;
  9980. codec->spec = spec;
  9981. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9982. alc861vd_models,
  9983. alc861vd_cfg_tbl);
  9984. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9985. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9986. "ALC861VD, trying auto-probe from BIOS...\n");
  9987. board_config = ALC861VD_AUTO;
  9988. }
  9989. if (board_config == ALC861VD_AUTO) {
  9990. /* automatic parse from the BIOS config */
  9991. err = alc861vd_parse_auto_config(codec);
  9992. if (err < 0) {
  9993. alc_free(codec);
  9994. return err;
  9995. } else if (!err) {
  9996. printk(KERN_INFO
  9997. "hda_codec: Cannot set up configuration "
  9998. "from BIOS. Using base mode...\n");
  9999. board_config = ALC861VD_3ST;
  10000. }
  10001. }
  10002. if (board_config != ALC861VD_AUTO)
  10003. setup_preset(spec, &alc861vd_presets[board_config]);
  10004. spec->stream_name_analog = "ALC861VD Analog";
  10005. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10006. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10007. spec->stream_name_digital = "ALC861VD Digital";
  10008. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10009. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10010. spec->adc_nids = alc861vd_adc_nids;
  10011. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10012. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10013. spec->num_mixers++;
  10014. codec->patch_ops = alc_patch_ops;
  10015. if (board_config == ALC861VD_AUTO)
  10016. spec->init_hook = alc861vd_auto_init;
  10017. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10018. if (!spec->loopback.amplist)
  10019. spec->loopback.amplist = alc861vd_loopbacks;
  10020. #endif
  10021. return 0;
  10022. }
  10023. /*
  10024. * ALC662 support
  10025. *
  10026. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10027. * configuration. Each pin widget can choose any input DACs and a mixer.
  10028. * Each ADC is connected from a mixer of all inputs. This makes possible
  10029. * 6-channel independent captures.
  10030. *
  10031. * In addition, an independent DAC for the multi-playback (not used in this
  10032. * driver yet).
  10033. */
  10034. #define ALC662_DIGOUT_NID 0x06
  10035. #define ALC662_DIGIN_NID 0x0a
  10036. static hda_nid_t alc662_dac_nids[4] = {
  10037. /* front, rear, clfe, rear_surr */
  10038. 0x02, 0x03, 0x04
  10039. };
  10040. static hda_nid_t alc662_adc_nids[1] = {
  10041. /* ADC1-2 */
  10042. 0x09,
  10043. };
  10044. /* input MUX */
  10045. /* FIXME: should be a matrix-type input source selection */
  10046. static struct hda_input_mux alc662_capture_source = {
  10047. .num_items = 4,
  10048. .items = {
  10049. { "Mic", 0x0 },
  10050. { "Front Mic", 0x1 },
  10051. { "Line", 0x2 },
  10052. { "CD", 0x4 },
  10053. },
  10054. };
  10055. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10056. .num_items = 2,
  10057. .items = {
  10058. { "Mic", 0x1 },
  10059. { "Line", 0x2 },
  10060. },
  10061. };
  10062. #define alc662_mux_enum_info alc_mux_enum_info
  10063. #define alc662_mux_enum_get alc_mux_enum_get
  10064. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10065. struct snd_ctl_elem_value *ucontrol)
  10066. {
  10067. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10068. struct alc_spec *spec = codec->spec;
  10069. const struct hda_input_mux *imux = spec->input_mux;
  10070. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10071. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10072. hda_nid_t nid = capture_mixers[adc_idx];
  10073. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10074. unsigned int i, idx;
  10075. idx = ucontrol->value.enumerated.item[0];
  10076. if (idx >= imux->num_items)
  10077. idx = imux->num_items - 1;
  10078. if (*cur_val == idx)
  10079. return 0;
  10080. for (i = 0; i < imux->num_items; i++) {
  10081. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10082. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10083. imux->items[i].index,
  10084. HDA_AMP_MUTE, v);
  10085. }
  10086. *cur_val = idx;
  10087. return 1;
  10088. }
  10089. /*
  10090. * 2ch mode
  10091. */
  10092. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10093. { 2, NULL }
  10094. };
  10095. /*
  10096. * 2ch mode
  10097. */
  10098. static struct hda_verb alc662_3ST_ch2_init[] = {
  10099. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10100. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10101. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10102. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10103. { } /* end */
  10104. };
  10105. /*
  10106. * 6ch mode
  10107. */
  10108. static struct hda_verb alc662_3ST_ch6_init[] = {
  10109. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10110. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10111. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10112. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10113. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10114. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10115. { } /* end */
  10116. };
  10117. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10118. { 2, alc662_3ST_ch2_init },
  10119. { 6, alc662_3ST_ch6_init },
  10120. };
  10121. /*
  10122. * 2ch mode
  10123. */
  10124. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10125. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10126. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10127. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10128. { } /* end */
  10129. };
  10130. /*
  10131. * 6ch mode
  10132. */
  10133. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10134. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10135. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10136. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10137. { } /* end */
  10138. };
  10139. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10140. { 2, alc662_sixstack_ch6_init },
  10141. { 6, alc662_sixstack_ch8_init },
  10142. };
  10143. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10144. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10145. */
  10146. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10147. /* output mixer control */
  10148. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10149. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10150. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10151. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10152. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10153. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10154. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10155. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10156. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10157. /*Input mixer control */
  10158. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10159. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10160. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10161. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10162. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10163. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10164. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10165. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10166. /* Capture mixer control */
  10167. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10168. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10169. {
  10170. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10171. .name = "Capture Source",
  10172. .count = 1,
  10173. .info = alc_mux_enum_info,
  10174. .get = alc_mux_enum_get,
  10175. .put = alc_mux_enum_put,
  10176. },
  10177. { } /* end */
  10178. };
  10179. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10180. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10181. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10182. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10183. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10184. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10185. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10186. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10187. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10188. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10189. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10190. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10191. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10192. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10193. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10194. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10195. {
  10196. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10197. /* .name = "Capture Source", */
  10198. .name = "Input Source",
  10199. .count = 1,
  10200. .info = alc662_mux_enum_info,
  10201. .get = alc662_mux_enum_get,
  10202. .put = alc662_mux_enum_put,
  10203. },
  10204. { } /* end */
  10205. };
  10206. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10207. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10208. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10209. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10210. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10211. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10212. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10213. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10214. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10215. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10216. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10217. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10218. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10219. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10220. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10221. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10222. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10223. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10224. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10225. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10226. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10227. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10228. {
  10229. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10230. /* .name = "Capture Source", */
  10231. .name = "Input Source",
  10232. .count = 1,
  10233. .info = alc662_mux_enum_info,
  10234. .get = alc662_mux_enum_get,
  10235. .put = alc662_mux_enum_put,
  10236. },
  10237. { } /* end */
  10238. };
  10239. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10240. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10241. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10242. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10243. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10244. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10245. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10246. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10247. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10248. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10249. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10250. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10251. {
  10252. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10253. /* .name = "Capture Source", */
  10254. .name = "Input Source",
  10255. .count = 1,
  10256. .info = alc662_mux_enum_info,
  10257. .get = alc662_mux_enum_get,
  10258. .put = alc662_mux_enum_put,
  10259. },
  10260. { } /* end */
  10261. };
  10262. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10263. {
  10264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10265. .name = "Channel Mode",
  10266. .info = alc_ch_mode_info,
  10267. .get = alc_ch_mode_get,
  10268. .put = alc_ch_mode_put,
  10269. },
  10270. { } /* end */
  10271. };
  10272. static struct hda_verb alc662_init_verbs[] = {
  10273. /* ADC: mute amp left and right */
  10274. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10275. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10276. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10280. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10281. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10282. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10283. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10284. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10285. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10286. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10287. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10288. /* Front Pin: output 0 (0x0c) */
  10289. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10290. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10291. /* Rear Pin: output 1 (0x0d) */
  10292. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10293. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10294. /* CLFE Pin: output 2 (0x0e) */
  10295. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10296. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10297. /* Mic (rear) pin: input vref at 80% */
  10298. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10299. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10300. /* Front Mic pin: input vref at 80% */
  10301. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10302. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10303. /* Line In pin: input */
  10304. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10305. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10306. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10307. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10308. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10309. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10310. /* CD pin widget for input */
  10311. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10312. /* FIXME: use matrix-type input source selection */
  10313. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10314. /* Input mixer */
  10315. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10316. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10317. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10318. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10319. { }
  10320. };
  10321. static struct hda_verb alc662_sue_init_verbs[] = {
  10322. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10323. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10324. {}
  10325. };
  10326. /*
  10327. * generic initialization of ADC, input mixers and output mixers
  10328. */
  10329. static struct hda_verb alc662_auto_init_verbs[] = {
  10330. /*
  10331. * Unmute ADC and set the default input to mic-in
  10332. */
  10333. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10334. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10335. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10336. * mixer widget
  10337. * Note: PASD motherboards uses the Line In 2 as the input for front
  10338. * panel mic (mic 2)
  10339. */
  10340. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10341. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10342. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10343. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10344. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10345. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10346. /*
  10347. * Set up output mixers (0x0c - 0x0f)
  10348. */
  10349. /* set vol=0 to output mixers */
  10350. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10351. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10352. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10353. /* set up input amps for analog loopback */
  10354. /* Amp Indices: DAC = 0, mixer = 1 */
  10355. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10356. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10357. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10358. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10359. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10360. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10361. /* FIXME: use matrix-type input source selection */
  10362. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10363. /* Input mixer */
  10364. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10365. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10366. { }
  10367. };
  10368. /* capture mixer elements */
  10369. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10370. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10371. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10372. {
  10373. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10374. /* The multiple "Capture Source" controls confuse alsamixer
  10375. * So call somewhat different..
  10376. * FIXME: the controls appear in the "playback" view!
  10377. */
  10378. /* .name = "Capture Source", */
  10379. .name = "Input Source",
  10380. .count = 1,
  10381. .info = alc882_mux_enum_info,
  10382. .get = alc882_mux_enum_get,
  10383. .put = alc882_mux_enum_put,
  10384. },
  10385. { } /* end */
  10386. };
  10387. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10388. {
  10389. unsigned int present;
  10390. unsigned char bits;
  10391. present = snd_hda_codec_read(codec, 0x14, 0,
  10392. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10393. bits = present ? HDA_AMP_MUTE : 0;
  10394. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10395. HDA_AMP_MUTE, bits);
  10396. }
  10397. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10398. {
  10399. unsigned int present;
  10400. unsigned char bits;
  10401. present = snd_hda_codec_read(codec, 0x1b, 0,
  10402. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10403. bits = present ? HDA_AMP_MUTE : 0;
  10404. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10405. HDA_AMP_MUTE, bits);
  10406. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10407. HDA_AMP_MUTE, bits);
  10408. }
  10409. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10410. unsigned int res)
  10411. {
  10412. if ((res >> 26) == ALC880_HP_EVENT)
  10413. alc662_lenovo_101e_all_automute(codec);
  10414. if ((res >> 26) == ALC880_FRONT_EVENT)
  10415. alc662_lenovo_101e_ispeaker_automute(codec);
  10416. }
  10417. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10418. #define alc662_loopbacks alc880_loopbacks
  10419. #endif
  10420. /* pcm configuration: identiacal with ALC880 */
  10421. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10422. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10423. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10424. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10425. /*
  10426. * configuration and preset
  10427. */
  10428. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10429. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10430. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10431. [ALC662_3ST_6ch] = "3stack-6ch",
  10432. [ALC662_5ST_DIG] = "6stack-dig",
  10433. [ALC662_LENOVO_101E] = "lenovo-101e",
  10434. [ALC662_AUTO] = "auto",
  10435. };
  10436. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10437. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10438. {}
  10439. };
  10440. static struct alc_config_preset alc662_presets[] = {
  10441. [ALC662_3ST_2ch_DIG] = {
  10442. .mixers = { alc662_3ST_2ch_mixer },
  10443. .init_verbs = { alc662_init_verbs },
  10444. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10445. .dac_nids = alc662_dac_nids,
  10446. .dig_out_nid = ALC662_DIGOUT_NID,
  10447. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10448. .adc_nids = alc662_adc_nids,
  10449. .dig_in_nid = ALC662_DIGIN_NID,
  10450. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10451. .channel_mode = alc662_3ST_2ch_modes,
  10452. .input_mux = &alc662_capture_source,
  10453. },
  10454. [ALC662_3ST_6ch_DIG] = {
  10455. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10456. .init_verbs = { alc662_init_verbs },
  10457. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10458. .dac_nids = alc662_dac_nids,
  10459. .dig_out_nid = ALC662_DIGOUT_NID,
  10460. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10461. .adc_nids = alc662_adc_nids,
  10462. .dig_in_nid = ALC662_DIGIN_NID,
  10463. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10464. .channel_mode = alc662_3ST_6ch_modes,
  10465. .need_dac_fix = 1,
  10466. .input_mux = &alc662_capture_source,
  10467. },
  10468. [ALC662_3ST_6ch] = {
  10469. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10470. .init_verbs = { alc662_init_verbs },
  10471. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10472. .dac_nids = alc662_dac_nids,
  10473. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10474. .adc_nids = alc662_adc_nids,
  10475. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10476. .channel_mode = alc662_3ST_6ch_modes,
  10477. .need_dac_fix = 1,
  10478. .input_mux = &alc662_capture_source,
  10479. },
  10480. [ALC662_5ST_DIG] = {
  10481. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10482. .init_verbs = { alc662_init_verbs },
  10483. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10484. .dac_nids = alc662_dac_nids,
  10485. .dig_out_nid = ALC662_DIGOUT_NID,
  10486. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10487. .adc_nids = alc662_adc_nids,
  10488. .dig_in_nid = ALC662_DIGIN_NID,
  10489. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10490. .channel_mode = alc662_5stack_modes,
  10491. .input_mux = &alc662_capture_source,
  10492. },
  10493. [ALC662_LENOVO_101E] = {
  10494. .mixers = { alc662_lenovo_101e_mixer },
  10495. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10496. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10497. .dac_nids = alc662_dac_nids,
  10498. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10499. .adc_nids = alc662_adc_nids,
  10500. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10501. .channel_mode = alc662_3ST_2ch_modes,
  10502. .input_mux = &alc662_lenovo_101e_capture_source,
  10503. .unsol_event = alc662_lenovo_101e_unsol_event,
  10504. .init_hook = alc662_lenovo_101e_all_automute,
  10505. },
  10506. };
  10507. /*
  10508. * BIOS auto configuration
  10509. */
  10510. /* add playback controls from the parsed DAC table */
  10511. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10512. const struct auto_pin_cfg *cfg)
  10513. {
  10514. char name[32];
  10515. static const char *chname[4] = {
  10516. "Front", "Surround", NULL /*CLFE*/, "Side"
  10517. };
  10518. hda_nid_t nid;
  10519. int i, err;
  10520. for (i = 0; i < cfg->line_outs; i++) {
  10521. if (!spec->multiout.dac_nids[i])
  10522. continue;
  10523. nid = alc880_idx_to_mixer(i);
  10524. if (i == 2) {
  10525. /* Center/LFE */
  10526. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10527. "Center Playback Volume",
  10528. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10529. HDA_OUTPUT));
  10530. if (err < 0)
  10531. return err;
  10532. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10533. "LFE Playback Volume",
  10534. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10535. HDA_OUTPUT));
  10536. if (err < 0)
  10537. return err;
  10538. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10539. "Center Playback Switch",
  10540. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10541. HDA_INPUT));
  10542. if (err < 0)
  10543. return err;
  10544. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10545. "LFE Playback Switch",
  10546. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10547. HDA_INPUT));
  10548. if (err < 0)
  10549. return err;
  10550. } else {
  10551. sprintf(name, "%s Playback Volume", chname[i]);
  10552. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10553. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10554. HDA_OUTPUT));
  10555. if (err < 0)
  10556. return err;
  10557. sprintf(name, "%s Playback Switch", chname[i]);
  10558. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10559. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10560. HDA_INPUT));
  10561. if (err < 0)
  10562. return err;
  10563. }
  10564. }
  10565. return 0;
  10566. }
  10567. /* add playback controls for speaker and HP outputs */
  10568. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10569. const char *pfx)
  10570. {
  10571. hda_nid_t nid;
  10572. int err;
  10573. char name[32];
  10574. if (!pin)
  10575. return 0;
  10576. if (alc880_is_fixed_pin(pin)) {
  10577. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10578. /* printk("DAC nid=%x\n",nid); */
  10579. /* specify the DAC as the extra output */
  10580. if (!spec->multiout.hp_nid)
  10581. spec->multiout.hp_nid = nid;
  10582. else
  10583. spec->multiout.extra_out_nid[0] = nid;
  10584. /* control HP volume/switch on the output mixer amp */
  10585. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10586. sprintf(name, "%s Playback Volume", pfx);
  10587. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10588. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10589. if (err < 0)
  10590. return err;
  10591. sprintf(name, "%s Playback Switch", pfx);
  10592. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10593. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10594. if (err < 0)
  10595. return err;
  10596. } else if (alc880_is_multi_pin(pin)) {
  10597. /* set manual connection */
  10598. /* we have only a switch on HP-out PIN */
  10599. sprintf(name, "%s Playback Switch", pfx);
  10600. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10601. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10602. if (err < 0)
  10603. return err;
  10604. }
  10605. return 0;
  10606. }
  10607. /* create playback/capture controls for input pins */
  10608. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10609. const struct auto_pin_cfg *cfg)
  10610. {
  10611. struct hda_input_mux *imux = &spec->private_imux;
  10612. int i, err, idx;
  10613. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10614. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10615. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10616. err = new_analog_input(spec, cfg->input_pins[i],
  10617. auto_pin_cfg_labels[i],
  10618. idx, 0x0b);
  10619. if (err < 0)
  10620. return err;
  10621. imux->items[imux->num_items].label =
  10622. auto_pin_cfg_labels[i];
  10623. imux->items[imux->num_items].index =
  10624. alc880_input_pin_idx(cfg->input_pins[i]);
  10625. imux->num_items++;
  10626. }
  10627. }
  10628. return 0;
  10629. }
  10630. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10631. hda_nid_t nid, int pin_type,
  10632. int dac_idx)
  10633. {
  10634. /* set as output */
  10635. snd_hda_codec_write(codec, nid, 0,
  10636. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10637. snd_hda_codec_write(codec, nid, 0,
  10638. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10639. /* need the manual connection? */
  10640. if (alc880_is_multi_pin(nid)) {
  10641. struct alc_spec *spec = codec->spec;
  10642. int idx = alc880_multi_pin_idx(nid);
  10643. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10644. AC_VERB_SET_CONNECT_SEL,
  10645. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10646. }
  10647. }
  10648. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10649. {
  10650. struct alc_spec *spec = codec->spec;
  10651. int i;
  10652. for (i = 0; i <= HDA_SIDE; i++) {
  10653. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10654. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10655. if (nid)
  10656. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10657. i);
  10658. }
  10659. }
  10660. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10661. {
  10662. struct alc_spec *spec = codec->spec;
  10663. hda_nid_t pin;
  10664. pin = spec->autocfg.hp_pins[0];
  10665. if (pin) /* connect to front */
  10666. /* use dac 0 */
  10667. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10668. }
  10669. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10670. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10671. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10672. {
  10673. struct alc_spec *spec = codec->spec;
  10674. int i;
  10675. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10676. hda_nid_t nid = spec->autocfg.input_pins[i];
  10677. if (alc662_is_input_pin(nid)) {
  10678. snd_hda_codec_write(codec, nid, 0,
  10679. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10680. (i <= AUTO_PIN_FRONT_MIC ?
  10681. PIN_VREF80 : PIN_IN));
  10682. if (nid != ALC662_PIN_CD_NID)
  10683. snd_hda_codec_write(codec, nid, 0,
  10684. AC_VERB_SET_AMP_GAIN_MUTE,
  10685. AMP_OUT_MUTE);
  10686. }
  10687. }
  10688. }
  10689. static int alc662_parse_auto_config(struct hda_codec *codec)
  10690. {
  10691. struct alc_spec *spec = codec->spec;
  10692. int err;
  10693. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10694. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10695. alc662_ignore);
  10696. if (err < 0)
  10697. return err;
  10698. if (!spec->autocfg.line_outs)
  10699. return 0; /* can't find valid BIOS pin config */
  10700. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10701. if (err < 0)
  10702. return err;
  10703. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10704. if (err < 0)
  10705. return err;
  10706. err = alc662_auto_create_extra_out(spec,
  10707. spec->autocfg.speaker_pins[0],
  10708. "Speaker");
  10709. if (err < 0)
  10710. return err;
  10711. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10712. "Headphone");
  10713. if (err < 0)
  10714. return err;
  10715. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10716. if (err < 0)
  10717. return err;
  10718. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10719. if (spec->autocfg.dig_out_pin)
  10720. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10721. if (spec->kctl_alloc)
  10722. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10723. spec->num_mux_defs = 1;
  10724. spec->input_mux = &spec->private_imux;
  10725. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10726. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10727. spec->num_mixers++;
  10728. return 1;
  10729. }
  10730. /* additional initialization for auto-configuration model */
  10731. static void alc662_auto_init(struct hda_codec *codec)
  10732. {
  10733. alc662_auto_init_multi_out(codec);
  10734. alc662_auto_init_hp_out(codec);
  10735. alc662_auto_init_analog_input(codec);
  10736. }
  10737. static int patch_alc662(struct hda_codec *codec)
  10738. {
  10739. struct alc_spec *spec;
  10740. int err, board_config;
  10741. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10742. if (!spec)
  10743. return -ENOMEM;
  10744. codec->spec = spec;
  10745. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10746. alc662_models,
  10747. alc662_cfg_tbl);
  10748. if (board_config < 0) {
  10749. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10750. "trying auto-probe from BIOS...\n");
  10751. board_config = ALC662_AUTO;
  10752. }
  10753. if (board_config == ALC662_AUTO) {
  10754. /* automatic parse from the BIOS config */
  10755. err = alc662_parse_auto_config(codec);
  10756. if (err < 0) {
  10757. alc_free(codec);
  10758. return err;
  10759. } else if (!err) {
  10760. printk(KERN_INFO
  10761. "hda_codec: Cannot set up configuration "
  10762. "from BIOS. Using base mode...\n");
  10763. board_config = ALC662_3ST_2ch_DIG;
  10764. }
  10765. }
  10766. if (board_config != ALC662_AUTO)
  10767. setup_preset(spec, &alc662_presets[board_config]);
  10768. spec->stream_name_analog = "ALC662 Analog";
  10769. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10770. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10771. spec->stream_name_digital = "ALC662 Digital";
  10772. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10773. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10774. if (!spec->adc_nids && spec->input_mux) {
  10775. spec->adc_nids = alc662_adc_nids;
  10776. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10777. }
  10778. codec->patch_ops = alc_patch_ops;
  10779. if (board_config == ALC662_AUTO)
  10780. spec->init_hook = alc662_auto_init;
  10781. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10782. if (!spec->loopback.amplist)
  10783. spec->loopback.amplist = alc662_loopbacks;
  10784. #endif
  10785. return 0;
  10786. }
  10787. /*
  10788. * patch entries
  10789. */
  10790. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10791. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10792. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10793. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10794. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10795. .patch = patch_alc861 },
  10796. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10797. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10798. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10799. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10800. .patch = patch_alc883 },
  10801. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10802. .patch = patch_alc662 },
  10803. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10804. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10805. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10806. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10807. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10808. {} /* terminator */
  10809. };