patch_realtek.c 408 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352
  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_ASUS_EEEPC_P701,
  138. ALC662_AUTO,
  139. ALC662_MODEL_LAST,
  140. };
  141. /* ALC882 models */
  142. enum {
  143. ALC882_3ST_DIG,
  144. ALC882_6ST_DIG,
  145. ALC882_ARIMA,
  146. ALC882_W2JC,
  147. ALC882_TARGA,
  148. ALC882_ASUS_A7J,
  149. ALC882_ASUS_A7M,
  150. ALC885_MACPRO,
  151. ALC885_MBP3,
  152. ALC885_IMAC24,
  153. ALC882_AUTO,
  154. ALC882_MODEL_LAST,
  155. };
  156. /* ALC883 models */
  157. enum {
  158. ALC883_3ST_2ch_DIG,
  159. ALC883_3ST_6ch_DIG,
  160. ALC883_3ST_6ch,
  161. ALC883_6ST_DIG,
  162. ALC883_TARGA_DIG,
  163. ALC883_TARGA_2ch_DIG,
  164. ALC883_ACER,
  165. ALC883_ACER_ASPIRE,
  166. ALC883_MEDION,
  167. ALC883_MEDION_MD2,
  168. ALC883_LAPTOP_EAPD,
  169. ALC883_LENOVO_101E_2ch,
  170. ALC883_LENOVO_NB0763,
  171. ALC888_LENOVO_MS7195_DIG,
  172. ALC883_HAIER_W66,
  173. ALC888_6ST_HP,
  174. ALC888_3ST_HP,
  175. ALC883_AUTO,
  176. ALC883_MODEL_LAST,
  177. };
  178. /* for GPIO Poll */
  179. #define GPIO_MASK 0x03
  180. struct alc_spec {
  181. /* codec parameterization */
  182. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  183. unsigned int num_mixers;
  184. const struct hda_verb *init_verbs[5]; /* initialization verbs
  185. * don't forget NULL
  186. * termination!
  187. */
  188. unsigned int num_init_verbs;
  189. char *stream_name_analog; /* analog PCM stream */
  190. struct hda_pcm_stream *stream_analog_playback;
  191. struct hda_pcm_stream *stream_analog_capture;
  192. char *stream_name_digital; /* digital PCM stream */
  193. struct hda_pcm_stream *stream_digital_playback;
  194. struct hda_pcm_stream *stream_digital_capture;
  195. /* playback */
  196. struct hda_multi_out multiout; /* playback set-up
  197. * max_channels, dacs must be set
  198. * dig_out_nid and hp_nid are optional
  199. */
  200. /* capture */
  201. unsigned int num_adc_nids;
  202. hda_nid_t *adc_nids;
  203. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  204. /* capture source */
  205. unsigned int num_mux_defs;
  206. const struct hda_input_mux *input_mux;
  207. unsigned int cur_mux[3];
  208. /* channel model */
  209. const struct hda_channel_mode *channel_mode;
  210. int num_channel_mode;
  211. int need_dac_fix;
  212. /* PCM information */
  213. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  214. /* dynamic controls, init_verbs and input_mux */
  215. struct auto_pin_cfg autocfg;
  216. unsigned int num_kctl_alloc, num_kctl_used;
  217. struct snd_kcontrol_new *kctl_alloc;
  218. struct hda_input_mux private_imux;
  219. hda_nid_t private_dac_nids[5];
  220. /* hooks */
  221. void (*init_hook)(struct hda_codec *codec);
  222. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  223. /* for pin sensing */
  224. unsigned int sense_updated: 1;
  225. unsigned int jack_present: 1;
  226. #ifdef CONFIG_SND_HDA_POWER_SAVE
  227. struct hda_loopback_check loopback;
  228. #endif
  229. };
  230. /*
  231. * configuration template - to be copied to the spec instance
  232. */
  233. struct alc_config_preset {
  234. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  235. * with spec
  236. */
  237. const struct hda_verb *init_verbs[5];
  238. unsigned int num_dacs;
  239. hda_nid_t *dac_nids;
  240. hda_nid_t dig_out_nid; /* optional */
  241. hda_nid_t hp_nid; /* optional */
  242. unsigned int num_adc_nids;
  243. hda_nid_t *adc_nids;
  244. hda_nid_t dig_in_nid;
  245. unsigned int num_channel_mode;
  246. const struct hda_channel_mode *channel_mode;
  247. int need_dac_fix;
  248. unsigned int num_mux_defs;
  249. const struct hda_input_mux *input_mux;
  250. void (*unsol_event)(struct hda_codec *, unsigned int);
  251. void (*init_hook)(struct hda_codec *);
  252. #ifdef CONFIG_SND_HDA_POWER_SAVE
  253. struct hda_amp_list *loopbacks;
  254. #endif
  255. };
  256. /*
  257. * input MUX handling
  258. */
  259. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  265. if (mux_idx >= spec->num_mux_defs)
  266. mux_idx = 0;
  267. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  268. }
  269. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  270. struct snd_ctl_elem_value *ucontrol)
  271. {
  272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  273. struct alc_spec *spec = codec->spec;
  274. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  275. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  276. return 0;
  277. }
  278. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_value *ucontrol)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  284. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  285. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  286. spec->adc_nids[adc_idx],
  287. &spec->cur_mux[adc_idx]);
  288. }
  289. /*
  290. * channel mode setting
  291. */
  292. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  293. struct snd_ctl_elem_info *uinfo)
  294. {
  295. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  296. struct alc_spec *spec = codec->spec;
  297. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  298. spec->num_channel_mode);
  299. }
  300. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  301. struct snd_ctl_elem_value *ucontrol)
  302. {
  303. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  304. struct alc_spec *spec = codec->spec;
  305. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  306. spec->num_channel_mode,
  307. spec->multiout.max_channels);
  308. }
  309. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_value *ucontrol)
  311. {
  312. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  313. struct alc_spec *spec = codec->spec;
  314. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  315. spec->num_channel_mode,
  316. &spec->multiout.max_channels);
  317. if (err >= 0 && spec->need_dac_fix)
  318. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  319. return err;
  320. }
  321. /*
  322. * Control the mode of pin widget settings via the mixer. "pc" is used
  323. * instead of "%" to avoid consequences of accidently treating the % as
  324. * being part of a format specifier. Maximum allowed length of a value is
  325. * 63 characters plus NULL terminator.
  326. *
  327. * Note: some retasking pin complexes seem to ignore requests for input
  328. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  329. * are requested. Therefore order this list so that this behaviour will not
  330. * cause problems when mixer clients move through the enum sequentially.
  331. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  332. * March 2006.
  333. */
  334. static char *alc_pin_mode_names[] = {
  335. "Mic 50pc bias", "Mic 80pc bias",
  336. "Line in", "Line out", "Headphone out",
  337. };
  338. static unsigned char alc_pin_mode_values[] = {
  339. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  340. };
  341. /* The control can present all 5 options, or it can limit the options based
  342. * in the pin being assumed to be exclusively an input or an output pin. In
  343. * addition, "input" pins may or may not process the mic bias option
  344. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  345. * accept requests for bias as of chip versions up to March 2006) and/or
  346. * wiring in the computer.
  347. */
  348. #define ALC_PIN_DIR_IN 0x00
  349. #define ALC_PIN_DIR_OUT 0x01
  350. #define ALC_PIN_DIR_INOUT 0x02
  351. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  352. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  353. /* Info about the pin modes supported by the different pin direction modes.
  354. * For each direction the minimum and maximum values are given.
  355. */
  356. static signed char alc_pin_mode_dir_info[5][2] = {
  357. { 0, 2 }, /* ALC_PIN_DIR_IN */
  358. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  359. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  360. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  361. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  362. };
  363. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  364. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  365. #define alc_pin_mode_n_items(_dir) \
  366. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  367. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  368. struct snd_ctl_elem_info *uinfo)
  369. {
  370. unsigned int item_num = uinfo->value.enumerated.item;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  373. uinfo->count = 1;
  374. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  375. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  376. item_num = alc_pin_mode_min(dir);
  377. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  378. return 0;
  379. }
  380. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. unsigned int i;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long *valp = ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. /* Find enumerated value for current pinctl setting */
  392. i = alc_pin_mode_min(dir);
  393. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  394. i++;
  395. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  396. return 0;
  397. }
  398. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_value *ucontrol)
  400. {
  401. signed int change;
  402. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  403. hda_nid_t nid = kcontrol->private_value & 0xffff;
  404. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  405. long val = *ucontrol->value.integer.value;
  406. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  407. AC_VERB_GET_PIN_WIDGET_CONTROL,
  408. 0x00);
  409. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  410. val = alc_pin_mode_min(dir);
  411. change = pinctl != alc_pin_mode_values[val];
  412. if (change) {
  413. /* Set pin mode to that requested */
  414. snd_hda_codec_write_cache(codec, nid, 0,
  415. AC_VERB_SET_PIN_WIDGET_CONTROL,
  416. alc_pin_mode_values[val]);
  417. /* Also enable the retasking pin's input/output as required
  418. * for the requested pin mode. Enum values of 2 or less are
  419. * input modes.
  420. *
  421. * Dynamically switching the input/output buffers probably
  422. * reduces noise slightly (particularly on input) so we'll
  423. * do it. However, having both input and output buffers
  424. * enabled simultaneously doesn't seem to be problematic if
  425. * this turns out to be necessary in the future.
  426. */
  427. if (val <= 2) {
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  429. HDA_AMP_MUTE, HDA_AMP_MUTE);
  430. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  431. HDA_AMP_MUTE, 0);
  432. } else {
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  434. HDA_AMP_MUTE, HDA_AMP_MUTE);
  435. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  436. HDA_AMP_MUTE, 0);
  437. }
  438. }
  439. return change;
  440. }
  441. #define ALC_PIN_MODE(xname, nid, dir) \
  442. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  443. .info = alc_pin_mode_info, \
  444. .get = alc_pin_mode_get, \
  445. .put = alc_pin_mode_put, \
  446. .private_value = nid | (dir<<16) }
  447. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  448. * together using a mask with more than one bit set. This control is
  449. * currently used only by the ALC260 test model. At this stage they are not
  450. * needed for any "production" models.
  451. */
  452. #ifdef CONFIG_SND_DEBUG
  453. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  454. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  455. struct snd_ctl_elem_value *ucontrol)
  456. {
  457. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  458. hda_nid_t nid = kcontrol->private_value & 0xffff;
  459. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  460. long *valp = ucontrol->value.integer.value;
  461. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  462. AC_VERB_GET_GPIO_DATA, 0x00);
  463. *valp = (val & mask) != 0;
  464. return 0;
  465. }
  466. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_value *ucontrol)
  468. {
  469. signed int change;
  470. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  471. hda_nid_t nid = kcontrol->private_value & 0xffff;
  472. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  473. long val = *ucontrol->value.integer.value;
  474. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  475. AC_VERB_GET_GPIO_DATA,
  476. 0x00);
  477. /* Set/unset the masked GPIO bit(s) as needed */
  478. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  479. if (val == 0)
  480. gpio_data &= ~mask;
  481. else
  482. gpio_data |= mask;
  483. snd_hda_codec_write_cache(codec, nid, 0,
  484. AC_VERB_SET_GPIO_DATA, gpio_data);
  485. return change;
  486. }
  487. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  488. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  489. .info = alc_gpio_data_info, \
  490. .get = alc_gpio_data_get, \
  491. .put = alc_gpio_data_put, \
  492. .private_value = nid | (mask<<16) }
  493. #endif /* CONFIG_SND_DEBUG */
  494. /* A switch control to allow the enabling of the digital IO pins on the
  495. * ALC260. This is incredibly simplistic; the intention of this control is
  496. * to provide something in the test model allowing digital outputs to be
  497. * identified if present. If models are found which can utilise these
  498. * outputs a more complete mixer control can be devised for those models if
  499. * necessary.
  500. */
  501. #ifdef CONFIG_SND_DEBUG
  502. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. #ifdef CONFIG_SND_HDA_POWER_SAVE
  574. spec->loopback.amplist = preset->loopbacks;
  575. #endif
  576. }
  577. /* Enable GPIO mask and set output */
  578. static struct hda_verb alc_gpio1_init_verbs[] = {
  579. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  582. { }
  583. };
  584. static struct hda_verb alc_gpio2_init_verbs[] = {
  585. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  588. { }
  589. };
  590. static struct hda_verb alc_gpio3_init_verbs[] = {
  591. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  594. { }
  595. };
  596. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  597. * 31 ~ 16 : Manufacture ID
  598. * 15 ~ 8 : SKU ID
  599. * 7 ~ 0 : Assembly ID
  600. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  601. */
  602. static void alc_subsystem_id(struct hda_codec *codec,
  603. unsigned int porta, unsigned int porte,
  604. unsigned int portd)
  605. {
  606. unsigned int ass, tmp;
  607. ass = codec->subsystem_id;
  608. if (!(ass & 1))
  609. return;
  610. /* Override */
  611. tmp = (ass & 0x38) >> 3; /* external Amp control */
  612. switch (tmp) {
  613. case 1:
  614. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  615. break;
  616. case 3:
  617. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  618. break;
  619. case 7:
  620. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  621. break;
  622. case 5:
  623. switch (codec->vendor_id) {
  624. case 0x10ec0862:
  625. case 0x10ec0660:
  626. case 0x10ec0662:
  627. case 0x10ec0267:
  628. case 0x10ec0268:
  629. snd_hda_codec_write(codec, 0x14, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. snd_hda_codec_write(codec, 0x15, 0,
  632. AC_VERB_SET_EAPD_BTLENABLE, 2);
  633. return;
  634. }
  635. case 6:
  636. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  637. hda_nid_t port = 0;
  638. tmp = (ass & 0x1800) >> 11;
  639. switch (tmp) {
  640. case 0: port = porta; break;
  641. case 1: port = porte; break;
  642. case 2: port = portd; break;
  643. }
  644. if (port)
  645. snd_hda_codec_write(codec, port, 0,
  646. AC_VERB_SET_EAPD_BTLENABLE,
  647. 2);
  648. }
  649. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  650. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  651. (tmp == 5 ? 0x3040 : 0x3050));
  652. break;
  653. }
  654. }
  655. /*
  656. * Fix-up pin default configurations
  657. */
  658. struct alc_pincfg {
  659. hda_nid_t nid;
  660. u32 val;
  661. };
  662. static void alc_fix_pincfg(struct hda_codec *codec,
  663. const struct snd_pci_quirk *quirk,
  664. const struct alc_pincfg **pinfix)
  665. {
  666. const struct alc_pincfg *cfg;
  667. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  668. if (!quirk)
  669. return;
  670. cfg = pinfix[quirk->value];
  671. for (; cfg->nid; cfg++) {
  672. int i;
  673. u32 val = cfg->val;
  674. for (i = 0; i < 4; i++) {
  675. snd_hda_codec_write(codec, cfg->nid, 0,
  676. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  677. val & 0xff);
  678. val >>= 8;
  679. }
  680. }
  681. }
  682. /*
  683. * ALC880 3-stack model
  684. *
  685. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  686. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  687. * F-Mic = 0x1b, HP = 0x19
  688. */
  689. static hda_nid_t alc880_dac_nids[4] = {
  690. /* front, rear, clfe, rear_surr */
  691. 0x02, 0x05, 0x04, 0x03
  692. };
  693. static hda_nid_t alc880_adc_nids[3] = {
  694. /* ADC0-2 */
  695. 0x07, 0x08, 0x09,
  696. };
  697. /* The datasheet says the node 0x07 is connected from inputs,
  698. * but it shows zero connection in the real implementation on some devices.
  699. * Note: this is a 915GAV bug, fixed on 915GLV
  700. */
  701. static hda_nid_t alc880_adc_nids_alt[2] = {
  702. /* ADC1-2 */
  703. 0x08, 0x09,
  704. };
  705. #define ALC880_DIGOUT_NID 0x06
  706. #define ALC880_DIGIN_NID 0x0a
  707. static struct hda_input_mux alc880_capture_source = {
  708. .num_items = 4,
  709. .items = {
  710. { "Mic", 0x0 },
  711. { "Front Mic", 0x3 },
  712. { "Line", 0x2 },
  713. { "CD", 0x4 },
  714. },
  715. };
  716. /* channel source setting (2/6 channel selection for 3-stack) */
  717. /* 2ch mode */
  718. static struct hda_verb alc880_threestack_ch2_init[] = {
  719. /* set line-in to input, mute it */
  720. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  721. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  722. /* set mic-in to input vref 80%, mute it */
  723. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  724. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  725. { } /* end */
  726. };
  727. /* 6ch mode */
  728. static struct hda_verb alc880_threestack_ch6_init[] = {
  729. /* set line-in to output, unmute it */
  730. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  731. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  732. /* set mic-in to output, unmute it */
  733. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  734. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  735. { } /* end */
  736. };
  737. static struct hda_channel_mode alc880_threestack_modes[2] = {
  738. { 2, alc880_threestack_ch2_init },
  739. { 6, alc880_threestack_ch6_init },
  740. };
  741. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  742. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  745. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  746. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  747. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  748. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  749. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  750. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  751. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  753. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  755. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  758. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  759. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  760. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  761. {
  762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  763. .name = "Channel Mode",
  764. .info = alc_ch_mode_info,
  765. .get = alc_ch_mode_get,
  766. .put = alc_ch_mode_put,
  767. },
  768. { } /* end */
  769. };
  770. /* capture mixer elements */
  771. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  772. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  776. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  777. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  778. {
  779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  780. /* The multiple "Capture Source" controls confuse alsamixer
  781. * So call somewhat different..
  782. * FIXME: the controls appear in the "playback" view!
  783. */
  784. /* .name = "Capture Source", */
  785. .name = "Input Source",
  786. .count = 3,
  787. .info = alc_mux_enum_info,
  788. .get = alc_mux_enum_get,
  789. .put = alc_mux_enum_put,
  790. },
  791. { } /* end */
  792. };
  793. /* capture mixer elements (in case NID 0x07 not available) */
  794. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  795. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  797. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  798. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  799. {
  800. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  801. /* The multiple "Capture Source" controls confuse alsamixer
  802. * So call somewhat different..
  803. * FIXME: the controls appear in the "playback" view!
  804. */
  805. /* .name = "Capture Source", */
  806. .name = "Input Source",
  807. .count = 2,
  808. .info = alc_mux_enum_info,
  809. .get = alc_mux_enum_get,
  810. .put = alc_mux_enum_put,
  811. },
  812. { } /* end */
  813. };
  814. /*
  815. * ALC880 5-stack model
  816. *
  817. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  818. * Side = 0x02 (0xd)
  819. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  820. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  821. */
  822. /* additional mixers to alc880_three_stack_mixer */
  823. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  824. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  825. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  826. { } /* end */
  827. };
  828. /* channel source setting (6/8 channel selection for 5-stack) */
  829. /* 6ch mode */
  830. static struct hda_verb alc880_fivestack_ch6_init[] = {
  831. /* set line-in to input, mute it */
  832. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  833. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  834. { } /* end */
  835. };
  836. /* 8ch mode */
  837. static struct hda_verb alc880_fivestack_ch8_init[] = {
  838. /* set line-in to output, unmute it */
  839. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  840. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  841. { } /* end */
  842. };
  843. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  844. { 6, alc880_fivestack_ch6_init },
  845. { 8, alc880_fivestack_ch8_init },
  846. };
  847. /*
  848. * ALC880 6-stack model
  849. *
  850. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  851. * Side = 0x05 (0x0f)
  852. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  853. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  854. */
  855. static hda_nid_t alc880_6st_dac_nids[4] = {
  856. /* front, rear, clfe, rear_surr */
  857. 0x02, 0x03, 0x04, 0x05
  858. };
  859. static struct hda_input_mux alc880_6stack_capture_source = {
  860. .num_items = 4,
  861. .items = {
  862. { "Mic", 0x0 },
  863. { "Front Mic", 0x1 },
  864. { "Line", 0x2 },
  865. { "CD", 0x4 },
  866. },
  867. };
  868. /* fixed 8-channels */
  869. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  870. { 8, NULL },
  871. };
  872. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  873. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  877. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  878. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  879. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  880. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  882. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  883. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  884. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  886. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  888. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  890. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  891. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  892. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  893. {
  894. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  895. .name = "Channel Mode",
  896. .info = alc_ch_mode_info,
  897. .get = alc_ch_mode_get,
  898. .put = alc_ch_mode_put,
  899. },
  900. { } /* end */
  901. };
  902. /*
  903. * ALC880 W810 model
  904. *
  905. * W810 has rear IO for:
  906. * Front (DAC 02)
  907. * Surround (DAC 03)
  908. * Center/LFE (DAC 04)
  909. * Digital out (06)
  910. *
  911. * The system also has a pair of internal speakers, and a headphone jack.
  912. * These are both connected to Line2 on the codec, hence to DAC 02.
  913. *
  914. * There is a variable resistor to control the speaker or headphone
  915. * volume. This is a hardware-only device without a software API.
  916. *
  917. * Plugging headphones in will disable the internal speakers. This is
  918. * implemented in hardware, not via the driver using jack sense. In
  919. * a similar fashion, plugging into the rear socket marked "front" will
  920. * disable both the speakers and headphones.
  921. *
  922. * For input, there's a microphone jack, and an "audio in" jack.
  923. * These may not do anything useful with this driver yet, because I
  924. * haven't setup any initialization verbs for these yet...
  925. */
  926. static hda_nid_t alc880_w810_dac_nids[3] = {
  927. /* front, rear/surround, clfe */
  928. 0x02, 0x03, 0x04
  929. };
  930. /* fixed 6 channels */
  931. static struct hda_channel_mode alc880_w810_modes[1] = {
  932. { 6, NULL }
  933. };
  934. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  935. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  936. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  939. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  940. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  941. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  942. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  943. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  944. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  945. { } /* end */
  946. };
  947. /*
  948. * Z710V model
  949. *
  950. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  951. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  952. * Line = 0x1a
  953. */
  954. static hda_nid_t alc880_z71v_dac_nids[1] = {
  955. 0x02
  956. };
  957. #define ALC880_Z71V_HP_DAC 0x03
  958. /* fixed 2 channels */
  959. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  960. { 2, NULL }
  961. };
  962. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  963. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  966. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  967. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  968. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  969. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  970. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  971. { } /* end */
  972. };
  973. /* FIXME! */
  974. /*
  975. * ALC880 F1734 model
  976. *
  977. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  978. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  979. */
  980. static hda_nid_t alc880_f1734_dac_nids[1] = {
  981. 0x03
  982. };
  983. #define ALC880_F1734_HP_DAC 0x02
  984. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  985. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  988. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  989. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  990. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  991. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  992. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  993. { } /* end */
  994. };
  995. /* FIXME! */
  996. /*
  997. * ALC880 ASUS model
  998. *
  999. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1000. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1001. * Mic = 0x18, Line = 0x1a
  1002. */
  1003. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1004. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1005. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1006. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1011. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1013. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1015. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1019. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1020. {
  1021. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1022. .name = "Channel Mode",
  1023. .info = alc_ch_mode_info,
  1024. .get = alc_ch_mode_get,
  1025. .put = alc_ch_mode_put,
  1026. },
  1027. { } /* end */
  1028. };
  1029. /* FIXME! */
  1030. /*
  1031. * ALC880 ASUS W1V model
  1032. *
  1033. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1034. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1035. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1036. */
  1037. /* additional mixers to alc880_asus_mixer */
  1038. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1039. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1040. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1041. { } /* end */
  1042. };
  1043. /* additional mixers to alc880_asus_mixer */
  1044. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1045. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1046. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1047. { } /* end */
  1048. };
  1049. /* TCL S700 */
  1050. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1051. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1054. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1055. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1059. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1060. {
  1061. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1062. /* The multiple "Capture Source" controls confuse alsamixer
  1063. * So call somewhat different..
  1064. * FIXME: the controls appear in the "playback" view!
  1065. */
  1066. /* .name = "Capture Source", */
  1067. .name = "Input Source",
  1068. .count = 1,
  1069. .info = alc_mux_enum_info,
  1070. .get = alc_mux_enum_get,
  1071. .put = alc_mux_enum_put,
  1072. },
  1073. { } /* end */
  1074. };
  1075. /* Uniwill */
  1076. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1077. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1080. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1081. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1082. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1083. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1084. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1086. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1092. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1093. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1094. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1095. {
  1096. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1097. .name = "Channel Mode",
  1098. .info = alc_ch_mode_info,
  1099. .get = alc_ch_mode_get,
  1100. .put = alc_ch_mode_put,
  1101. },
  1102. { } /* end */
  1103. };
  1104. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1105. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1108. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1110. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1113. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1114. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1115. { } /* end */
  1116. };
  1117. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1118. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1121. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1122. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1123. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1124. { } /* end */
  1125. };
  1126. /*
  1127. * build control elements
  1128. */
  1129. static int alc_build_controls(struct hda_codec *codec)
  1130. {
  1131. struct alc_spec *spec = codec->spec;
  1132. int err;
  1133. int i;
  1134. for (i = 0; i < spec->num_mixers; i++) {
  1135. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1136. if (err < 0)
  1137. return err;
  1138. }
  1139. if (spec->multiout.dig_out_nid) {
  1140. err = snd_hda_create_spdif_out_ctls(codec,
  1141. spec->multiout.dig_out_nid);
  1142. if (err < 0)
  1143. return err;
  1144. }
  1145. if (spec->dig_in_nid) {
  1146. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1147. if (err < 0)
  1148. return err;
  1149. }
  1150. return 0;
  1151. }
  1152. /*
  1153. * initialize the codec volumes, etc
  1154. */
  1155. /*
  1156. * generic initialization of ADC, input mixers and output mixers
  1157. */
  1158. static struct hda_verb alc880_volume_init_verbs[] = {
  1159. /*
  1160. * Unmute ADC0-2 and set the default input to mic-in
  1161. */
  1162. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1167. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1168. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1169. * mixer widget
  1170. * Note: PASD motherboards uses the Line In 2 as the input for front
  1171. * panel mic (mic 2)
  1172. */
  1173. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1181. /*
  1182. * Set up output mixers (0x0c - 0x0f)
  1183. */
  1184. /* set vol=0 to output mixers */
  1185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1188. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1189. /* set up input amps for analog loopback */
  1190. /* Amp Indices: DAC = 0, mixer = 1 */
  1191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1199. { }
  1200. };
  1201. /*
  1202. * 3-stack pin configuration:
  1203. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1204. */
  1205. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1206. /*
  1207. * preset connection lists of input pins
  1208. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1209. */
  1210. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1211. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1212. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1213. /*
  1214. * Set pin mode and muting
  1215. */
  1216. /* set front pin widgets 0x14 for output */
  1217. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1218. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1219. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1220. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1221. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1222. /* Mic2 (as headphone out) for HP output */
  1223. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1224. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. /* Line In pin widget for input */
  1226. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1227. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1228. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1229. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1230. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1231. /* CD pin widget for input */
  1232. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1233. { }
  1234. };
  1235. /*
  1236. * 5-stack pin configuration:
  1237. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1238. * line-in/side = 0x1a, f-mic = 0x1b
  1239. */
  1240. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1241. /*
  1242. * preset connection lists of input pins
  1243. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1244. */
  1245. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1246. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1247. /*
  1248. * Set pin mode and muting
  1249. */
  1250. /* set pin widgets 0x14-0x17 for output */
  1251. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1255. /* unmute pins for output (no gain on this amp) */
  1256. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1259. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1260. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1261. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1262. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1263. /* Mic2 (as headphone out) for HP output */
  1264. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1265. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1266. /* Line In pin widget for input */
  1267. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1268. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1269. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1270. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1271. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1272. /* CD pin widget for input */
  1273. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1274. { }
  1275. };
  1276. /*
  1277. * W810 pin configuration:
  1278. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1279. */
  1280. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1281. /* hphone/speaker input selector: front DAC */
  1282. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1283. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1288. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1289. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1290. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1291. { }
  1292. };
  1293. /*
  1294. * Z71V pin configuration:
  1295. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1296. */
  1297. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1298. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1299. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1301. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1302. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1305. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1306. { }
  1307. };
  1308. /*
  1309. * 6-stack pin configuration:
  1310. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1311. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1312. */
  1313. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1314. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1315. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1322. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1323. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1329. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1330. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1331. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1332. { }
  1333. };
  1334. /*
  1335. * Uniwill pin configuration:
  1336. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1337. * line = 0x1a
  1338. */
  1339. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1340. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1341. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1346. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1348. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1354. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1355. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1358. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1360. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1361. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1362. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1363. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1364. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1365. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1366. { }
  1367. };
  1368. /*
  1369. * Uniwill P53
  1370. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1371. */
  1372. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1373. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1374. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1379. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1385. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1386. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1389. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1391. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1392. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1393. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1394. { }
  1395. };
  1396. static struct hda_verb alc880_beep_init_verbs[] = {
  1397. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1398. { }
  1399. };
  1400. /* toggle speaker-output according to the hp-jack state */
  1401. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1402. {
  1403. unsigned int present;
  1404. unsigned char bits;
  1405. present = snd_hda_codec_read(codec, 0x14, 0,
  1406. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1407. bits = present ? HDA_AMP_MUTE : 0;
  1408. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1409. HDA_AMP_MUTE, bits);
  1410. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1411. HDA_AMP_MUTE, bits);
  1412. }
  1413. /* auto-toggle front mic */
  1414. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1415. {
  1416. unsigned int present;
  1417. unsigned char bits;
  1418. present = snd_hda_codec_read(codec, 0x18, 0,
  1419. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1420. bits = present ? HDA_AMP_MUTE : 0;
  1421. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1422. }
  1423. static void alc880_uniwill_automute(struct hda_codec *codec)
  1424. {
  1425. alc880_uniwill_hp_automute(codec);
  1426. alc880_uniwill_mic_automute(codec);
  1427. }
  1428. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1429. unsigned int res)
  1430. {
  1431. /* Looks like the unsol event is incompatible with the standard
  1432. * definition. 4bit tag is placed at 28 bit!
  1433. */
  1434. switch (res >> 28) {
  1435. case ALC880_HP_EVENT:
  1436. alc880_uniwill_hp_automute(codec);
  1437. break;
  1438. case ALC880_MIC_EVENT:
  1439. alc880_uniwill_mic_automute(codec);
  1440. break;
  1441. }
  1442. }
  1443. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1444. {
  1445. unsigned int present;
  1446. unsigned char bits;
  1447. present = snd_hda_codec_read(codec, 0x14, 0,
  1448. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1449. bits = present ? HDA_AMP_MUTE : 0;
  1450. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1451. }
  1452. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1453. {
  1454. unsigned int present;
  1455. present = snd_hda_codec_read(codec, 0x21, 0,
  1456. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1457. present &= HDA_AMP_VOLMASK;
  1458. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1459. HDA_AMP_VOLMASK, present);
  1460. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1461. HDA_AMP_VOLMASK, present);
  1462. }
  1463. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1464. unsigned int res)
  1465. {
  1466. /* Looks like the unsol event is incompatible with the standard
  1467. * definition. 4bit tag is placed at 28 bit!
  1468. */
  1469. if ((res >> 28) == ALC880_HP_EVENT)
  1470. alc880_uniwill_p53_hp_automute(codec);
  1471. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1472. alc880_uniwill_p53_dcvol_automute(codec);
  1473. }
  1474. /* FIXME! */
  1475. /*
  1476. * F1734 pin configuration:
  1477. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1478. */
  1479. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1480. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1481. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1482. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1483. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1484. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1485. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1487. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1488. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1489. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1490. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1491. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1492. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1495. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1496. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1497. { }
  1498. };
  1499. /* FIXME! */
  1500. /*
  1501. * ASUS pin configuration:
  1502. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1503. */
  1504. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1505. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1506. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1507. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1508. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1509. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1517. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1521. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1522. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1523. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1524. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1526. { }
  1527. };
  1528. /* Enable GPIO mask and set output */
  1529. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1530. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1531. /* Clevo m520g init */
  1532. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1533. /* headphone output */
  1534. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1535. /* line-out */
  1536. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1537. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1538. /* Line-in */
  1539. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1540. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1541. /* CD */
  1542. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1543. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1544. /* Mic1 (rear panel) */
  1545. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1546. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1547. /* Mic2 (front panel) */
  1548. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1549. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1550. /* headphone */
  1551. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1552. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1553. /* change to EAPD mode */
  1554. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1555. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1556. { }
  1557. };
  1558. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1559. /* change to EAPD mode */
  1560. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1561. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1562. /* Headphone output */
  1563. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1564. /* Front output*/
  1565. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1566. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1567. /* Line In pin widget for input */
  1568. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1569. /* CD pin widget for input */
  1570. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1571. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1572. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1573. /* change to EAPD mode */
  1574. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1575. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1576. { }
  1577. };
  1578. /*
  1579. * LG m1 express dual
  1580. *
  1581. * Pin assignment:
  1582. * Rear Line-In/Out (blue): 0x14
  1583. * Build-in Mic-In: 0x15
  1584. * Speaker-out: 0x17
  1585. * HP-Out (green): 0x1b
  1586. * Mic-In/Out (red): 0x19
  1587. * SPDIF-Out: 0x1e
  1588. */
  1589. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1590. static hda_nid_t alc880_lg_dac_nids[3] = {
  1591. 0x05, 0x02, 0x03
  1592. };
  1593. /* seems analog CD is not working */
  1594. static struct hda_input_mux alc880_lg_capture_source = {
  1595. .num_items = 3,
  1596. .items = {
  1597. { "Mic", 0x1 },
  1598. { "Line", 0x5 },
  1599. { "Internal Mic", 0x6 },
  1600. },
  1601. };
  1602. /* 2,4,6 channel modes */
  1603. static struct hda_verb alc880_lg_ch2_init[] = {
  1604. /* set line-in and mic-in to input */
  1605. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1606. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1607. { }
  1608. };
  1609. static struct hda_verb alc880_lg_ch4_init[] = {
  1610. /* set line-in to out and mic-in to input */
  1611. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1612. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1613. { }
  1614. };
  1615. static struct hda_verb alc880_lg_ch6_init[] = {
  1616. /* set line-in and mic-in to output */
  1617. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1618. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1619. { }
  1620. };
  1621. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1622. { 2, alc880_lg_ch2_init },
  1623. { 4, alc880_lg_ch4_init },
  1624. { 6, alc880_lg_ch6_init },
  1625. };
  1626. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1627. /* FIXME: it's not really "master" but front channels */
  1628. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1629. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1630. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1631. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1632. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1633. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1634. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1635. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1638. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1639. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1640. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1641. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1642. {
  1643. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1644. .name = "Channel Mode",
  1645. .info = alc_ch_mode_info,
  1646. .get = alc_ch_mode_get,
  1647. .put = alc_ch_mode_put,
  1648. },
  1649. { } /* end */
  1650. };
  1651. static struct hda_verb alc880_lg_init_verbs[] = {
  1652. /* set capture source to mic-in */
  1653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1655. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1656. /* mute all amp mixer inputs */
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1659. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1660. /* line-in to input */
  1661. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1662. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1663. /* built-in mic */
  1664. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1665. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1666. /* speaker-out */
  1667. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1668. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1669. /* mic-in to input */
  1670. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1671. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1672. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1673. /* HP-out */
  1674. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1675. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1676. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1677. /* jack sense */
  1678. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1679. { }
  1680. };
  1681. /* toggle speaker-output according to the hp-jack state */
  1682. static void alc880_lg_automute(struct hda_codec *codec)
  1683. {
  1684. unsigned int present;
  1685. unsigned char bits;
  1686. present = snd_hda_codec_read(codec, 0x1b, 0,
  1687. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1688. bits = present ? HDA_AMP_MUTE : 0;
  1689. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1690. HDA_AMP_MUTE, bits);
  1691. }
  1692. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1693. {
  1694. /* Looks like the unsol event is incompatible with the standard
  1695. * definition. 4bit tag is placed at 28 bit!
  1696. */
  1697. if ((res >> 28) == 0x01)
  1698. alc880_lg_automute(codec);
  1699. }
  1700. /*
  1701. * LG LW20
  1702. *
  1703. * Pin assignment:
  1704. * Speaker-out: 0x14
  1705. * Mic-In: 0x18
  1706. * Built-in Mic-In: 0x19
  1707. * Line-In: 0x1b
  1708. * HP-Out: 0x1a
  1709. * SPDIF-Out: 0x1e
  1710. */
  1711. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1712. .num_items = 3,
  1713. .items = {
  1714. { "Mic", 0x0 },
  1715. { "Internal Mic", 0x1 },
  1716. { "Line In", 0x2 },
  1717. },
  1718. };
  1719. #define alc880_lg_lw_modes alc880_threestack_modes
  1720. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1721. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1722. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1723. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1724. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1725. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1726. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1727. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1728. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1729. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1730. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1731. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1732. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1733. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1734. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1735. {
  1736. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1737. .name = "Channel Mode",
  1738. .info = alc_ch_mode_info,
  1739. .get = alc_ch_mode_get,
  1740. .put = alc_ch_mode_put,
  1741. },
  1742. { } /* end */
  1743. };
  1744. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1745. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1746. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1747. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1748. /* set capture source to mic-in */
  1749. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1751. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1752. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1753. /* speaker-out */
  1754. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1755. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1756. /* HP-out */
  1757. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1758. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1759. /* mic-in to input */
  1760. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1761. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1762. /* built-in mic */
  1763. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1764. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1765. /* jack sense */
  1766. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1767. { }
  1768. };
  1769. /* toggle speaker-output according to the hp-jack state */
  1770. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1771. {
  1772. unsigned int present;
  1773. unsigned char bits;
  1774. present = snd_hda_codec_read(codec, 0x1b, 0,
  1775. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1776. bits = present ? HDA_AMP_MUTE : 0;
  1777. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1778. HDA_AMP_MUTE, bits);
  1779. }
  1780. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1781. {
  1782. /* Looks like the unsol event is incompatible with the standard
  1783. * definition. 4bit tag is placed at 28 bit!
  1784. */
  1785. if ((res >> 28) == 0x01)
  1786. alc880_lg_lw_automute(codec);
  1787. }
  1788. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1789. static struct hda_amp_list alc880_loopbacks[] = {
  1790. { 0x0b, HDA_INPUT, 0 },
  1791. { 0x0b, HDA_INPUT, 1 },
  1792. { 0x0b, HDA_INPUT, 2 },
  1793. { 0x0b, HDA_INPUT, 3 },
  1794. { 0x0b, HDA_INPUT, 4 },
  1795. { } /* end */
  1796. };
  1797. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1798. { 0x0b, HDA_INPUT, 1 },
  1799. { 0x0b, HDA_INPUT, 6 },
  1800. { 0x0b, HDA_INPUT, 7 },
  1801. { } /* end */
  1802. };
  1803. #endif
  1804. /*
  1805. * Common callbacks
  1806. */
  1807. static int alc_init(struct hda_codec *codec)
  1808. {
  1809. struct alc_spec *spec = codec->spec;
  1810. unsigned int i;
  1811. for (i = 0; i < spec->num_init_verbs; i++)
  1812. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1813. if (spec->init_hook)
  1814. spec->init_hook(codec);
  1815. return 0;
  1816. }
  1817. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1818. {
  1819. struct alc_spec *spec = codec->spec;
  1820. if (spec->unsol_event)
  1821. spec->unsol_event(codec, res);
  1822. }
  1823. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1824. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1825. {
  1826. struct alc_spec *spec = codec->spec;
  1827. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1828. }
  1829. #endif
  1830. /*
  1831. * Analog playback callbacks
  1832. */
  1833. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1834. struct hda_codec *codec,
  1835. struct snd_pcm_substream *substream)
  1836. {
  1837. struct alc_spec *spec = codec->spec;
  1838. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1839. }
  1840. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1841. struct hda_codec *codec,
  1842. unsigned int stream_tag,
  1843. unsigned int format,
  1844. struct snd_pcm_substream *substream)
  1845. {
  1846. struct alc_spec *spec = codec->spec;
  1847. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1848. stream_tag, format, substream);
  1849. }
  1850. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1851. struct hda_codec *codec,
  1852. struct snd_pcm_substream *substream)
  1853. {
  1854. struct alc_spec *spec = codec->spec;
  1855. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1856. }
  1857. /*
  1858. * Digital out
  1859. */
  1860. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1861. struct hda_codec *codec,
  1862. struct snd_pcm_substream *substream)
  1863. {
  1864. struct alc_spec *spec = codec->spec;
  1865. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1866. }
  1867. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1868. struct hda_codec *codec,
  1869. unsigned int stream_tag,
  1870. unsigned int format,
  1871. struct snd_pcm_substream *substream)
  1872. {
  1873. struct alc_spec *spec = codec->spec;
  1874. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1875. stream_tag, format, substream);
  1876. }
  1877. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1878. struct hda_codec *codec,
  1879. struct snd_pcm_substream *substream)
  1880. {
  1881. struct alc_spec *spec = codec->spec;
  1882. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1883. }
  1884. /*
  1885. * Analog capture
  1886. */
  1887. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1888. struct hda_codec *codec,
  1889. unsigned int stream_tag,
  1890. unsigned int format,
  1891. struct snd_pcm_substream *substream)
  1892. {
  1893. struct alc_spec *spec = codec->spec;
  1894. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1895. stream_tag, 0, format);
  1896. return 0;
  1897. }
  1898. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1899. struct hda_codec *codec,
  1900. struct snd_pcm_substream *substream)
  1901. {
  1902. struct alc_spec *spec = codec->spec;
  1903. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1904. 0, 0, 0);
  1905. return 0;
  1906. }
  1907. /*
  1908. */
  1909. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1910. .substreams = 1,
  1911. .channels_min = 2,
  1912. .channels_max = 8,
  1913. /* NID is set in alc_build_pcms */
  1914. .ops = {
  1915. .open = alc880_playback_pcm_open,
  1916. .prepare = alc880_playback_pcm_prepare,
  1917. .cleanup = alc880_playback_pcm_cleanup
  1918. },
  1919. };
  1920. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1921. .substreams = 2,
  1922. .channels_min = 2,
  1923. .channels_max = 2,
  1924. /* NID is set in alc_build_pcms */
  1925. .ops = {
  1926. .prepare = alc880_capture_pcm_prepare,
  1927. .cleanup = alc880_capture_pcm_cleanup
  1928. },
  1929. };
  1930. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1931. .substreams = 1,
  1932. .channels_min = 2,
  1933. .channels_max = 2,
  1934. /* NID is set in alc_build_pcms */
  1935. .ops = {
  1936. .open = alc880_dig_playback_pcm_open,
  1937. .close = alc880_dig_playback_pcm_close,
  1938. .prepare = alc880_dig_playback_pcm_prepare
  1939. },
  1940. };
  1941. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1942. .substreams = 1,
  1943. .channels_min = 2,
  1944. .channels_max = 2,
  1945. /* NID is set in alc_build_pcms */
  1946. };
  1947. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1948. static struct hda_pcm_stream alc_pcm_null_playback = {
  1949. .substreams = 0,
  1950. .channels_min = 0,
  1951. .channels_max = 0,
  1952. };
  1953. static int alc_build_pcms(struct hda_codec *codec)
  1954. {
  1955. struct alc_spec *spec = codec->spec;
  1956. struct hda_pcm *info = spec->pcm_rec;
  1957. int i;
  1958. codec->num_pcms = 1;
  1959. codec->pcm_info = info;
  1960. info->name = spec->stream_name_analog;
  1961. if (spec->stream_analog_playback) {
  1962. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1963. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1964. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1965. }
  1966. if (spec->stream_analog_capture) {
  1967. snd_assert(spec->adc_nids, return -EINVAL);
  1968. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1969. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1970. }
  1971. if (spec->channel_mode) {
  1972. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1973. for (i = 0; i < spec->num_channel_mode; i++) {
  1974. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1975. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1976. }
  1977. }
  1978. }
  1979. /* SPDIF for stream index #1 */
  1980. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1981. codec->num_pcms = 2;
  1982. info = spec->pcm_rec + 1;
  1983. info->name = spec->stream_name_digital;
  1984. if (spec->multiout.dig_out_nid &&
  1985. spec->stream_digital_playback) {
  1986. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1987. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1988. }
  1989. if (spec->dig_in_nid &&
  1990. spec->stream_digital_capture) {
  1991. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1992. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1993. }
  1994. }
  1995. /* If the use of more than one ADC is requested for the current
  1996. * model, configure a second analog capture-only PCM.
  1997. */
  1998. /* Additional Analaog capture for index #2 */
  1999. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2000. spec->adc_nids) {
  2001. codec->num_pcms = 3;
  2002. info = spec->pcm_rec + 2;
  2003. info->name = spec->stream_name_analog;
  2004. /* No playback stream for second PCM */
  2005. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2006. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2007. if (spec->stream_analog_capture) {
  2008. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2009. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2010. }
  2011. }
  2012. return 0;
  2013. }
  2014. static void alc_free(struct hda_codec *codec)
  2015. {
  2016. struct alc_spec *spec = codec->spec;
  2017. unsigned int i;
  2018. if (!spec)
  2019. return;
  2020. if (spec->kctl_alloc) {
  2021. for (i = 0; i < spec->num_kctl_used; i++)
  2022. kfree(spec->kctl_alloc[i].name);
  2023. kfree(spec->kctl_alloc);
  2024. }
  2025. kfree(spec);
  2026. }
  2027. /*
  2028. */
  2029. static struct hda_codec_ops alc_patch_ops = {
  2030. .build_controls = alc_build_controls,
  2031. .build_pcms = alc_build_pcms,
  2032. .init = alc_init,
  2033. .free = alc_free,
  2034. .unsol_event = alc_unsol_event,
  2035. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2036. .check_power_status = alc_check_power_status,
  2037. #endif
  2038. };
  2039. /*
  2040. * Test configuration for debugging
  2041. *
  2042. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2043. * enum controls.
  2044. */
  2045. #ifdef CONFIG_SND_DEBUG
  2046. static hda_nid_t alc880_test_dac_nids[4] = {
  2047. 0x02, 0x03, 0x04, 0x05
  2048. };
  2049. static struct hda_input_mux alc880_test_capture_source = {
  2050. .num_items = 7,
  2051. .items = {
  2052. { "In-1", 0x0 },
  2053. { "In-2", 0x1 },
  2054. { "In-3", 0x2 },
  2055. { "In-4", 0x3 },
  2056. { "CD", 0x4 },
  2057. { "Front", 0x5 },
  2058. { "Surround", 0x6 },
  2059. },
  2060. };
  2061. static struct hda_channel_mode alc880_test_modes[4] = {
  2062. { 2, NULL },
  2063. { 4, NULL },
  2064. { 6, NULL },
  2065. { 8, NULL },
  2066. };
  2067. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2068. struct snd_ctl_elem_info *uinfo)
  2069. {
  2070. static char *texts[] = {
  2071. "N/A", "Line Out", "HP Out",
  2072. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2073. };
  2074. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2075. uinfo->count = 1;
  2076. uinfo->value.enumerated.items = 8;
  2077. if (uinfo->value.enumerated.item >= 8)
  2078. uinfo->value.enumerated.item = 7;
  2079. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2080. return 0;
  2081. }
  2082. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2083. struct snd_ctl_elem_value *ucontrol)
  2084. {
  2085. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2086. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2087. unsigned int pin_ctl, item = 0;
  2088. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2089. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2090. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2091. if (pin_ctl & AC_PINCTL_HP_EN)
  2092. item = 2;
  2093. else
  2094. item = 1;
  2095. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2096. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2097. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2098. case AC_PINCTL_VREF_50: item = 4; break;
  2099. case AC_PINCTL_VREF_GRD: item = 5; break;
  2100. case AC_PINCTL_VREF_80: item = 6; break;
  2101. case AC_PINCTL_VREF_100: item = 7; break;
  2102. }
  2103. }
  2104. ucontrol->value.enumerated.item[0] = item;
  2105. return 0;
  2106. }
  2107. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2108. struct snd_ctl_elem_value *ucontrol)
  2109. {
  2110. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2111. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2112. static unsigned int ctls[] = {
  2113. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2117. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2118. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2119. };
  2120. unsigned int old_ctl, new_ctl;
  2121. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2122. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2123. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2124. if (old_ctl != new_ctl) {
  2125. int val;
  2126. snd_hda_codec_write_cache(codec, nid, 0,
  2127. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2128. new_ctl);
  2129. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2130. HDA_AMP_MUTE : 0;
  2131. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2132. HDA_AMP_MUTE, val);
  2133. return 1;
  2134. }
  2135. return 0;
  2136. }
  2137. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2138. struct snd_ctl_elem_info *uinfo)
  2139. {
  2140. static char *texts[] = {
  2141. "Front", "Surround", "CLFE", "Side"
  2142. };
  2143. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2144. uinfo->count = 1;
  2145. uinfo->value.enumerated.items = 4;
  2146. if (uinfo->value.enumerated.item >= 4)
  2147. uinfo->value.enumerated.item = 3;
  2148. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2149. return 0;
  2150. }
  2151. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2152. struct snd_ctl_elem_value *ucontrol)
  2153. {
  2154. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2155. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2156. unsigned int sel;
  2157. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2158. ucontrol->value.enumerated.item[0] = sel & 3;
  2159. return 0;
  2160. }
  2161. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2162. struct snd_ctl_elem_value *ucontrol)
  2163. {
  2164. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2165. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2166. unsigned int sel;
  2167. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2168. if (ucontrol->value.enumerated.item[0] != sel) {
  2169. sel = ucontrol->value.enumerated.item[0] & 3;
  2170. snd_hda_codec_write_cache(codec, nid, 0,
  2171. AC_VERB_SET_CONNECT_SEL, sel);
  2172. return 1;
  2173. }
  2174. return 0;
  2175. }
  2176. #define PIN_CTL_TEST(xname,nid) { \
  2177. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2178. .name = xname, \
  2179. .info = alc_test_pin_ctl_info, \
  2180. .get = alc_test_pin_ctl_get, \
  2181. .put = alc_test_pin_ctl_put, \
  2182. .private_value = nid \
  2183. }
  2184. #define PIN_SRC_TEST(xname,nid) { \
  2185. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2186. .name = xname, \
  2187. .info = alc_test_pin_src_info, \
  2188. .get = alc_test_pin_src_get, \
  2189. .put = alc_test_pin_src_put, \
  2190. .private_value = nid \
  2191. }
  2192. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2193. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2195. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2196. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2197. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2199. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2200. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2201. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2202. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2203. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2204. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2205. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2206. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2207. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2208. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2209. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2210. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2211. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2212. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2213. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2214. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2215. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2216. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2217. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2218. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2219. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2220. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2221. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2222. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2223. {
  2224. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2225. .name = "Channel Mode",
  2226. .info = alc_ch_mode_info,
  2227. .get = alc_ch_mode_get,
  2228. .put = alc_ch_mode_put,
  2229. },
  2230. { } /* end */
  2231. };
  2232. static struct hda_verb alc880_test_init_verbs[] = {
  2233. /* Unmute inputs of 0x0c - 0x0f */
  2234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2235. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2237. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2238. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2239. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2240. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2241. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2242. /* Vol output for 0x0c-0x0f */
  2243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2247. /* Set output pins 0x14-0x17 */
  2248. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2251. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2252. /* Unmute output pins 0x14-0x17 */
  2253. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2256. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2257. /* Set input pins 0x18-0x1c */
  2258. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2259. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2260. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2262. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2263. /* Mute input pins 0x18-0x1b */
  2264. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2267. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2268. /* ADC set up */
  2269. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2272. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2273. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2274. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2275. /* Analog input/passthru */
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2280. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2281. { }
  2282. };
  2283. #endif
  2284. /*
  2285. */
  2286. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2287. [ALC880_3ST] = "3stack",
  2288. [ALC880_TCL_S700] = "tcl",
  2289. [ALC880_3ST_DIG] = "3stack-digout",
  2290. [ALC880_CLEVO] = "clevo",
  2291. [ALC880_5ST] = "5stack",
  2292. [ALC880_5ST_DIG] = "5stack-digout",
  2293. [ALC880_W810] = "w810",
  2294. [ALC880_Z71V] = "z71v",
  2295. [ALC880_6ST] = "6stack",
  2296. [ALC880_6ST_DIG] = "6stack-digout",
  2297. [ALC880_ASUS] = "asus",
  2298. [ALC880_ASUS_W1V] = "asus-w1v",
  2299. [ALC880_ASUS_DIG] = "asus-dig",
  2300. [ALC880_ASUS_DIG2] = "asus-dig2",
  2301. [ALC880_UNIWILL_DIG] = "uniwill",
  2302. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2303. [ALC880_FUJITSU] = "fujitsu",
  2304. [ALC880_F1734] = "F1734",
  2305. [ALC880_LG] = "lg",
  2306. [ALC880_LG_LW] = "lg-lw",
  2307. #ifdef CONFIG_SND_DEBUG
  2308. [ALC880_TEST] = "test",
  2309. #endif
  2310. [ALC880_AUTO] = "auto",
  2311. };
  2312. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2313. /* Broken BIOS configuration */
  2314. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2316. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2317. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2318. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2319. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2323. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2324. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2325. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2326. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2327. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2328. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2332. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2333. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2334. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2335. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2338. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2339. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2340. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2341. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2342. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2343. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2344. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2346. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2347. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2348. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2349. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2350. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2351. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2352. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2353. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2354. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2358. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2359. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2360. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2361. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2362. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2363. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2364. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2365. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2366. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2367. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2368. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2369. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2370. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2371. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2372. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2382. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2383. {}
  2384. };
  2385. /*
  2386. * ALC880 codec presets
  2387. */
  2388. static struct alc_config_preset alc880_presets[] = {
  2389. [ALC880_3ST] = {
  2390. .mixers = { alc880_three_stack_mixer },
  2391. .init_verbs = { alc880_volume_init_verbs,
  2392. alc880_pin_3stack_init_verbs },
  2393. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2394. .dac_nids = alc880_dac_nids,
  2395. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2396. .channel_mode = alc880_threestack_modes,
  2397. .need_dac_fix = 1,
  2398. .input_mux = &alc880_capture_source,
  2399. },
  2400. [ALC880_3ST_DIG] = {
  2401. .mixers = { alc880_three_stack_mixer },
  2402. .init_verbs = { alc880_volume_init_verbs,
  2403. alc880_pin_3stack_init_verbs },
  2404. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2405. .dac_nids = alc880_dac_nids,
  2406. .dig_out_nid = ALC880_DIGOUT_NID,
  2407. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2408. .channel_mode = alc880_threestack_modes,
  2409. .need_dac_fix = 1,
  2410. .input_mux = &alc880_capture_source,
  2411. },
  2412. [ALC880_TCL_S700] = {
  2413. .mixers = { alc880_tcl_s700_mixer },
  2414. .init_verbs = { alc880_volume_init_verbs,
  2415. alc880_pin_tcl_S700_init_verbs,
  2416. alc880_gpio2_init_verbs },
  2417. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2418. .dac_nids = alc880_dac_nids,
  2419. .hp_nid = 0x03,
  2420. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2421. .channel_mode = alc880_2_jack_modes,
  2422. .input_mux = &alc880_capture_source,
  2423. },
  2424. [ALC880_5ST] = {
  2425. .mixers = { alc880_three_stack_mixer,
  2426. alc880_five_stack_mixer},
  2427. .init_verbs = { alc880_volume_init_verbs,
  2428. alc880_pin_5stack_init_verbs },
  2429. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2430. .dac_nids = alc880_dac_nids,
  2431. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2432. .channel_mode = alc880_fivestack_modes,
  2433. .input_mux = &alc880_capture_source,
  2434. },
  2435. [ALC880_5ST_DIG] = {
  2436. .mixers = { alc880_three_stack_mixer,
  2437. alc880_five_stack_mixer },
  2438. .init_verbs = { alc880_volume_init_verbs,
  2439. alc880_pin_5stack_init_verbs },
  2440. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2441. .dac_nids = alc880_dac_nids,
  2442. .dig_out_nid = ALC880_DIGOUT_NID,
  2443. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2444. .channel_mode = alc880_fivestack_modes,
  2445. .input_mux = &alc880_capture_source,
  2446. },
  2447. [ALC880_6ST] = {
  2448. .mixers = { alc880_six_stack_mixer },
  2449. .init_verbs = { alc880_volume_init_verbs,
  2450. alc880_pin_6stack_init_verbs },
  2451. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2452. .dac_nids = alc880_6st_dac_nids,
  2453. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2454. .channel_mode = alc880_sixstack_modes,
  2455. .input_mux = &alc880_6stack_capture_source,
  2456. },
  2457. [ALC880_6ST_DIG] = {
  2458. .mixers = { alc880_six_stack_mixer },
  2459. .init_verbs = { alc880_volume_init_verbs,
  2460. alc880_pin_6stack_init_verbs },
  2461. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2462. .dac_nids = alc880_6st_dac_nids,
  2463. .dig_out_nid = ALC880_DIGOUT_NID,
  2464. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2465. .channel_mode = alc880_sixstack_modes,
  2466. .input_mux = &alc880_6stack_capture_source,
  2467. },
  2468. [ALC880_W810] = {
  2469. .mixers = { alc880_w810_base_mixer },
  2470. .init_verbs = { alc880_volume_init_verbs,
  2471. alc880_pin_w810_init_verbs,
  2472. alc880_gpio2_init_verbs },
  2473. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2474. .dac_nids = alc880_w810_dac_nids,
  2475. .dig_out_nid = ALC880_DIGOUT_NID,
  2476. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2477. .channel_mode = alc880_w810_modes,
  2478. .input_mux = &alc880_capture_source,
  2479. },
  2480. [ALC880_Z71V] = {
  2481. .mixers = { alc880_z71v_mixer },
  2482. .init_verbs = { alc880_volume_init_verbs,
  2483. alc880_pin_z71v_init_verbs },
  2484. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2485. .dac_nids = alc880_z71v_dac_nids,
  2486. .dig_out_nid = ALC880_DIGOUT_NID,
  2487. .hp_nid = 0x03,
  2488. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2489. .channel_mode = alc880_2_jack_modes,
  2490. .input_mux = &alc880_capture_source,
  2491. },
  2492. [ALC880_F1734] = {
  2493. .mixers = { alc880_f1734_mixer },
  2494. .init_verbs = { alc880_volume_init_verbs,
  2495. alc880_pin_f1734_init_verbs },
  2496. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2497. .dac_nids = alc880_f1734_dac_nids,
  2498. .hp_nid = 0x02,
  2499. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2500. .channel_mode = alc880_2_jack_modes,
  2501. .input_mux = &alc880_capture_source,
  2502. },
  2503. [ALC880_ASUS] = {
  2504. .mixers = { alc880_asus_mixer },
  2505. .init_verbs = { alc880_volume_init_verbs,
  2506. alc880_pin_asus_init_verbs,
  2507. alc880_gpio1_init_verbs },
  2508. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2509. .dac_nids = alc880_asus_dac_nids,
  2510. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2511. .channel_mode = alc880_asus_modes,
  2512. .need_dac_fix = 1,
  2513. .input_mux = &alc880_capture_source,
  2514. },
  2515. [ALC880_ASUS_DIG] = {
  2516. .mixers = { alc880_asus_mixer },
  2517. .init_verbs = { alc880_volume_init_verbs,
  2518. alc880_pin_asus_init_verbs,
  2519. alc880_gpio1_init_verbs },
  2520. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2521. .dac_nids = alc880_asus_dac_nids,
  2522. .dig_out_nid = ALC880_DIGOUT_NID,
  2523. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2524. .channel_mode = alc880_asus_modes,
  2525. .need_dac_fix = 1,
  2526. .input_mux = &alc880_capture_source,
  2527. },
  2528. [ALC880_ASUS_DIG2] = {
  2529. .mixers = { alc880_asus_mixer },
  2530. .init_verbs = { alc880_volume_init_verbs,
  2531. alc880_pin_asus_init_verbs,
  2532. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2533. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2534. .dac_nids = alc880_asus_dac_nids,
  2535. .dig_out_nid = ALC880_DIGOUT_NID,
  2536. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2537. .channel_mode = alc880_asus_modes,
  2538. .need_dac_fix = 1,
  2539. .input_mux = &alc880_capture_source,
  2540. },
  2541. [ALC880_ASUS_W1V] = {
  2542. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2543. .init_verbs = { alc880_volume_init_verbs,
  2544. alc880_pin_asus_init_verbs,
  2545. alc880_gpio1_init_verbs },
  2546. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2547. .dac_nids = alc880_asus_dac_nids,
  2548. .dig_out_nid = ALC880_DIGOUT_NID,
  2549. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2550. .channel_mode = alc880_asus_modes,
  2551. .need_dac_fix = 1,
  2552. .input_mux = &alc880_capture_source,
  2553. },
  2554. [ALC880_UNIWILL_DIG] = {
  2555. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2556. .init_verbs = { alc880_volume_init_verbs,
  2557. alc880_pin_asus_init_verbs },
  2558. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2559. .dac_nids = alc880_asus_dac_nids,
  2560. .dig_out_nid = ALC880_DIGOUT_NID,
  2561. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2562. .channel_mode = alc880_asus_modes,
  2563. .need_dac_fix = 1,
  2564. .input_mux = &alc880_capture_source,
  2565. },
  2566. [ALC880_UNIWILL] = {
  2567. .mixers = { alc880_uniwill_mixer },
  2568. .init_verbs = { alc880_volume_init_verbs,
  2569. alc880_uniwill_init_verbs },
  2570. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2571. .dac_nids = alc880_asus_dac_nids,
  2572. .dig_out_nid = ALC880_DIGOUT_NID,
  2573. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2574. .channel_mode = alc880_threestack_modes,
  2575. .need_dac_fix = 1,
  2576. .input_mux = &alc880_capture_source,
  2577. .unsol_event = alc880_uniwill_unsol_event,
  2578. .init_hook = alc880_uniwill_automute,
  2579. },
  2580. [ALC880_UNIWILL_P53] = {
  2581. .mixers = { alc880_uniwill_p53_mixer },
  2582. .init_verbs = { alc880_volume_init_verbs,
  2583. alc880_uniwill_p53_init_verbs },
  2584. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2585. .dac_nids = alc880_asus_dac_nids,
  2586. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2587. .channel_mode = alc880_threestack_modes,
  2588. .input_mux = &alc880_capture_source,
  2589. .unsol_event = alc880_uniwill_p53_unsol_event,
  2590. .init_hook = alc880_uniwill_p53_hp_automute,
  2591. },
  2592. [ALC880_FUJITSU] = {
  2593. .mixers = { alc880_fujitsu_mixer,
  2594. alc880_pcbeep_mixer, },
  2595. .init_verbs = { alc880_volume_init_verbs,
  2596. alc880_uniwill_p53_init_verbs,
  2597. alc880_beep_init_verbs },
  2598. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2599. .dac_nids = alc880_dac_nids,
  2600. .dig_out_nid = ALC880_DIGOUT_NID,
  2601. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2602. .channel_mode = alc880_2_jack_modes,
  2603. .input_mux = &alc880_capture_source,
  2604. .unsol_event = alc880_uniwill_p53_unsol_event,
  2605. .init_hook = alc880_uniwill_p53_hp_automute,
  2606. },
  2607. [ALC880_CLEVO] = {
  2608. .mixers = { alc880_three_stack_mixer },
  2609. .init_verbs = { alc880_volume_init_verbs,
  2610. alc880_pin_clevo_init_verbs },
  2611. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2612. .dac_nids = alc880_dac_nids,
  2613. .hp_nid = 0x03,
  2614. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2615. .channel_mode = alc880_threestack_modes,
  2616. .need_dac_fix = 1,
  2617. .input_mux = &alc880_capture_source,
  2618. },
  2619. [ALC880_LG] = {
  2620. .mixers = { alc880_lg_mixer },
  2621. .init_verbs = { alc880_volume_init_verbs,
  2622. alc880_lg_init_verbs },
  2623. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2624. .dac_nids = alc880_lg_dac_nids,
  2625. .dig_out_nid = ALC880_DIGOUT_NID,
  2626. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2627. .channel_mode = alc880_lg_ch_modes,
  2628. .need_dac_fix = 1,
  2629. .input_mux = &alc880_lg_capture_source,
  2630. .unsol_event = alc880_lg_unsol_event,
  2631. .init_hook = alc880_lg_automute,
  2632. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2633. .loopbacks = alc880_lg_loopbacks,
  2634. #endif
  2635. },
  2636. [ALC880_LG_LW] = {
  2637. .mixers = { alc880_lg_lw_mixer },
  2638. .init_verbs = { alc880_volume_init_verbs,
  2639. alc880_lg_lw_init_verbs },
  2640. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2641. .dac_nids = alc880_dac_nids,
  2642. .dig_out_nid = ALC880_DIGOUT_NID,
  2643. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2644. .channel_mode = alc880_lg_lw_modes,
  2645. .input_mux = &alc880_lg_lw_capture_source,
  2646. .unsol_event = alc880_lg_lw_unsol_event,
  2647. .init_hook = alc880_lg_lw_automute,
  2648. },
  2649. #ifdef CONFIG_SND_DEBUG
  2650. [ALC880_TEST] = {
  2651. .mixers = { alc880_test_mixer },
  2652. .init_verbs = { alc880_test_init_verbs },
  2653. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2654. .dac_nids = alc880_test_dac_nids,
  2655. .dig_out_nid = ALC880_DIGOUT_NID,
  2656. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2657. .channel_mode = alc880_test_modes,
  2658. .input_mux = &alc880_test_capture_source,
  2659. },
  2660. #endif
  2661. };
  2662. /*
  2663. * Automatic parse of I/O pins from the BIOS configuration
  2664. */
  2665. #define NUM_CONTROL_ALLOC 32
  2666. #define NUM_VERB_ALLOC 32
  2667. enum {
  2668. ALC_CTL_WIDGET_VOL,
  2669. ALC_CTL_WIDGET_MUTE,
  2670. ALC_CTL_BIND_MUTE,
  2671. };
  2672. static struct snd_kcontrol_new alc880_control_templates[] = {
  2673. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2674. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2675. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2676. };
  2677. /* add dynamic controls */
  2678. static int add_control(struct alc_spec *spec, int type, const char *name,
  2679. unsigned long val)
  2680. {
  2681. struct snd_kcontrol_new *knew;
  2682. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2683. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2684. /* array + terminator */
  2685. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2686. if (!knew)
  2687. return -ENOMEM;
  2688. if (spec->kctl_alloc) {
  2689. memcpy(knew, spec->kctl_alloc,
  2690. sizeof(*knew) * spec->num_kctl_alloc);
  2691. kfree(spec->kctl_alloc);
  2692. }
  2693. spec->kctl_alloc = knew;
  2694. spec->num_kctl_alloc = num;
  2695. }
  2696. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2697. *knew = alc880_control_templates[type];
  2698. knew->name = kstrdup(name, GFP_KERNEL);
  2699. if (!knew->name)
  2700. return -ENOMEM;
  2701. knew->private_value = val;
  2702. spec->num_kctl_used++;
  2703. return 0;
  2704. }
  2705. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2706. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2707. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2708. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2709. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2710. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2711. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2712. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2713. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2714. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2715. #define ALC880_PIN_CD_NID 0x1c
  2716. /* fill in the dac_nids table from the parsed pin configuration */
  2717. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2718. const struct auto_pin_cfg *cfg)
  2719. {
  2720. hda_nid_t nid;
  2721. int assigned[4];
  2722. int i, j;
  2723. memset(assigned, 0, sizeof(assigned));
  2724. spec->multiout.dac_nids = spec->private_dac_nids;
  2725. /* check the pins hardwired to audio widget */
  2726. for (i = 0; i < cfg->line_outs; i++) {
  2727. nid = cfg->line_out_pins[i];
  2728. if (alc880_is_fixed_pin(nid)) {
  2729. int idx = alc880_fixed_pin_idx(nid);
  2730. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2731. assigned[idx] = 1;
  2732. }
  2733. }
  2734. /* left pins can be connect to any audio widget */
  2735. for (i = 0; i < cfg->line_outs; i++) {
  2736. nid = cfg->line_out_pins[i];
  2737. if (alc880_is_fixed_pin(nid))
  2738. continue;
  2739. /* search for an empty channel */
  2740. for (j = 0; j < cfg->line_outs; j++) {
  2741. if (!assigned[j]) {
  2742. spec->multiout.dac_nids[i] =
  2743. alc880_idx_to_dac(j);
  2744. assigned[j] = 1;
  2745. break;
  2746. }
  2747. }
  2748. }
  2749. spec->multiout.num_dacs = cfg->line_outs;
  2750. return 0;
  2751. }
  2752. /* add playback controls from the parsed DAC table */
  2753. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2754. const struct auto_pin_cfg *cfg)
  2755. {
  2756. char name[32];
  2757. static const char *chname[4] = {
  2758. "Front", "Surround", NULL /*CLFE*/, "Side"
  2759. };
  2760. hda_nid_t nid;
  2761. int i, err;
  2762. for (i = 0; i < cfg->line_outs; i++) {
  2763. if (!spec->multiout.dac_nids[i])
  2764. continue;
  2765. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2766. if (i == 2) {
  2767. /* Center/LFE */
  2768. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2769. "Center Playback Volume",
  2770. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2771. HDA_OUTPUT));
  2772. if (err < 0)
  2773. return err;
  2774. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2775. "LFE Playback Volume",
  2776. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2777. HDA_OUTPUT));
  2778. if (err < 0)
  2779. return err;
  2780. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2781. "Center Playback Switch",
  2782. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2783. HDA_INPUT));
  2784. if (err < 0)
  2785. return err;
  2786. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2787. "LFE Playback Switch",
  2788. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2789. HDA_INPUT));
  2790. if (err < 0)
  2791. return err;
  2792. } else {
  2793. sprintf(name, "%s Playback Volume", chname[i]);
  2794. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2795. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2796. HDA_OUTPUT));
  2797. if (err < 0)
  2798. return err;
  2799. sprintf(name, "%s Playback Switch", chname[i]);
  2800. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2801. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2802. HDA_INPUT));
  2803. if (err < 0)
  2804. return err;
  2805. }
  2806. }
  2807. return 0;
  2808. }
  2809. /* add playback controls for speaker and HP outputs */
  2810. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2811. const char *pfx)
  2812. {
  2813. hda_nid_t nid;
  2814. int err;
  2815. char name[32];
  2816. if (!pin)
  2817. return 0;
  2818. if (alc880_is_fixed_pin(pin)) {
  2819. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2820. /* specify the DAC as the extra output */
  2821. if (!spec->multiout.hp_nid)
  2822. spec->multiout.hp_nid = nid;
  2823. else
  2824. spec->multiout.extra_out_nid[0] = nid;
  2825. /* control HP volume/switch on the output mixer amp */
  2826. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2827. sprintf(name, "%s Playback Volume", pfx);
  2828. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2829. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2830. if (err < 0)
  2831. return err;
  2832. sprintf(name, "%s Playback Switch", pfx);
  2833. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2834. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2835. if (err < 0)
  2836. return err;
  2837. } else if (alc880_is_multi_pin(pin)) {
  2838. /* set manual connection */
  2839. /* we have only a switch on HP-out PIN */
  2840. sprintf(name, "%s Playback Switch", pfx);
  2841. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2842. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2843. if (err < 0)
  2844. return err;
  2845. }
  2846. return 0;
  2847. }
  2848. /* create input playback/capture controls for the given pin */
  2849. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2850. const char *ctlname,
  2851. int idx, hda_nid_t mix_nid)
  2852. {
  2853. char name[32];
  2854. int err;
  2855. sprintf(name, "%s Playback Volume", ctlname);
  2856. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2857. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2858. if (err < 0)
  2859. return err;
  2860. sprintf(name, "%s Playback Switch", ctlname);
  2861. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2862. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2863. if (err < 0)
  2864. return err;
  2865. return 0;
  2866. }
  2867. /* create playback/capture controls for input pins */
  2868. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2869. const struct auto_pin_cfg *cfg)
  2870. {
  2871. struct hda_input_mux *imux = &spec->private_imux;
  2872. int i, err, idx;
  2873. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2874. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2875. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2876. err = new_analog_input(spec, cfg->input_pins[i],
  2877. auto_pin_cfg_labels[i],
  2878. idx, 0x0b);
  2879. if (err < 0)
  2880. return err;
  2881. imux->items[imux->num_items].label =
  2882. auto_pin_cfg_labels[i];
  2883. imux->items[imux->num_items].index =
  2884. alc880_input_pin_idx(cfg->input_pins[i]);
  2885. imux->num_items++;
  2886. }
  2887. }
  2888. return 0;
  2889. }
  2890. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2891. hda_nid_t nid, int pin_type,
  2892. int dac_idx)
  2893. {
  2894. /* set as output */
  2895. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2896. pin_type);
  2897. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2898. AMP_OUT_UNMUTE);
  2899. /* need the manual connection? */
  2900. if (alc880_is_multi_pin(nid)) {
  2901. struct alc_spec *spec = codec->spec;
  2902. int idx = alc880_multi_pin_idx(nid);
  2903. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2904. AC_VERB_SET_CONNECT_SEL,
  2905. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2906. }
  2907. }
  2908. static int get_pin_type(int line_out_type)
  2909. {
  2910. if (line_out_type == AUTO_PIN_HP_OUT)
  2911. return PIN_HP;
  2912. else
  2913. return PIN_OUT;
  2914. }
  2915. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2916. {
  2917. struct alc_spec *spec = codec->spec;
  2918. int i;
  2919. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2920. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2921. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2922. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2923. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2924. }
  2925. }
  2926. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2927. {
  2928. struct alc_spec *spec = codec->spec;
  2929. hda_nid_t pin;
  2930. pin = spec->autocfg.speaker_pins[0];
  2931. if (pin) /* connect to front */
  2932. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2933. pin = spec->autocfg.hp_pins[0];
  2934. if (pin) /* connect to front */
  2935. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2936. }
  2937. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2938. {
  2939. struct alc_spec *spec = codec->spec;
  2940. int i;
  2941. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2942. hda_nid_t nid = spec->autocfg.input_pins[i];
  2943. if (alc880_is_input_pin(nid)) {
  2944. snd_hda_codec_write(codec, nid, 0,
  2945. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2946. i <= AUTO_PIN_FRONT_MIC ?
  2947. PIN_VREF80 : PIN_IN);
  2948. if (nid != ALC880_PIN_CD_NID)
  2949. snd_hda_codec_write(codec, nid, 0,
  2950. AC_VERB_SET_AMP_GAIN_MUTE,
  2951. AMP_OUT_MUTE);
  2952. }
  2953. }
  2954. }
  2955. /* parse the BIOS configuration and set up the alc_spec */
  2956. /* return 1 if successful, 0 if the proper config is not found,
  2957. * or a negative error code
  2958. */
  2959. static int alc880_parse_auto_config(struct hda_codec *codec)
  2960. {
  2961. struct alc_spec *spec = codec->spec;
  2962. int err;
  2963. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2964. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2965. alc880_ignore);
  2966. if (err < 0)
  2967. return err;
  2968. if (!spec->autocfg.line_outs)
  2969. return 0; /* can't find valid BIOS pin config */
  2970. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2971. if (err < 0)
  2972. return err;
  2973. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2974. if (err < 0)
  2975. return err;
  2976. err = alc880_auto_create_extra_out(spec,
  2977. spec->autocfg.speaker_pins[0],
  2978. "Speaker");
  2979. if (err < 0)
  2980. return err;
  2981. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2982. "Headphone");
  2983. if (err < 0)
  2984. return err;
  2985. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2986. if (err < 0)
  2987. return err;
  2988. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2989. if (spec->autocfg.dig_out_pin)
  2990. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2991. if (spec->autocfg.dig_in_pin)
  2992. spec->dig_in_nid = ALC880_DIGIN_NID;
  2993. if (spec->kctl_alloc)
  2994. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2995. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2996. spec->num_mux_defs = 1;
  2997. spec->input_mux = &spec->private_imux;
  2998. return 1;
  2999. }
  3000. /* additional initialization for auto-configuration model */
  3001. static void alc880_auto_init(struct hda_codec *codec)
  3002. {
  3003. alc880_auto_init_multi_out(codec);
  3004. alc880_auto_init_extra_out(codec);
  3005. alc880_auto_init_analog_input(codec);
  3006. }
  3007. /*
  3008. * OK, here we have finally the patch for ALC880
  3009. */
  3010. static int patch_alc880(struct hda_codec *codec)
  3011. {
  3012. struct alc_spec *spec;
  3013. int board_config;
  3014. int err;
  3015. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3016. if (spec == NULL)
  3017. return -ENOMEM;
  3018. codec->spec = spec;
  3019. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3020. alc880_models,
  3021. alc880_cfg_tbl);
  3022. if (board_config < 0) {
  3023. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3024. "trying auto-probe from BIOS...\n");
  3025. board_config = ALC880_AUTO;
  3026. }
  3027. if (board_config == ALC880_AUTO) {
  3028. /* automatic parse from the BIOS config */
  3029. err = alc880_parse_auto_config(codec);
  3030. if (err < 0) {
  3031. alc_free(codec);
  3032. return err;
  3033. } else if (!err) {
  3034. printk(KERN_INFO
  3035. "hda_codec: Cannot set up configuration "
  3036. "from BIOS. Using 3-stack mode...\n");
  3037. board_config = ALC880_3ST;
  3038. }
  3039. }
  3040. if (board_config != ALC880_AUTO)
  3041. setup_preset(spec, &alc880_presets[board_config]);
  3042. spec->stream_name_analog = "ALC880 Analog";
  3043. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3044. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3045. spec->stream_name_digital = "ALC880 Digital";
  3046. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3047. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3048. if (!spec->adc_nids && spec->input_mux) {
  3049. /* check whether NID 0x07 is valid */
  3050. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3051. /* get type */
  3052. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3053. if (wcap != AC_WID_AUD_IN) {
  3054. spec->adc_nids = alc880_adc_nids_alt;
  3055. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3056. spec->mixers[spec->num_mixers] =
  3057. alc880_capture_alt_mixer;
  3058. spec->num_mixers++;
  3059. } else {
  3060. spec->adc_nids = alc880_adc_nids;
  3061. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3062. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3063. spec->num_mixers++;
  3064. }
  3065. }
  3066. codec->patch_ops = alc_patch_ops;
  3067. if (board_config == ALC880_AUTO)
  3068. spec->init_hook = alc880_auto_init;
  3069. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3070. if (!spec->loopback.amplist)
  3071. spec->loopback.amplist = alc880_loopbacks;
  3072. #endif
  3073. return 0;
  3074. }
  3075. /*
  3076. * ALC260 support
  3077. */
  3078. static hda_nid_t alc260_dac_nids[1] = {
  3079. /* front */
  3080. 0x02,
  3081. };
  3082. static hda_nid_t alc260_adc_nids[1] = {
  3083. /* ADC0 */
  3084. 0x04,
  3085. };
  3086. static hda_nid_t alc260_adc_nids_alt[1] = {
  3087. /* ADC1 */
  3088. 0x05,
  3089. };
  3090. static hda_nid_t alc260_hp_adc_nids[2] = {
  3091. /* ADC1, 0 */
  3092. 0x05, 0x04
  3093. };
  3094. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3095. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3096. */
  3097. static hda_nid_t alc260_dual_adc_nids[2] = {
  3098. /* ADC0, ADC1 */
  3099. 0x04, 0x05
  3100. };
  3101. #define ALC260_DIGOUT_NID 0x03
  3102. #define ALC260_DIGIN_NID 0x06
  3103. static struct hda_input_mux alc260_capture_source = {
  3104. .num_items = 4,
  3105. .items = {
  3106. { "Mic", 0x0 },
  3107. { "Front Mic", 0x1 },
  3108. { "Line", 0x2 },
  3109. { "CD", 0x4 },
  3110. },
  3111. };
  3112. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3113. * headphone jack and the internal CD lines since these are the only pins at
  3114. * which audio can appear. For flexibility, also allow the option of
  3115. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3116. * connection to the mixer output).
  3117. */
  3118. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3119. {
  3120. .num_items = 3,
  3121. .items = {
  3122. { "Mic/Line", 0x0 },
  3123. { "CD", 0x4 },
  3124. { "Headphone", 0x2 },
  3125. },
  3126. },
  3127. {
  3128. .num_items = 4,
  3129. .items = {
  3130. { "Mic/Line", 0x0 },
  3131. { "CD", 0x4 },
  3132. { "Headphone", 0x2 },
  3133. { "Mixer", 0x5 },
  3134. },
  3135. },
  3136. };
  3137. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3138. * the Fujitsu S702x, but jacks are marked differently.
  3139. */
  3140. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3141. {
  3142. .num_items = 4,
  3143. .items = {
  3144. { "Mic", 0x0 },
  3145. { "Line", 0x2 },
  3146. { "CD", 0x4 },
  3147. { "Headphone", 0x5 },
  3148. },
  3149. },
  3150. {
  3151. .num_items = 5,
  3152. .items = {
  3153. { "Mic", 0x0 },
  3154. { "Line", 0x2 },
  3155. { "CD", 0x4 },
  3156. { "Headphone", 0x6 },
  3157. { "Mixer", 0x5 },
  3158. },
  3159. },
  3160. };
  3161. /*
  3162. * This is just place-holder, so there's something for alc_build_pcms to look
  3163. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3164. * element which allows changing the channel mode, so the verb list is
  3165. * never used.
  3166. */
  3167. static struct hda_channel_mode alc260_modes[1] = {
  3168. { 2, NULL },
  3169. };
  3170. /* Mixer combinations
  3171. *
  3172. * basic: base_output + input + pc_beep + capture
  3173. * HP: base_output + input + capture_alt
  3174. * HP_3013: hp_3013 + input + capture
  3175. * fujitsu: fujitsu + capture
  3176. * acer: acer + capture
  3177. */
  3178. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3179. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3183. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3184. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3185. { } /* end */
  3186. };
  3187. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3188. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3189. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3194. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3195. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3196. { } /* end */
  3197. };
  3198. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3199. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3200. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3201. { } /* end */
  3202. };
  3203. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3204. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3206. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3207. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3208. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3210. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3211. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3212. { } /* end */
  3213. };
  3214. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3215. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3216. */
  3217. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3218. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3219. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3220. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3221. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3222. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3224. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3225. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3226. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3227. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3228. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3229. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3230. { } /* end */
  3231. };
  3232. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3233. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3234. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3235. * datasheet doesn't mention this restriction. At this stage it's not clear
  3236. * whether this behaviour is intentional or is a hardware bug in chip
  3237. * revisions available in early 2006. Therefore for now allow the
  3238. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3239. * that the lack of mic bias for this NID is intentional we could change the
  3240. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3241. *
  3242. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3243. * don't appear to make the mic bias available from the "line" jack, even
  3244. * though the NID used for this jack (0x14) can supply it. The theory is
  3245. * that perhaps Acer have included blocking capacitors between the ALC260
  3246. * and the output jack. If this turns out to be the case for all such
  3247. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3248. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3249. *
  3250. * The C20x Tablet series have a mono internal speaker which is controlled
  3251. * via the chip's Mono sum widget and pin complex, so include the necessary
  3252. * controls for such models. On models without a "mono speaker" the control
  3253. * won't do anything.
  3254. */
  3255. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3256. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3257. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3258. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3259. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3260. HDA_OUTPUT),
  3261. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3262. HDA_INPUT),
  3263. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3264. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3266. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3267. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3268. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3269. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3270. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3271. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3272. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3273. { } /* end */
  3274. };
  3275. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3276. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3277. */
  3278. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3279. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3280. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3281. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3282. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3283. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3284. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3285. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3286. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3287. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3288. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3289. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3290. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3291. { } /* end */
  3292. };
  3293. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3294. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3295. */
  3296. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3297. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3298. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3299. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3300. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3301. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3302. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3303. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3304. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3305. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3306. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3307. { } /* end */
  3308. };
  3309. /* capture mixer elements */
  3310. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3311. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3313. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3314. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3315. {
  3316. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3317. /* The multiple "Capture Source" controls confuse alsamixer
  3318. * So call somewhat different..
  3319. * FIXME: the controls appear in the "playback" view!
  3320. */
  3321. /* .name = "Capture Source", */
  3322. .name = "Input Source",
  3323. .count = 2,
  3324. .info = alc_mux_enum_info,
  3325. .get = alc_mux_enum_get,
  3326. .put = alc_mux_enum_put,
  3327. },
  3328. { } /* end */
  3329. };
  3330. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3331. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3332. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3333. {
  3334. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3335. /* The multiple "Capture Source" controls confuse alsamixer
  3336. * So call somewhat different..
  3337. * FIXME: the controls appear in the "playback" view!
  3338. */
  3339. /* .name = "Capture Source", */
  3340. .name = "Input Source",
  3341. .count = 1,
  3342. .info = alc_mux_enum_info,
  3343. .get = alc_mux_enum_get,
  3344. .put = alc_mux_enum_put,
  3345. },
  3346. { } /* end */
  3347. };
  3348. /*
  3349. * initialization verbs
  3350. */
  3351. static struct hda_verb alc260_init_verbs[] = {
  3352. /* Line In pin widget for input */
  3353. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* CD pin widget for input */
  3355. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3356. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3357. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3359. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3360. /* LINE-2 is used for line-out in rear */
  3361. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3362. /* select line-out */
  3363. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3364. /* LINE-OUT pin */
  3365. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3366. /* enable HP */
  3367. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3368. /* enable Mono */
  3369. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3370. /* mute capture amp left and right */
  3371. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3372. /* set connection select to line in (default select for this ADC) */
  3373. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3374. /* mute capture amp left and right */
  3375. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3376. /* set connection select to line in (default select for this ADC) */
  3377. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3378. /* set vol=0 Line-Out mixer amp left and right */
  3379. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3380. /* unmute pin widget amp left and right (no gain on this amp) */
  3381. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3382. /* set vol=0 HP mixer amp left and right */
  3383. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3384. /* unmute pin widget amp left and right (no gain on this amp) */
  3385. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3386. /* set vol=0 Mono mixer amp left and right */
  3387. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3388. /* unmute pin widget amp left and right (no gain on this amp) */
  3389. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* unmute LINE-2 out pin */
  3391. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3392. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3393. * Line In 2 = 0x03
  3394. */
  3395. /* mute analog inputs */
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3399. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3400. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3401. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3402. /* mute Front out path */
  3403. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3404. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3405. /* mute Headphone out path */
  3406. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3407. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3408. /* mute Mono out path */
  3409. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3410. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3411. { }
  3412. };
  3413. #if 0 /* should be identical with alc260_init_verbs? */
  3414. static struct hda_verb alc260_hp_init_verbs[] = {
  3415. /* Headphone and output */
  3416. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3417. /* mono output */
  3418. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3419. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3420. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3422. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3423. /* Line In pin widget for input */
  3424. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3425. /* Line-2 pin widget for output */
  3426. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3427. /* CD pin widget for input */
  3428. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3429. /* unmute amp left and right */
  3430. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3431. /* set connection select to line in (default select for this ADC) */
  3432. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3433. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3434. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3435. /* mute pin widget amp left and right (no gain on this amp) */
  3436. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3437. /* unmute HP mixer amp left and right (volume = 0) */
  3438. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3439. /* mute pin widget amp left and right (no gain on this amp) */
  3440. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3441. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3442. * Line In 2 = 0x03
  3443. */
  3444. /* mute analog inputs */
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3448. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3449. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3450. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3451. /* Unmute Front out path */
  3452. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3453. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3454. /* Unmute Headphone out path */
  3455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3456. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3457. /* Unmute Mono out path */
  3458. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3459. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3460. { }
  3461. };
  3462. #endif
  3463. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3464. /* Line out and output */
  3465. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* mono output */
  3467. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3468. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3469. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3471. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3472. /* Line In pin widget for input */
  3473. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3474. /* Headphone pin widget for output */
  3475. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3476. /* CD pin widget for input */
  3477. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3478. /* unmute amp left and right */
  3479. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3480. /* set connection select to line in (default select for this ADC) */
  3481. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3482. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3483. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3484. /* mute pin widget amp left and right (no gain on this amp) */
  3485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3486. /* unmute HP mixer amp left and right (volume = 0) */
  3487. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3488. /* mute pin widget amp left and right (no gain on this amp) */
  3489. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3490. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3491. * Line In 2 = 0x03
  3492. */
  3493. /* mute analog inputs */
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3497. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3498. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3499. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3500. /* Unmute Front out path */
  3501. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3502. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3503. /* Unmute Headphone out path */
  3504. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3505. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3506. /* Unmute Mono out path */
  3507. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3508. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3509. { }
  3510. };
  3511. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3512. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3513. * audio = 0x16, internal speaker = 0x10.
  3514. */
  3515. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3516. /* Disable all GPIOs */
  3517. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3518. /* Internal speaker is connected to headphone pin */
  3519. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3520. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3521. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3522. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3523. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3524. /* Ensure all other unused pins are disabled and muted. */
  3525. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3532. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3533. /* Disable digital (SPDIF) pins */
  3534. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3535. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3536. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3537. * when acting as an output.
  3538. */
  3539. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3540. /* Start with output sum widgets muted and their output gains at min */
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3542. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3543. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3545. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3546. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3548. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3549. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3550. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3551. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3552. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3553. * If the pin mode is changed by the user the pin mode control will
  3554. * take care of enabling the pin's input/output buffers as needed.
  3555. * Therefore there's no need to enable the input buffer at this
  3556. * stage.
  3557. */
  3558. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3559. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3560. * mixer ctrl)
  3561. */
  3562. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3563. /* Mute capture amp left and right */
  3564. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3565. /* Set ADC connection select to match default mixer setting - line
  3566. * in (on mic1 pin)
  3567. */
  3568. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3569. /* Do the same for the second ADC: mute capture input amp and
  3570. * set ADC connection to line in (on mic1 pin)
  3571. */
  3572. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3573. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3574. /* Mute all inputs to mixer widget (even unconnected ones) */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3582. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3583. { }
  3584. };
  3585. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3586. * similar laptops (adapted from Fujitsu init verbs).
  3587. */
  3588. static struct hda_verb alc260_acer_init_verbs[] = {
  3589. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3590. * the headphone jack. Turn this on and rely on the standard mute
  3591. * methods whenever the user wants to turn these outputs off.
  3592. */
  3593. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3594. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3595. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3596. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3597. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3598. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3599. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3600. /* Line In jack is connected to Line1 pin */
  3601. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3602. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3603. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3604. /* Ensure all other unused pins are disabled and muted. */
  3605. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3610. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3611. /* Disable digital (SPDIF) pins */
  3612. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3613. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3614. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3615. * bus when acting as outputs.
  3616. */
  3617. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3618. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3619. /* Start with output sum widgets muted and their output gains at min */
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3621. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3622. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3624. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3625. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3627. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3628. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3629. /* Unmute Line-out pin widget amp left and right
  3630. * (no equiv mixer ctrl)
  3631. */
  3632. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3634. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3635. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3636. * inputs. If the pin mode is changed by the user the pin mode control
  3637. * will take care of enabling the pin's input/output buffers as needed.
  3638. * Therefore there's no need to enable the input buffer at this
  3639. * stage.
  3640. */
  3641. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3642. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3643. /* Mute capture amp left and right */
  3644. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3645. /* Set ADC connection select to match default mixer setting - mic
  3646. * (on mic1 pin)
  3647. */
  3648. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3649. /* Do similar with the second ADC: mute capture input amp and
  3650. * set ADC connection to mic to match ALSA's default state.
  3651. */
  3652. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3653. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3654. /* Mute all inputs to mixer widget (even unconnected ones) */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3661. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3662. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3663. { }
  3664. };
  3665. static struct hda_verb alc260_will_verbs[] = {
  3666. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3667. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3668. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3669. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3670. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3671. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3672. {}
  3673. };
  3674. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3675. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3676. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3677. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3678. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3679. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3680. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3681. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3682. {}
  3683. };
  3684. /* toggle speaker-output according to the hp-jack state */
  3685. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3686. {
  3687. unsigned int present;
  3688. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3689. present = snd_hda_codec_read(codec, 0x0f, 0,
  3690. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3691. if (present) {
  3692. snd_hda_codec_write_cache(codec, 0x01, 0,
  3693. AC_VERB_SET_GPIO_DATA, 1);
  3694. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3695. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3696. PIN_HP);
  3697. } else {
  3698. snd_hda_codec_write_cache(codec, 0x01, 0,
  3699. AC_VERB_SET_GPIO_DATA, 0);
  3700. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3701. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3702. PIN_OUT);
  3703. }
  3704. }
  3705. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3706. unsigned int res)
  3707. {
  3708. if ((res >> 26) == ALC880_HP_EVENT)
  3709. alc260_replacer_672v_automute(codec);
  3710. }
  3711. /* Test configuration for debugging, modelled after the ALC880 test
  3712. * configuration.
  3713. */
  3714. #ifdef CONFIG_SND_DEBUG
  3715. static hda_nid_t alc260_test_dac_nids[1] = {
  3716. 0x02,
  3717. };
  3718. static hda_nid_t alc260_test_adc_nids[2] = {
  3719. 0x04, 0x05,
  3720. };
  3721. /* For testing the ALC260, each input MUX needs its own definition since
  3722. * the signal assignments are different. This assumes that the first ADC
  3723. * is NID 0x04.
  3724. */
  3725. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3726. {
  3727. .num_items = 7,
  3728. .items = {
  3729. { "MIC1 pin", 0x0 },
  3730. { "MIC2 pin", 0x1 },
  3731. { "LINE1 pin", 0x2 },
  3732. { "LINE2 pin", 0x3 },
  3733. { "CD pin", 0x4 },
  3734. { "LINE-OUT pin", 0x5 },
  3735. { "HP-OUT pin", 0x6 },
  3736. },
  3737. },
  3738. {
  3739. .num_items = 8,
  3740. .items = {
  3741. { "MIC1 pin", 0x0 },
  3742. { "MIC2 pin", 0x1 },
  3743. { "LINE1 pin", 0x2 },
  3744. { "LINE2 pin", 0x3 },
  3745. { "CD pin", 0x4 },
  3746. { "Mixer", 0x5 },
  3747. { "LINE-OUT pin", 0x6 },
  3748. { "HP-OUT pin", 0x7 },
  3749. },
  3750. },
  3751. };
  3752. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3753. /* Output driver widgets */
  3754. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3755. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3756. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3757. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3758. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3759. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3760. /* Modes for retasking pin widgets
  3761. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3762. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3763. * mention this restriction. At this stage it's not clear whether
  3764. * this behaviour is intentional or is a hardware bug in chip
  3765. * revisions available at least up until early 2006. Therefore for
  3766. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3767. * choices, but if it turns out that the lack of mic bias for these
  3768. * NIDs is intentional we could change their modes from
  3769. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3770. */
  3771. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3775. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3776. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3777. /* Loopback mixer controls */
  3778. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3779. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3781. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3783. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3785. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3787. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3788. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3789. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3790. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3791. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3792. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3793. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3794. /* Controls for GPIO pins, assuming they are configured as outputs */
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3797. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3798. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3799. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3800. * is ambigious as to which NID is which; testing on laptops which
  3801. * make this output available should provide clarification.
  3802. */
  3803. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3804. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3805. { } /* end */
  3806. };
  3807. static struct hda_verb alc260_test_init_verbs[] = {
  3808. /* Enable all GPIOs as outputs with an initial value of 0 */
  3809. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3810. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3811. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3812. /* Enable retasking pins as output, initially without power amp */
  3813. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3818. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3819. /* Disable digital (SPDIF) pins initially, but users can enable
  3820. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3821. * payload also sets the generation to 0, output to be in "consumer"
  3822. * PCM format, copyright asserted, no pre-emphasis and no validity
  3823. * control.
  3824. */
  3825. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3826. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3827. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3828. * OUT1 sum bus when acting as an output.
  3829. */
  3830. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3832. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3833. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3834. /* Start with output sum widgets muted and their output gains at min */
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3836. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3837. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3839. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3840. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3842. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3843. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3844. /* Unmute retasking pin widget output buffers since the default
  3845. * state appears to be output. As the pin mode is changed by the
  3846. * user the pin mode control will take care of enabling the pin's
  3847. * input/output buffers as needed.
  3848. */
  3849. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3854. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3855. /* Also unmute the mono-out pin widget */
  3856. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3857. /* Mute capture amp left and right */
  3858. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3859. /* Set ADC connection select to match default mixer setting (mic1
  3860. * pin)
  3861. */
  3862. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3863. /* Do the same for the second ADC: mute capture input amp and
  3864. * set ADC connection to mic1 pin
  3865. */
  3866. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3867. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3868. /* Mute all inputs to mixer widget (even unconnected ones) */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3875. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3876. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3877. { }
  3878. };
  3879. #endif
  3880. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3881. .substreams = 1,
  3882. .channels_min = 2,
  3883. .channels_max = 2,
  3884. };
  3885. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3886. .substreams = 1,
  3887. .channels_min = 2,
  3888. .channels_max = 2,
  3889. };
  3890. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3891. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3892. /*
  3893. * for BIOS auto-configuration
  3894. */
  3895. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3896. const char *pfx)
  3897. {
  3898. hda_nid_t nid_vol;
  3899. unsigned long vol_val, sw_val;
  3900. char name[32];
  3901. int err;
  3902. if (nid >= 0x0f && nid < 0x11) {
  3903. nid_vol = nid - 0x7;
  3904. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3905. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3906. } else if (nid == 0x11) {
  3907. nid_vol = nid - 0x7;
  3908. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3909. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3910. } else if (nid >= 0x12 && nid <= 0x15) {
  3911. nid_vol = 0x08;
  3912. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3913. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3914. } else
  3915. return 0; /* N/A */
  3916. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3917. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3918. if (err < 0)
  3919. return err;
  3920. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3921. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3922. if (err < 0)
  3923. return err;
  3924. return 1;
  3925. }
  3926. /* add playback controls from the parsed DAC table */
  3927. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3928. const struct auto_pin_cfg *cfg)
  3929. {
  3930. hda_nid_t nid;
  3931. int err;
  3932. spec->multiout.num_dacs = 1;
  3933. spec->multiout.dac_nids = spec->private_dac_nids;
  3934. spec->multiout.dac_nids[0] = 0x02;
  3935. nid = cfg->line_out_pins[0];
  3936. if (nid) {
  3937. err = alc260_add_playback_controls(spec, nid, "Front");
  3938. if (err < 0)
  3939. return err;
  3940. }
  3941. nid = cfg->speaker_pins[0];
  3942. if (nid) {
  3943. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3944. if (err < 0)
  3945. return err;
  3946. }
  3947. nid = cfg->hp_pins[0];
  3948. if (nid) {
  3949. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3950. if (err < 0)
  3951. return err;
  3952. }
  3953. return 0;
  3954. }
  3955. /* create playback/capture controls for input pins */
  3956. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3957. const struct auto_pin_cfg *cfg)
  3958. {
  3959. struct hda_input_mux *imux = &spec->private_imux;
  3960. int i, err, idx;
  3961. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3962. if (cfg->input_pins[i] >= 0x12) {
  3963. idx = cfg->input_pins[i] - 0x12;
  3964. err = new_analog_input(spec, cfg->input_pins[i],
  3965. auto_pin_cfg_labels[i], idx,
  3966. 0x07);
  3967. if (err < 0)
  3968. return err;
  3969. imux->items[imux->num_items].label =
  3970. auto_pin_cfg_labels[i];
  3971. imux->items[imux->num_items].index = idx;
  3972. imux->num_items++;
  3973. }
  3974. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3975. idx = cfg->input_pins[i] - 0x09;
  3976. err = new_analog_input(spec, cfg->input_pins[i],
  3977. auto_pin_cfg_labels[i], idx,
  3978. 0x07);
  3979. if (err < 0)
  3980. return err;
  3981. imux->items[imux->num_items].label =
  3982. auto_pin_cfg_labels[i];
  3983. imux->items[imux->num_items].index = idx;
  3984. imux->num_items++;
  3985. }
  3986. }
  3987. return 0;
  3988. }
  3989. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3990. hda_nid_t nid, int pin_type,
  3991. int sel_idx)
  3992. {
  3993. /* set as output */
  3994. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3995. pin_type);
  3996. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3997. AMP_OUT_UNMUTE);
  3998. /* need the manual connection? */
  3999. if (nid >= 0x12) {
  4000. int idx = nid - 0x12;
  4001. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4002. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4003. }
  4004. }
  4005. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4006. {
  4007. struct alc_spec *spec = codec->spec;
  4008. hda_nid_t nid;
  4009. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4010. nid = spec->autocfg.line_out_pins[0];
  4011. if (nid) {
  4012. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4013. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4014. }
  4015. nid = spec->autocfg.speaker_pins[0];
  4016. if (nid)
  4017. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4018. nid = spec->autocfg.hp_pins[0];
  4019. if (nid)
  4020. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4021. }
  4022. #define ALC260_PIN_CD_NID 0x16
  4023. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4024. {
  4025. struct alc_spec *spec = codec->spec;
  4026. int i;
  4027. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4028. hda_nid_t nid = spec->autocfg.input_pins[i];
  4029. if (nid >= 0x12) {
  4030. snd_hda_codec_write(codec, nid, 0,
  4031. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4032. i <= AUTO_PIN_FRONT_MIC ?
  4033. PIN_VREF80 : PIN_IN);
  4034. if (nid != ALC260_PIN_CD_NID)
  4035. snd_hda_codec_write(codec, nid, 0,
  4036. AC_VERB_SET_AMP_GAIN_MUTE,
  4037. AMP_OUT_MUTE);
  4038. }
  4039. }
  4040. }
  4041. /*
  4042. * generic initialization of ADC, input mixers and output mixers
  4043. */
  4044. static struct hda_verb alc260_volume_init_verbs[] = {
  4045. /*
  4046. * Unmute ADC0-1 and set the default input to mic-in
  4047. */
  4048. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4049. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4050. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4051. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4052. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4053. * mixer widget
  4054. * Note: PASD motherboards uses the Line In 2 as the input for
  4055. * front panel mic (mic 2)
  4056. */
  4057. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4058. /* mute analog inputs */
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4064. /*
  4065. * Set up output mixers (0x08 - 0x0a)
  4066. */
  4067. /* set vol=0 to output mixers */
  4068. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4071. /* set up input amps for analog loopback */
  4072. /* Amp Indices: DAC = 0, mixer = 1 */
  4073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4074. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4075. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4076. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4077. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4078. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4079. { }
  4080. };
  4081. static int alc260_parse_auto_config(struct hda_codec *codec)
  4082. {
  4083. struct alc_spec *spec = codec->spec;
  4084. unsigned int wcap;
  4085. int err;
  4086. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4087. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4088. alc260_ignore);
  4089. if (err < 0)
  4090. return err;
  4091. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4092. if (err < 0)
  4093. return err;
  4094. if (!spec->kctl_alloc)
  4095. return 0; /* can't find valid BIOS pin config */
  4096. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4097. if (err < 0)
  4098. return err;
  4099. spec->multiout.max_channels = 2;
  4100. if (spec->autocfg.dig_out_pin)
  4101. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4102. if (spec->kctl_alloc)
  4103. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4104. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4105. spec->num_mux_defs = 1;
  4106. spec->input_mux = &spec->private_imux;
  4107. /* check whether NID 0x04 is valid */
  4108. wcap = get_wcaps(codec, 0x04);
  4109. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4110. if (wcap != AC_WID_AUD_IN) {
  4111. spec->adc_nids = alc260_adc_nids_alt;
  4112. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4113. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4114. } else {
  4115. spec->adc_nids = alc260_adc_nids;
  4116. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4117. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4118. }
  4119. spec->num_mixers++;
  4120. return 1;
  4121. }
  4122. /* additional initialization for auto-configuration model */
  4123. static void alc260_auto_init(struct hda_codec *codec)
  4124. {
  4125. alc260_auto_init_multi_out(codec);
  4126. alc260_auto_init_analog_input(codec);
  4127. }
  4128. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4129. static struct hda_amp_list alc260_loopbacks[] = {
  4130. { 0x07, HDA_INPUT, 0 },
  4131. { 0x07, HDA_INPUT, 1 },
  4132. { 0x07, HDA_INPUT, 2 },
  4133. { 0x07, HDA_INPUT, 3 },
  4134. { 0x07, HDA_INPUT, 4 },
  4135. { } /* end */
  4136. };
  4137. #endif
  4138. /*
  4139. * ALC260 configurations
  4140. */
  4141. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4142. [ALC260_BASIC] = "basic",
  4143. [ALC260_HP] = "hp",
  4144. [ALC260_HP_3013] = "hp-3013",
  4145. [ALC260_FUJITSU_S702X] = "fujitsu",
  4146. [ALC260_ACER] = "acer",
  4147. [ALC260_WILL] = "will",
  4148. [ALC260_REPLACER_672V] = "replacer",
  4149. #ifdef CONFIG_SND_DEBUG
  4150. [ALC260_TEST] = "test",
  4151. #endif
  4152. [ALC260_AUTO] = "auto",
  4153. };
  4154. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4155. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4156. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4157. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4159. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4160. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4161. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4162. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4163. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4165. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4166. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4168. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4169. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4170. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4171. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4172. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4173. {}
  4174. };
  4175. static struct alc_config_preset alc260_presets[] = {
  4176. [ALC260_BASIC] = {
  4177. .mixers = { alc260_base_output_mixer,
  4178. alc260_input_mixer,
  4179. alc260_pc_beep_mixer,
  4180. alc260_capture_mixer },
  4181. .init_verbs = { alc260_init_verbs },
  4182. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4183. .dac_nids = alc260_dac_nids,
  4184. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4185. .adc_nids = alc260_adc_nids,
  4186. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4187. .channel_mode = alc260_modes,
  4188. .input_mux = &alc260_capture_source,
  4189. },
  4190. [ALC260_HP] = {
  4191. .mixers = { alc260_base_output_mixer,
  4192. alc260_input_mixer,
  4193. alc260_capture_alt_mixer },
  4194. .init_verbs = { alc260_init_verbs },
  4195. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4196. .dac_nids = alc260_dac_nids,
  4197. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4198. .adc_nids = alc260_hp_adc_nids,
  4199. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4200. .channel_mode = alc260_modes,
  4201. .input_mux = &alc260_capture_source,
  4202. },
  4203. [ALC260_HP_3013] = {
  4204. .mixers = { alc260_hp_3013_mixer,
  4205. alc260_input_mixer,
  4206. alc260_capture_alt_mixer },
  4207. .init_verbs = { alc260_hp_3013_init_verbs },
  4208. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4209. .dac_nids = alc260_dac_nids,
  4210. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4211. .adc_nids = alc260_hp_adc_nids,
  4212. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4213. .channel_mode = alc260_modes,
  4214. .input_mux = &alc260_capture_source,
  4215. },
  4216. [ALC260_FUJITSU_S702X] = {
  4217. .mixers = { alc260_fujitsu_mixer,
  4218. alc260_capture_mixer },
  4219. .init_verbs = { alc260_fujitsu_init_verbs },
  4220. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4221. .dac_nids = alc260_dac_nids,
  4222. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4223. .adc_nids = alc260_dual_adc_nids,
  4224. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4225. .channel_mode = alc260_modes,
  4226. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4227. .input_mux = alc260_fujitsu_capture_sources,
  4228. },
  4229. [ALC260_ACER] = {
  4230. .mixers = { alc260_acer_mixer,
  4231. alc260_capture_mixer },
  4232. .init_verbs = { alc260_acer_init_verbs },
  4233. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4234. .dac_nids = alc260_dac_nids,
  4235. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4236. .adc_nids = alc260_dual_adc_nids,
  4237. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4238. .channel_mode = alc260_modes,
  4239. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4240. .input_mux = alc260_acer_capture_sources,
  4241. },
  4242. [ALC260_WILL] = {
  4243. .mixers = { alc260_will_mixer,
  4244. alc260_capture_mixer },
  4245. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4246. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4247. .dac_nids = alc260_dac_nids,
  4248. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4249. .adc_nids = alc260_adc_nids,
  4250. .dig_out_nid = ALC260_DIGOUT_NID,
  4251. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4252. .channel_mode = alc260_modes,
  4253. .input_mux = &alc260_capture_source,
  4254. },
  4255. [ALC260_REPLACER_672V] = {
  4256. .mixers = { alc260_replacer_672v_mixer,
  4257. alc260_capture_mixer },
  4258. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4259. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4260. .dac_nids = alc260_dac_nids,
  4261. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4262. .adc_nids = alc260_adc_nids,
  4263. .dig_out_nid = ALC260_DIGOUT_NID,
  4264. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4265. .channel_mode = alc260_modes,
  4266. .input_mux = &alc260_capture_source,
  4267. .unsol_event = alc260_replacer_672v_unsol_event,
  4268. .init_hook = alc260_replacer_672v_automute,
  4269. },
  4270. #ifdef CONFIG_SND_DEBUG
  4271. [ALC260_TEST] = {
  4272. .mixers = { alc260_test_mixer,
  4273. alc260_capture_mixer },
  4274. .init_verbs = { alc260_test_init_verbs },
  4275. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4276. .dac_nids = alc260_test_dac_nids,
  4277. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4278. .adc_nids = alc260_test_adc_nids,
  4279. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4280. .channel_mode = alc260_modes,
  4281. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4282. .input_mux = alc260_test_capture_sources,
  4283. },
  4284. #endif
  4285. };
  4286. static int patch_alc260(struct hda_codec *codec)
  4287. {
  4288. struct alc_spec *spec;
  4289. int err, board_config;
  4290. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4291. if (spec == NULL)
  4292. return -ENOMEM;
  4293. codec->spec = spec;
  4294. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4295. alc260_models,
  4296. alc260_cfg_tbl);
  4297. if (board_config < 0) {
  4298. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4299. "trying auto-probe from BIOS...\n");
  4300. board_config = ALC260_AUTO;
  4301. }
  4302. if (board_config == ALC260_AUTO) {
  4303. /* automatic parse from the BIOS config */
  4304. err = alc260_parse_auto_config(codec);
  4305. if (err < 0) {
  4306. alc_free(codec);
  4307. return err;
  4308. } else if (!err) {
  4309. printk(KERN_INFO
  4310. "hda_codec: Cannot set up configuration "
  4311. "from BIOS. Using base mode...\n");
  4312. board_config = ALC260_BASIC;
  4313. }
  4314. }
  4315. if (board_config != ALC260_AUTO)
  4316. setup_preset(spec, &alc260_presets[board_config]);
  4317. spec->stream_name_analog = "ALC260 Analog";
  4318. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4319. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4320. spec->stream_name_digital = "ALC260 Digital";
  4321. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4322. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4323. codec->patch_ops = alc_patch_ops;
  4324. if (board_config == ALC260_AUTO)
  4325. spec->init_hook = alc260_auto_init;
  4326. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4327. if (!spec->loopback.amplist)
  4328. spec->loopback.amplist = alc260_loopbacks;
  4329. #endif
  4330. return 0;
  4331. }
  4332. /*
  4333. * ALC882 support
  4334. *
  4335. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4336. * configuration. Each pin widget can choose any input DACs and a mixer.
  4337. * Each ADC is connected from a mixer of all inputs. This makes possible
  4338. * 6-channel independent captures.
  4339. *
  4340. * In addition, an independent DAC for the multi-playback (not used in this
  4341. * driver yet).
  4342. */
  4343. #define ALC882_DIGOUT_NID 0x06
  4344. #define ALC882_DIGIN_NID 0x0a
  4345. static struct hda_channel_mode alc882_ch_modes[1] = {
  4346. { 8, NULL }
  4347. };
  4348. static hda_nid_t alc882_dac_nids[4] = {
  4349. /* front, rear, clfe, rear_surr */
  4350. 0x02, 0x03, 0x04, 0x05
  4351. };
  4352. /* identical with ALC880 */
  4353. #define alc882_adc_nids alc880_adc_nids
  4354. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4355. /* input MUX */
  4356. /* FIXME: should be a matrix-type input source selection */
  4357. static struct hda_input_mux alc882_capture_source = {
  4358. .num_items = 4,
  4359. .items = {
  4360. { "Mic", 0x0 },
  4361. { "Front Mic", 0x1 },
  4362. { "Line", 0x2 },
  4363. { "CD", 0x4 },
  4364. },
  4365. };
  4366. #define alc882_mux_enum_info alc_mux_enum_info
  4367. #define alc882_mux_enum_get alc_mux_enum_get
  4368. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4369. struct snd_ctl_elem_value *ucontrol)
  4370. {
  4371. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4372. struct alc_spec *spec = codec->spec;
  4373. const struct hda_input_mux *imux = spec->input_mux;
  4374. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4375. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4376. hda_nid_t nid = capture_mixers[adc_idx];
  4377. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4378. unsigned int i, idx;
  4379. idx = ucontrol->value.enumerated.item[0];
  4380. if (idx >= imux->num_items)
  4381. idx = imux->num_items - 1;
  4382. if (*cur_val == idx)
  4383. return 0;
  4384. for (i = 0; i < imux->num_items; i++) {
  4385. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4386. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4387. imux->items[i].index,
  4388. HDA_AMP_MUTE, v);
  4389. }
  4390. *cur_val = idx;
  4391. return 1;
  4392. }
  4393. /*
  4394. * 2ch mode
  4395. */
  4396. static struct hda_verb alc882_3ST_ch2_init[] = {
  4397. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4398. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4399. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4400. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4401. { } /* end */
  4402. };
  4403. /*
  4404. * 6ch mode
  4405. */
  4406. static struct hda_verb alc882_3ST_ch6_init[] = {
  4407. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4408. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4409. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4410. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4411. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4412. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4413. { } /* end */
  4414. };
  4415. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4416. { 2, alc882_3ST_ch2_init },
  4417. { 6, alc882_3ST_ch6_init },
  4418. };
  4419. /*
  4420. * 6ch mode
  4421. */
  4422. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4423. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4424. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4426. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4427. { } /* end */
  4428. };
  4429. /*
  4430. * 8ch mode
  4431. */
  4432. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4433. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4436. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4437. { } /* end */
  4438. };
  4439. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4440. { 6, alc882_sixstack_ch6_init },
  4441. { 8, alc882_sixstack_ch8_init },
  4442. };
  4443. /*
  4444. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4445. */
  4446. /*
  4447. * 2ch mode
  4448. */
  4449. static struct hda_verb alc885_mbp_ch2_init[] = {
  4450. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4451. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4452. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4453. { } /* end */
  4454. };
  4455. /*
  4456. * 6ch mode
  4457. */
  4458. static struct hda_verb alc885_mbp_ch6_init[] = {
  4459. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4460. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4461. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4462. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4463. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4464. { } /* end */
  4465. };
  4466. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4467. { 2, alc885_mbp_ch2_init },
  4468. { 6, alc885_mbp_ch6_init },
  4469. };
  4470. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4471. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4472. */
  4473. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4474. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4475. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4476. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4477. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4478. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4479. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4480. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4481. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4482. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4483. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4484. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4486. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4488. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4491. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4492. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4493. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4494. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4495. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4496. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4497. { } /* end */
  4498. };
  4499. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4500. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4501. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4502. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4503. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4504. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4505. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4506. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4507. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4508. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4509. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4510. { } /* end */
  4511. };
  4512. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4513. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4514. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4515. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4516. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4517. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4518. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4519. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4520. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4521. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4522. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4523. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4524. { } /* end */
  4525. };
  4526. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4527. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4528. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4529. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4530. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4531. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4532. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4533. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4534. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4535. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4536. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4537. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4538. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4539. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4540. { } /* end */
  4541. };
  4542. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4543. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4544. */
  4545. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4546. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4547. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4548. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4549. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4550. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4551. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4552. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4553. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4554. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4555. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4556. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4557. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4558. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4559. { } /* end */
  4560. };
  4561. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4562. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4563. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4564. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4565. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4566. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4567. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4568. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4569. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4570. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4571. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4572. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4573. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4574. { } /* end */
  4575. };
  4576. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4577. {
  4578. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4579. .name = "Channel Mode",
  4580. .info = alc_ch_mode_info,
  4581. .get = alc_ch_mode_get,
  4582. .put = alc_ch_mode_put,
  4583. },
  4584. { } /* end */
  4585. };
  4586. static struct hda_verb alc882_init_verbs[] = {
  4587. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4588. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4589. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4590. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4591. /* Rear mixer */
  4592. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4593. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4594. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4595. /* CLFE mixer */
  4596. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4597. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4598. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4599. /* Side mixer */
  4600. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4601. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4602. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4603. /* Front Pin: output 0 (0x0c) */
  4604. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4605. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4606. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4607. /* Rear Pin: output 1 (0x0d) */
  4608. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4610. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4611. /* CLFE Pin: output 2 (0x0e) */
  4612. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4613. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4614. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4615. /* Side Pin: output 3 (0x0f) */
  4616. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4617. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4618. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4619. /* Mic (rear) pin: input vref at 80% */
  4620. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4621. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4622. /* Front Mic pin: input vref at 80% */
  4623. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4624. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4625. /* Line In pin: input */
  4626. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4627. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4628. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4629. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4630. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4631. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4632. /* CD pin widget for input */
  4633. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4634. /* FIXME: use matrix-type input source selection */
  4635. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4636. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4637. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4638. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4640. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4641. /* Input mixer2 */
  4642. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4643. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4645. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4646. /* Input mixer3 */
  4647. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4648. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4651. /* ADC1: mute amp left and right */
  4652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4653. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4654. /* ADC2: mute amp left and right */
  4655. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4656. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4657. /* ADC3: mute amp left and right */
  4658. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4659. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4660. { }
  4661. };
  4662. static struct hda_verb alc882_eapd_verbs[] = {
  4663. /* change to EAPD mode */
  4664. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4665. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4666. { }
  4667. };
  4668. /* Mac Pro test */
  4669. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4670. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4671. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4672. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4673. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4674. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4675. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4676. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4677. { } /* end */
  4678. };
  4679. static struct hda_verb alc882_macpro_init_verbs[] = {
  4680. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4684. /* Front Pin: output 0 (0x0c) */
  4685. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4686. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4687. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4688. /* Front Mic pin: input vref at 80% */
  4689. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4690. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4691. /* Speaker: output */
  4692. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4693. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4694. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4695. /* Headphone output (output 0 - 0x0c) */
  4696. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4698. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4699. /* FIXME: use matrix-type input source selection */
  4700. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4701. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4702. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4703. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4704. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4705. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4706. /* Input mixer2 */
  4707. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4708. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4709. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4710. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4711. /* Input mixer3 */
  4712. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4713. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4714. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4715. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4716. /* ADC1: mute amp left and right */
  4717. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4718. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4719. /* ADC2: mute amp left and right */
  4720. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4721. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4722. /* ADC3: mute amp left and right */
  4723. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4724. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4725. { }
  4726. };
  4727. /* Macbook Pro rev3 */
  4728. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4729. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4730. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4731. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4732. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4733. /* Rear mixer */
  4734. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4735. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4736. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4737. /* Front Pin: output 0 (0x0c) */
  4738. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4739. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4740. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4741. /* HP Pin: output 0 (0x0d) */
  4742. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4743. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4744. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4745. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4746. /* Mic (rear) pin: input vref at 80% */
  4747. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4748. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4749. /* Front Mic pin: input vref at 80% */
  4750. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4751. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4752. /* Line In pin: use output 1 when in LineOut mode */
  4753. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4754. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4755. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4756. /* FIXME: use matrix-type input source selection */
  4757. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4758. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4759. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4760. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4761. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4762. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4763. /* Input mixer2 */
  4764. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4765. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4766. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4767. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4768. /* Input mixer3 */
  4769. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4770. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4771. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4772. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4773. /* ADC1: mute amp left and right */
  4774. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4775. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4776. /* ADC2: mute amp left and right */
  4777. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4778. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4779. /* ADC3: mute amp left and right */
  4780. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4781. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4782. { }
  4783. };
  4784. /* iMac 24 mixer. */
  4785. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4786. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4787. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4788. { } /* end */
  4789. };
  4790. /* iMac 24 init verbs. */
  4791. static struct hda_verb alc885_imac24_init_verbs[] = {
  4792. /* Internal speakers: output 0 (0x0c) */
  4793. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4794. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4795. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4796. /* Internal speakers: output 0 (0x0c) */
  4797. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4798. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4799. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4800. /* Headphone: output 0 (0x0c) */
  4801. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4802. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4803. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4804. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4805. /* Front Mic: input vref at 80% */
  4806. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4807. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4808. { }
  4809. };
  4810. /* Toggle speaker-output according to the hp-jack state */
  4811. static void alc885_imac24_automute(struct hda_codec *codec)
  4812. {
  4813. unsigned int present;
  4814. present = snd_hda_codec_read(codec, 0x14, 0,
  4815. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4816. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4817. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4818. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4819. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4820. }
  4821. /* Processes unsolicited events. */
  4822. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4823. unsigned int res)
  4824. {
  4825. /* Headphone insertion or removal. */
  4826. if ((res >> 26) == ALC880_HP_EVENT)
  4827. alc885_imac24_automute(codec);
  4828. }
  4829. static void alc885_mbp3_automute(struct hda_codec *codec)
  4830. {
  4831. unsigned int present;
  4832. present = snd_hda_codec_read(codec, 0x15, 0,
  4833. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4834. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4835. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4836. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4837. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4838. }
  4839. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4840. unsigned int res)
  4841. {
  4842. /* Headphone insertion or removal. */
  4843. if ((res >> 26) == ALC880_HP_EVENT)
  4844. alc885_mbp3_automute(codec);
  4845. }
  4846. static struct hda_verb alc882_targa_verbs[] = {
  4847. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4848. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4849. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4850. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4851. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4852. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4853. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4854. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4855. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4856. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4857. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4858. { } /* end */
  4859. };
  4860. /* toggle speaker-output according to the hp-jack state */
  4861. static void alc882_targa_automute(struct hda_codec *codec)
  4862. {
  4863. unsigned int present;
  4864. present = snd_hda_codec_read(codec, 0x14, 0,
  4865. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4866. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4867. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4868. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4869. present ? 1 : 3);
  4870. }
  4871. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4872. {
  4873. /* Looks like the unsol event is incompatible with the standard
  4874. * definition. 4bit tag is placed at 26 bit!
  4875. */
  4876. if (((res >> 26) == ALC880_HP_EVENT)) {
  4877. alc882_targa_automute(codec);
  4878. }
  4879. }
  4880. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4881. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4882. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4883. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4884. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4885. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4886. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4887. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4888. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4889. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4890. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4891. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4892. { } /* end */
  4893. };
  4894. static struct hda_verb alc882_asus_a7m_verbs[] = {
  4895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4896. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4897. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4898. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4899. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4900. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4901. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4902. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4903. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4904. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4905. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4906. { } /* end */
  4907. };
  4908. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4909. {
  4910. unsigned int gpiostate, gpiomask, gpiodir;
  4911. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4912. AC_VERB_GET_GPIO_DATA, 0);
  4913. if (!muted)
  4914. gpiostate |= (1 << pin);
  4915. else
  4916. gpiostate &= ~(1 << pin);
  4917. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4918. AC_VERB_GET_GPIO_MASK, 0);
  4919. gpiomask |= (1 << pin);
  4920. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4921. AC_VERB_GET_GPIO_DIRECTION, 0);
  4922. gpiodir |= (1 << pin);
  4923. snd_hda_codec_write(codec, codec->afg, 0,
  4924. AC_VERB_SET_GPIO_MASK, gpiomask);
  4925. snd_hda_codec_write(codec, codec->afg, 0,
  4926. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4927. msleep(1);
  4928. snd_hda_codec_write(codec, codec->afg, 0,
  4929. AC_VERB_SET_GPIO_DATA, gpiostate);
  4930. }
  4931. /* set up GPIO at initialization */
  4932. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4933. {
  4934. alc882_gpio_mute(codec, 0, 0);
  4935. alc882_gpio_mute(codec, 1, 0);
  4936. }
  4937. /* set up GPIO and update auto-muting at initialization */
  4938. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4939. {
  4940. alc885_macpro_init_hook(codec);
  4941. alc885_imac24_automute(codec);
  4942. }
  4943. /*
  4944. * generic initialization of ADC, input mixers and output mixers
  4945. */
  4946. static struct hda_verb alc882_auto_init_verbs[] = {
  4947. /*
  4948. * Unmute ADC0-2 and set the default input to mic-in
  4949. */
  4950. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4951. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4952. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4953. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4954. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4955. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4956. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4957. * mixer widget
  4958. * Note: PASD motherboards uses the Line In 2 as the input for
  4959. * front panel mic (mic 2)
  4960. */
  4961. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4965. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4966. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4967. /*
  4968. * Set up output mixers (0x0c - 0x0f)
  4969. */
  4970. /* set vol=0 to output mixers */
  4971. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4972. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4973. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4974. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4975. /* set up input amps for analog loopback */
  4976. /* Amp Indices: DAC = 0, mixer = 1 */
  4977. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4978. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4979. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4980. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4981. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4982. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4983. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4984. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4985. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4986. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4987. /* FIXME: use matrix-type input source selection */
  4988. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4989. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4990. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4991. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4992. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4993. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4994. /* Input mixer2 */
  4995. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4996. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4997. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4998. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4999. /* Input mixer3 */
  5000. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5001. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5002. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5003. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5004. { }
  5005. };
  5006. /* capture mixer elements */
  5007. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5008. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5009. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5010. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5011. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5012. {
  5013. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5014. /* The multiple "Capture Source" controls confuse alsamixer
  5015. * So call somewhat different..
  5016. * FIXME: the controls appear in the "playback" view!
  5017. */
  5018. /* .name = "Capture Source", */
  5019. .name = "Input Source",
  5020. .count = 2,
  5021. .info = alc882_mux_enum_info,
  5022. .get = alc882_mux_enum_get,
  5023. .put = alc882_mux_enum_put,
  5024. },
  5025. { } /* end */
  5026. };
  5027. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5028. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5029. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5030. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5031. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5032. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5033. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5034. {
  5035. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5036. /* The multiple "Capture Source" controls confuse alsamixer
  5037. * So call somewhat different..
  5038. * FIXME: the controls appear in the "playback" view!
  5039. */
  5040. /* .name = "Capture Source", */
  5041. .name = "Input Source",
  5042. .count = 3,
  5043. .info = alc882_mux_enum_info,
  5044. .get = alc882_mux_enum_get,
  5045. .put = alc882_mux_enum_put,
  5046. },
  5047. { } /* end */
  5048. };
  5049. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5050. #define alc882_loopbacks alc880_loopbacks
  5051. #endif
  5052. /* pcm configuration: identiacal with ALC880 */
  5053. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5054. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5055. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5056. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5057. /*
  5058. * configuration and preset
  5059. */
  5060. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5061. [ALC882_3ST_DIG] = "3stack-dig",
  5062. [ALC882_6ST_DIG] = "6stack-dig",
  5063. [ALC882_ARIMA] = "arima",
  5064. [ALC882_W2JC] = "w2jc",
  5065. [ALC882_TARGA] = "targa",
  5066. [ALC882_ASUS_A7J] = "asus-a7j",
  5067. [ALC882_ASUS_A7M] = "asus-a7m",
  5068. [ALC885_MACPRO] = "macpro",
  5069. [ALC885_MBP3] = "mbp3",
  5070. [ALC885_IMAC24] = "imac24",
  5071. [ALC882_AUTO] = "auto",
  5072. };
  5073. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5074. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5075. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5076. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5077. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5078. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5079. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5080. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5081. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5082. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5083. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5084. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5085. {}
  5086. };
  5087. static struct alc_config_preset alc882_presets[] = {
  5088. [ALC882_3ST_DIG] = {
  5089. .mixers = { alc882_base_mixer },
  5090. .init_verbs = { alc882_init_verbs },
  5091. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5092. .dac_nids = alc882_dac_nids,
  5093. .dig_out_nid = ALC882_DIGOUT_NID,
  5094. .dig_in_nid = ALC882_DIGIN_NID,
  5095. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5096. .channel_mode = alc882_ch_modes,
  5097. .need_dac_fix = 1,
  5098. .input_mux = &alc882_capture_source,
  5099. },
  5100. [ALC882_6ST_DIG] = {
  5101. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5102. .init_verbs = { alc882_init_verbs },
  5103. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5104. .dac_nids = alc882_dac_nids,
  5105. .dig_out_nid = ALC882_DIGOUT_NID,
  5106. .dig_in_nid = ALC882_DIGIN_NID,
  5107. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5108. .channel_mode = alc882_sixstack_modes,
  5109. .input_mux = &alc882_capture_source,
  5110. },
  5111. [ALC882_ARIMA] = {
  5112. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5113. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5114. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5115. .dac_nids = alc882_dac_nids,
  5116. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5117. .channel_mode = alc882_sixstack_modes,
  5118. .input_mux = &alc882_capture_source,
  5119. },
  5120. [ALC882_W2JC] = {
  5121. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5122. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5123. alc880_gpio1_init_verbs },
  5124. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5125. .dac_nids = alc882_dac_nids,
  5126. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5127. .channel_mode = alc880_threestack_modes,
  5128. .need_dac_fix = 1,
  5129. .input_mux = &alc882_capture_source,
  5130. .dig_out_nid = ALC882_DIGOUT_NID,
  5131. },
  5132. [ALC885_MBP3] = {
  5133. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5134. .init_verbs = { alc885_mbp3_init_verbs,
  5135. alc880_gpio1_init_verbs },
  5136. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5137. .dac_nids = alc882_dac_nids,
  5138. .channel_mode = alc885_mbp_6ch_modes,
  5139. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5140. .input_mux = &alc882_capture_source,
  5141. .dig_out_nid = ALC882_DIGOUT_NID,
  5142. .dig_in_nid = ALC882_DIGIN_NID,
  5143. .unsol_event = alc885_mbp3_unsol_event,
  5144. .init_hook = alc885_mbp3_automute,
  5145. },
  5146. [ALC885_MACPRO] = {
  5147. .mixers = { alc882_macpro_mixer },
  5148. .init_verbs = { alc882_macpro_init_verbs },
  5149. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5150. .dac_nids = alc882_dac_nids,
  5151. .dig_out_nid = ALC882_DIGOUT_NID,
  5152. .dig_in_nid = ALC882_DIGIN_NID,
  5153. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5154. .channel_mode = alc882_ch_modes,
  5155. .input_mux = &alc882_capture_source,
  5156. .init_hook = alc885_macpro_init_hook,
  5157. },
  5158. [ALC885_IMAC24] = {
  5159. .mixers = { alc885_imac24_mixer },
  5160. .init_verbs = { alc885_imac24_init_verbs },
  5161. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5162. .dac_nids = alc882_dac_nids,
  5163. .dig_out_nid = ALC882_DIGOUT_NID,
  5164. .dig_in_nid = ALC882_DIGIN_NID,
  5165. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5166. .channel_mode = alc882_ch_modes,
  5167. .input_mux = &alc882_capture_source,
  5168. .unsol_event = alc885_imac24_unsol_event,
  5169. .init_hook = alc885_imac24_init_hook,
  5170. },
  5171. [ALC882_TARGA] = {
  5172. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5173. alc882_capture_mixer },
  5174. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5175. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5176. .dac_nids = alc882_dac_nids,
  5177. .dig_out_nid = ALC882_DIGOUT_NID,
  5178. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5179. .adc_nids = alc882_adc_nids,
  5180. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5181. .channel_mode = alc882_3ST_6ch_modes,
  5182. .need_dac_fix = 1,
  5183. .input_mux = &alc882_capture_source,
  5184. .unsol_event = alc882_targa_unsol_event,
  5185. .init_hook = alc882_targa_automute,
  5186. },
  5187. [ALC882_ASUS_A7J] = {
  5188. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5189. alc882_capture_mixer },
  5190. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5191. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5192. .dac_nids = alc882_dac_nids,
  5193. .dig_out_nid = ALC882_DIGOUT_NID,
  5194. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5195. .adc_nids = alc882_adc_nids,
  5196. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5197. .channel_mode = alc882_3ST_6ch_modes,
  5198. .need_dac_fix = 1,
  5199. .input_mux = &alc882_capture_source,
  5200. },
  5201. [ALC882_ASUS_A7M] = {
  5202. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5203. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5204. alc880_gpio1_init_verbs,
  5205. alc882_asus_a7m_verbs },
  5206. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5207. .dac_nids = alc882_dac_nids,
  5208. .dig_out_nid = ALC882_DIGOUT_NID,
  5209. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5210. .channel_mode = alc880_threestack_modes,
  5211. .need_dac_fix = 1,
  5212. .input_mux = &alc882_capture_source,
  5213. },
  5214. };
  5215. /*
  5216. * Pin config fixes
  5217. */
  5218. enum {
  5219. PINFIX_ABIT_AW9D_MAX
  5220. };
  5221. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5222. { 0x15, 0x01080104 }, /* side */
  5223. { 0x16, 0x01011012 }, /* rear */
  5224. { 0x17, 0x01016011 }, /* clfe */
  5225. { }
  5226. };
  5227. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5228. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5229. };
  5230. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5231. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5232. {}
  5233. };
  5234. /*
  5235. * BIOS auto configuration
  5236. */
  5237. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5238. hda_nid_t nid, int pin_type,
  5239. int dac_idx)
  5240. {
  5241. /* set as output */
  5242. struct alc_spec *spec = codec->spec;
  5243. int idx;
  5244. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5245. idx = 4;
  5246. else
  5247. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5248. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5249. pin_type);
  5250. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5251. AMP_OUT_UNMUTE);
  5252. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5253. }
  5254. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5255. {
  5256. struct alc_spec *spec = codec->spec;
  5257. int i;
  5258. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5259. for (i = 0; i <= HDA_SIDE; i++) {
  5260. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5261. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5262. if (nid)
  5263. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5264. i);
  5265. }
  5266. }
  5267. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5268. {
  5269. struct alc_spec *spec = codec->spec;
  5270. hda_nid_t pin;
  5271. pin = spec->autocfg.hp_pins[0];
  5272. if (pin) /* connect to front */
  5273. /* use dac 0 */
  5274. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5275. }
  5276. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5277. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5278. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5279. {
  5280. struct alc_spec *spec = codec->spec;
  5281. int i;
  5282. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5283. hda_nid_t nid = spec->autocfg.input_pins[i];
  5284. if (alc882_is_input_pin(nid)) {
  5285. snd_hda_codec_write(codec, nid, 0,
  5286. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5287. i <= AUTO_PIN_FRONT_MIC ?
  5288. PIN_VREF80 : PIN_IN);
  5289. if (nid != ALC882_PIN_CD_NID)
  5290. snd_hda_codec_write(codec, nid, 0,
  5291. AC_VERB_SET_AMP_GAIN_MUTE,
  5292. AMP_OUT_MUTE);
  5293. }
  5294. }
  5295. }
  5296. /* add mic boosts if needed */
  5297. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5298. {
  5299. struct alc_spec *spec = codec->spec;
  5300. int err;
  5301. hda_nid_t nid;
  5302. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5303. if (nid) {
  5304. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5305. "Mic Boost",
  5306. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5307. if (err < 0)
  5308. return err;
  5309. }
  5310. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5311. if (nid) {
  5312. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5313. "Front Mic Boost",
  5314. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5315. if (err < 0)
  5316. return err;
  5317. }
  5318. return 0;
  5319. }
  5320. /* almost identical with ALC880 parser... */
  5321. static int alc882_parse_auto_config(struct hda_codec *codec)
  5322. {
  5323. struct alc_spec *spec = codec->spec;
  5324. int err = alc880_parse_auto_config(codec);
  5325. if (err < 0)
  5326. return err;
  5327. else if (!err)
  5328. return 0; /* no config found */
  5329. err = alc_auto_add_mic_boost(codec);
  5330. if (err < 0)
  5331. return err;
  5332. /* hack - override the init verbs */
  5333. spec->init_verbs[0] = alc882_auto_init_verbs;
  5334. return 1; /* config found */
  5335. }
  5336. /* additional initialization for auto-configuration model */
  5337. static void alc882_auto_init(struct hda_codec *codec)
  5338. {
  5339. alc882_auto_init_multi_out(codec);
  5340. alc882_auto_init_hp_out(codec);
  5341. alc882_auto_init_analog_input(codec);
  5342. }
  5343. static int patch_alc882(struct hda_codec *codec)
  5344. {
  5345. struct alc_spec *spec;
  5346. int err, board_config;
  5347. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5348. if (spec == NULL)
  5349. return -ENOMEM;
  5350. codec->spec = spec;
  5351. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5352. alc882_models,
  5353. alc882_cfg_tbl);
  5354. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5355. /* Pick up systems that don't supply PCI SSID */
  5356. switch (codec->subsystem_id) {
  5357. case 0x106b0c00: /* Mac Pro */
  5358. board_config = ALC885_MACPRO;
  5359. break;
  5360. case 0x106b1000: /* iMac 24 */
  5361. board_config = ALC885_IMAC24;
  5362. break;
  5363. case 0x106b2c00: /* Macbook Pro rev3 */
  5364. board_config = ALC885_MBP3;
  5365. break;
  5366. default:
  5367. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5368. "trying auto-probe from BIOS...\n");
  5369. board_config = ALC882_AUTO;
  5370. }
  5371. }
  5372. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5373. if (board_config == ALC882_AUTO) {
  5374. /* automatic parse from the BIOS config */
  5375. err = alc882_parse_auto_config(codec);
  5376. if (err < 0) {
  5377. alc_free(codec);
  5378. return err;
  5379. } else if (!err) {
  5380. printk(KERN_INFO
  5381. "hda_codec: Cannot set up configuration "
  5382. "from BIOS. Using base mode...\n");
  5383. board_config = ALC882_3ST_DIG;
  5384. }
  5385. }
  5386. if (board_config != ALC882_AUTO)
  5387. setup_preset(spec, &alc882_presets[board_config]);
  5388. spec->stream_name_analog = "ALC882 Analog";
  5389. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5390. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5391. spec->stream_name_digital = "ALC882 Digital";
  5392. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5393. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5394. if (!spec->adc_nids && spec->input_mux) {
  5395. /* check whether NID 0x07 is valid */
  5396. unsigned int wcap = get_wcaps(codec, 0x07);
  5397. /* get type */
  5398. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5399. if (wcap != AC_WID_AUD_IN) {
  5400. spec->adc_nids = alc882_adc_nids_alt;
  5401. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5402. spec->mixers[spec->num_mixers] =
  5403. alc882_capture_alt_mixer;
  5404. spec->num_mixers++;
  5405. } else {
  5406. spec->adc_nids = alc882_adc_nids;
  5407. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5408. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5409. spec->num_mixers++;
  5410. }
  5411. }
  5412. codec->patch_ops = alc_patch_ops;
  5413. if (board_config == ALC882_AUTO)
  5414. spec->init_hook = alc882_auto_init;
  5415. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5416. if (!spec->loopback.amplist)
  5417. spec->loopback.amplist = alc882_loopbacks;
  5418. #endif
  5419. return 0;
  5420. }
  5421. /*
  5422. * ALC883 support
  5423. *
  5424. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5425. * configuration. Each pin widget can choose any input DACs and a mixer.
  5426. * Each ADC is connected from a mixer of all inputs. This makes possible
  5427. * 6-channel independent captures.
  5428. *
  5429. * In addition, an independent DAC for the multi-playback (not used in this
  5430. * driver yet).
  5431. */
  5432. #define ALC883_DIGOUT_NID 0x06
  5433. #define ALC883_DIGIN_NID 0x0a
  5434. static hda_nid_t alc883_dac_nids[4] = {
  5435. /* front, rear, clfe, rear_surr */
  5436. 0x02, 0x04, 0x03, 0x05
  5437. };
  5438. static hda_nid_t alc883_adc_nids[2] = {
  5439. /* ADC1-2 */
  5440. 0x08, 0x09,
  5441. };
  5442. /* input MUX */
  5443. /* FIXME: should be a matrix-type input source selection */
  5444. static struct hda_input_mux alc883_capture_source = {
  5445. .num_items = 4,
  5446. .items = {
  5447. { "Mic", 0x0 },
  5448. { "Front Mic", 0x1 },
  5449. { "Line", 0x2 },
  5450. { "CD", 0x4 },
  5451. },
  5452. };
  5453. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5454. .num_items = 2,
  5455. .items = {
  5456. { "Mic", 0x1 },
  5457. { "Line", 0x2 },
  5458. },
  5459. };
  5460. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5461. .num_items = 4,
  5462. .items = {
  5463. { "Mic", 0x0 },
  5464. { "iMic", 0x1 },
  5465. { "Line", 0x2 },
  5466. { "CD", 0x4 },
  5467. },
  5468. };
  5469. #define alc883_mux_enum_info alc_mux_enum_info
  5470. #define alc883_mux_enum_get alc_mux_enum_get
  5471. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5472. struct snd_ctl_elem_value *ucontrol)
  5473. {
  5474. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5475. struct alc_spec *spec = codec->spec;
  5476. const struct hda_input_mux *imux = spec->input_mux;
  5477. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5478. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5479. hda_nid_t nid = capture_mixers[adc_idx];
  5480. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5481. unsigned int i, idx;
  5482. idx = ucontrol->value.enumerated.item[0];
  5483. if (idx >= imux->num_items)
  5484. idx = imux->num_items - 1;
  5485. if (*cur_val == idx)
  5486. return 0;
  5487. for (i = 0; i < imux->num_items; i++) {
  5488. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5489. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5490. imux->items[i].index,
  5491. HDA_AMP_MUTE, v);
  5492. }
  5493. *cur_val = idx;
  5494. return 1;
  5495. }
  5496. /*
  5497. * 2ch mode
  5498. */
  5499. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5500. { 2, NULL }
  5501. };
  5502. /*
  5503. * 2ch mode
  5504. */
  5505. static struct hda_verb alc883_3ST_ch2_init[] = {
  5506. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5507. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5508. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5509. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5510. { } /* end */
  5511. };
  5512. /*
  5513. * 4ch mode
  5514. */
  5515. static struct hda_verb alc883_3ST_ch4_init[] = {
  5516. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5517. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5518. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5519. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5520. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5521. { } /* end */
  5522. };
  5523. /*
  5524. * 6ch mode
  5525. */
  5526. static struct hda_verb alc883_3ST_ch6_init[] = {
  5527. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5528. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5529. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5530. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5531. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5532. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5533. { } /* end */
  5534. };
  5535. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5536. { 2, alc883_3ST_ch2_init },
  5537. { 4, alc883_3ST_ch4_init },
  5538. { 6, alc883_3ST_ch6_init },
  5539. };
  5540. /*
  5541. * 6ch mode
  5542. */
  5543. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5544. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5545. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5546. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5547. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5548. { } /* end */
  5549. };
  5550. /*
  5551. * 8ch mode
  5552. */
  5553. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5554. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5555. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5556. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5557. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5558. { } /* end */
  5559. };
  5560. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5561. { 6, alc883_sixstack_ch6_init },
  5562. { 8, alc883_sixstack_ch8_init },
  5563. };
  5564. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5565. /* eanable EAPD on medion laptop */
  5566. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5567. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5568. { }
  5569. };
  5570. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5571. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5572. */
  5573. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5574. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5575. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5577. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5578. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5579. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5580. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5581. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5582. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5583. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5584. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5585. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5586. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5587. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5588. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5589. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5590. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5591. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5592. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5594. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5598. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5599. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5600. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5601. {
  5602. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5603. /* .name = "Capture Source", */
  5604. .name = "Input Source",
  5605. .count = 2,
  5606. .info = alc883_mux_enum_info,
  5607. .get = alc883_mux_enum_get,
  5608. .put = alc883_mux_enum_put,
  5609. },
  5610. { } /* end */
  5611. };
  5612. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5613. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5614. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5615. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5616. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5617. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5618. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5619. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5620. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5621. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5622. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5623. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5624. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5625. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5627. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5628. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5629. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5630. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5631. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5632. {
  5633. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5634. /* .name = "Capture Source", */
  5635. .name = "Input Source",
  5636. .count = 2,
  5637. .info = alc883_mux_enum_info,
  5638. .get = alc883_mux_enum_get,
  5639. .put = alc883_mux_enum_put,
  5640. },
  5641. { } /* end */
  5642. };
  5643. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5644. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5645. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5646. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5647. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5648. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5649. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5650. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5651. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5652. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5653. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5654. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5655. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5656. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5657. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5659. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5660. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5662. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5664. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5665. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5666. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5667. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5668. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5669. {
  5670. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5671. /* .name = "Capture Source", */
  5672. .name = "Input Source",
  5673. .count = 2,
  5674. .info = alc883_mux_enum_info,
  5675. .get = alc883_mux_enum_get,
  5676. .put = alc883_mux_enum_put,
  5677. },
  5678. { } /* end */
  5679. };
  5680. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5681. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5682. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5683. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5684. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5686. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5687. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5688. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5689. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5690. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5691. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5692. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5693. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5694. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5695. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5696. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5697. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5698. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5699. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5700. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5701. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5702. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5703. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5704. {
  5705. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5706. /* .name = "Capture Source", */
  5707. .name = "Input Source",
  5708. .count = 1,
  5709. .info = alc883_mux_enum_info,
  5710. .get = alc883_mux_enum_get,
  5711. .put = alc883_mux_enum_put,
  5712. },
  5713. { } /* end */
  5714. };
  5715. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5716. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5717. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5718. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5719. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5720. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5721. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5722. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5723. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5724. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5726. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5734. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5735. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5736. {
  5737. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5738. /* .name = "Capture Source", */
  5739. .name = "Input Source",
  5740. .count = 2,
  5741. .info = alc883_mux_enum_info,
  5742. .get = alc883_mux_enum_get,
  5743. .put = alc883_mux_enum_put,
  5744. },
  5745. { } /* end */
  5746. };
  5747. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5748. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5749. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5750. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5751. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5752. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5753. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5754. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5755. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5757. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5758. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5759. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5760. {
  5761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5762. /* .name = "Capture Source", */
  5763. .name = "Input Source",
  5764. .count = 2,
  5765. .info = alc883_mux_enum_info,
  5766. .get = alc883_mux_enum_get,
  5767. .put = alc883_mux_enum_put,
  5768. },
  5769. { } /* end */
  5770. };
  5771. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5772. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5773. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5774. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5775. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5776. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5777. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5778. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5779. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5780. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5781. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5782. {
  5783. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5784. /* .name = "Capture Source", */
  5785. .name = "Input Source",
  5786. .count = 1,
  5787. .info = alc883_mux_enum_info,
  5788. .get = alc883_mux_enum_get,
  5789. .put = alc883_mux_enum_put,
  5790. },
  5791. { } /* end */
  5792. };
  5793. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5794. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5795. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5796. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5797. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5798. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5800. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5802. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5803. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5804. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5805. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5806. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5807. {
  5808. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5809. /* .name = "Capture Source", */
  5810. .name = "Input Source",
  5811. .count = 2,
  5812. .info = alc883_mux_enum_info,
  5813. .get = alc883_mux_enum_get,
  5814. .put = alc883_mux_enum_put,
  5815. },
  5816. { } /* end */
  5817. };
  5818. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5819. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5821. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5822. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5823. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5824. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5825. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5826. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5827. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5828. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5829. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5830. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5831. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5832. {
  5833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5834. /* .name = "Capture Source", */
  5835. .name = "Input Source",
  5836. .count = 2,
  5837. .info = alc883_mux_enum_info,
  5838. .get = alc883_mux_enum_get,
  5839. .put = alc883_mux_enum_put,
  5840. },
  5841. { } /* end */
  5842. };
  5843. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5844. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5845. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5846. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5847. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5848. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5849. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5850. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5851. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5852. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5853. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5854. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5855. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5856. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5857. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5858. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5859. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5860. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5861. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5863. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5864. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5866. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5867. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5868. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5869. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5870. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5871. {
  5872. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5873. /* .name = "Capture Source", */
  5874. .name = "Input Source",
  5875. .count = 2,
  5876. .info = alc883_mux_enum_info,
  5877. .get = alc883_mux_enum_get,
  5878. .put = alc883_mux_enum_put,
  5879. },
  5880. { } /* end */
  5881. };
  5882. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5883. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5884. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5885. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5886. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5887. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5888. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5889. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5890. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5891. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5892. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5893. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5894. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5895. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5896. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5897. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5898. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5899. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5900. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5901. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5902. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5903. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5904. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5905. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5906. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5907. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5908. {
  5909. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5910. /* .name = "Capture Source", */
  5911. .name = "Input Source",
  5912. .count = 2,
  5913. .info = alc883_mux_enum_info,
  5914. .get = alc883_mux_enum_get,
  5915. .put = alc883_mux_enum_put,
  5916. },
  5917. { } /* end */
  5918. };
  5919. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5920. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5921. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5922. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5923. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5924. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5925. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5926. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5927. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5928. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5929. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5930. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5931. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5932. {
  5933. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5934. /* .name = "Capture Source", */
  5935. .name = "Input Source",
  5936. .count = 2,
  5937. .info = alc883_mux_enum_info,
  5938. .get = alc883_mux_enum_get,
  5939. .put = alc883_mux_enum_put,
  5940. },
  5941. { } /* end */
  5942. };
  5943. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5944. {
  5945. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5946. .name = "Channel Mode",
  5947. .info = alc_ch_mode_info,
  5948. .get = alc_ch_mode_get,
  5949. .put = alc_ch_mode_put,
  5950. },
  5951. { } /* end */
  5952. };
  5953. static struct hda_verb alc883_init_verbs[] = {
  5954. /* ADC1: mute amp left and right */
  5955. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5956. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5957. /* ADC2: mute amp left and right */
  5958. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5959. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5960. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5962. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5963. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5964. /* Rear mixer */
  5965. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5966. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5967. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5968. /* CLFE mixer */
  5969. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5970. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5971. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5972. /* Side mixer */
  5973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5974. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5975. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5976. /* mute analog input loopbacks */
  5977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5980. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5982. /* Front Pin: output 0 (0x0c) */
  5983. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5984. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5985. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5986. /* Rear Pin: output 1 (0x0d) */
  5987. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5988. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5989. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5990. /* CLFE Pin: output 2 (0x0e) */
  5991. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5992. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5993. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5994. /* Side Pin: output 3 (0x0f) */
  5995. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5996. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5997. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5998. /* Mic (rear) pin: input vref at 80% */
  5999. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6000. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6001. /* Front Mic pin: input vref at 80% */
  6002. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6003. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6004. /* Line In pin: input */
  6005. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6006. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6007. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6008. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6009. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6010. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6011. /* CD pin widget for input */
  6012. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6013. /* FIXME: use matrix-type input source selection */
  6014. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6015. /* Input mixer2 */
  6016. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6017. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6018. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6019. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6020. /* Input mixer3 */
  6021. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6022. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6023. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6024. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6025. { }
  6026. };
  6027. static struct hda_verb alc883_tagra_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. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6032. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6033. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6034. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6035. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6036. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6037. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6038. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6039. { } /* end */
  6040. };
  6041. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6042. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6043. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6044. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6045. { } /* end */
  6046. };
  6047. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6048. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6049. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6050. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6051. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6052. { } /* end */
  6053. };
  6054. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6055. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6056. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6057. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6058. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6059. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6060. { } /* end */
  6061. };
  6062. static struct hda_verb alc883_haier_w66_verbs[] = {
  6063. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6064. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6065. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6066. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6067. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6068. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6069. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6070. { } /* end */
  6071. };
  6072. static struct hda_verb alc888_6st_hp_verbs[] = {
  6073. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6074. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6075. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6076. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6077. { }
  6078. };
  6079. static struct hda_verb alc888_3st_hp_verbs[] = {
  6080. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6081. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6082. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6083. { }
  6084. };
  6085. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6086. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6087. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6088. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6089. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6090. { }
  6091. };
  6092. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6093. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6094. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6095. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6096. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6097. { }
  6098. };
  6099. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6100. { 2, alc888_3st_hp_2ch_init },
  6101. { 6, alc888_3st_hp_6ch_init },
  6102. };
  6103. /* toggle front-jack and RCA according to the hp-jack state */
  6104. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6105. {
  6106. unsigned int present;
  6107. present = snd_hda_codec_read(codec, 0x1b, 0,
  6108. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6109. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6110. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6111. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6112. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6113. }
  6114. /* toggle RCA according to the front-jack state */
  6115. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6116. {
  6117. unsigned int present;
  6118. present = snd_hda_codec_read(codec, 0x14, 0,
  6119. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6120. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6121. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6122. }
  6123. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6124. unsigned int res)
  6125. {
  6126. if ((res >> 26) == ALC880_HP_EVENT)
  6127. alc888_lenovo_ms7195_front_automute(codec);
  6128. if ((res >> 26) == ALC880_FRONT_EVENT)
  6129. alc888_lenovo_ms7195_rca_automute(codec);
  6130. }
  6131. static struct hda_verb alc883_medion_md2_verbs[] = {
  6132. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6133. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6134. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6135. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6136. { } /* end */
  6137. };
  6138. /* toggle speaker-output according to the hp-jack state */
  6139. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6140. {
  6141. unsigned int present;
  6142. present = snd_hda_codec_read(codec, 0x14, 0,
  6143. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6144. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6145. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6146. }
  6147. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6148. unsigned int res)
  6149. {
  6150. if ((res >> 26) == ALC880_HP_EVENT)
  6151. alc883_medion_md2_automute(codec);
  6152. }
  6153. /* toggle speaker-output according to the hp-jack state */
  6154. static void alc883_tagra_automute(struct hda_codec *codec)
  6155. {
  6156. unsigned int present;
  6157. unsigned char bits;
  6158. present = snd_hda_codec_read(codec, 0x14, 0,
  6159. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6160. bits = present ? HDA_AMP_MUTE : 0;
  6161. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6162. HDA_AMP_MUTE, bits);
  6163. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6164. present ? 1 : 3);
  6165. }
  6166. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6167. {
  6168. if ((res >> 26) == ALC880_HP_EVENT)
  6169. alc883_tagra_automute(codec);
  6170. }
  6171. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6172. {
  6173. unsigned int present;
  6174. unsigned char bits;
  6175. present = snd_hda_codec_read(codec, 0x1b, 0,
  6176. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6177. bits = present ? 0x80 : 0;
  6178. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6179. 0x80, bits);
  6180. }
  6181. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6182. unsigned int res)
  6183. {
  6184. if ((res >> 26) == ALC880_HP_EVENT)
  6185. alc883_haier_w66_automute(codec);
  6186. }
  6187. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6188. {
  6189. unsigned int present;
  6190. unsigned char bits;
  6191. present = snd_hda_codec_read(codec, 0x14, 0,
  6192. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6193. bits = present ? HDA_AMP_MUTE : 0;
  6194. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6195. HDA_AMP_MUTE, bits);
  6196. }
  6197. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6198. {
  6199. unsigned int present;
  6200. unsigned char bits;
  6201. present = snd_hda_codec_read(codec, 0x1b, 0,
  6202. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6203. bits = present ? HDA_AMP_MUTE : 0;
  6204. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6205. HDA_AMP_MUTE, bits);
  6206. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6207. HDA_AMP_MUTE, bits);
  6208. }
  6209. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6210. unsigned int res)
  6211. {
  6212. if ((res >> 26) == ALC880_HP_EVENT)
  6213. alc883_lenovo_101e_all_automute(codec);
  6214. if ((res >> 26) == ALC880_FRONT_EVENT)
  6215. alc883_lenovo_101e_ispeaker_automute(codec);
  6216. }
  6217. /* toggle speaker-output according to the hp-jack state */
  6218. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6219. {
  6220. unsigned int present;
  6221. present = snd_hda_codec_read(codec, 0x14, 0,
  6222. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6223. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6224. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6225. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6226. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6227. }
  6228. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6229. unsigned int res)
  6230. {
  6231. if ((res >> 26) == ALC880_HP_EVENT)
  6232. alc883_acer_aspire_automute(codec);
  6233. }
  6234. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6235. /* HP Pin: output 0 (0x0c) */
  6236. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6237. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6238. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6239. /* Front Pin: output 0 (0x0c) */
  6240. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6241. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6242. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6243. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6244. /* eanable EAPD on medion laptop */
  6245. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6246. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6247. /* enable unsolicited event */
  6248. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6249. { }
  6250. };
  6251. /*
  6252. * generic initialization of ADC, input mixers and output mixers
  6253. */
  6254. static struct hda_verb alc883_auto_init_verbs[] = {
  6255. /*
  6256. * Unmute ADC0-2 and set the default input to mic-in
  6257. */
  6258. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6259. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6260. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6261. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6262. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6263. * mixer widget
  6264. * Note: PASD motherboards uses the Line In 2 as the input for
  6265. * front panel mic (mic 2)
  6266. */
  6267. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6268. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6271. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6272. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6273. /*
  6274. * Set up output mixers (0x0c - 0x0f)
  6275. */
  6276. /* set vol=0 to output mixers */
  6277. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6278. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6279. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6280. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6281. /* set up input amps for analog loopback */
  6282. /* Amp Indices: DAC = 0, mixer = 1 */
  6283. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6284. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6285. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6286. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6287. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6288. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6289. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6290. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6291. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6292. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6293. /* FIXME: use matrix-type input source selection */
  6294. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6295. /* Input mixer1 */
  6296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6299. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6300. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6301. /* Input mixer2 */
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6303. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6304. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6305. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6306. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6307. { }
  6308. };
  6309. /* capture mixer elements */
  6310. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6311. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6312. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6313. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6314. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6315. {
  6316. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6317. /* The multiple "Capture Source" controls confuse alsamixer
  6318. * So call somewhat different..
  6319. * FIXME: the controls appear in the "playback" view!
  6320. */
  6321. /* .name = "Capture Source", */
  6322. .name = "Input Source",
  6323. .count = 2,
  6324. .info = alc882_mux_enum_info,
  6325. .get = alc882_mux_enum_get,
  6326. .put = alc882_mux_enum_put,
  6327. },
  6328. { } /* end */
  6329. };
  6330. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6331. #define alc883_loopbacks alc880_loopbacks
  6332. #endif
  6333. /* pcm configuration: identiacal with ALC880 */
  6334. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6335. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6336. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6337. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6338. /*
  6339. * configuration and preset
  6340. */
  6341. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6342. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6343. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6344. [ALC883_3ST_6ch] = "3stack-6ch",
  6345. [ALC883_6ST_DIG] = "6stack-dig",
  6346. [ALC883_TARGA_DIG] = "targa-dig",
  6347. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6348. [ALC883_ACER] = "acer",
  6349. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6350. [ALC883_MEDION] = "medion",
  6351. [ALC883_MEDION_MD2] = "medion-md2",
  6352. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6353. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6354. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6355. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6356. [ALC883_HAIER_W66] = "haier-w66",
  6357. [ALC888_6ST_HP] = "6stack-hp",
  6358. [ALC888_3ST_HP] = "3stack-hp",
  6359. [ALC883_AUTO] = "auto",
  6360. };
  6361. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6362. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6363. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6364. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6365. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6366. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6367. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6368. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6369. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6370. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6371. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6372. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6373. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6374. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6375. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6376. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6377. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6378. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6379. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6380. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6381. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6382. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6383. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6384. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6385. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6386. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6387. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6388. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6389. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6390. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6391. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6392. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6393. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6394. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6395. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6396. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6397. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6398. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6399. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6400. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6401. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6402. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6403. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6404. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6405. {}
  6406. };
  6407. static struct alc_config_preset alc883_presets[] = {
  6408. [ALC883_3ST_2ch_DIG] = {
  6409. .mixers = { alc883_3ST_2ch_mixer },
  6410. .init_verbs = { alc883_init_verbs },
  6411. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6412. .dac_nids = alc883_dac_nids,
  6413. .dig_out_nid = ALC883_DIGOUT_NID,
  6414. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6415. .adc_nids = alc883_adc_nids,
  6416. .dig_in_nid = ALC883_DIGIN_NID,
  6417. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6418. .channel_mode = alc883_3ST_2ch_modes,
  6419. .input_mux = &alc883_capture_source,
  6420. },
  6421. [ALC883_3ST_6ch_DIG] = {
  6422. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6423. .init_verbs = { alc883_init_verbs },
  6424. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6425. .dac_nids = alc883_dac_nids,
  6426. .dig_out_nid = ALC883_DIGOUT_NID,
  6427. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6428. .adc_nids = alc883_adc_nids,
  6429. .dig_in_nid = ALC883_DIGIN_NID,
  6430. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6431. .channel_mode = alc883_3ST_6ch_modes,
  6432. .need_dac_fix = 1,
  6433. .input_mux = &alc883_capture_source,
  6434. },
  6435. [ALC883_3ST_6ch] = {
  6436. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6437. .init_verbs = { alc883_init_verbs },
  6438. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6439. .dac_nids = alc883_dac_nids,
  6440. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6441. .adc_nids = alc883_adc_nids,
  6442. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6443. .channel_mode = alc883_3ST_6ch_modes,
  6444. .need_dac_fix = 1,
  6445. .input_mux = &alc883_capture_source,
  6446. },
  6447. [ALC883_6ST_DIG] = {
  6448. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6449. .init_verbs = { alc883_init_verbs },
  6450. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6451. .dac_nids = alc883_dac_nids,
  6452. .dig_out_nid = ALC883_DIGOUT_NID,
  6453. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6454. .adc_nids = alc883_adc_nids,
  6455. .dig_in_nid = ALC883_DIGIN_NID,
  6456. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6457. .channel_mode = alc883_sixstack_modes,
  6458. .input_mux = &alc883_capture_source,
  6459. },
  6460. [ALC883_TARGA_DIG] = {
  6461. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6462. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6463. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6464. .dac_nids = alc883_dac_nids,
  6465. .dig_out_nid = ALC883_DIGOUT_NID,
  6466. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6467. .adc_nids = alc883_adc_nids,
  6468. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6469. .channel_mode = alc883_3ST_6ch_modes,
  6470. .need_dac_fix = 1,
  6471. .input_mux = &alc883_capture_source,
  6472. .unsol_event = alc883_tagra_unsol_event,
  6473. .init_hook = alc883_tagra_automute,
  6474. },
  6475. [ALC883_TARGA_2ch_DIG] = {
  6476. .mixers = { alc883_tagra_2ch_mixer},
  6477. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6478. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6479. .dac_nids = alc883_dac_nids,
  6480. .dig_out_nid = ALC883_DIGOUT_NID,
  6481. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6482. .adc_nids = alc883_adc_nids,
  6483. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6484. .channel_mode = alc883_3ST_2ch_modes,
  6485. .input_mux = &alc883_capture_source,
  6486. .unsol_event = alc883_tagra_unsol_event,
  6487. .init_hook = alc883_tagra_automute,
  6488. },
  6489. [ALC883_ACER] = {
  6490. .mixers = { alc883_base_mixer },
  6491. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6492. * and the headphone jack. Turn this on and rely on the
  6493. * standard mute methods whenever the user wants to turn
  6494. * these outputs off.
  6495. */
  6496. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6497. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6498. .dac_nids = alc883_dac_nids,
  6499. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6500. .adc_nids = alc883_adc_nids,
  6501. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6502. .channel_mode = alc883_3ST_2ch_modes,
  6503. .input_mux = &alc883_capture_source,
  6504. },
  6505. [ALC883_ACER_ASPIRE] = {
  6506. .mixers = { alc883_acer_aspire_mixer },
  6507. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6508. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6509. .dac_nids = alc883_dac_nids,
  6510. .dig_out_nid = ALC883_DIGOUT_NID,
  6511. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6512. .adc_nids = alc883_adc_nids,
  6513. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6514. .channel_mode = alc883_3ST_2ch_modes,
  6515. .input_mux = &alc883_capture_source,
  6516. .unsol_event = alc883_acer_aspire_unsol_event,
  6517. .init_hook = alc883_acer_aspire_automute,
  6518. },
  6519. [ALC883_MEDION] = {
  6520. .mixers = { alc883_fivestack_mixer,
  6521. alc883_chmode_mixer },
  6522. .init_verbs = { alc883_init_verbs,
  6523. alc883_medion_eapd_verbs },
  6524. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6525. .dac_nids = alc883_dac_nids,
  6526. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6527. .adc_nids = alc883_adc_nids,
  6528. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6529. .channel_mode = alc883_sixstack_modes,
  6530. .input_mux = &alc883_capture_source,
  6531. },
  6532. [ALC883_MEDION_MD2] = {
  6533. .mixers = { alc883_medion_md2_mixer},
  6534. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6535. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6536. .dac_nids = alc883_dac_nids,
  6537. .dig_out_nid = ALC883_DIGOUT_NID,
  6538. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6539. .adc_nids = alc883_adc_nids,
  6540. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6541. .channel_mode = alc883_3ST_2ch_modes,
  6542. .input_mux = &alc883_capture_source,
  6543. .unsol_event = alc883_medion_md2_unsol_event,
  6544. .init_hook = alc883_medion_md2_automute,
  6545. },
  6546. [ALC883_LAPTOP_EAPD] = {
  6547. .mixers = { alc883_base_mixer },
  6548. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6549. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6550. .dac_nids = alc883_dac_nids,
  6551. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6552. .adc_nids = alc883_adc_nids,
  6553. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6554. .channel_mode = alc883_3ST_2ch_modes,
  6555. .input_mux = &alc883_capture_source,
  6556. },
  6557. [ALC883_LENOVO_101E_2ch] = {
  6558. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6559. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6560. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6561. .dac_nids = alc883_dac_nids,
  6562. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6563. .adc_nids = alc883_adc_nids,
  6564. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6565. .channel_mode = alc883_3ST_2ch_modes,
  6566. .input_mux = &alc883_lenovo_101e_capture_source,
  6567. .unsol_event = alc883_lenovo_101e_unsol_event,
  6568. .init_hook = alc883_lenovo_101e_all_automute,
  6569. },
  6570. [ALC883_LENOVO_NB0763] = {
  6571. .mixers = { alc883_lenovo_nb0763_mixer },
  6572. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6573. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6574. .dac_nids = alc883_dac_nids,
  6575. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6576. .adc_nids = alc883_adc_nids,
  6577. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6578. .channel_mode = alc883_3ST_2ch_modes,
  6579. .need_dac_fix = 1,
  6580. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6581. .unsol_event = alc883_medion_md2_unsol_event,
  6582. .init_hook = alc883_medion_md2_automute,
  6583. },
  6584. [ALC888_LENOVO_MS7195_DIG] = {
  6585. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6586. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6587. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6588. .dac_nids = alc883_dac_nids,
  6589. .dig_out_nid = ALC883_DIGOUT_NID,
  6590. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6591. .adc_nids = alc883_adc_nids,
  6592. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6593. .channel_mode = alc883_3ST_6ch_modes,
  6594. .need_dac_fix = 1,
  6595. .input_mux = &alc883_capture_source,
  6596. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6597. .init_hook = alc888_lenovo_ms7195_front_automute,
  6598. },
  6599. [ALC883_HAIER_W66] = {
  6600. .mixers = { alc883_tagra_2ch_mixer},
  6601. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6602. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6603. .dac_nids = alc883_dac_nids,
  6604. .dig_out_nid = ALC883_DIGOUT_NID,
  6605. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6606. .adc_nids = alc883_adc_nids,
  6607. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6608. .channel_mode = alc883_3ST_2ch_modes,
  6609. .input_mux = &alc883_capture_source,
  6610. .unsol_event = alc883_haier_w66_unsol_event,
  6611. .init_hook = alc883_haier_w66_automute,
  6612. },
  6613. [ALC888_6ST_HP] = {
  6614. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6615. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6616. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6617. .dac_nids = alc883_dac_nids,
  6618. .dig_out_nid = ALC883_DIGOUT_NID,
  6619. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6620. .adc_nids = alc883_adc_nids,
  6621. .dig_in_nid = ALC883_DIGIN_NID,
  6622. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6623. .channel_mode = alc883_sixstack_modes,
  6624. .input_mux = &alc883_capture_source,
  6625. },
  6626. [ALC888_3ST_HP] = {
  6627. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6628. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6629. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6630. .dac_nids = alc883_dac_nids,
  6631. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6632. .adc_nids = alc883_adc_nids,
  6633. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6634. .channel_mode = alc888_3st_hp_modes,
  6635. .need_dac_fix = 1,
  6636. .input_mux = &alc883_capture_source,
  6637. },
  6638. };
  6639. /*
  6640. * BIOS auto configuration
  6641. */
  6642. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6643. hda_nid_t nid, int pin_type,
  6644. int dac_idx)
  6645. {
  6646. /* set as output */
  6647. struct alc_spec *spec = codec->spec;
  6648. int idx;
  6649. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6650. idx = 4;
  6651. else
  6652. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6653. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6654. pin_type);
  6655. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6656. AMP_OUT_UNMUTE);
  6657. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6658. }
  6659. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6660. {
  6661. struct alc_spec *spec = codec->spec;
  6662. int i;
  6663. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6664. for (i = 0; i <= HDA_SIDE; i++) {
  6665. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6666. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6667. if (nid)
  6668. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6669. i);
  6670. }
  6671. }
  6672. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6673. {
  6674. struct alc_spec *spec = codec->spec;
  6675. hda_nid_t pin;
  6676. pin = spec->autocfg.hp_pins[0];
  6677. if (pin) /* connect to front */
  6678. /* use dac 0 */
  6679. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6680. }
  6681. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6682. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6683. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6684. {
  6685. struct alc_spec *spec = codec->spec;
  6686. int i;
  6687. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6688. hda_nid_t nid = spec->autocfg.input_pins[i];
  6689. if (alc883_is_input_pin(nid)) {
  6690. snd_hda_codec_write(codec, nid, 0,
  6691. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6692. (i <= AUTO_PIN_FRONT_MIC ?
  6693. PIN_VREF80 : PIN_IN));
  6694. if (nid != ALC883_PIN_CD_NID)
  6695. snd_hda_codec_write(codec, nid, 0,
  6696. AC_VERB_SET_AMP_GAIN_MUTE,
  6697. AMP_OUT_MUTE);
  6698. }
  6699. }
  6700. }
  6701. /* almost identical with ALC880 parser... */
  6702. static int alc883_parse_auto_config(struct hda_codec *codec)
  6703. {
  6704. struct alc_spec *spec = codec->spec;
  6705. int err = alc880_parse_auto_config(codec);
  6706. if (err < 0)
  6707. return err;
  6708. else if (!err)
  6709. return 0; /* no config found */
  6710. err = alc_auto_add_mic_boost(codec);
  6711. if (err < 0)
  6712. return err;
  6713. /* hack - override the init verbs */
  6714. spec->init_verbs[0] = alc883_auto_init_verbs;
  6715. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6716. spec->num_mixers++;
  6717. return 1; /* config found */
  6718. }
  6719. /* additional initialization for auto-configuration model */
  6720. static void alc883_auto_init(struct hda_codec *codec)
  6721. {
  6722. alc883_auto_init_multi_out(codec);
  6723. alc883_auto_init_hp_out(codec);
  6724. alc883_auto_init_analog_input(codec);
  6725. }
  6726. static int patch_alc883(struct hda_codec *codec)
  6727. {
  6728. struct alc_spec *spec;
  6729. int err, board_config;
  6730. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6731. if (spec == NULL)
  6732. return -ENOMEM;
  6733. codec->spec = spec;
  6734. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6735. alc883_models,
  6736. alc883_cfg_tbl);
  6737. if (board_config < 0) {
  6738. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6739. "trying auto-probe from BIOS...\n");
  6740. board_config = ALC883_AUTO;
  6741. }
  6742. if (board_config == ALC883_AUTO) {
  6743. /* automatic parse from the BIOS config */
  6744. err = alc883_parse_auto_config(codec);
  6745. if (err < 0) {
  6746. alc_free(codec);
  6747. return err;
  6748. } else if (!err) {
  6749. printk(KERN_INFO
  6750. "hda_codec: Cannot set up configuration "
  6751. "from BIOS. Using base mode...\n");
  6752. board_config = ALC883_3ST_2ch_DIG;
  6753. }
  6754. }
  6755. if (board_config != ALC883_AUTO)
  6756. setup_preset(spec, &alc883_presets[board_config]);
  6757. spec->stream_name_analog = "ALC883 Analog";
  6758. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6759. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6760. spec->stream_name_digital = "ALC883 Digital";
  6761. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6762. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6763. if (!spec->adc_nids && spec->input_mux) {
  6764. spec->adc_nids = alc883_adc_nids;
  6765. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6766. }
  6767. codec->patch_ops = alc_patch_ops;
  6768. if (board_config == ALC883_AUTO)
  6769. spec->init_hook = alc883_auto_init;
  6770. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6771. if (!spec->loopback.amplist)
  6772. spec->loopback.amplist = alc883_loopbacks;
  6773. #endif
  6774. return 0;
  6775. }
  6776. /*
  6777. * ALC262 support
  6778. */
  6779. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6780. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6781. #define alc262_dac_nids alc260_dac_nids
  6782. #define alc262_adc_nids alc882_adc_nids
  6783. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6784. #define alc262_modes alc260_modes
  6785. #define alc262_capture_source alc882_capture_source
  6786. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6787. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6788. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6789. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6790. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6791. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6792. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6793. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6794. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6795. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6796. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6797. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6798. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6799. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6800. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6801. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6802. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6803. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6804. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6805. { } /* end */
  6806. };
  6807. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6808. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6809. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6810. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6811. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6812. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6813. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6814. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6815. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6816. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6817. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6818. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6819. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6820. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6821. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6822. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6823. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6824. { } /* end */
  6825. };
  6826. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6827. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6828. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6829. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6830. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6831. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6832. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6833. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6834. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6835. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6836. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6837. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6838. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6839. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6840. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6841. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6842. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6843. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6844. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6845. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6846. { } /* end */
  6847. };
  6848. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6849. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6850. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6851. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6853. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6854. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6855. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6856. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6857. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6858. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6859. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6860. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6861. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6862. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6863. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6864. { } /* end */
  6865. };
  6866. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6867. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6868. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6869. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6870. { } /* end */
  6871. };
  6872. /* bind hp and internal speaker mute (with plug check) */
  6873. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6874. struct snd_ctl_elem_value *ucontrol)
  6875. {
  6876. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6877. long *valp = ucontrol->value.integer.value;
  6878. int change;
  6879. /* change hp mute */
  6880. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6881. HDA_AMP_MUTE,
  6882. valp[0] ? 0 : HDA_AMP_MUTE);
  6883. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6884. HDA_AMP_MUTE,
  6885. valp[1] ? 0 : HDA_AMP_MUTE);
  6886. if (change) {
  6887. /* change speaker according to HP jack state */
  6888. struct alc_spec *spec = codec->spec;
  6889. unsigned int mute;
  6890. if (spec->jack_present)
  6891. mute = HDA_AMP_MUTE;
  6892. else
  6893. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6894. HDA_OUTPUT, 0);
  6895. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6896. HDA_AMP_MUTE, mute);
  6897. }
  6898. return change;
  6899. }
  6900. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6901. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6902. {
  6903. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6904. .name = "Master Playback Switch",
  6905. .info = snd_hda_mixer_amp_switch_info,
  6906. .get = snd_hda_mixer_amp_switch_get,
  6907. .put = alc262_sony_master_sw_put,
  6908. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6909. },
  6910. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6911. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6912. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6913. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6914. { } /* end */
  6915. };
  6916. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6917. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6918. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6919. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6920. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6921. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6922. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6923. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6924. { } /* end */
  6925. };
  6926. #define alc262_capture_mixer alc882_capture_mixer
  6927. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6928. /*
  6929. * generic initialization of ADC, input mixers and output mixers
  6930. */
  6931. static struct hda_verb alc262_init_verbs[] = {
  6932. /*
  6933. * Unmute ADC0-2 and set the default input to mic-in
  6934. */
  6935. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6936. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6937. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6938. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6939. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6940. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6941. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6942. * mixer widget
  6943. * Note: PASD motherboards uses the Line In 2 as the input for
  6944. * front panel mic (mic 2)
  6945. */
  6946. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6948. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6949. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6950. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6951. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6952. /*
  6953. * Set up output mixers (0x0c - 0x0e)
  6954. */
  6955. /* set vol=0 to output mixers */
  6956. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6957. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6958. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6959. /* set up input amps for analog loopback */
  6960. /* Amp Indices: DAC = 0, mixer = 1 */
  6961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6962. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6963. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6964. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6965. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6966. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6967. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6968. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6969. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6970. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6971. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6972. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6973. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6974. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6975. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6976. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6977. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6978. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6979. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6980. /* FIXME: use matrix-type input source selection */
  6981. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6982. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6983. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6984. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6985. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6986. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6987. /* Input mixer2 */
  6988. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6989. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6990. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6991. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6992. /* Input mixer3 */
  6993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6994. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6995. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6996. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6997. { }
  6998. };
  6999. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7000. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7001. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7002. {}
  7003. };
  7004. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7005. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7006. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7007. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7008. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7009. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7010. {}
  7011. };
  7012. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7013. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7014. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7015. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7016. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7017. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7018. };
  7019. /* mute/unmute internal speaker according to the hp jack and mute state */
  7020. static void alc262_hippo_automute(struct hda_codec *codec)
  7021. {
  7022. struct alc_spec *spec = codec->spec;
  7023. unsigned int mute;
  7024. unsigned int present;
  7025. /* need to execute and sync at first */
  7026. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7027. present = snd_hda_codec_read(codec, 0x15, 0,
  7028. AC_VERB_GET_PIN_SENSE, 0);
  7029. spec->jack_present = (present & 0x80000000) != 0;
  7030. if (spec->jack_present) {
  7031. /* mute internal speaker */
  7032. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7033. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7034. } else {
  7035. /* unmute internal speaker if necessary */
  7036. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7037. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7038. HDA_AMP_MUTE, mute);
  7039. }
  7040. }
  7041. /* unsolicited event for HP jack sensing */
  7042. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7043. unsigned int res)
  7044. {
  7045. if ((res >> 26) != ALC880_HP_EVENT)
  7046. return;
  7047. alc262_hippo_automute(codec);
  7048. }
  7049. static void alc262_hippo1_automute(struct hda_codec *codec)
  7050. {
  7051. unsigned int mute;
  7052. unsigned int present;
  7053. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7054. present = snd_hda_codec_read(codec, 0x1b, 0,
  7055. AC_VERB_GET_PIN_SENSE, 0);
  7056. present = (present & 0x80000000) != 0;
  7057. if (present) {
  7058. /* mute internal speaker */
  7059. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7060. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7061. } else {
  7062. /* unmute internal speaker if necessary */
  7063. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7064. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7065. HDA_AMP_MUTE, mute);
  7066. }
  7067. }
  7068. /* unsolicited event for HP jack sensing */
  7069. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7070. unsigned int res)
  7071. {
  7072. if ((res >> 26) != ALC880_HP_EVENT)
  7073. return;
  7074. alc262_hippo1_automute(codec);
  7075. }
  7076. /*
  7077. * fujitsu model
  7078. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7079. */
  7080. #define ALC_HP_EVENT 0x37
  7081. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7082. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7083. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7084. {}
  7085. };
  7086. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7087. .num_items = 3,
  7088. .items = {
  7089. { "Mic", 0x0 },
  7090. { "Int Mic", 0x1 },
  7091. { "CD", 0x4 },
  7092. },
  7093. };
  7094. static struct hda_input_mux alc262_HP_capture_source = {
  7095. .num_items = 5,
  7096. .items = {
  7097. { "Mic", 0x0 },
  7098. { "Front Mic", 0x1 },
  7099. { "Line", 0x2 },
  7100. { "CD", 0x4 },
  7101. { "AUX IN", 0x6 },
  7102. },
  7103. };
  7104. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7105. .num_items = 4,
  7106. .items = {
  7107. { "Mic", 0x0 },
  7108. { "Front Mic", 0x2 },
  7109. { "Line", 0x1 },
  7110. { "CD", 0x4 },
  7111. },
  7112. };
  7113. /* mute/unmute internal speaker according to the hp jack and mute state */
  7114. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7115. {
  7116. struct alc_spec *spec = codec->spec;
  7117. unsigned int mute;
  7118. if (force || !spec->sense_updated) {
  7119. unsigned int present;
  7120. /* need to execute and sync at first */
  7121. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7122. present = snd_hda_codec_read(codec, 0x14, 0,
  7123. AC_VERB_GET_PIN_SENSE, 0);
  7124. spec->jack_present = (present & 0x80000000) != 0;
  7125. spec->sense_updated = 1;
  7126. }
  7127. if (spec->jack_present) {
  7128. /* mute internal speaker */
  7129. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7130. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7131. } else {
  7132. /* unmute internal speaker if necessary */
  7133. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7134. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7135. HDA_AMP_MUTE, mute);
  7136. }
  7137. }
  7138. /* unsolicited event for HP jack sensing */
  7139. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7140. unsigned int res)
  7141. {
  7142. if ((res >> 26) != ALC_HP_EVENT)
  7143. return;
  7144. alc262_fujitsu_automute(codec, 1);
  7145. }
  7146. /* bind volumes of both NID 0x0c and 0x0d */
  7147. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7148. .ops = &snd_hda_bind_vol,
  7149. .values = {
  7150. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7151. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7152. 0
  7153. },
  7154. };
  7155. /* bind hp and internal speaker mute (with plug check) */
  7156. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7157. struct snd_ctl_elem_value *ucontrol)
  7158. {
  7159. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7160. long *valp = ucontrol->value.integer.value;
  7161. int change;
  7162. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7163. HDA_AMP_MUTE,
  7164. valp[0] ? 0 : HDA_AMP_MUTE);
  7165. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7166. HDA_AMP_MUTE,
  7167. valp[1] ? 0 : HDA_AMP_MUTE);
  7168. if (change)
  7169. alc262_fujitsu_automute(codec, 0);
  7170. return change;
  7171. }
  7172. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7173. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7174. {
  7175. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7176. .name = "Master Playback Switch",
  7177. .info = snd_hda_mixer_amp_switch_info,
  7178. .get = snd_hda_mixer_amp_switch_get,
  7179. .put = alc262_fujitsu_master_sw_put,
  7180. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7181. },
  7182. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7183. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7184. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7185. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7186. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7187. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7188. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7189. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7190. { } /* end */
  7191. };
  7192. /* additional init verbs for Benq laptops */
  7193. static struct hda_verb alc262_EAPD_verbs[] = {
  7194. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7195. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7196. {}
  7197. };
  7198. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7199. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7200. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7201. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7202. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7203. {}
  7204. };
  7205. /* add playback controls from the parsed DAC table */
  7206. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7207. const struct auto_pin_cfg *cfg)
  7208. {
  7209. hda_nid_t nid;
  7210. int err;
  7211. spec->multiout.num_dacs = 1; /* only use one dac */
  7212. spec->multiout.dac_nids = spec->private_dac_nids;
  7213. spec->multiout.dac_nids[0] = 2;
  7214. nid = cfg->line_out_pins[0];
  7215. if (nid) {
  7216. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7217. "Front Playback Volume",
  7218. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7219. if (err < 0)
  7220. return err;
  7221. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7222. "Front Playback Switch",
  7223. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7224. if (err < 0)
  7225. return err;
  7226. }
  7227. nid = cfg->speaker_pins[0];
  7228. if (nid) {
  7229. if (nid == 0x16) {
  7230. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7231. "Speaker Playback Volume",
  7232. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7233. HDA_OUTPUT));
  7234. if (err < 0)
  7235. return err;
  7236. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7237. "Speaker Playback Switch",
  7238. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7239. HDA_OUTPUT));
  7240. if (err < 0)
  7241. return err;
  7242. } else {
  7243. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7244. "Speaker Playback Switch",
  7245. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7246. HDA_OUTPUT));
  7247. if (err < 0)
  7248. return err;
  7249. }
  7250. }
  7251. nid = cfg->hp_pins[0];
  7252. if (nid) {
  7253. /* spec->multiout.hp_nid = 2; */
  7254. if (nid == 0x16) {
  7255. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7256. "Headphone Playback Volume",
  7257. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7258. HDA_OUTPUT));
  7259. if (err < 0)
  7260. return err;
  7261. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7262. "Headphone Playback Switch",
  7263. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7264. HDA_OUTPUT));
  7265. if (err < 0)
  7266. return err;
  7267. } else {
  7268. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7269. "Headphone Playback Switch",
  7270. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7271. HDA_OUTPUT));
  7272. if (err < 0)
  7273. return err;
  7274. }
  7275. }
  7276. return 0;
  7277. }
  7278. /* identical with ALC880 */
  7279. #define alc262_auto_create_analog_input_ctls \
  7280. alc880_auto_create_analog_input_ctls
  7281. /*
  7282. * generic initialization of ADC, input mixers and output mixers
  7283. */
  7284. static struct hda_verb alc262_volume_init_verbs[] = {
  7285. /*
  7286. * Unmute ADC0-2 and set the default input to mic-in
  7287. */
  7288. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7289. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7290. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7291. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7292. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7293. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7294. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7295. * mixer widget
  7296. * Note: PASD motherboards uses the Line In 2 as the input for
  7297. * front panel mic (mic 2)
  7298. */
  7299. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7300. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7301. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7302. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7303. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7304. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7305. /*
  7306. * Set up output mixers (0x0c - 0x0f)
  7307. */
  7308. /* set vol=0 to output mixers */
  7309. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7310. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7311. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7312. /* set up input amps for analog loopback */
  7313. /* Amp Indices: DAC = 0, mixer = 1 */
  7314. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7315. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7316. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7317. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7318. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7319. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7320. /* FIXME: use matrix-type input source selection */
  7321. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7322. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7323. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7324. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7325. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7326. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7327. /* Input mixer2 */
  7328. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7329. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7330. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7331. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7332. /* Input mixer3 */
  7333. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7334. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7335. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7336. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7337. { }
  7338. };
  7339. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7340. /*
  7341. * Unmute ADC0-2 and set the default input to mic-in
  7342. */
  7343. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7344. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7345. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7347. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7348. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7349. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7350. * mixer widget
  7351. * Note: PASD motherboards uses the Line In 2 as the input for
  7352. * front panel mic (mic 2)
  7353. */
  7354. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7355. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7356. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7357. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7358. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7359. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7360. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7361. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7362. /*
  7363. * Set up output mixers (0x0c - 0x0e)
  7364. */
  7365. /* set vol=0 to output mixers */
  7366. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7367. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7368. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7369. /* set up input amps for analog loopback */
  7370. /* Amp Indices: DAC = 0, mixer = 1 */
  7371. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7372. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7373. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7374. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7375. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7376. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7377. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7378. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7379. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7380. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7381. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7382. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7383. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7384. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7385. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7387. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7388. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7389. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7390. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7391. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7392. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7393. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7394. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7395. /* FIXME: use matrix-type input source selection */
  7396. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7397. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7398. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7399. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7400. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7401. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7402. /* Input mixer2 */
  7403. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7404. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7405. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7406. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7407. /* Input mixer3 */
  7408. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7409. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7410. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7411. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7412. { }
  7413. };
  7414. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7415. /*
  7416. * Unmute ADC0-2 and set the default input to mic-in
  7417. */
  7418. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7419. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7420. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7421. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7422. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7423. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7424. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7425. * mixer widget
  7426. * Note: PASD motherboards uses the Line In 2 as the input for front
  7427. * panel mic (mic 2)
  7428. */
  7429. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7430. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7431. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7432. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7433. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7434. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7435. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7436. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7437. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7438. /*
  7439. * Set up output mixers (0x0c - 0x0e)
  7440. */
  7441. /* set vol=0 to output mixers */
  7442. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7443. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7444. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7445. /* set up input amps for analog loopback */
  7446. /* Amp Indices: DAC = 0, mixer = 1 */
  7447. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7448. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7449. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7450. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7451. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7452. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7453. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7454. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7455. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7456. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7457. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7458. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7459. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7460. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7461. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7462. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7463. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7464. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7465. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7466. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7467. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7468. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7469. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7470. /* FIXME: use matrix-type input source selection */
  7471. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7472. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7473. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7474. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7475. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7476. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7477. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7478. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7479. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7480. /* Input mixer2 */
  7481. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7482. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7483. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7484. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7485. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7486. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7487. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7488. /* Input mixer3 */
  7489. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7490. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7491. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7492. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7493. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7494. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7495. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7496. { }
  7497. };
  7498. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7499. #define alc262_loopbacks alc880_loopbacks
  7500. #endif
  7501. /* pcm configuration: identiacal with ALC880 */
  7502. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7503. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7504. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7505. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7506. /*
  7507. * BIOS auto configuration
  7508. */
  7509. static int alc262_parse_auto_config(struct hda_codec *codec)
  7510. {
  7511. struct alc_spec *spec = codec->spec;
  7512. int err;
  7513. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7514. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7515. alc262_ignore);
  7516. if (err < 0)
  7517. return err;
  7518. if (!spec->autocfg.line_outs)
  7519. return 0; /* can't find valid BIOS pin config */
  7520. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7521. if (err < 0)
  7522. return err;
  7523. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7524. if (err < 0)
  7525. return err;
  7526. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7527. if (spec->autocfg.dig_out_pin)
  7528. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7529. if (spec->autocfg.dig_in_pin)
  7530. spec->dig_in_nid = ALC262_DIGIN_NID;
  7531. if (spec->kctl_alloc)
  7532. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7533. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7534. spec->num_mux_defs = 1;
  7535. spec->input_mux = &spec->private_imux;
  7536. err = alc_auto_add_mic_boost(codec);
  7537. if (err < 0)
  7538. return err;
  7539. return 1;
  7540. }
  7541. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7542. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7543. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7544. /* init callback for auto-configuration model -- overriding the default init */
  7545. static void alc262_auto_init(struct hda_codec *codec)
  7546. {
  7547. alc262_auto_init_multi_out(codec);
  7548. alc262_auto_init_hp_out(codec);
  7549. alc262_auto_init_analog_input(codec);
  7550. }
  7551. /*
  7552. * configuration and preset
  7553. */
  7554. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7555. [ALC262_BASIC] = "basic",
  7556. [ALC262_HIPPO] = "hippo",
  7557. [ALC262_HIPPO_1] = "hippo_1",
  7558. [ALC262_FUJITSU] = "fujitsu",
  7559. [ALC262_HP_BPC] = "hp-bpc",
  7560. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7561. [ALC262_BENQ_ED8] = "benq",
  7562. [ALC262_BENQ_T31] = "benq-t31",
  7563. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7564. [ALC262_AUTO] = "auto",
  7565. };
  7566. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7567. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7568. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7569. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7570. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7571. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7572. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7573. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7574. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7575. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7576. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7577. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7578. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7579. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7580. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7581. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7582. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7583. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7584. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7585. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7586. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7587. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7588. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7589. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7590. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7591. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7592. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7593. {}
  7594. };
  7595. static struct alc_config_preset alc262_presets[] = {
  7596. [ALC262_BASIC] = {
  7597. .mixers = { alc262_base_mixer },
  7598. .init_verbs = { alc262_init_verbs },
  7599. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7600. .dac_nids = alc262_dac_nids,
  7601. .hp_nid = 0x03,
  7602. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7603. .channel_mode = alc262_modes,
  7604. .input_mux = &alc262_capture_source,
  7605. },
  7606. [ALC262_HIPPO] = {
  7607. .mixers = { alc262_base_mixer },
  7608. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7609. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7610. .dac_nids = alc262_dac_nids,
  7611. .hp_nid = 0x03,
  7612. .dig_out_nid = ALC262_DIGOUT_NID,
  7613. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7614. .channel_mode = alc262_modes,
  7615. .input_mux = &alc262_capture_source,
  7616. .unsol_event = alc262_hippo_unsol_event,
  7617. .init_hook = alc262_hippo_automute,
  7618. },
  7619. [ALC262_HIPPO_1] = {
  7620. .mixers = { alc262_hippo1_mixer },
  7621. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7622. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7623. .dac_nids = alc262_dac_nids,
  7624. .hp_nid = 0x02,
  7625. .dig_out_nid = ALC262_DIGOUT_NID,
  7626. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7627. .channel_mode = alc262_modes,
  7628. .input_mux = &alc262_capture_source,
  7629. .unsol_event = alc262_hippo1_unsol_event,
  7630. .init_hook = alc262_hippo1_automute,
  7631. },
  7632. [ALC262_FUJITSU] = {
  7633. .mixers = { alc262_fujitsu_mixer },
  7634. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7635. alc262_fujitsu_unsol_verbs },
  7636. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7637. .dac_nids = alc262_dac_nids,
  7638. .hp_nid = 0x03,
  7639. .dig_out_nid = ALC262_DIGOUT_NID,
  7640. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7641. .channel_mode = alc262_modes,
  7642. .input_mux = &alc262_fujitsu_capture_source,
  7643. .unsol_event = alc262_fujitsu_unsol_event,
  7644. },
  7645. [ALC262_HP_BPC] = {
  7646. .mixers = { alc262_HP_BPC_mixer },
  7647. .init_verbs = { alc262_HP_BPC_init_verbs },
  7648. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7649. .dac_nids = alc262_dac_nids,
  7650. .hp_nid = 0x03,
  7651. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7652. .channel_mode = alc262_modes,
  7653. .input_mux = &alc262_HP_capture_source,
  7654. },
  7655. [ALC262_HP_BPC_D7000_WF] = {
  7656. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7657. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7658. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7659. .dac_nids = alc262_dac_nids,
  7660. .hp_nid = 0x03,
  7661. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7662. .channel_mode = alc262_modes,
  7663. .input_mux = &alc262_HP_D7000_capture_source,
  7664. },
  7665. [ALC262_HP_BPC_D7000_WL] = {
  7666. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7667. alc262_HP_BPC_WildWest_option_mixer },
  7668. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7669. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7670. .dac_nids = alc262_dac_nids,
  7671. .hp_nid = 0x03,
  7672. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7673. .channel_mode = alc262_modes,
  7674. .input_mux = &alc262_HP_D7000_capture_source,
  7675. },
  7676. [ALC262_BENQ_ED8] = {
  7677. .mixers = { alc262_base_mixer },
  7678. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7679. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7680. .dac_nids = alc262_dac_nids,
  7681. .hp_nid = 0x03,
  7682. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7683. .channel_mode = alc262_modes,
  7684. .input_mux = &alc262_capture_source,
  7685. },
  7686. [ALC262_SONY_ASSAMD] = {
  7687. .mixers = { alc262_sony_mixer },
  7688. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7689. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7690. .dac_nids = alc262_dac_nids,
  7691. .hp_nid = 0x02,
  7692. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7693. .channel_mode = alc262_modes,
  7694. .input_mux = &alc262_capture_source,
  7695. .unsol_event = alc262_hippo_unsol_event,
  7696. .init_hook = alc262_hippo_automute,
  7697. },
  7698. [ALC262_BENQ_T31] = {
  7699. .mixers = { alc262_benq_t31_mixer },
  7700. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7701. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7702. .dac_nids = alc262_dac_nids,
  7703. .hp_nid = 0x03,
  7704. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7705. .channel_mode = alc262_modes,
  7706. .input_mux = &alc262_capture_source,
  7707. .unsol_event = alc262_hippo_unsol_event,
  7708. .init_hook = alc262_hippo_automute,
  7709. },
  7710. };
  7711. static int patch_alc262(struct hda_codec *codec)
  7712. {
  7713. struct alc_spec *spec;
  7714. int board_config;
  7715. int err;
  7716. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7717. if (spec == NULL)
  7718. return -ENOMEM;
  7719. codec->spec = spec;
  7720. #if 0
  7721. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7722. * under-run
  7723. */
  7724. {
  7725. int tmp;
  7726. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7727. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7728. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7729. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7730. }
  7731. #endif
  7732. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7733. alc262_models,
  7734. alc262_cfg_tbl);
  7735. if (board_config < 0) {
  7736. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7737. "trying auto-probe from BIOS...\n");
  7738. board_config = ALC262_AUTO;
  7739. }
  7740. if (board_config == ALC262_AUTO) {
  7741. /* automatic parse from the BIOS config */
  7742. err = alc262_parse_auto_config(codec);
  7743. if (err < 0) {
  7744. alc_free(codec);
  7745. return err;
  7746. } else if (!err) {
  7747. printk(KERN_INFO
  7748. "hda_codec: Cannot set up configuration "
  7749. "from BIOS. Using base mode...\n");
  7750. board_config = ALC262_BASIC;
  7751. }
  7752. }
  7753. if (board_config != ALC262_AUTO)
  7754. setup_preset(spec, &alc262_presets[board_config]);
  7755. spec->stream_name_analog = "ALC262 Analog";
  7756. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7757. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7758. spec->stream_name_digital = "ALC262 Digital";
  7759. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7760. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7761. if (!spec->adc_nids && spec->input_mux) {
  7762. /* check whether NID 0x07 is valid */
  7763. unsigned int wcap = get_wcaps(codec, 0x07);
  7764. /* get type */
  7765. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7766. if (wcap != AC_WID_AUD_IN) {
  7767. spec->adc_nids = alc262_adc_nids_alt;
  7768. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7769. spec->mixers[spec->num_mixers] =
  7770. alc262_capture_alt_mixer;
  7771. spec->num_mixers++;
  7772. } else {
  7773. spec->adc_nids = alc262_adc_nids;
  7774. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7775. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7776. spec->num_mixers++;
  7777. }
  7778. }
  7779. codec->patch_ops = alc_patch_ops;
  7780. if (board_config == ALC262_AUTO)
  7781. spec->init_hook = alc262_auto_init;
  7782. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7783. if (!spec->loopback.amplist)
  7784. spec->loopback.amplist = alc262_loopbacks;
  7785. #endif
  7786. return 0;
  7787. }
  7788. /*
  7789. * ALC268 channel source setting (2 channel)
  7790. */
  7791. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7792. #define alc268_modes alc260_modes
  7793. static hda_nid_t alc268_dac_nids[2] = {
  7794. /* front, hp */
  7795. 0x02, 0x03
  7796. };
  7797. static hda_nid_t alc268_adc_nids[2] = {
  7798. /* ADC0-1 */
  7799. 0x08, 0x07
  7800. };
  7801. static hda_nid_t alc268_adc_nids_alt[1] = {
  7802. /* ADC0 */
  7803. 0x08
  7804. };
  7805. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7806. /* output mixer control */
  7807. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7808. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7809. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7810. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7811. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7812. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7813. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7814. { }
  7815. };
  7816. static struct hda_verb alc268_eapd_verbs[] = {
  7817. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7818. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7819. { }
  7820. };
  7821. /* Toshiba specific */
  7822. #define alc268_toshiba_automute alc262_hippo_automute
  7823. static struct hda_verb alc268_toshiba_verbs[] = {
  7824. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7825. { } /* end */
  7826. };
  7827. /* Acer specific */
  7828. /* bind volumes of both NID 0x02 and 0x03 */
  7829. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7830. .ops = &snd_hda_bind_vol,
  7831. .values = {
  7832. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7833. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7834. 0
  7835. },
  7836. };
  7837. /* mute/unmute internal speaker according to the hp jack and mute state */
  7838. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7839. {
  7840. struct alc_spec *spec = codec->spec;
  7841. unsigned int mute;
  7842. if (force || !spec->sense_updated) {
  7843. unsigned int present;
  7844. present = snd_hda_codec_read(codec, 0x14, 0,
  7845. AC_VERB_GET_PIN_SENSE, 0);
  7846. spec->jack_present = (present & 0x80000000) != 0;
  7847. spec->sense_updated = 1;
  7848. }
  7849. if (spec->jack_present)
  7850. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7851. else /* unmute internal speaker if necessary */
  7852. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7853. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7854. HDA_AMP_MUTE, mute);
  7855. }
  7856. /* bind hp and internal speaker mute (with plug check) */
  7857. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7858. struct snd_ctl_elem_value *ucontrol)
  7859. {
  7860. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7861. long *valp = ucontrol->value.integer.value;
  7862. int change;
  7863. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7864. HDA_AMP_MUTE,
  7865. valp[0] ? 0 : HDA_AMP_MUTE);
  7866. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7867. HDA_AMP_MUTE,
  7868. valp[1] ? 0 : HDA_AMP_MUTE);
  7869. if (change)
  7870. alc268_acer_automute(codec, 0);
  7871. return change;
  7872. }
  7873. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7874. /* output mixer control */
  7875. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7876. {
  7877. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7878. .name = "Master Playback Switch",
  7879. .info = snd_hda_mixer_amp_switch_info,
  7880. .get = snd_hda_mixer_amp_switch_get,
  7881. .put = alc268_acer_master_sw_put,
  7882. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7883. },
  7884. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7885. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7886. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7887. { }
  7888. };
  7889. static struct hda_verb alc268_acer_verbs[] = {
  7890. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7891. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7892. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7893. { }
  7894. };
  7895. /* unsolicited event for HP jack sensing */
  7896. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7897. unsigned int res)
  7898. {
  7899. if ((res >> 26) != ALC880_HP_EVENT)
  7900. return;
  7901. alc268_toshiba_automute(codec);
  7902. }
  7903. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7904. unsigned int res)
  7905. {
  7906. if ((res >> 26) != ALC880_HP_EVENT)
  7907. return;
  7908. alc268_acer_automute(codec, 1);
  7909. }
  7910. static void alc268_acer_init_hook(struct hda_codec *codec)
  7911. {
  7912. alc268_acer_automute(codec, 1);
  7913. }
  7914. /*
  7915. * generic initialization of ADC, input mixers and output mixers
  7916. */
  7917. static struct hda_verb alc268_base_init_verbs[] = {
  7918. /* Unmute DAC0-1 and set vol = 0 */
  7919. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7920. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7921. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7922. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7923. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7924. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7925. /*
  7926. * Set up output mixers (0x0c - 0x0e)
  7927. */
  7928. /* set vol=0 to output mixers */
  7929. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7930. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7931. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7932. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7933. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7934. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7935. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7936. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7937. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7938. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7939. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7940. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7941. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7942. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7943. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7944. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7945. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7946. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7947. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7948. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7949. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7950. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7951. /* FIXME: use matrix-type input source selection */
  7952. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7953. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7954. /* Input mixer2 */
  7955. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7956. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7957. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7958. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7959. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7960. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7961. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7962. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7963. { }
  7964. };
  7965. /*
  7966. * generic initialization of ADC, input mixers and output mixers
  7967. */
  7968. static struct hda_verb alc268_volume_init_verbs[] = {
  7969. /* set output DAC */
  7970. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7971. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7972. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7973. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7974. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7975. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7976. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7977. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7978. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7979. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7980. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7981. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7982. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7983. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7984. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7985. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7986. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7987. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7988. /* set PCBEEP vol = 0 */
  7989. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7990. { }
  7991. };
  7992. #define alc268_mux_enum_info alc_mux_enum_info
  7993. #define alc268_mux_enum_get alc_mux_enum_get
  7994. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7995. struct snd_ctl_elem_value *ucontrol)
  7996. {
  7997. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7998. struct alc_spec *spec = codec->spec;
  7999. const struct hda_input_mux *imux = spec->input_mux;
  8000. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8001. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8002. hda_nid_t nid = capture_mixers[adc_idx];
  8003. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8004. unsigned int i, idx;
  8005. idx = ucontrol->value.enumerated.item[0];
  8006. if (idx >= imux->num_items)
  8007. idx = imux->num_items - 1;
  8008. if (*cur_val == idx)
  8009. return 0;
  8010. for (i = 0; i < imux->num_items; i++) {
  8011. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8012. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8013. imux->items[i].index,
  8014. HDA_AMP_MUTE, v);
  8015. snd_hda_codec_write_cache(codec, nid, 0,
  8016. AC_VERB_SET_CONNECT_SEL,
  8017. idx );
  8018. }
  8019. *cur_val = idx;
  8020. return 1;
  8021. }
  8022. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8023. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8024. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8025. {
  8026. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8027. /* The multiple "Capture Source" controls confuse alsamixer
  8028. * So call somewhat different..
  8029. * FIXME: the controls appear in the "playback" view!
  8030. */
  8031. /* .name = "Capture Source", */
  8032. .name = "Input Source",
  8033. .count = 1,
  8034. .info = alc268_mux_enum_info,
  8035. .get = alc268_mux_enum_get,
  8036. .put = alc268_mux_enum_put,
  8037. },
  8038. { } /* end */
  8039. };
  8040. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8041. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8042. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8043. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8044. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8045. {
  8046. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8047. /* The multiple "Capture Source" controls confuse alsamixer
  8048. * So call somewhat different..
  8049. * FIXME: the controls appear in the "playback" view!
  8050. */
  8051. /* .name = "Capture Source", */
  8052. .name = "Input Source",
  8053. .count = 2,
  8054. .info = alc268_mux_enum_info,
  8055. .get = alc268_mux_enum_get,
  8056. .put = alc268_mux_enum_put,
  8057. },
  8058. { } /* end */
  8059. };
  8060. static struct hda_input_mux alc268_capture_source = {
  8061. .num_items = 4,
  8062. .items = {
  8063. { "Mic", 0x0 },
  8064. { "Front Mic", 0x1 },
  8065. { "Line", 0x2 },
  8066. { "CD", 0x3 },
  8067. },
  8068. };
  8069. /* create input playback/capture controls for the given pin */
  8070. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8071. const char *ctlname, int idx)
  8072. {
  8073. char name[32];
  8074. int err;
  8075. sprintf(name, "%s Playback Volume", ctlname);
  8076. if (nid == 0x14) {
  8077. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8078. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8079. HDA_OUTPUT));
  8080. if (err < 0)
  8081. return err;
  8082. } else if (nid == 0x15) {
  8083. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8084. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8085. HDA_OUTPUT));
  8086. if (err < 0)
  8087. return err;
  8088. } else
  8089. return -1;
  8090. sprintf(name, "%s Playback Switch", ctlname);
  8091. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8092. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8093. if (err < 0)
  8094. return err;
  8095. return 0;
  8096. }
  8097. /* add playback controls from the parsed DAC table */
  8098. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8099. const struct auto_pin_cfg *cfg)
  8100. {
  8101. hda_nid_t nid;
  8102. int err;
  8103. spec->multiout.num_dacs = 2; /* only use one dac */
  8104. spec->multiout.dac_nids = spec->private_dac_nids;
  8105. spec->multiout.dac_nids[0] = 2;
  8106. spec->multiout.dac_nids[1] = 3;
  8107. nid = cfg->line_out_pins[0];
  8108. if (nid)
  8109. alc268_new_analog_output(spec, nid, "Front", 0);
  8110. nid = cfg->speaker_pins[0];
  8111. if (nid == 0x1d) {
  8112. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8113. "Speaker Playback Volume",
  8114. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8115. if (err < 0)
  8116. return err;
  8117. }
  8118. nid = cfg->hp_pins[0];
  8119. if (nid)
  8120. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8121. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8122. if (nid == 0x16) {
  8123. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8124. "Mono Playback Switch",
  8125. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8126. if (err < 0)
  8127. return err;
  8128. }
  8129. return 0;
  8130. }
  8131. /* create playback/capture controls for input pins */
  8132. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8133. const struct auto_pin_cfg *cfg)
  8134. {
  8135. struct hda_input_mux *imux = &spec->private_imux;
  8136. int i, idx1;
  8137. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8138. switch(cfg->input_pins[i]) {
  8139. case 0x18:
  8140. idx1 = 0; /* Mic 1 */
  8141. break;
  8142. case 0x19:
  8143. idx1 = 1; /* Mic 2 */
  8144. break;
  8145. case 0x1a:
  8146. idx1 = 2; /* Line In */
  8147. break;
  8148. case 0x1c:
  8149. idx1 = 3; /* CD */
  8150. break;
  8151. default:
  8152. continue;
  8153. }
  8154. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8155. imux->items[imux->num_items].index = idx1;
  8156. imux->num_items++;
  8157. }
  8158. return 0;
  8159. }
  8160. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8161. {
  8162. struct alc_spec *spec = codec->spec;
  8163. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8164. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8165. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8166. unsigned int dac_vol1, dac_vol2;
  8167. if (speaker_nid) {
  8168. snd_hda_codec_write(codec, speaker_nid, 0,
  8169. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8170. snd_hda_codec_write(codec, 0x0f, 0,
  8171. AC_VERB_SET_AMP_GAIN_MUTE,
  8172. AMP_IN_UNMUTE(1));
  8173. snd_hda_codec_write(codec, 0x10, 0,
  8174. AC_VERB_SET_AMP_GAIN_MUTE,
  8175. AMP_IN_UNMUTE(1));
  8176. } else {
  8177. snd_hda_codec_write(codec, 0x0f, 0,
  8178. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8179. snd_hda_codec_write(codec, 0x10, 0,
  8180. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8181. }
  8182. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8183. if (line_nid == 0x14)
  8184. dac_vol2 = AMP_OUT_ZERO;
  8185. else if (line_nid == 0x15)
  8186. dac_vol1 = AMP_OUT_ZERO;
  8187. if (hp_nid == 0x14)
  8188. dac_vol2 = AMP_OUT_ZERO;
  8189. else if (hp_nid == 0x15)
  8190. dac_vol1 = AMP_OUT_ZERO;
  8191. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8192. spec->autocfg.line_out_pins[1] != 0x16 ||
  8193. spec->autocfg.line_out_pins[2] != 0x16)
  8194. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8195. snd_hda_codec_write(codec, 0x02, 0,
  8196. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8197. snd_hda_codec_write(codec, 0x03, 0,
  8198. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8199. }
  8200. /* pcm configuration: identiacal with ALC880 */
  8201. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8202. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8203. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8204. /*
  8205. * BIOS auto configuration
  8206. */
  8207. static int alc268_parse_auto_config(struct hda_codec *codec)
  8208. {
  8209. struct alc_spec *spec = codec->spec;
  8210. int err;
  8211. static hda_nid_t alc268_ignore[] = { 0 };
  8212. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8213. alc268_ignore);
  8214. if (err < 0)
  8215. return err;
  8216. if (!spec->autocfg.line_outs)
  8217. return 0; /* can't find valid BIOS pin config */
  8218. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8219. if (err < 0)
  8220. return err;
  8221. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8222. if (err < 0)
  8223. return err;
  8224. spec->multiout.max_channels = 2;
  8225. /* digital only support output */
  8226. if (spec->autocfg.dig_out_pin)
  8227. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8228. if (spec->kctl_alloc)
  8229. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8230. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8231. spec->num_mux_defs = 1;
  8232. spec->input_mux = &spec->private_imux;
  8233. err = alc_auto_add_mic_boost(codec);
  8234. if (err < 0)
  8235. return err;
  8236. return 1;
  8237. }
  8238. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8239. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8240. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8241. /* init callback for auto-configuration model -- overriding the default init */
  8242. static void alc268_auto_init(struct hda_codec *codec)
  8243. {
  8244. alc268_auto_init_multi_out(codec);
  8245. alc268_auto_init_hp_out(codec);
  8246. alc268_auto_init_mono_speaker_out(codec);
  8247. alc268_auto_init_analog_input(codec);
  8248. }
  8249. /*
  8250. * configuration and preset
  8251. */
  8252. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8253. [ALC268_3ST] = "3stack",
  8254. [ALC268_TOSHIBA] = "toshiba",
  8255. [ALC268_ACER] = "acer",
  8256. [ALC268_AUTO] = "auto",
  8257. };
  8258. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8259. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8260. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8261. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8262. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8263. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8264. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8265. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8266. {}
  8267. };
  8268. static struct alc_config_preset alc268_presets[] = {
  8269. [ALC268_3ST] = {
  8270. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8271. .init_verbs = { alc268_base_init_verbs },
  8272. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8273. .dac_nids = alc268_dac_nids,
  8274. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8275. .adc_nids = alc268_adc_nids_alt,
  8276. .hp_nid = 0x03,
  8277. .dig_out_nid = ALC268_DIGOUT_NID,
  8278. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8279. .channel_mode = alc268_modes,
  8280. .input_mux = &alc268_capture_source,
  8281. },
  8282. [ALC268_TOSHIBA] = {
  8283. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8284. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8285. alc268_toshiba_verbs },
  8286. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8287. .dac_nids = alc268_dac_nids,
  8288. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8289. .adc_nids = alc268_adc_nids_alt,
  8290. .hp_nid = 0x03,
  8291. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8292. .channel_mode = alc268_modes,
  8293. .input_mux = &alc268_capture_source,
  8294. .input_mux = &alc268_capture_source,
  8295. .unsol_event = alc268_toshiba_unsol_event,
  8296. .init_hook = alc268_toshiba_automute,
  8297. },
  8298. [ALC268_ACER] = {
  8299. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8300. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8301. alc268_acer_verbs },
  8302. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8303. .dac_nids = alc268_dac_nids,
  8304. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8305. .adc_nids = alc268_adc_nids_alt,
  8306. .hp_nid = 0x02,
  8307. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8308. .channel_mode = alc268_modes,
  8309. .input_mux = &alc268_capture_source,
  8310. .unsol_event = alc268_acer_unsol_event,
  8311. .init_hook = alc268_acer_init_hook,
  8312. },
  8313. };
  8314. static int patch_alc268(struct hda_codec *codec)
  8315. {
  8316. struct alc_spec *spec;
  8317. int board_config;
  8318. int err;
  8319. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8320. if (spec == NULL)
  8321. return -ENOMEM;
  8322. codec->spec = spec;
  8323. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8324. alc268_models,
  8325. alc268_cfg_tbl);
  8326. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8327. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8328. "trying auto-probe from BIOS...\n");
  8329. board_config = ALC268_AUTO;
  8330. }
  8331. if (board_config == ALC268_AUTO) {
  8332. /* automatic parse from the BIOS config */
  8333. err = alc268_parse_auto_config(codec);
  8334. if (err < 0) {
  8335. alc_free(codec);
  8336. return err;
  8337. } else if (!err) {
  8338. printk(KERN_INFO
  8339. "hda_codec: Cannot set up configuration "
  8340. "from BIOS. Using base mode...\n");
  8341. board_config = ALC268_3ST;
  8342. }
  8343. }
  8344. if (board_config != ALC268_AUTO)
  8345. setup_preset(spec, &alc268_presets[board_config]);
  8346. spec->stream_name_analog = "ALC268 Analog";
  8347. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8348. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8349. spec->stream_name_digital = "ALC268 Digital";
  8350. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8351. if (board_config == ALC268_AUTO) {
  8352. if (!spec->adc_nids && spec->input_mux) {
  8353. /* check whether NID 0x07 is valid */
  8354. unsigned int wcap = get_wcaps(codec, 0x07);
  8355. /* get type */
  8356. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8357. if (wcap != AC_WID_AUD_IN) {
  8358. spec->adc_nids = alc268_adc_nids_alt;
  8359. spec->num_adc_nids =
  8360. ARRAY_SIZE(alc268_adc_nids_alt);
  8361. spec->mixers[spec->num_mixers] =
  8362. alc268_capture_alt_mixer;
  8363. spec->num_mixers++;
  8364. } else {
  8365. spec->adc_nids = alc268_adc_nids;
  8366. spec->num_adc_nids =
  8367. ARRAY_SIZE(alc268_adc_nids);
  8368. spec->mixers[spec->num_mixers] =
  8369. alc268_capture_mixer;
  8370. spec->num_mixers++;
  8371. }
  8372. }
  8373. }
  8374. codec->patch_ops = alc_patch_ops;
  8375. if (board_config == ALC268_AUTO)
  8376. spec->init_hook = alc268_auto_init;
  8377. return 0;
  8378. }
  8379. /*
  8380. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8381. */
  8382. /*
  8383. * set the path ways for 2 channel output
  8384. * need to set the codec line out and mic 1 pin widgets to inputs
  8385. */
  8386. static struct hda_verb alc861_threestack_ch2_init[] = {
  8387. /* set pin widget 1Ah (line in) for input */
  8388. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8389. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8390. * the vref
  8391. */
  8392. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8393. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8394. #if 0
  8395. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8396. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8397. #endif
  8398. { } /* end */
  8399. };
  8400. /*
  8401. * 6ch mode
  8402. * need to set the codec line out and mic 1 pin widgets to outputs
  8403. */
  8404. static struct hda_verb alc861_threestack_ch6_init[] = {
  8405. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8406. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8407. /* set pin widget 18h (mic1) for output (CLFE)*/
  8408. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8409. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8410. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8411. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8412. #if 0
  8413. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8414. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8415. #endif
  8416. { } /* end */
  8417. };
  8418. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8419. { 2, alc861_threestack_ch2_init },
  8420. { 6, alc861_threestack_ch6_init },
  8421. };
  8422. /* Set mic1 as input and unmute the mixer */
  8423. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8424. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8425. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8426. { } /* end */
  8427. };
  8428. /* Set mic1 as output and mute mixer */
  8429. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8430. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8431. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8432. { } /* end */
  8433. };
  8434. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8435. { 2, alc861_uniwill_m31_ch2_init },
  8436. { 4, alc861_uniwill_m31_ch4_init },
  8437. };
  8438. /* Set mic1 and line-in as input and unmute the mixer */
  8439. static struct hda_verb alc861_asus_ch2_init[] = {
  8440. /* set pin widget 1Ah (line in) for input */
  8441. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8442. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8443. * the vref
  8444. */
  8445. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8446. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8447. #if 0
  8448. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8449. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8450. #endif
  8451. { } /* end */
  8452. };
  8453. /* Set mic1 nad line-in as output and mute mixer */
  8454. static struct hda_verb alc861_asus_ch6_init[] = {
  8455. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8456. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8457. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8458. /* set pin widget 18h (mic1) for output (CLFE)*/
  8459. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8460. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8461. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8462. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8463. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8464. #if 0
  8465. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8466. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8467. #endif
  8468. { } /* end */
  8469. };
  8470. static struct hda_channel_mode alc861_asus_modes[2] = {
  8471. { 2, alc861_asus_ch2_init },
  8472. { 6, alc861_asus_ch6_init },
  8473. };
  8474. /* patch-ALC861 */
  8475. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8476. /* output mixer control */
  8477. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8478. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8479. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8480. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8481. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8482. /*Input mixer control */
  8483. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8484. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8485. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8486. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8487. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8488. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8489. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8490. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8491. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8492. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8493. /* Capture mixer control */
  8494. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8495. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8496. {
  8497. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8498. .name = "Capture Source",
  8499. .count = 1,
  8500. .info = alc_mux_enum_info,
  8501. .get = alc_mux_enum_get,
  8502. .put = alc_mux_enum_put,
  8503. },
  8504. { } /* end */
  8505. };
  8506. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8507. /* output mixer control */
  8508. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8509. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8510. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8511. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8512. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8513. /* Input mixer control */
  8514. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8515. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8516. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8517. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8518. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8519. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8520. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8521. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8522. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8523. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8524. /* Capture mixer control */
  8525. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8526. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8527. {
  8528. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8529. .name = "Capture Source",
  8530. .count = 1,
  8531. .info = alc_mux_enum_info,
  8532. .get = alc_mux_enum_get,
  8533. .put = alc_mux_enum_put,
  8534. },
  8535. {
  8536. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8537. .name = "Channel Mode",
  8538. .info = alc_ch_mode_info,
  8539. .get = alc_ch_mode_get,
  8540. .put = alc_ch_mode_put,
  8541. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8542. },
  8543. { } /* end */
  8544. };
  8545. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8546. /* output mixer control */
  8547. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8548. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8549. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8550. /*Capture mixer control */
  8551. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8552. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8553. {
  8554. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8555. .name = "Capture Source",
  8556. .count = 1,
  8557. .info = alc_mux_enum_info,
  8558. .get = alc_mux_enum_get,
  8559. .put = alc_mux_enum_put,
  8560. },
  8561. { } /* end */
  8562. };
  8563. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8564. /* output mixer control */
  8565. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8566. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8567. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8568. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8569. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8570. /* Input mixer control */
  8571. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8572. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8573. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8574. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8575. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8576. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8577. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8578. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8579. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8580. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8581. /* Capture mixer control */
  8582. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8583. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8584. {
  8585. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8586. .name = "Capture Source",
  8587. .count = 1,
  8588. .info = alc_mux_enum_info,
  8589. .get = alc_mux_enum_get,
  8590. .put = alc_mux_enum_put,
  8591. },
  8592. {
  8593. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8594. .name = "Channel Mode",
  8595. .info = alc_ch_mode_info,
  8596. .get = alc_ch_mode_get,
  8597. .put = alc_ch_mode_put,
  8598. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8599. },
  8600. { } /* end */
  8601. };
  8602. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8603. /* output mixer control */
  8604. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8605. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8606. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8607. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8608. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8609. /* Input mixer control */
  8610. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8611. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8612. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8613. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8614. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8615. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8616. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8617. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8618. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8619. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8620. /* Capture mixer control */
  8621. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8622. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8623. {
  8624. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8625. .name = "Capture Source",
  8626. .count = 1,
  8627. .info = alc_mux_enum_info,
  8628. .get = alc_mux_enum_get,
  8629. .put = alc_mux_enum_put,
  8630. },
  8631. {
  8632. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8633. .name = "Channel Mode",
  8634. .info = alc_ch_mode_info,
  8635. .get = alc_ch_mode_get,
  8636. .put = alc_ch_mode_put,
  8637. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8638. },
  8639. { }
  8640. };
  8641. /* additional mixer */
  8642. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8643. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8644. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8645. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8646. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8647. { }
  8648. };
  8649. /*
  8650. * generic initialization of ADC, input mixers and output mixers
  8651. */
  8652. static struct hda_verb alc861_base_init_verbs[] = {
  8653. /*
  8654. * Unmute ADC0 and set the default input to mic-in
  8655. */
  8656. /* port-A for surround (rear panel) */
  8657. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8658. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8659. /* port-B for mic-in (rear panel) with vref */
  8660. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8661. /* port-C for line-in (rear panel) */
  8662. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8663. /* port-D for Front */
  8664. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8665. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8666. /* port-E for HP out (front panel) */
  8667. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8668. /* route front PCM to HP */
  8669. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8670. /* port-F for mic-in (front panel) with vref */
  8671. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8672. /* port-G for CLFE (rear panel) */
  8673. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8674. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8675. /* port-H for side (rear panel) */
  8676. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8677. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8678. /* CD-in */
  8679. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8680. /* route front mic to ADC1*/
  8681. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8682. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8683. /* Unmute DAC0~3 & spdif out*/
  8684. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8685. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8686. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8687. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8688. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8689. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8690. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8691. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8692. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8693. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8694. /* Unmute Stereo Mixer 15 */
  8695. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8696. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8697. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8698. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8699. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8700. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8701. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8702. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8703. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8704. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8705. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8706. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8707. /* hp used DAC 3 (Front) */
  8708. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8709. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8710. { }
  8711. };
  8712. static struct hda_verb alc861_threestack_init_verbs[] = {
  8713. /*
  8714. * Unmute ADC0 and set the default input to mic-in
  8715. */
  8716. /* port-A for surround (rear panel) */
  8717. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8718. /* port-B for mic-in (rear panel) with vref */
  8719. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8720. /* port-C for line-in (rear panel) */
  8721. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8722. /* port-D for Front */
  8723. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8724. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8725. /* port-E for HP out (front panel) */
  8726. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8727. /* route front PCM to HP */
  8728. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8729. /* port-F for mic-in (front panel) with vref */
  8730. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8731. /* port-G for CLFE (rear panel) */
  8732. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8733. /* port-H for side (rear panel) */
  8734. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8735. /* CD-in */
  8736. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8737. /* route front mic to ADC1*/
  8738. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8739. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8740. /* Unmute DAC0~3 & spdif out*/
  8741. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8742. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8743. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8744. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8745. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8746. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8747. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8748. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8749. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8750. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8751. /* Unmute Stereo Mixer 15 */
  8752. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8753. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8754. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8755. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8756. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8757. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8758. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8759. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8760. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8761. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8762. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8763. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8764. /* hp used DAC 3 (Front) */
  8765. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8766. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8767. { }
  8768. };
  8769. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8770. /*
  8771. * Unmute ADC0 and set the default input to mic-in
  8772. */
  8773. /* port-A for surround (rear panel) */
  8774. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8775. /* port-B for mic-in (rear panel) with vref */
  8776. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8777. /* port-C for line-in (rear panel) */
  8778. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8779. /* port-D for Front */
  8780. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8781. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8782. /* port-E for HP out (front panel) */
  8783. /* this has to be set to VREF80 */
  8784. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8785. /* route front PCM to HP */
  8786. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8787. /* port-F for mic-in (front panel) with vref */
  8788. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8789. /* port-G for CLFE (rear panel) */
  8790. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8791. /* port-H for side (rear panel) */
  8792. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8793. /* CD-in */
  8794. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8795. /* route front mic to ADC1*/
  8796. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8797. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8798. /* Unmute DAC0~3 & spdif out*/
  8799. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8800. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8801. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8802. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8803. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8804. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8805. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8806. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8807. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8808. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8809. /* Unmute Stereo Mixer 15 */
  8810. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8811. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8812. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8813. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8814. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8815. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8816. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8817. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8818. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8819. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8820. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8821. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8822. /* hp used DAC 3 (Front) */
  8823. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8824. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8825. { }
  8826. };
  8827. static struct hda_verb alc861_asus_init_verbs[] = {
  8828. /*
  8829. * Unmute ADC0 and set the default input to mic-in
  8830. */
  8831. /* port-A for surround (rear panel)
  8832. * according to codec#0 this is the HP jack
  8833. */
  8834. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8835. /* route front PCM to HP */
  8836. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8837. /* port-B for mic-in (rear panel) with vref */
  8838. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8839. /* port-C for line-in (rear panel) */
  8840. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8841. /* port-D for Front */
  8842. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8843. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8844. /* port-E for HP out (front panel) */
  8845. /* this has to be set to VREF80 */
  8846. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8847. /* route front PCM to HP */
  8848. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8849. /* port-F for mic-in (front panel) with vref */
  8850. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8851. /* port-G for CLFE (rear panel) */
  8852. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8853. /* port-H for side (rear panel) */
  8854. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8855. /* CD-in */
  8856. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8857. /* route front mic to ADC1*/
  8858. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8859. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8860. /* Unmute DAC0~3 & spdif out*/
  8861. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8862. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8863. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8864. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8866. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8867. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8868. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8869. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8870. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8871. /* Unmute Stereo Mixer 15 */
  8872. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8873. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8874. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8875. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8876. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8877. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8878. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8879. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8880. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8881. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8882. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8883. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8884. /* hp used DAC 3 (Front) */
  8885. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8886. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8887. { }
  8888. };
  8889. /* additional init verbs for ASUS laptops */
  8890. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8891. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8892. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8893. { }
  8894. };
  8895. /*
  8896. * generic initialization of ADC, input mixers and output mixers
  8897. */
  8898. static struct hda_verb alc861_auto_init_verbs[] = {
  8899. /*
  8900. * Unmute ADC0 and set the default input to mic-in
  8901. */
  8902. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8903. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8904. /* Unmute DAC0~3 & spdif out*/
  8905. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8906. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8907. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8908. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8909. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8910. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8911. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8912. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8913. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8914. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8915. /* Unmute Stereo Mixer 15 */
  8916. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8917. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8918. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8919. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8920. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8921. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8922. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8923. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8924. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8925. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8926. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8927. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8928. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8929. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8930. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8931. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8932. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8933. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8934. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8935. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8936. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8937. { }
  8938. };
  8939. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8940. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8941. { }
  8942. };
  8943. /* toggle speaker-output according to the hp-jack state */
  8944. static void alc861_toshiba_automute(struct hda_codec *codec)
  8945. {
  8946. unsigned int present;
  8947. present = snd_hda_codec_read(codec, 0x0f, 0,
  8948. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8949. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8950. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8951. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8952. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8953. }
  8954. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8955. unsigned int res)
  8956. {
  8957. if ((res >> 26) == ALC880_HP_EVENT)
  8958. alc861_toshiba_automute(codec);
  8959. }
  8960. /* pcm configuration: identiacal with ALC880 */
  8961. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8962. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8963. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8964. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8965. #define ALC861_DIGOUT_NID 0x07
  8966. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8967. { 8, NULL }
  8968. };
  8969. static hda_nid_t alc861_dac_nids[4] = {
  8970. /* front, surround, clfe, side */
  8971. 0x03, 0x06, 0x05, 0x04
  8972. };
  8973. static hda_nid_t alc660_dac_nids[3] = {
  8974. /* front, clfe, surround */
  8975. 0x03, 0x05, 0x06
  8976. };
  8977. static hda_nid_t alc861_adc_nids[1] = {
  8978. /* ADC0-2 */
  8979. 0x08,
  8980. };
  8981. static struct hda_input_mux alc861_capture_source = {
  8982. .num_items = 5,
  8983. .items = {
  8984. { "Mic", 0x0 },
  8985. { "Front Mic", 0x3 },
  8986. { "Line", 0x1 },
  8987. { "CD", 0x4 },
  8988. { "Mixer", 0x5 },
  8989. },
  8990. };
  8991. /* fill in the dac_nids table from the parsed pin configuration */
  8992. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8993. const struct auto_pin_cfg *cfg)
  8994. {
  8995. int i;
  8996. hda_nid_t nid;
  8997. spec->multiout.dac_nids = spec->private_dac_nids;
  8998. for (i = 0; i < cfg->line_outs; i++) {
  8999. nid = cfg->line_out_pins[i];
  9000. if (nid) {
  9001. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9002. continue;
  9003. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9004. }
  9005. }
  9006. spec->multiout.num_dacs = cfg->line_outs;
  9007. return 0;
  9008. }
  9009. /* add playback controls from the parsed DAC table */
  9010. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9011. const struct auto_pin_cfg *cfg)
  9012. {
  9013. char name[32];
  9014. static const char *chname[4] = {
  9015. "Front", "Surround", NULL /*CLFE*/, "Side"
  9016. };
  9017. hda_nid_t nid;
  9018. int i, idx, err;
  9019. for (i = 0; i < cfg->line_outs; i++) {
  9020. nid = spec->multiout.dac_nids[i];
  9021. if (!nid)
  9022. continue;
  9023. if (nid == 0x05) {
  9024. /* Center/LFE */
  9025. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9026. "Center Playback Switch",
  9027. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9028. HDA_OUTPUT));
  9029. if (err < 0)
  9030. return err;
  9031. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9032. "LFE Playback Switch",
  9033. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9034. HDA_OUTPUT));
  9035. if (err < 0)
  9036. return err;
  9037. } else {
  9038. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9039. idx++)
  9040. if (nid == alc861_dac_nids[idx])
  9041. break;
  9042. sprintf(name, "%s Playback Switch", chname[idx]);
  9043. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9044. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9045. HDA_OUTPUT));
  9046. if (err < 0)
  9047. return err;
  9048. }
  9049. }
  9050. return 0;
  9051. }
  9052. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9053. {
  9054. int err;
  9055. hda_nid_t nid;
  9056. if (!pin)
  9057. return 0;
  9058. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9059. nid = 0x03;
  9060. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9061. "Headphone Playback Switch",
  9062. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9063. if (err < 0)
  9064. return err;
  9065. spec->multiout.hp_nid = nid;
  9066. }
  9067. return 0;
  9068. }
  9069. /* create playback/capture controls for input pins */
  9070. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9071. const struct auto_pin_cfg *cfg)
  9072. {
  9073. struct hda_input_mux *imux = &spec->private_imux;
  9074. int i, err, idx, idx1;
  9075. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9076. switch (cfg->input_pins[i]) {
  9077. case 0x0c:
  9078. idx1 = 1;
  9079. idx = 2; /* Line In */
  9080. break;
  9081. case 0x0f:
  9082. idx1 = 2;
  9083. idx = 2; /* Line In */
  9084. break;
  9085. case 0x0d:
  9086. idx1 = 0;
  9087. idx = 1; /* Mic In */
  9088. break;
  9089. case 0x10:
  9090. idx1 = 3;
  9091. idx = 1; /* Mic In */
  9092. break;
  9093. case 0x11:
  9094. idx1 = 4;
  9095. idx = 0; /* CD */
  9096. break;
  9097. default:
  9098. continue;
  9099. }
  9100. err = new_analog_input(spec, cfg->input_pins[i],
  9101. auto_pin_cfg_labels[i], idx, 0x15);
  9102. if (err < 0)
  9103. return err;
  9104. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9105. imux->items[imux->num_items].index = idx1;
  9106. imux->num_items++;
  9107. }
  9108. return 0;
  9109. }
  9110. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9111. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9112. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9113. {
  9114. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9115. /* The multiple "Capture Source" controls confuse alsamixer
  9116. * So call somewhat different..
  9117. *FIXME: the controls appear in the "playback" view!
  9118. */
  9119. /* .name = "Capture Source", */
  9120. .name = "Input Source",
  9121. .count = 1,
  9122. .info = alc_mux_enum_info,
  9123. .get = alc_mux_enum_get,
  9124. .put = alc_mux_enum_put,
  9125. },
  9126. { } /* end */
  9127. };
  9128. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9129. hda_nid_t nid,
  9130. int pin_type, int dac_idx)
  9131. {
  9132. /* set as output */
  9133. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9134. pin_type);
  9135. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9136. AMP_OUT_UNMUTE);
  9137. }
  9138. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9139. {
  9140. struct alc_spec *spec = codec->spec;
  9141. int i;
  9142. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9143. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9144. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9145. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9146. if (nid)
  9147. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9148. spec->multiout.dac_nids[i]);
  9149. }
  9150. }
  9151. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9152. {
  9153. struct alc_spec *spec = codec->spec;
  9154. hda_nid_t pin;
  9155. pin = spec->autocfg.hp_pins[0];
  9156. if (pin) /* connect to front */
  9157. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9158. spec->multiout.dac_nids[0]);
  9159. }
  9160. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9161. {
  9162. struct alc_spec *spec = codec->spec;
  9163. int i;
  9164. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9165. hda_nid_t nid = spec->autocfg.input_pins[i];
  9166. if (nid >= 0x0c && nid <= 0x11) {
  9167. snd_hda_codec_write(codec, nid, 0,
  9168. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9169. i <= AUTO_PIN_FRONT_MIC ?
  9170. PIN_VREF80 : PIN_IN);
  9171. }
  9172. }
  9173. }
  9174. /* parse the BIOS configuration and set up the alc_spec */
  9175. /* return 1 if successful, 0 if the proper config is not found,
  9176. * or a negative error code
  9177. */
  9178. static int alc861_parse_auto_config(struct hda_codec *codec)
  9179. {
  9180. struct alc_spec *spec = codec->spec;
  9181. int err;
  9182. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9183. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9184. alc861_ignore);
  9185. if (err < 0)
  9186. return err;
  9187. if (!spec->autocfg.line_outs)
  9188. return 0; /* can't find valid BIOS pin config */
  9189. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9190. if (err < 0)
  9191. return err;
  9192. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9193. if (err < 0)
  9194. return err;
  9195. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9196. if (err < 0)
  9197. return err;
  9198. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9199. if (err < 0)
  9200. return err;
  9201. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9202. if (spec->autocfg.dig_out_pin)
  9203. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9204. if (spec->kctl_alloc)
  9205. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9206. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9207. spec->num_mux_defs = 1;
  9208. spec->input_mux = &spec->private_imux;
  9209. spec->adc_nids = alc861_adc_nids;
  9210. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9211. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9212. spec->num_mixers++;
  9213. return 1;
  9214. }
  9215. /* additional initialization for auto-configuration model */
  9216. static void alc861_auto_init(struct hda_codec *codec)
  9217. {
  9218. alc861_auto_init_multi_out(codec);
  9219. alc861_auto_init_hp_out(codec);
  9220. alc861_auto_init_analog_input(codec);
  9221. }
  9222. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9223. static struct hda_amp_list alc861_loopbacks[] = {
  9224. { 0x15, HDA_INPUT, 0 },
  9225. { 0x15, HDA_INPUT, 1 },
  9226. { 0x15, HDA_INPUT, 2 },
  9227. { 0x15, HDA_INPUT, 3 },
  9228. { } /* end */
  9229. };
  9230. #endif
  9231. /*
  9232. * configuration and preset
  9233. */
  9234. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9235. [ALC861_3ST] = "3stack",
  9236. [ALC660_3ST] = "3stack-660",
  9237. [ALC861_3ST_DIG] = "3stack-dig",
  9238. [ALC861_6ST_DIG] = "6stack-dig",
  9239. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9240. [ALC861_TOSHIBA] = "toshiba",
  9241. [ALC861_ASUS] = "asus",
  9242. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9243. [ALC861_AUTO] = "auto",
  9244. };
  9245. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9246. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9247. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9248. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9249. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9250. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9251. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9252. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9253. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9254. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9255. * Any other models that need this preset?
  9256. */
  9257. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9258. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9259. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9260. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9261. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9262. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9263. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9264. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9265. {}
  9266. };
  9267. static struct alc_config_preset alc861_presets[] = {
  9268. [ALC861_3ST] = {
  9269. .mixers = { alc861_3ST_mixer },
  9270. .init_verbs = { alc861_threestack_init_verbs },
  9271. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9272. .dac_nids = alc861_dac_nids,
  9273. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9274. .channel_mode = alc861_threestack_modes,
  9275. .need_dac_fix = 1,
  9276. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9277. .adc_nids = alc861_adc_nids,
  9278. .input_mux = &alc861_capture_source,
  9279. },
  9280. [ALC861_3ST_DIG] = {
  9281. .mixers = { alc861_base_mixer },
  9282. .init_verbs = { alc861_threestack_init_verbs },
  9283. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9284. .dac_nids = alc861_dac_nids,
  9285. .dig_out_nid = ALC861_DIGOUT_NID,
  9286. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9287. .channel_mode = alc861_threestack_modes,
  9288. .need_dac_fix = 1,
  9289. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9290. .adc_nids = alc861_adc_nids,
  9291. .input_mux = &alc861_capture_source,
  9292. },
  9293. [ALC861_6ST_DIG] = {
  9294. .mixers = { alc861_base_mixer },
  9295. .init_verbs = { alc861_base_init_verbs },
  9296. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9297. .dac_nids = alc861_dac_nids,
  9298. .dig_out_nid = ALC861_DIGOUT_NID,
  9299. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9300. .channel_mode = alc861_8ch_modes,
  9301. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9302. .adc_nids = alc861_adc_nids,
  9303. .input_mux = &alc861_capture_source,
  9304. },
  9305. [ALC660_3ST] = {
  9306. .mixers = { alc861_3ST_mixer },
  9307. .init_verbs = { alc861_threestack_init_verbs },
  9308. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9309. .dac_nids = alc660_dac_nids,
  9310. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9311. .channel_mode = alc861_threestack_modes,
  9312. .need_dac_fix = 1,
  9313. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9314. .adc_nids = alc861_adc_nids,
  9315. .input_mux = &alc861_capture_source,
  9316. },
  9317. [ALC861_UNIWILL_M31] = {
  9318. .mixers = { alc861_uniwill_m31_mixer },
  9319. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9320. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9321. .dac_nids = alc861_dac_nids,
  9322. .dig_out_nid = ALC861_DIGOUT_NID,
  9323. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9324. .channel_mode = alc861_uniwill_m31_modes,
  9325. .need_dac_fix = 1,
  9326. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9327. .adc_nids = alc861_adc_nids,
  9328. .input_mux = &alc861_capture_source,
  9329. },
  9330. [ALC861_TOSHIBA] = {
  9331. .mixers = { alc861_toshiba_mixer },
  9332. .init_verbs = { alc861_base_init_verbs,
  9333. alc861_toshiba_init_verbs },
  9334. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9335. .dac_nids = alc861_dac_nids,
  9336. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9337. .channel_mode = alc883_3ST_2ch_modes,
  9338. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9339. .adc_nids = alc861_adc_nids,
  9340. .input_mux = &alc861_capture_source,
  9341. .unsol_event = alc861_toshiba_unsol_event,
  9342. .init_hook = alc861_toshiba_automute,
  9343. },
  9344. [ALC861_ASUS] = {
  9345. .mixers = { alc861_asus_mixer },
  9346. .init_verbs = { alc861_asus_init_verbs },
  9347. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9348. .dac_nids = alc861_dac_nids,
  9349. .dig_out_nid = ALC861_DIGOUT_NID,
  9350. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9351. .channel_mode = alc861_asus_modes,
  9352. .need_dac_fix = 1,
  9353. .hp_nid = 0x06,
  9354. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9355. .adc_nids = alc861_adc_nids,
  9356. .input_mux = &alc861_capture_source,
  9357. },
  9358. [ALC861_ASUS_LAPTOP] = {
  9359. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9360. .init_verbs = { alc861_asus_init_verbs,
  9361. alc861_asus_laptop_init_verbs },
  9362. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9363. .dac_nids = alc861_dac_nids,
  9364. .dig_out_nid = ALC861_DIGOUT_NID,
  9365. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9366. .channel_mode = alc883_3ST_2ch_modes,
  9367. .need_dac_fix = 1,
  9368. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9369. .adc_nids = alc861_adc_nids,
  9370. .input_mux = &alc861_capture_source,
  9371. },
  9372. };
  9373. static int patch_alc861(struct hda_codec *codec)
  9374. {
  9375. struct alc_spec *spec;
  9376. int board_config;
  9377. int err;
  9378. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9379. if (spec == NULL)
  9380. return -ENOMEM;
  9381. codec->spec = spec;
  9382. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9383. alc861_models,
  9384. alc861_cfg_tbl);
  9385. if (board_config < 0) {
  9386. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9387. "trying auto-probe from BIOS...\n");
  9388. board_config = ALC861_AUTO;
  9389. }
  9390. if (board_config == ALC861_AUTO) {
  9391. /* automatic parse from the BIOS config */
  9392. err = alc861_parse_auto_config(codec);
  9393. if (err < 0) {
  9394. alc_free(codec);
  9395. return err;
  9396. } else if (!err) {
  9397. printk(KERN_INFO
  9398. "hda_codec: Cannot set up configuration "
  9399. "from BIOS. Using base mode...\n");
  9400. board_config = ALC861_3ST_DIG;
  9401. }
  9402. }
  9403. if (board_config != ALC861_AUTO)
  9404. setup_preset(spec, &alc861_presets[board_config]);
  9405. spec->stream_name_analog = "ALC861 Analog";
  9406. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9407. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9408. spec->stream_name_digital = "ALC861 Digital";
  9409. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9410. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9411. codec->patch_ops = alc_patch_ops;
  9412. if (board_config == ALC861_AUTO)
  9413. spec->init_hook = alc861_auto_init;
  9414. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9415. if (!spec->loopback.amplist)
  9416. spec->loopback.amplist = alc861_loopbacks;
  9417. #endif
  9418. return 0;
  9419. }
  9420. /*
  9421. * ALC861-VD support
  9422. *
  9423. * Based on ALC882
  9424. *
  9425. * In addition, an independent DAC
  9426. */
  9427. #define ALC861VD_DIGOUT_NID 0x06
  9428. static hda_nid_t alc861vd_dac_nids[4] = {
  9429. /* front, surr, clfe, side surr */
  9430. 0x02, 0x03, 0x04, 0x05
  9431. };
  9432. /* dac_nids for ALC660vd are in a different order - according to
  9433. * Realtek's driver.
  9434. * This should probably tesult in a different mixer for 6stack models
  9435. * of ALC660vd codecs, but for now there is only 3stack mixer
  9436. * - and it is the same as in 861vd.
  9437. * adc_nids in ALC660vd are (is) the same as in 861vd
  9438. */
  9439. static hda_nid_t alc660vd_dac_nids[3] = {
  9440. /* front, rear, clfe, rear_surr */
  9441. 0x02, 0x04, 0x03
  9442. };
  9443. static hda_nid_t alc861vd_adc_nids[1] = {
  9444. /* ADC0 */
  9445. 0x09,
  9446. };
  9447. /* input MUX */
  9448. /* FIXME: should be a matrix-type input source selection */
  9449. static struct hda_input_mux alc861vd_capture_source = {
  9450. .num_items = 4,
  9451. .items = {
  9452. { "Mic", 0x0 },
  9453. { "Front Mic", 0x1 },
  9454. { "Line", 0x2 },
  9455. { "CD", 0x4 },
  9456. },
  9457. };
  9458. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9459. .num_items = 3,
  9460. .items = {
  9461. { "Front Mic", 0x0 },
  9462. { "ATAPI Mic", 0x1 },
  9463. { "Line In", 0x5 },
  9464. },
  9465. };
  9466. static struct hda_input_mux alc861vd_hp_capture_source = {
  9467. .num_items = 2,
  9468. .items = {
  9469. { "Front Mic", 0x0 },
  9470. { "ATAPI Mic", 0x1 },
  9471. },
  9472. };
  9473. #define alc861vd_mux_enum_info alc_mux_enum_info
  9474. #define alc861vd_mux_enum_get alc_mux_enum_get
  9475. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9476. struct snd_ctl_elem_value *ucontrol)
  9477. {
  9478. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9479. struct alc_spec *spec = codec->spec;
  9480. const struct hda_input_mux *imux = spec->input_mux;
  9481. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9482. static hda_nid_t capture_mixers[1] = { 0x22 };
  9483. hda_nid_t nid = capture_mixers[adc_idx];
  9484. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9485. unsigned int i, idx;
  9486. idx = ucontrol->value.enumerated.item[0];
  9487. if (idx >= imux->num_items)
  9488. idx = imux->num_items - 1;
  9489. if (*cur_val == idx)
  9490. return 0;
  9491. for (i = 0; i < imux->num_items; i++) {
  9492. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9493. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9494. imux->items[i].index,
  9495. HDA_AMP_MUTE, v);
  9496. }
  9497. *cur_val = idx;
  9498. return 1;
  9499. }
  9500. /*
  9501. * 2ch mode
  9502. */
  9503. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9504. { 2, NULL }
  9505. };
  9506. /*
  9507. * 6ch mode
  9508. */
  9509. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9510. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9511. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9512. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9513. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9514. { } /* end */
  9515. };
  9516. /*
  9517. * 8ch mode
  9518. */
  9519. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9520. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9521. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9522. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9523. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9524. { } /* end */
  9525. };
  9526. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9527. { 6, alc861vd_6stack_ch6_init },
  9528. { 8, alc861vd_6stack_ch8_init },
  9529. };
  9530. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9531. {
  9532. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9533. .name = "Channel Mode",
  9534. .info = alc_ch_mode_info,
  9535. .get = alc_ch_mode_get,
  9536. .put = alc_ch_mode_put,
  9537. },
  9538. { } /* end */
  9539. };
  9540. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9541. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9542. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9543. {
  9544. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9545. /* The multiple "Capture Source" controls confuse alsamixer
  9546. * So call somewhat different..
  9547. *FIXME: the controls appear in the "playback" view!
  9548. */
  9549. /* .name = "Capture Source", */
  9550. .name = "Input Source",
  9551. .count = 1,
  9552. .info = alc861vd_mux_enum_info,
  9553. .get = alc861vd_mux_enum_get,
  9554. .put = alc861vd_mux_enum_put,
  9555. },
  9556. { } /* end */
  9557. };
  9558. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9559. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9560. */
  9561. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9562. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9563. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9564. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9565. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9566. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9567. HDA_OUTPUT),
  9568. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9569. HDA_OUTPUT),
  9570. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9571. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9572. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9573. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9574. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9575. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9576. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9577. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9578. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9579. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9580. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9581. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9582. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9583. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9584. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9585. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9586. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9587. { } /* end */
  9588. };
  9589. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9590. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9591. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9592. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9593. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9594. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9595. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9596. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9597. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9598. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9599. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9600. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9601. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9602. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9603. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9604. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9605. { } /* end */
  9606. };
  9607. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9608. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9609. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9610. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9611. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9612. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9613. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9614. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9615. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9616. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9617. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9618. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9619. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9620. { } /* end */
  9621. };
  9622. /* Pin assignment: Front=0x14, HP = 0x15,
  9623. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9624. */
  9625. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9626. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9627. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9628. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9629. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9630. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9631. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9632. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9633. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9634. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9635. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9636. { } /* end */
  9637. };
  9638. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9639. * Front Mic=0x18, ATAPI Mic = 0x19,
  9640. */
  9641. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9642. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9643. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9644. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9645. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9646. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9647. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9648. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9649. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9650. { } /* end */
  9651. };
  9652. /*
  9653. * generic initialization of ADC, input mixers and output mixers
  9654. */
  9655. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9656. /*
  9657. * Unmute ADC0 and set the default input to mic-in
  9658. */
  9659. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9660. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9661. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9662. * the analog-loopback mixer widget
  9663. */
  9664. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9665. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9666. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9667. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9668. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9669. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9670. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9671. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9672. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9675. /*
  9676. * Set up output mixers (0x02 - 0x05)
  9677. */
  9678. /* set vol=0 to output mixers */
  9679. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9680. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9681. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9682. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9683. /* set up input amps for analog loopback */
  9684. /* Amp Indices: DAC = 0, mixer = 1 */
  9685. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9686. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9687. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9688. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9689. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9690. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9691. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9692. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9693. { }
  9694. };
  9695. /*
  9696. * 3-stack pin configuration:
  9697. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9698. */
  9699. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9700. /*
  9701. * Set pin mode and muting
  9702. */
  9703. /* set front pin widgets 0x14 for output */
  9704. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9705. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9706. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9707. /* Mic (rear) pin: input vref at 80% */
  9708. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9709. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9710. /* Front Mic pin: input vref at 80% */
  9711. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9712. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9713. /* Line In pin: input */
  9714. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9715. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9716. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9717. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9718. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9719. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9720. /* CD pin widget for input */
  9721. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9722. { }
  9723. };
  9724. /*
  9725. * 6-stack pin configuration:
  9726. */
  9727. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9728. /*
  9729. * Set pin mode and muting
  9730. */
  9731. /* set front pin widgets 0x14 for output */
  9732. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9733. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9734. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9735. /* Rear Pin: output 1 (0x0d) */
  9736. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9737. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9738. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9739. /* CLFE Pin: output 2 (0x0e) */
  9740. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9741. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9742. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9743. /* Side Pin: output 3 (0x0f) */
  9744. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9745. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9746. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9747. /* Mic (rear) pin: input vref at 80% */
  9748. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9749. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9750. /* Front Mic pin: input vref at 80% */
  9751. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9752. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9753. /* Line In pin: input */
  9754. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9755. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9756. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9757. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9758. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9759. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9760. /* CD pin widget for input */
  9761. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9762. { }
  9763. };
  9764. static struct hda_verb alc861vd_eapd_verbs[] = {
  9765. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9766. { }
  9767. };
  9768. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9769. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9770. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9771. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9772. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9773. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9774. {}
  9775. };
  9776. /* toggle speaker-output according to the hp-jack state */
  9777. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9778. {
  9779. unsigned int present;
  9780. unsigned char bits;
  9781. present = snd_hda_codec_read(codec, 0x1b, 0,
  9782. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9783. bits = present ? HDA_AMP_MUTE : 0;
  9784. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9785. HDA_AMP_MUTE, bits);
  9786. }
  9787. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9788. {
  9789. unsigned int present;
  9790. unsigned char bits;
  9791. present = snd_hda_codec_read(codec, 0x18, 0,
  9792. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9793. bits = present ? HDA_AMP_MUTE : 0;
  9794. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9795. HDA_AMP_MUTE, bits);
  9796. }
  9797. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9798. {
  9799. alc861vd_lenovo_hp_automute(codec);
  9800. alc861vd_lenovo_mic_automute(codec);
  9801. }
  9802. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9803. unsigned int res)
  9804. {
  9805. switch (res >> 26) {
  9806. case ALC880_HP_EVENT:
  9807. alc861vd_lenovo_hp_automute(codec);
  9808. break;
  9809. case ALC880_MIC_EVENT:
  9810. alc861vd_lenovo_mic_automute(codec);
  9811. break;
  9812. }
  9813. }
  9814. static struct hda_verb alc861vd_dallas_verbs[] = {
  9815. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9816. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9817. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9818. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9821. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9822. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9823. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9824. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9825. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9826. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9827. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9828. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9829. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9830. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9831. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9832. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9833. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9834. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9835. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9836. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9837. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9838. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9839. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9840. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9841. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9842. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9843. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9844. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9845. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9846. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9847. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9848. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9849. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9850. { } /* end */
  9851. };
  9852. /* toggle speaker-output according to the hp-jack state */
  9853. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9854. {
  9855. unsigned int present;
  9856. present = snd_hda_codec_read(codec, 0x15, 0,
  9857. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9858. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9859. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9860. }
  9861. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9862. {
  9863. if ((res >> 26) == ALC880_HP_EVENT)
  9864. alc861vd_dallas_automute(codec);
  9865. }
  9866. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9867. #define alc861vd_loopbacks alc880_loopbacks
  9868. #endif
  9869. /* pcm configuration: identiacal with ALC880 */
  9870. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9871. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9872. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9873. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9874. /*
  9875. * configuration and preset
  9876. */
  9877. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9878. [ALC660VD_3ST] = "3stack-660",
  9879. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9880. [ALC861VD_3ST] = "3stack",
  9881. [ALC861VD_3ST_DIG] = "3stack-digout",
  9882. [ALC861VD_6ST_DIG] = "6stack-digout",
  9883. [ALC861VD_LENOVO] = "lenovo",
  9884. [ALC861VD_DALLAS] = "dallas",
  9885. [ALC861VD_HP] = "hp",
  9886. [ALC861VD_AUTO] = "auto",
  9887. };
  9888. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9889. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9890. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9891. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9892. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9893. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9894. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9895. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9896. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9897. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9898. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9899. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9900. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9901. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9902. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9903. {}
  9904. };
  9905. static struct alc_config_preset alc861vd_presets[] = {
  9906. [ALC660VD_3ST] = {
  9907. .mixers = { alc861vd_3st_mixer },
  9908. .init_verbs = { alc861vd_volume_init_verbs,
  9909. alc861vd_3stack_init_verbs },
  9910. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9911. .dac_nids = alc660vd_dac_nids,
  9912. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9913. .adc_nids = alc861vd_adc_nids,
  9914. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9915. .channel_mode = alc861vd_3stack_2ch_modes,
  9916. .input_mux = &alc861vd_capture_source,
  9917. },
  9918. [ALC660VD_3ST_DIG] = {
  9919. .mixers = { alc861vd_3st_mixer },
  9920. .init_verbs = { alc861vd_volume_init_verbs,
  9921. alc861vd_3stack_init_verbs },
  9922. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9923. .dac_nids = alc660vd_dac_nids,
  9924. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9925. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9926. .adc_nids = alc861vd_adc_nids,
  9927. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9928. .channel_mode = alc861vd_3stack_2ch_modes,
  9929. .input_mux = &alc861vd_capture_source,
  9930. },
  9931. [ALC861VD_3ST] = {
  9932. .mixers = { alc861vd_3st_mixer },
  9933. .init_verbs = { alc861vd_volume_init_verbs,
  9934. alc861vd_3stack_init_verbs },
  9935. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9936. .dac_nids = alc861vd_dac_nids,
  9937. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9938. .channel_mode = alc861vd_3stack_2ch_modes,
  9939. .input_mux = &alc861vd_capture_source,
  9940. },
  9941. [ALC861VD_3ST_DIG] = {
  9942. .mixers = { alc861vd_3st_mixer },
  9943. .init_verbs = { alc861vd_volume_init_verbs,
  9944. alc861vd_3stack_init_verbs },
  9945. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9946. .dac_nids = alc861vd_dac_nids,
  9947. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9948. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9949. .channel_mode = alc861vd_3stack_2ch_modes,
  9950. .input_mux = &alc861vd_capture_source,
  9951. },
  9952. [ALC861VD_6ST_DIG] = {
  9953. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9954. .init_verbs = { alc861vd_volume_init_verbs,
  9955. alc861vd_6stack_init_verbs },
  9956. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9957. .dac_nids = alc861vd_dac_nids,
  9958. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9959. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9960. .channel_mode = alc861vd_6stack_modes,
  9961. .input_mux = &alc861vd_capture_source,
  9962. },
  9963. [ALC861VD_LENOVO] = {
  9964. .mixers = { alc861vd_lenovo_mixer },
  9965. .init_verbs = { alc861vd_volume_init_verbs,
  9966. alc861vd_3stack_init_verbs,
  9967. alc861vd_eapd_verbs,
  9968. alc861vd_lenovo_unsol_verbs },
  9969. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9970. .dac_nids = alc660vd_dac_nids,
  9971. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9972. .adc_nids = alc861vd_adc_nids,
  9973. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9974. .channel_mode = alc861vd_3stack_2ch_modes,
  9975. .input_mux = &alc861vd_capture_source,
  9976. .unsol_event = alc861vd_lenovo_unsol_event,
  9977. .init_hook = alc861vd_lenovo_automute,
  9978. },
  9979. [ALC861VD_DALLAS] = {
  9980. .mixers = { alc861vd_dallas_mixer },
  9981. .init_verbs = { alc861vd_dallas_verbs },
  9982. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9983. .dac_nids = alc861vd_dac_nids,
  9984. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9985. .adc_nids = alc861vd_adc_nids,
  9986. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9987. .channel_mode = alc861vd_3stack_2ch_modes,
  9988. .input_mux = &alc861vd_dallas_capture_source,
  9989. .unsol_event = alc861vd_dallas_unsol_event,
  9990. .init_hook = alc861vd_dallas_automute,
  9991. },
  9992. [ALC861VD_HP] = {
  9993. .mixers = { alc861vd_hp_mixer },
  9994. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9995. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9996. .dac_nids = alc861vd_dac_nids,
  9997. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9998. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9999. .adc_nids = alc861vd_adc_nids,
  10000. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10001. .channel_mode = alc861vd_3stack_2ch_modes,
  10002. .input_mux = &alc861vd_hp_capture_source,
  10003. .unsol_event = alc861vd_dallas_unsol_event,
  10004. .init_hook = alc861vd_dallas_automute,
  10005. },
  10006. };
  10007. /*
  10008. * BIOS auto configuration
  10009. */
  10010. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10011. hda_nid_t nid, int pin_type, int dac_idx)
  10012. {
  10013. /* set as output */
  10014. snd_hda_codec_write(codec, nid, 0,
  10015. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10016. snd_hda_codec_write(codec, nid, 0,
  10017. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10018. }
  10019. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10020. {
  10021. struct alc_spec *spec = codec->spec;
  10022. int i;
  10023. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10024. for (i = 0; i <= HDA_SIDE; i++) {
  10025. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10026. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10027. if (nid)
  10028. alc861vd_auto_set_output_and_unmute(codec, nid,
  10029. pin_type, i);
  10030. }
  10031. }
  10032. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10033. {
  10034. struct alc_spec *spec = codec->spec;
  10035. hda_nid_t pin;
  10036. pin = spec->autocfg.hp_pins[0];
  10037. if (pin) /* connect to front and use dac 0 */
  10038. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10039. }
  10040. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10041. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10042. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10043. {
  10044. struct alc_spec *spec = codec->spec;
  10045. int i;
  10046. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10047. hda_nid_t nid = spec->autocfg.input_pins[i];
  10048. if (alc861vd_is_input_pin(nid)) {
  10049. snd_hda_codec_write(codec, nid, 0,
  10050. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10051. i <= AUTO_PIN_FRONT_MIC ?
  10052. PIN_VREF80 : PIN_IN);
  10053. if (nid != ALC861VD_PIN_CD_NID)
  10054. snd_hda_codec_write(codec, nid, 0,
  10055. AC_VERB_SET_AMP_GAIN_MUTE,
  10056. AMP_OUT_MUTE);
  10057. }
  10058. }
  10059. }
  10060. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10061. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10062. /* add playback controls from the parsed DAC table */
  10063. /* Based on ALC880 version. But ALC861VD has separate,
  10064. * different NIDs for mute/unmute switch and volume control */
  10065. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10066. const struct auto_pin_cfg *cfg)
  10067. {
  10068. char name[32];
  10069. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10070. hda_nid_t nid_v, nid_s;
  10071. int i, err;
  10072. for (i = 0; i < cfg->line_outs; i++) {
  10073. if (!spec->multiout.dac_nids[i])
  10074. continue;
  10075. nid_v = alc861vd_idx_to_mixer_vol(
  10076. alc880_dac_to_idx(
  10077. spec->multiout.dac_nids[i]));
  10078. nid_s = alc861vd_idx_to_mixer_switch(
  10079. alc880_dac_to_idx(
  10080. spec->multiout.dac_nids[i]));
  10081. if (i == 2) {
  10082. /* Center/LFE */
  10083. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10084. "Center Playback Volume",
  10085. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10086. HDA_OUTPUT));
  10087. if (err < 0)
  10088. return err;
  10089. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10090. "LFE Playback Volume",
  10091. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10092. HDA_OUTPUT));
  10093. if (err < 0)
  10094. return err;
  10095. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10096. "Center Playback Switch",
  10097. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10098. HDA_INPUT));
  10099. if (err < 0)
  10100. return err;
  10101. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10102. "LFE Playback Switch",
  10103. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10104. HDA_INPUT));
  10105. if (err < 0)
  10106. return err;
  10107. } else {
  10108. sprintf(name, "%s Playback Volume", chname[i]);
  10109. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10110. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10111. HDA_OUTPUT));
  10112. if (err < 0)
  10113. return err;
  10114. sprintf(name, "%s Playback Switch", chname[i]);
  10115. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10116. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10117. HDA_INPUT));
  10118. if (err < 0)
  10119. return err;
  10120. }
  10121. }
  10122. return 0;
  10123. }
  10124. /* add playback controls for speaker and HP outputs */
  10125. /* Based on ALC880 version. But ALC861VD has separate,
  10126. * different NIDs for mute/unmute switch and volume control */
  10127. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10128. hda_nid_t pin, const char *pfx)
  10129. {
  10130. hda_nid_t nid_v, nid_s;
  10131. int err;
  10132. char name[32];
  10133. if (!pin)
  10134. return 0;
  10135. if (alc880_is_fixed_pin(pin)) {
  10136. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10137. /* specify the DAC as the extra output */
  10138. if (!spec->multiout.hp_nid)
  10139. spec->multiout.hp_nid = nid_v;
  10140. else
  10141. spec->multiout.extra_out_nid[0] = nid_v;
  10142. /* control HP volume/switch on the output mixer amp */
  10143. nid_v = alc861vd_idx_to_mixer_vol(
  10144. alc880_fixed_pin_idx(pin));
  10145. nid_s = alc861vd_idx_to_mixer_switch(
  10146. alc880_fixed_pin_idx(pin));
  10147. sprintf(name, "%s Playback Volume", pfx);
  10148. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10149. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10150. if (err < 0)
  10151. return err;
  10152. sprintf(name, "%s Playback Switch", pfx);
  10153. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10154. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10155. if (err < 0)
  10156. return err;
  10157. } else if (alc880_is_multi_pin(pin)) {
  10158. /* set manual connection */
  10159. /* we have only a switch on HP-out PIN */
  10160. sprintf(name, "%s Playback Switch", pfx);
  10161. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10162. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10163. if (err < 0)
  10164. return err;
  10165. }
  10166. return 0;
  10167. }
  10168. /* parse the BIOS configuration and set up the alc_spec
  10169. * return 1 if successful, 0 if the proper config is not found,
  10170. * or a negative error code
  10171. * Based on ALC880 version - had to change it to override
  10172. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10173. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10174. {
  10175. struct alc_spec *spec = codec->spec;
  10176. int err;
  10177. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10178. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10179. alc861vd_ignore);
  10180. if (err < 0)
  10181. return err;
  10182. if (!spec->autocfg.line_outs)
  10183. return 0; /* can't find valid BIOS pin config */
  10184. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10185. if (err < 0)
  10186. return err;
  10187. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10188. if (err < 0)
  10189. return err;
  10190. err = alc861vd_auto_create_extra_out(spec,
  10191. spec->autocfg.speaker_pins[0],
  10192. "Speaker");
  10193. if (err < 0)
  10194. return err;
  10195. err = alc861vd_auto_create_extra_out(spec,
  10196. spec->autocfg.hp_pins[0],
  10197. "Headphone");
  10198. if (err < 0)
  10199. return err;
  10200. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10201. if (err < 0)
  10202. return err;
  10203. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10204. if (spec->autocfg.dig_out_pin)
  10205. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10206. if (spec->kctl_alloc)
  10207. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10208. spec->init_verbs[spec->num_init_verbs++]
  10209. = alc861vd_volume_init_verbs;
  10210. spec->num_mux_defs = 1;
  10211. spec->input_mux = &spec->private_imux;
  10212. err = alc_auto_add_mic_boost(codec);
  10213. if (err < 0)
  10214. return err;
  10215. return 1;
  10216. }
  10217. /* additional initialization for auto-configuration model */
  10218. static void alc861vd_auto_init(struct hda_codec *codec)
  10219. {
  10220. alc861vd_auto_init_multi_out(codec);
  10221. alc861vd_auto_init_hp_out(codec);
  10222. alc861vd_auto_init_analog_input(codec);
  10223. }
  10224. static int patch_alc861vd(struct hda_codec *codec)
  10225. {
  10226. struct alc_spec *spec;
  10227. int err, board_config;
  10228. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10229. if (spec == NULL)
  10230. return -ENOMEM;
  10231. codec->spec = spec;
  10232. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10233. alc861vd_models,
  10234. alc861vd_cfg_tbl);
  10235. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10236. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10237. "ALC861VD, trying auto-probe from BIOS...\n");
  10238. board_config = ALC861VD_AUTO;
  10239. }
  10240. if (board_config == ALC861VD_AUTO) {
  10241. /* automatic parse from the BIOS config */
  10242. err = alc861vd_parse_auto_config(codec);
  10243. if (err < 0) {
  10244. alc_free(codec);
  10245. return err;
  10246. } else if (!err) {
  10247. printk(KERN_INFO
  10248. "hda_codec: Cannot set up configuration "
  10249. "from BIOS. Using base mode...\n");
  10250. board_config = ALC861VD_3ST;
  10251. }
  10252. }
  10253. if (board_config != ALC861VD_AUTO)
  10254. setup_preset(spec, &alc861vd_presets[board_config]);
  10255. spec->stream_name_analog = "ALC861VD Analog";
  10256. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10257. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10258. spec->stream_name_digital = "ALC861VD Digital";
  10259. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10260. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10261. spec->adc_nids = alc861vd_adc_nids;
  10262. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10263. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10264. spec->num_mixers++;
  10265. codec->patch_ops = alc_patch_ops;
  10266. if (board_config == ALC861VD_AUTO)
  10267. spec->init_hook = alc861vd_auto_init;
  10268. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10269. if (!spec->loopback.amplist)
  10270. spec->loopback.amplist = alc861vd_loopbacks;
  10271. #endif
  10272. return 0;
  10273. }
  10274. /*
  10275. * ALC662 support
  10276. *
  10277. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10278. * configuration. Each pin widget can choose any input DACs and a mixer.
  10279. * Each ADC is connected from a mixer of all inputs. This makes possible
  10280. * 6-channel independent captures.
  10281. *
  10282. * In addition, an independent DAC for the multi-playback (not used in this
  10283. * driver yet).
  10284. */
  10285. #define ALC662_DIGOUT_NID 0x06
  10286. #define ALC662_DIGIN_NID 0x0a
  10287. static hda_nid_t alc662_dac_nids[4] = {
  10288. /* front, rear, clfe, rear_surr */
  10289. 0x02, 0x03, 0x04
  10290. };
  10291. static hda_nid_t alc662_adc_nids[1] = {
  10292. /* ADC1-2 */
  10293. 0x09,
  10294. };
  10295. /* input MUX */
  10296. /* FIXME: should be a matrix-type input source selection */
  10297. static struct hda_input_mux alc662_capture_source = {
  10298. .num_items = 4,
  10299. .items = {
  10300. { "Mic", 0x0 },
  10301. { "Front Mic", 0x1 },
  10302. { "Line", 0x2 },
  10303. { "CD", 0x4 },
  10304. },
  10305. };
  10306. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10307. .num_items = 2,
  10308. .items = {
  10309. { "Mic", 0x1 },
  10310. { "Line", 0x2 },
  10311. },
  10312. };
  10313. static struct hda_input_mux alc662_eeepc_capture_source = {
  10314. .num_items = 2,
  10315. .items = {
  10316. { "i-Mic", 0x1 },
  10317. { "e-Mic", 0x0 },
  10318. },
  10319. };
  10320. #define alc662_mux_enum_info alc_mux_enum_info
  10321. #define alc662_mux_enum_get alc_mux_enum_get
  10322. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10323. struct snd_ctl_elem_value *ucontrol)
  10324. {
  10325. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10326. struct alc_spec *spec = codec->spec;
  10327. const struct hda_input_mux *imux = spec->input_mux;
  10328. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10329. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10330. hda_nid_t nid = capture_mixers[adc_idx];
  10331. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10332. unsigned int i, idx;
  10333. idx = ucontrol->value.enumerated.item[0];
  10334. if (idx >= imux->num_items)
  10335. idx = imux->num_items - 1;
  10336. if (*cur_val == idx)
  10337. return 0;
  10338. for (i = 0; i < imux->num_items; i++) {
  10339. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10340. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10341. imux->items[i].index,
  10342. HDA_AMP_MUTE, v);
  10343. }
  10344. *cur_val = idx;
  10345. return 1;
  10346. }
  10347. /*
  10348. * 2ch mode
  10349. */
  10350. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10351. { 2, NULL }
  10352. };
  10353. /*
  10354. * 2ch mode
  10355. */
  10356. static struct hda_verb alc662_3ST_ch2_init[] = {
  10357. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10358. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10359. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10360. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10361. { } /* end */
  10362. };
  10363. /*
  10364. * 6ch mode
  10365. */
  10366. static struct hda_verb alc662_3ST_ch6_init[] = {
  10367. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10368. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10369. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10370. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10371. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10372. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10373. { } /* end */
  10374. };
  10375. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10376. { 2, alc662_3ST_ch2_init },
  10377. { 6, alc662_3ST_ch6_init },
  10378. };
  10379. /*
  10380. * 2ch mode
  10381. */
  10382. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10383. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10384. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10385. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10386. { } /* end */
  10387. };
  10388. /*
  10389. * 6ch mode
  10390. */
  10391. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10392. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10393. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10394. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10395. { } /* end */
  10396. };
  10397. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10398. { 2, alc662_sixstack_ch6_init },
  10399. { 6, alc662_sixstack_ch8_init },
  10400. };
  10401. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10402. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10403. */
  10404. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10405. /* output mixer control */
  10406. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10407. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10408. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10409. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10410. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10411. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10412. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10413. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10414. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10415. /*Input mixer control */
  10416. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10417. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10418. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10419. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10420. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10421. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10422. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10423. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10424. /* Capture mixer control */
  10425. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10426. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10427. {
  10428. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10429. .name = "Capture Source",
  10430. .count = 1,
  10431. .info = alc_mux_enum_info,
  10432. .get = alc_mux_enum_get,
  10433. .put = alc_mux_enum_put,
  10434. },
  10435. { } /* end */
  10436. };
  10437. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10438. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10439. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10440. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10441. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10442. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10443. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10444. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10445. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10446. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10447. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10448. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10449. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10450. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10451. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10452. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10453. {
  10454. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10455. /* .name = "Capture Source", */
  10456. .name = "Input Source",
  10457. .count = 1,
  10458. .info = alc662_mux_enum_info,
  10459. .get = alc662_mux_enum_get,
  10460. .put = alc662_mux_enum_put,
  10461. },
  10462. { } /* end */
  10463. };
  10464. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10465. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10466. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10467. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10468. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10469. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10470. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10471. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10472. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10473. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10474. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10475. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10476. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10477. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10478. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10479. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10480. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10481. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10482. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10483. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10484. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10485. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10486. {
  10487. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10488. /* .name = "Capture Source", */
  10489. .name = "Input Source",
  10490. .count = 1,
  10491. .info = alc662_mux_enum_info,
  10492. .get = alc662_mux_enum_get,
  10493. .put = alc662_mux_enum_put,
  10494. },
  10495. { } /* end */
  10496. };
  10497. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10498. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10499. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10500. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10501. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10502. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10503. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10504. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10505. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10506. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10507. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10508. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10509. {
  10510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10511. /* .name = "Capture Source", */
  10512. .name = "Input Source",
  10513. .count = 1,
  10514. .info = alc662_mux_enum_info,
  10515. .get = alc662_mux_enum_get,
  10516. .put = alc662_mux_enum_put,
  10517. },
  10518. { } /* end */
  10519. };
  10520. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  10521. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10522. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10523. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10524. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  10525. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10526. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10527. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  10528. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10529. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10530. { } /* end */
  10531. };
  10532. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10533. {
  10534. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10535. .name = "Channel Mode",
  10536. .info = alc_ch_mode_info,
  10537. .get = alc_ch_mode_get,
  10538. .put = alc_ch_mode_put,
  10539. },
  10540. { } /* end */
  10541. };
  10542. static struct hda_verb alc662_init_verbs[] = {
  10543. /* ADC: mute amp left and right */
  10544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10545. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10546. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10548. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10549. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10550. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10551. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10554. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10555. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10556. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10557. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10558. /* Front Pin: output 0 (0x0c) */
  10559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10560. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10561. /* Rear Pin: output 1 (0x0d) */
  10562. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10563. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10564. /* CLFE Pin: output 2 (0x0e) */
  10565. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10566. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10567. /* Mic (rear) pin: input vref at 80% */
  10568. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10569. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10570. /* Front Mic pin: input vref at 80% */
  10571. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10572. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10573. /* Line In pin: input */
  10574. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10575. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10576. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10577. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10578. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10579. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10580. /* CD pin widget for input */
  10581. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10582. /* FIXME: use matrix-type input source selection */
  10583. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10584. /* Input mixer */
  10585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10586. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10587. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10588. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10589. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10590. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10591. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10592. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10593. { }
  10594. };
  10595. static struct hda_verb alc662_sue_init_verbs[] = {
  10596. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10597. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10598. {}
  10599. };
  10600. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  10601. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10602. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10603. {}
  10604. };
  10605. /*
  10606. * generic initialization of ADC, input mixers and output mixers
  10607. */
  10608. static struct hda_verb alc662_auto_init_verbs[] = {
  10609. /*
  10610. * Unmute ADC and set the default input to mic-in
  10611. */
  10612. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10613. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10614. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10615. * mixer widget
  10616. * Note: PASD motherboards uses the Line In 2 as the input for front
  10617. * panel mic (mic 2)
  10618. */
  10619. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10620. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10621. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10622. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10623. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10624. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10625. /*
  10626. * Set up output mixers (0x0c - 0x0f)
  10627. */
  10628. /* set vol=0 to output mixers */
  10629. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10630. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10631. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10632. /* set up input amps for analog loopback */
  10633. /* Amp Indices: DAC = 0, mixer = 1 */
  10634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10635. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10636. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10637. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10638. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10639. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10640. /* FIXME: use matrix-type input source selection */
  10641. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10642. /* Input mixer */
  10643. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10645. { }
  10646. };
  10647. /* capture mixer elements */
  10648. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10649. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10650. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10651. {
  10652. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10653. /* The multiple "Capture Source" controls confuse alsamixer
  10654. * So call somewhat different..
  10655. * FIXME: the controls appear in the "playback" view!
  10656. */
  10657. /* .name = "Capture Source", */
  10658. .name = "Input Source",
  10659. .count = 1,
  10660. .info = alc882_mux_enum_info,
  10661. .get = alc882_mux_enum_get,
  10662. .put = alc882_mux_enum_put,
  10663. },
  10664. { } /* end */
  10665. };
  10666. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10667. {
  10668. unsigned int present;
  10669. unsigned char bits;
  10670. present = snd_hda_codec_read(codec, 0x14, 0,
  10671. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10672. bits = present ? HDA_AMP_MUTE : 0;
  10673. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10674. HDA_AMP_MUTE, bits);
  10675. }
  10676. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10677. {
  10678. unsigned int present;
  10679. unsigned char bits;
  10680. present = snd_hda_codec_read(codec, 0x1b, 0,
  10681. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10682. bits = present ? HDA_AMP_MUTE : 0;
  10683. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10684. HDA_AMP_MUTE, bits);
  10685. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10686. HDA_AMP_MUTE, bits);
  10687. }
  10688. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10689. unsigned int res)
  10690. {
  10691. if ((res >> 26) == ALC880_HP_EVENT)
  10692. alc662_lenovo_101e_all_automute(codec);
  10693. if ((res >> 26) == ALC880_FRONT_EVENT)
  10694. alc662_lenovo_101e_ispeaker_automute(codec);
  10695. }
  10696. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  10697. {
  10698. unsigned int present;
  10699. present = snd_hda_codec_read(codec, 0x18, 0,
  10700. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10701. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10702. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10703. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10704. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10705. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10706. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10707. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10708. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10709. }
  10710. /* unsolicited event for HP jack sensing */
  10711. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  10712. unsigned int res)
  10713. {
  10714. if ((res >> 26) == ALC880_HP_EVENT)
  10715. alc262_hippo1_automute( codec );
  10716. if ((res >> 26) == ALC880_MIC_EVENT)
  10717. alc662_eeepc_mic_automute(codec);
  10718. }
  10719. static void alc662_eeepc_inithook(struct hda_codec *codec)
  10720. {
  10721. alc262_hippo1_automute( codec );
  10722. alc662_eeepc_mic_automute(codec);
  10723. }
  10724. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10725. #define alc662_loopbacks alc880_loopbacks
  10726. #endif
  10727. /* pcm configuration: identiacal with ALC880 */
  10728. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10729. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10730. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10731. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10732. /*
  10733. * configuration and preset
  10734. */
  10735. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10736. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10737. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10738. [ALC662_3ST_6ch] = "3stack-6ch",
  10739. [ALC662_5ST_DIG] = "6stack-dig",
  10740. [ALC662_LENOVO_101E] = "lenovo-101e",
  10741. [ALC662_AUTO] = "auto",
  10742. };
  10743. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10744. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10745. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  10746. {}
  10747. };
  10748. static struct alc_config_preset alc662_presets[] = {
  10749. [ALC662_3ST_2ch_DIG] = {
  10750. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  10751. .init_verbs = { alc662_init_verbs },
  10752. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10753. .dac_nids = alc662_dac_nids,
  10754. .dig_out_nid = ALC662_DIGOUT_NID,
  10755. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10756. .adc_nids = alc662_adc_nids,
  10757. .dig_in_nid = ALC662_DIGIN_NID,
  10758. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10759. .channel_mode = alc662_3ST_2ch_modes,
  10760. .input_mux = &alc662_capture_source,
  10761. },
  10762. [ALC662_3ST_6ch_DIG] = {
  10763. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10764. alc662_capture_mixer },
  10765. .init_verbs = { alc662_init_verbs },
  10766. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10767. .dac_nids = alc662_dac_nids,
  10768. .dig_out_nid = ALC662_DIGOUT_NID,
  10769. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10770. .adc_nids = alc662_adc_nids,
  10771. .dig_in_nid = ALC662_DIGIN_NID,
  10772. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10773. .channel_mode = alc662_3ST_6ch_modes,
  10774. .need_dac_fix = 1,
  10775. .input_mux = &alc662_capture_source,
  10776. },
  10777. [ALC662_3ST_6ch] = {
  10778. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10779. alc662_capture_mixer },
  10780. .init_verbs = { alc662_init_verbs },
  10781. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10782. .dac_nids = alc662_dac_nids,
  10783. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10784. .adc_nids = alc662_adc_nids,
  10785. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10786. .channel_mode = alc662_3ST_6ch_modes,
  10787. .need_dac_fix = 1,
  10788. .input_mux = &alc662_capture_source,
  10789. },
  10790. [ALC662_5ST_DIG] = {
  10791. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  10792. alc662_capture_mixer },
  10793. .init_verbs = { alc662_init_verbs },
  10794. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10795. .dac_nids = alc662_dac_nids,
  10796. .dig_out_nid = ALC662_DIGOUT_NID,
  10797. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10798. .adc_nids = alc662_adc_nids,
  10799. .dig_in_nid = ALC662_DIGIN_NID,
  10800. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10801. .channel_mode = alc662_5stack_modes,
  10802. .input_mux = &alc662_capture_source,
  10803. },
  10804. [ALC662_LENOVO_101E] = {
  10805. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  10806. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10807. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10808. .dac_nids = alc662_dac_nids,
  10809. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10810. .adc_nids = alc662_adc_nids,
  10811. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10812. .channel_mode = alc662_3ST_2ch_modes,
  10813. .input_mux = &alc662_lenovo_101e_capture_source,
  10814. .unsol_event = alc662_lenovo_101e_unsol_event,
  10815. .init_hook = alc662_lenovo_101e_all_automute,
  10816. },
  10817. [ALC662_ASUS_EEEPC_P701] = {
  10818. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  10819. .init_verbs = { alc662_init_verbs,
  10820. alc662_eeepc_sue_init_verbs },
  10821. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10822. .dac_nids = alc662_dac_nids,
  10823. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10824. .adc_nids = alc662_adc_nids,
  10825. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10826. .channel_mode = alc662_3ST_2ch_modes,
  10827. .input_mux = &alc662_eeepc_capture_source,
  10828. .unsol_event = alc662_eeepc_unsol_event,
  10829. .init_hook = alc662_eeepc_inithook,
  10830. },
  10831. };
  10832. /*
  10833. * BIOS auto configuration
  10834. */
  10835. /* add playback controls from the parsed DAC table */
  10836. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10837. const struct auto_pin_cfg *cfg)
  10838. {
  10839. char name[32];
  10840. static const char *chname[4] = {
  10841. "Front", "Surround", NULL /*CLFE*/, "Side"
  10842. };
  10843. hda_nid_t nid;
  10844. int i, err;
  10845. for (i = 0; i < cfg->line_outs; i++) {
  10846. if (!spec->multiout.dac_nids[i])
  10847. continue;
  10848. nid = alc880_idx_to_dac(i);
  10849. if (i == 2) {
  10850. /* Center/LFE */
  10851. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10852. "Center Playback Volume",
  10853. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10854. HDA_OUTPUT));
  10855. if (err < 0)
  10856. return err;
  10857. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10858. "LFE Playback Volume",
  10859. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10860. HDA_OUTPUT));
  10861. if (err < 0)
  10862. return err;
  10863. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10864. "Center Playback Switch",
  10865. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10866. HDA_INPUT));
  10867. if (err < 0)
  10868. return err;
  10869. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10870. "LFE Playback Switch",
  10871. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10872. HDA_INPUT));
  10873. if (err < 0)
  10874. return err;
  10875. } else {
  10876. sprintf(name, "%s Playback Volume", chname[i]);
  10877. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10878. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10879. HDA_OUTPUT));
  10880. if (err < 0)
  10881. return err;
  10882. sprintf(name, "%s Playback Switch", chname[i]);
  10883. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10884. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10885. HDA_INPUT));
  10886. if (err < 0)
  10887. return err;
  10888. }
  10889. }
  10890. return 0;
  10891. }
  10892. /* add playback controls for speaker and HP outputs */
  10893. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10894. const char *pfx)
  10895. {
  10896. hda_nid_t nid;
  10897. int err;
  10898. char name[32];
  10899. if (!pin)
  10900. return 0;
  10901. if (alc880_is_fixed_pin(pin)) {
  10902. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10903. /* printk("DAC nid=%x\n",nid); */
  10904. /* specify the DAC as the extra output */
  10905. if (!spec->multiout.hp_nid)
  10906. spec->multiout.hp_nid = nid;
  10907. else
  10908. spec->multiout.extra_out_nid[0] = nid;
  10909. /* control HP volume/switch on the output mixer amp */
  10910. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10911. sprintf(name, "%s Playback Volume", pfx);
  10912. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10913. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10914. if (err < 0)
  10915. return err;
  10916. sprintf(name, "%s Playback Switch", pfx);
  10917. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10918. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10919. if (err < 0)
  10920. return err;
  10921. } else if (alc880_is_multi_pin(pin)) {
  10922. /* set manual connection */
  10923. /* we have only a switch on HP-out PIN */
  10924. sprintf(name, "%s Playback Switch", pfx);
  10925. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10926. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10927. if (err < 0)
  10928. return err;
  10929. }
  10930. return 0;
  10931. }
  10932. /* create playback/capture controls for input pins */
  10933. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10934. const struct auto_pin_cfg *cfg)
  10935. {
  10936. struct hda_input_mux *imux = &spec->private_imux;
  10937. int i, err, idx;
  10938. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10939. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10940. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10941. err = new_analog_input(spec, cfg->input_pins[i],
  10942. auto_pin_cfg_labels[i],
  10943. idx, 0x0b);
  10944. if (err < 0)
  10945. return err;
  10946. imux->items[imux->num_items].label =
  10947. auto_pin_cfg_labels[i];
  10948. imux->items[imux->num_items].index =
  10949. alc880_input_pin_idx(cfg->input_pins[i]);
  10950. imux->num_items++;
  10951. }
  10952. }
  10953. return 0;
  10954. }
  10955. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10956. hda_nid_t nid, int pin_type,
  10957. int dac_idx)
  10958. {
  10959. /* set as output */
  10960. snd_hda_codec_write(codec, nid, 0,
  10961. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10962. snd_hda_codec_write(codec, nid, 0,
  10963. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10964. /* need the manual connection? */
  10965. if (alc880_is_multi_pin(nid)) {
  10966. struct alc_spec *spec = codec->spec;
  10967. int idx = alc880_multi_pin_idx(nid);
  10968. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10969. AC_VERB_SET_CONNECT_SEL,
  10970. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10971. }
  10972. }
  10973. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10974. {
  10975. struct alc_spec *spec = codec->spec;
  10976. int i;
  10977. for (i = 0; i <= HDA_SIDE; i++) {
  10978. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10979. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10980. if (nid)
  10981. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10982. i);
  10983. }
  10984. }
  10985. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10986. {
  10987. struct alc_spec *spec = codec->spec;
  10988. hda_nid_t pin;
  10989. pin = spec->autocfg.hp_pins[0];
  10990. if (pin) /* connect to front */
  10991. /* use dac 0 */
  10992. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10993. }
  10994. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10995. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10996. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10997. {
  10998. struct alc_spec *spec = codec->spec;
  10999. int i;
  11000. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11001. hda_nid_t nid = spec->autocfg.input_pins[i];
  11002. if (alc662_is_input_pin(nid)) {
  11003. snd_hda_codec_write(codec, nid, 0,
  11004. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11005. (i <= AUTO_PIN_FRONT_MIC ?
  11006. PIN_VREF80 : PIN_IN));
  11007. if (nid != ALC662_PIN_CD_NID)
  11008. snd_hda_codec_write(codec, nid, 0,
  11009. AC_VERB_SET_AMP_GAIN_MUTE,
  11010. AMP_OUT_MUTE);
  11011. }
  11012. }
  11013. }
  11014. static int alc662_parse_auto_config(struct hda_codec *codec)
  11015. {
  11016. struct alc_spec *spec = codec->spec;
  11017. int err;
  11018. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11019. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11020. alc662_ignore);
  11021. if (err < 0)
  11022. return err;
  11023. if (!spec->autocfg.line_outs)
  11024. return 0; /* can't find valid BIOS pin config */
  11025. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11026. if (err < 0)
  11027. return err;
  11028. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11029. if (err < 0)
  11030. return err;
  11031. err = alc662_auto_create_extra_out(spec,
  11032. spec->autocfg.speaker_pins[0],
  11033. "Speaker");
  11034. if (err < 0)
  11035. return err;
  11036. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11037. "Headphone");
  11038. if (err < 0)
  11039. return err;
  11040. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11041. if (err < 0)
  11042. return err;
  11043. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11044. if (spec->autocfg.dig_out_pin)
  11045. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11046. if (spec->kctl_alloc)
  11047. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11048. spec->num_mux_defs = 1;
  11049. spec->input_mux = &spec->private_imux;
  11050. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11051. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11052. spec->num_mixers++;
  11053. return 1;
  11054. }
  11055. /* additional initialization for auto-configuration model */
  11056. static void alc662_auto_init(struct hda_codec *codec)
  11057. {
  11058. alc662_auto_init_multi_out(codec);
  11059. alc662_auto_init_hp_out(codec);
  11060. alc662_auto_init_analog_input(codec);
  11061. }
  11062. static int patch_alc662(struct hda_codec *codec)
  11063. {
  11064. struct alc_spec *spec;
  11065. int err, board_config;
  11066. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11067. if (!spec)
  11068. return -ENOMEM;
  11069. codec->spec = spec;
  11070. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11071. alc662_models,
  11072. alc662_cfg_tbl);
  11073. if (board_config < 0) {
  11074. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11075. "trying auto-probe from BIOS...\n");
  11076. board_config = ALC662_AUTO;
  11077. }
  11078. if (board_config == ALC662_AUTO) {
  11079. /* automatic parse from the BIOS config */
  11080. err = alc662_parse_auto_config(codec);
  11081. if (err < 0) {
  11082. alc_free(codec);
  11083. return err;
  11084. } else if (!err) {
  11085. printk(KERN_INFO
  11086. "hda_codec: Cannot set up configuration "
  11087. "from BIOS. Using base mode...\n");
  11088. board_config = ALC662_3ST_2ch_DIG;
  11089. }
  11090. }
  11091. if (board_config != ALC662_AUTO)
  11092. setup_preset(spec, &alc662_presets[board_config]);
  11093. spec->stream_name_analog = "ALC662 Analog";
  11094. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11095. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11096. spec->stream_name_digital = "ALC662 Digital";
  11097. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11098. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11099. if (!spec->adc_nids && spec->input_mux) {
  11100. spec->adc_nids = alc662_adc_nids;
  11101. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11102. }
  11103. codec->patch_ops = alc_patch_ops;
  11104. if (board_config == ALC662_AUTO)
  11105. spec->init_hook = alc662_auto_init;
  11106. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11107. if (!spec->loopback.amplist)
  11108. spec->loopback.amplist = alc662_loopbacks;
  11109. #endif
  11110. return 0;
  11111. }
  11112. /*
  11113. * patch entries
  11114. */
  11115. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11116. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11117. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11118. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11119. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11120. .patch = patch_alc861 },
  11121. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11122. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11123. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11124. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11125. .patch = patch_alc883 },
  11126. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11127. .patch = patch_alc662 },
  11128. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11129. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11130. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11131. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11132. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11133. {} /* terminator */
  11134. };