patch_realtek.c 402 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC885_MACPRO,
  149. ALC885_MBP3,
  150. ALC885_IMAC24,
  151. ALC882_AUTO,
  152. ALC882_MODEL_LAST,
  153. };
  154. /* ALC883 models */
  155. enum {
  156. ALC883_3ST_2ch_DIG,
  157. ALC883_3ST_6ch_DIG,
  158. ALC883_3ST_6ch,
  159. ALC883_6ST_DIG,
  160. ALC883_TARGA_DIG,
  161. ALC883_TARGA_2ch_DIG,
  162. ALC883_ACER,
  163. ALC883_ACER_ASPIRE,
  164. ALC883_MEDION,
  165. ALC883_MEDION_MD2,
  166. ALC883_LAPTOP_EAPD,
  167. ALC883_LENOVO_101E_2ch,
  168. ALC883_LENOVO_NB0763,
  169. ALC888_LENOVO_MS7195_DIG,
  170. ALC883_HAIER_W66,
  171. ALC888_6ST_HP,
  172. ALC888_3ST_HP,
  173. ALC883_AUTO,
  174. ALC883_MODEL_LAST,
  175. };
  176. /* for GPIO Poll */
  177. #define GPIO_MASK 0x03
  178. struct alc_spec {
  179. /* codec parameterization */
  180. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  181. unsigned int num_mixers;
  182. const struct hda_verb *init_verbs[5]; /* initialization verbs
  183. * don't forget NULL
  184. * termination!
  185. */
  186. unsigned int num_init_verbs;
  187. char *stream_name_analog; /* analog PCM stream */
  188. struct hda_pcm_stream *stream_analog_playback;
  189. struct hda_pcm_stream *stream_analog_capture;
  190. char *stream_name_digital; /* digital PCM stream */
  191. struct hda_pcm_stream *stream_digital_playback;
  192. struct hda_pcm_stream *stream_digital_capture;
  193. /* playback */
  194. struct hda_multi_out multiout; /* playback set-up
  195. * max_channels, dacs must be set
  196. * dig_out_nid and hp_nid are optional
  197. */
  198. /* capture */
  199. unsigned int num_adc_nids;
  200. hda_nid_t *adc_nids;
  201. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  202. /* capture source */
  203. unsigned int num_mux_defs;
  204. const struct hda_input_mux *input_mux;
  205. unsigned int cur_mux[3];
  206. /* channel model */
  207. const struct hda_channel_mode *channel_mode;
  208. int num_channel_mode;
  209. int need_dac_fix;
  210. /* PCM information */
  211. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  212. /* dynamic controls, init_verbs and input_mux */
  213. struct auto_pin_cfg autocfg;
  214. unsigned int num_kctl_alloc, num_kctl_used;
  215. struct snd_kcontrol_new *kctl_alloc;
  216. struct hda_input_mux private_imux;
  217. hda_nid_t private_dac_nids[5];
  218. /* hooks */
  219. void (*init_hook)(struct hda_codec *codec);
  220. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  221. /* for pin sensing */
  222. unsigned int sense_updated: 1;
  223. unsigned int jack_present: 1;
  224. #ifdef CONFIG_SND_HDA_POWER_SAVE
  225. struct hda_loopback_check loopback;
  226. #endif
  227. };
  228. /*
  229. * configuration template - to be copied to the spec instance
  230. */
  231. struct alc_config_preset {
  232. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  233. * with spec
  234. */
  235. const struct hda_verb *init_verbs[5];
  236. unsigned int num_dacs;
  237. hda_nid_t *dac_nids;
  238. hda_nid_t dig_out_nid; /* optional */
  239. hda_nid_t hp_nid; /* optional */
  240. unsigned int num_adc_nids;
  241. hda_nid_t *adc_nids;
  242. hda_nid_t dig_in_nid;
  243. unsigned int num_channel_mode;
  244. const struct hda_channel_mode *channel_mode;
  245. int need_dac_fix;
  246. unsigned int num_mux_defs;
  247. const struct hda_input_mux *input_mux;
  248. void (*unsol_event)(struct hda_codec *, unsigned int);
  249. void (*init_hook)(struct hda_codec *);
  250. #ifdef CONFIG_SND_HDA_POWER_SAVE
  251. struct hda_amp_list *loopbacks;
  252. #endif
  253. };
  254. /*
  255. * input MUX handling
  256. */
  257. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  258. struct snd_ctl_elem_info *uinfo)
  259. {
  260. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  261. struct alc_spec *spec = codec->spec;
  262. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  263. if (mux_idx >= spec->num_mux_defs)
  264. mux_idx = 0;
  265. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  266. }
  267. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_value *ucontrol)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  273. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  274. return 0;
  275. }
  276. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_value *ucontrol)
  278. {
  279. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  280. struct alc_spec *spec = codec->spec;
  281. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  282. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  283. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  284. spec->adc_nids[adc_idx],
  285. &spec->cur_mux[adc_idx]);
  286. }
  287. /*
  288. * channel mode setting
  289. */
  290. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  291. struct snd_ctl_elem_info *uinfo)
  292. {
  293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  294. struct alc_spec *spec = codec->spec;
  295. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  296. spec->num_channel_mode);
  297. }
  298. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  299. struct snd_ctl_elem_value *ucontrol)
  300. {
  301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  302. struct alc_spec *spec = codec->spec;
  303. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  304. spec->num_channel_mode,
  305. spec->multiout.max_channels);
  306. }
  307. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  308. struct snd_ctl_elem_value *ucontrol)
  309. {
  310. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  311. struct alc_spec *spec = codec->spec;
  312. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  313. spec->num_channel_mode,
  314. &spec->multiout.max_channels);
  315. if (err >= 0 && spec->need_dac_fix)
  316. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  317. return err;
  318. }
  319. /*
  320. * Control the mode of pin widget settings via the mixer. "pc" is used
  321. * instead of "%" to avoid consequences of accidently treating the % as
  322. * being part of a format specifier. Maximum allowed length of a value is
  323. * 63 characters plus NULL terminator.
  324. *
  325. * Note: some retasking pin complexes seem to ignore requests for input
  326. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  327. * are requested. Therefore order this list so that this behaviour will not
  328. * cause problems when mixer clients move through the enum sequentially.
  329. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  330. * March 2006.
  331. */
  332. static char *alc_pin_mode_names[] = {
  333. "Mic 50pc bias", "Mic 80pc bias",
  334. "Line in", "Line out", "Headphone out",
  335. };
  336. static unsigned char alc_pin_mode_values[] = {
  337. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  338. };
  339. /* The control can present all 5 options, or it can limit the options based
  340. * in the pin being assumed to be exclusively an input or an output pin. In
  341. * addition, "input" pins may or may not process the mic bias option
  342. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  343. * accept requests for bias as of chip versions up to March 2006) and/or
  344. * wiring in the computer.
  345. */
  346. #define ALC_PIN_DIR_IN 0x00
  347. #define ALC_PIN_DIR_OUT 0x01
  348. #define ALC_PIN_DIR_INOUT 0x02
  349. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  350. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  351. /* Info about the pin modes supported by the different pin direction modes.
  352. * For each direction the minimum and maximum values are given.
  353. */
  354. static signed char alc_pin_mode_dir_info[5][2] = {
  355. { 0, 2 }, /* ALC_PIN_DIR_IN */
  356. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  357. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  358. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  359. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  360. };
  361. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  362. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  363. #define alc_pin_mode_n_items(_dir) \
  364. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  365. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_info *uinfo)
  367. {
  368. unsigned int item_num = uinfo->value.enumerated.item;
  369. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  370. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  371. uinfo->count = 1;
  372. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  373. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  374. item_num = alc_pin_mode_min(dir);
  375. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  376. return 0;
  377. }
  378. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  379. struct snd_ctl_elem_value *ucontrol)
  380. {
  381. unsigned int i;
  382. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  383. hda_nid_t nid = kcontrol->private_value & 0xffff;
  384. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  385. long *valp = ucontrol->value.integer.value;
  386. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  387. AC_VERB_GET_PIN_WIDGET_CONTROL,
  388. 0x00);
  389. /* Find enumerated value for current pinctl setting */
  390. i = alc_pin_mode_min(dir);
  391. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  392. i++;
  393. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  394. return 0;
  395. }
  396. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol)
  398. {
  399. signed int change;
  400. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  401. hda_nid_t nid = kcontrol->private_value & 0xffff;
  402. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  403. long val = *ucontrol->value.integer.value;
  404. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  405. AC_VERB_GET_PIN_WIDGET_CONTROL,
  406. 0x00);
  407. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  408. val = alc_pin_mode_min(dir);
  409. change = pinctl != alc_pin_mode_values[val];
  410. if (change) {
  411. /* Set pin mode to that requested */
  412. snd_hda_codec_write_cache(codec, nid, 0,
  413. AC_VERB_SET_PIN_WIDGET_CONTROL,
  414. alc_pin_mode_values[val]);
  415. /* Also enable the retasking pin's input/output as required
  416. * for the requested pin mode. Enum values of 2 or less are
  417. * input modes.
  418. *
  419. * Dynamically switching the input/output buffers probably
  420. * reduces noise slightly (particularly on input) so we'll
  421. * do it. However, having both input and output buffers
  422. * enabled simultaneously doesn't seem to be problematic if
  423. * this turns out to be necessary in the future.
  424. */
  425. if (val <= 2) {
  426. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  427. HDA_AMP_MUTE, HDA_AMP_MUTE);
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  429. HDA_AMP_MUTE, 0);
  430. } else {
  431. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  432. HDA_AMP_MUTE, HDA_AMP_MUTE);
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  434. HDA_AMP_MUTE, 0);
  435. }
  436. }
  437. return change;
  438. }
  439. #define ALC_PIN_MODE(xname, nid, dir) \
  440. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  441. .info = alc_pin_mode_info, \
  442. .get = alc_pin_mode_get, \
  443. .put = alc_pin_mode_put, \
  444. .private_value = nid | (dir<<16) }
  445. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  446. * together using a mask with more than one bit set. This control is
  447. * currently used only by the ALC260 test model. At this stage they are not
  448. * needed for any "production" models.
  449. */
  450. #ifdef CONFIG_SND_DEBUG
  451. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  452. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  453. struct snd_ctl_elem_value *ucontrol)
  454. {
  455. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  456. hda_nid_t nid = kcontrol->private_value & 0xffff;
  457. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  458. long *valp = ucontrol->value.integer.value;
  459. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  460. AC_VERB_GET_GPIO_DATA, 0x00);
  461. *valp = (val & mask) != 0;
  462. return 0;
  463. }
  464. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  465. struct snd_ctl_elem_value *ucontrol)
  466. {
  467. signed int change;
  468. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  469. hda_nid_t nid = kcontrol->private_value & 0xffff;
  470. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  471. long val = *ucontrol->value.integer.value;
  472. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  473. AC_VERB_GET_GPIO_DATA,
  474. 0x00);
  475. /* Set/unset the masked GPIO bit(s) as needed */
  476. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  477. if (val == 0)
  478. gpio_data &= ~mask;
  479. else
  480. gpio_data |= mask;
  481. snd_hda_codec_write_cache(codec, nid, 0,
  482. AC_VERB_SET_GPIO_DATA, gpio_data);
  483. return change;
  484. }
  485. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  486. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  487. .info = alc_gpio_data_info, \
  488. .get = alc_gpio_data_get, \
  489. .put = alc_gpio_data_put, \
  490. .private_value = nid | (mask<<16) }
  491. #endif /* CONFIG_SND_DEBUG */
  492. /* A switch control to allow the enabling of the digital IO pins on the
  493. * ALC260. This is incredibly simplistic; the intention of this control is
  494. * to provide something in the test model allowing digital outputs to be
  495. * identified if present. If models are found which can utilise these
  496. * outputs a more complete mixer control can be devised for those models if
  497. * necessary.
  498. */
  499. #ifdef CONFIG_SND_DEBUG
  500. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  501. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  502. struct snd_ctl_elem_value *ucontrol)
  503. {
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. hda_nid_t nid = kcontrol->private_value & 0xffff;
  506. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  507. long *valp = ucontrol->value.integer.value;
  508. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  509. AC_VERB_GET_DIGI_CONVERT, 0x00);
  510. *valp = (val & mask) != 0;
  511. return 0;
  512. }
  513. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  514. struct snd_ctl_elem_value *ucontrol)
  515. {
  516. signed int change;
  517. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  518. hda_nid_t nid = kcontrol->private_value & 0xffff;
  519. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  520. long val = *ucontrol->value.integer.value;
  521. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  522. AC_VERB_GET_DIGI_CONVERT,
  523. 0x00);
  524. /* Set/unset the masked control bit(s) as needed */
  525. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  526. if (val==0)
  527. ctrl_data &= ~mask;
  528. else
  529. ctrl_data |= mask;
  530. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  531. ctrl_data);
  532. return change;
  533. }
  534. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  535. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  536. .info = alc_spdif_ctrl_info, \
  537. .get = alc_spdif_ctrl_get, \
  538. .put = alc_spdif_ctrl_put, \
  539. .private_value = nid | (mask<<16) }
  540. #endif /* CONFIG_SND_DEBUG */
  541. /*
  542. * set up from the preset table
  543. */
  544. static void setup_preset(struct alc_spec *spec,
  545. const struct alc_config_preset *preset)
  546. {
  547. int i;
  548. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  549. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  550. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  551. i++)
  552. spec->init_verbs[spec->num_init_verbs++] =
  553. preset->init_verbs[i];
  554. spec->channel_mode = preset->channel_mode;
  555. spec->num_channel_mode = preset->num_channel_mode;
  556. spec->need_dac_fix = preset->need_dac_fix;
  557. spec->multiout.max_channels = spec->channel_mode[0].channels;
  558. spec->multiout.num_dacs = preset->num_dacs;
  559. spec->multiout.dac_nids = preset->dac_nids;
  560. spec->multiout.dig_out_nid = preset->dig_out_nid;
  561. spec->multiout.hp_nid = preset->hp_nid;
  562. spec->num_mux_defs = preset->num_mux_defs;
  563. if (!spec->num_mux_defs)
  564. spec->num_mux_defs = 1;
  565. spec->input_mux = preset->input_mux;
  566. spec->num_adc_nids = preset->num_adc_nids;
  567. spec->adc_nids = preset->adc_nids;
  568. spec->dig_in_nid = preset->dig_in_nid;
  569. spec->unsol_event = preset->unsol_event;
  570. spec->init_hook = preset->init_hook;
  571. #ifdef CONFIG_SND_HDA_POWER_SAVE
  572. spec->loopback.amplist = preset->loopbacks;
  573. #endif
  574. }
  575. /* Enable GPIO mask and set output */
  576. static struct hda_verb alc_gpio1_init_verbs[] = {
  577. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  579. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  580. { }
  581. };
  582. static struct hda_verb alc_gpio2_init_verbs[] = {
  583. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  585. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  586. { }
  587. };
  588. static struct hda_verb alc_gpio3_init_verbs[] = {
  589. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  591. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  592. { }
  593. };
  594. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  595. * 31 ~ 16 : Manufacture ID
  596. * 15 ~ 8 : SKU ID
  597. * 7 ~ 0 : Assembly ID
  598. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  599. */
  600. static void alc_subsystem_id(struct hda_codec *codec,
  601. unsigned int porta, unsigned int porte,
  602. unsigned int portd)
  603. {
  604. unsigned int ass, tmp;
  605. ass = codec->subsystem_id;
  606. if (!(ass & 1))
  607. return;
  608. /* Override */
  609. tmp = (ass & 0x38) >> 3; /* external Amp control */
  610. switch (tmp) {
  611. case 1:
  612. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  613. break;
  614. case 3:
  615. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  616. break;
  617. case 7:
  618. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  619. break;
  620. case 5:
  621. switch (codec->vendor_id) {
  622. case 0x10ec0862:
  623. case 0x10ec0660:
  624. case 0x10ec0662:
  625. case 0x10ec0267:
  626. case 0x10ec0268:
  627. snd_hda_codec_write(codec, 0x14, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. snd_hda_codec_write(codec, 0x15, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. return;
  632. }
  633. case 6:
  634. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  635. hda_nid_t port = 0;
  636. tmp = (ass & 0x1800) >> 11;
  637. switch (tmp) {
  638. case 0: port = porta; break;
  639. case 1: port = porte; break;
  640. case 2: port = portd; break;
  641. }
  642. if (port)
  643. snd_hda_codec_write(codec, port, 0,
  644. AC_VERB_SET_EAPD_BTLENABLE,
  645. 2);
  646. }
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  649. (tmp == 5 ? 0x3040 : 0x3050));
  650. break;
  651. }
  652. }
  653. /*
  654. * Fix-up pin default configurations
  655. */
  656. struct alc_pincfg {
  657. hda_nid_t nid;
  658. u32 val;
  659. };
  660. static void alc_fix_pincfg(struct hda_codec *codec,
  661. const struct snd_pci_quirk *quirk,
  662. const struct alc_pincfg **pinfix)
  663. {
  664. const struct alc_pincfg *cfg;
  665. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  666. if (!quirk)
  667. return;
  668. cfg = pinfix[quirk->value];
  669. for (; cfg->nid; cfg++) {
  670. int i;
  671. u32 val = cfg->val;
  672. for (i = 0; i < 4; i++) {
  673. snd_hda_codec_write(codec, cfg->nid, 0,
  674. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  675. val & 0xff);
  676. val >>= 8;
  677. }
  678. }
  679. }
  680. /*
  681. * ALC880 3-stack model
  682. *
  683. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  684. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  685. * F-Mic = 0x1b, HP = 0x19
  686. */
  687. static hda_nid_t alc880_dac_nids[4] = {
  688. /* front, rear, clfe, rear_surr */
  689. 0x02, 0x05, 0x04, 0x03
  690. };
  691. static hda_nid_t alc880_adc_nids[3] = {
  692. /* ADC0-2 */
  693. 0x07, 0x08, 0x09,
  694. };
  695. /* The datasheet says the node 0x07 is connected from inputs,
  696. * but it shows zero connection in the real implementation on some devices.
  697. * Note: this is a 915GAV bug, fixed on 915GLV
  698. */
  699. static hda_nid_t alc880_adc_nids_alt[2] = {
  700. /* ADC1-2 */
  701. 0x08, 0x09,
  702. };
  703. #define ALC880_DIGOUT_NID 0x06
  704. #define ALC880_DIGIN_NID 0x0a
  705. static struct hda_input_mux alc880_capture_source = {
  706. .num_items = 4,
  707. .items = {
  708. { "Mic", 0x0 },
  709. { "Front Mic", 0x3 },
  710. { "Line", 0x2 },
  711. { "CD", 0x4 },
  712. },
  713. };
  714. /* channel source setting (2/6 channel selection for 3-stack) */
  715. /* 2ch mode */
  716. static struct hda_verb alc880_threestack_ch2_init[] = {
  717. /* set line-in to input, mute it */
  718. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  719. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  720. /* set mic-in to input vref 80%, mute it */
  721. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  722. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  723. { } /* end */
  724. };
  725. /* 6ch mode */
  726. static struct hda_verb alc880_threestack_ch6_init[] = {
  727. /* set line-in to output, unmute it */
  728. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  729. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  730. /* set mic-in to output, unmute it */
  731. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  732. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  733. { } /* end */
  734. };
  735. static struct hda_channel_mode alc880_threestack_modes[2] = {
  736. { 2, alc880_threestack_ch2_init },
  737. { 6, alc880_threestack_ch6_init },
  738. };
  739. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  740. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  741. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  742. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  745. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  747. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  748. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  750. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  755. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  756. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  757. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  759. {
  760. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  761. .name = "Channel Mode",
  762. .info = alc_ch_mode_info,
  763. .get = alc_ch_mode_get,
  764. .put = alc_ch_mode_put,
  765. },
  766. { } /* end */
  767. };
  768. /* capture mixer elements */
  769. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  770. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  772. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  776. {
  777. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  778. /* The multiple "Capture Source" controls confuse alsamixer
  779. * So call somewhat different..
  780. * FIXME: the controls appear in the "playback" view!
  781. */
  782. /* .name = "Capture Source", */
  783. .name = "Input Source",
  784. .count = 3,
  785. .info = alc_mux_enum_info,
  786. .get = alc_mux_enum_get,
  787. .put = alc_mux_enum_put,
  788. },
  789. { } /* end */
  790. };
  791. /* capture mixer elements (in case NID 0x07 not available) */
  792. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  793. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  794. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  795. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  797. {
  798. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  799. /* The multiple "Capture Source" controls confuse alsamixer
  800. * So call somewhat different..
  801. * FIXME: the controls appear in the "playback" view!
  802. */
  803. /* .name = "Capture Source", */
  804. .name = "Input Source",
  805. .count = 2,
  806. .info = alc_mux_enum_info,
  807. .get = alc_mux_enum_get,
  808. .put = alc_mux_enum_put,
  809. },
  810. { } /* end */
  811. };
  812. /*
  813. * ALC880 5-stack model
  814. *
  815. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  816. * Side = 0x02 (0xd)
  817. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  818. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  819. */
  820. /* additional mixers to alc880_three_stack_mixer */
  821. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  822. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  823. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  824. { } /* end */
  825. };
  826. /* channel source setting (6/8 channel selection for 5-stack) */
  827. /* 6ch mode */
  828. static struct hda_verb alc880_fivestack_ch6_init[] = {
  829. /* set line-in to input, mute it */
  830. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  831. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  832. { } /* end */
  833. };
  834. /* 8ch mode */
  835. static struct hda_verb alc880_fivestack_ch8_init[] = {
  836. /* set line-in to output, unmute it */
  837. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  838. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  839. { } /* end */
  840. };
  841. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  842. { 6, alc880_fivestack_ch6_init },
  843. { 8, alc880_fivestack_ch8_init },
  844. };
  845. /*
  846. * ALC880 6-stack model
  847. *
  848. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  849. * Side = 0x05 (0x0f)
  850. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  851. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  852. */
  853. static hda_nid_t alc880_6st_dac_nids[4] = {
  854. /* front, rear, clfe, rear_surr */
  855. 0x02, 0x03, 0x04, 0x05
  856. };
  857. static struct hda_input_mux alc880_6stack_capture_source = {
  858. .num_items = 4,
  859. .items = {
  860. { "Mic", 0x0 },
  861. { "Front Mic", 0x1 },
  862. { "Line", 0x2 },
  863. { "CD", 0x4 },
  864. },
  865. };
  866. /* fixed 8-channels */
  867. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  868. { 8, NULL },
  869. };
  870. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  871. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  872. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  873. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  876. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  877. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  878. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  882. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  883. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  884. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  886. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  888. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  889. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  890. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  891. {
  892. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  893. .name = "Channel Mode",
  894. .info = alc_ch_mode_info,
  895. .get = alc_ch_mode_get,
  896. .put = alc_ch_mode_put,
  897. },
  898. { } /* end */
  899. };
  900. /*
  901. * ALC880 W810 model
  902. *
  903. * W810 has rear IO for:
  904. * Front (DAC 02)
  905. * Surround (DAC 03)
  906. * Center/LFE (DAC 04)
  907. * Digital out (06)
  908. *
  909. * The system also has a pair of internal speakers, and a headphone jack.
  910. * These are both connected to Line2 on the codec, hence to DAC 02.
  911. *
  912. * There is a variable resistor to control the speaker or headphone
  913. * volume. This is a hardware-only device without a software API.
  914. *
  915. * Plugging headphones in will disable the internal speakers. This is
  916. * implemented in hardware, not via the driver using jack sense. In
  917. * a similar fashion, plugging into the rear socket marked "front" will
  918. * disable both the speakers and headphones.
  919. *
  920. * For input, there's a microphone jack, and an "audio in" jack.
  921. * These may not do anything useful with this driver yet, because I
  922. * haven't setup any initialization verbs for these yet...
  923. */
  924. static hda_nid_t alc880_w810_dac_nids[3] = {
  925. /* front, rear/surround, clfe */
  926. 0x02, 0x03, 0x04
  927. };
  928. /* fixed 6 channels */
  929. static struct hda_channel_mode alc880_w810_modes[1] = {
  930. { 6, NULL }
  931. };
  932. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  933. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  934. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  939. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  940. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  941. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  942. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  943. { } /* end */
  944. };
  945. /*
  946. * Z710V model
  947. *
  948. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  949. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  950. * Line = 0x1a
  951. */
  952. static hda_nid_t alc880_z71v_dac_nids[1] = {
  953. 0x02
  954. };
  955. #define ALC880_Z71V_HP_DAC 0x03
  956. /* fixed 2 channels */
  957. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  958. { 2, NULL }
  959. };
  960. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  961. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  962. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  963. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  966. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  969. { } /* end */
  970. };
  971. /* FIXME! */
  972. /*
  973. * ALC880 F1734 model
  974. *
  975. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  976. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  977. */
  978. static hda_nid_t alc880_f1734_dac_nids[1] = {
  979. 0x03
  980. };
  981. #define ALC880_F1734_HP_DAC 0x02
  982. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  983. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  984. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  985. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  988. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  990. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  991. { } /* end */
  992. };
  993. /* FIXME! */
  994. /*
  995. * ALC880 ASUS model
  996. *
  997. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  998. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  999. * Mic = 0x18, Line = 0x1a
  1000. */
  1001. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1002. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1003. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1004. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1005. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1006. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1009. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1010. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1011. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1013. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1015. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1018. {
  1019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1020. .name = "Channel Mode",
  1021. .info = alc_ch_mode_info,
  1022. .get = alc_ch_mode_get,
  1023. .put = alc_ch_mode_put,
  1024. },
  1025. { } /* end */
  1026. };
  1027. /* FIXME! */
  1028. /*
  1029. * ALC880 ASUS W1V model
  1030. *
  1031. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1032. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1033. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1034. */
  1035. /* additional mixers to alc880_asus_mixer */
  1036. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1037. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1038. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1039. { } /* end */
  1040. };
  1041. /* additional mixers to alc880_asus_mixer */
  1042. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1043. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1044. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1045. { } /* end */
  1046. };
  1047. /* TCL S700 */
  1048. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1049. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1050. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1053. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1058. {
  1059. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1060. /* The multiple "Capture Source" controls confuse alsamixer
  1061. * So call somewhat different..
  1062. * FIXME: the controls appear in the "playback" view!
  1063. */
  1064. /* .name = "Capture Source", */
  1065. .name = "Input Source",
  1066. .count = 1,
  1067. .info = alc_mux_enum_info,
  1068. .get = alc_mux_enum_get,
  1069. .put = alc_mux_enum_put,
  1070. },
  1071. { } /* end */
  1072. };
  1073. /* Uniwill */
  1074. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1075. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1080. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1081. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1082. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1084. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1092. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1093. {
  1094. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1095. .name = "Channel Mode",
  1096. .info = alc_ch_mode_info,
  1097. .get = alc_ch_mode_get,
  1098. .put = alc_ch_mode_put,
  1099. },
  1100. { } /* end */
  1101. };
  1102. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1103. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1104. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1108. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1110. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1113. { } /* end */
  1114. };
  1115. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1116. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1117. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1118. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1122. { } /* end */
  1123. };
  1124. /*
  1125. * build control elements
  1126. */
  1127. static int alc_build_controls(struct hda_codec *codec)
  1128. {
  1129. struct alc_spec *spec = codec->spec;
  1130. int err;
  1131. int i;
  1132. for (i = 0; i < spec->num_mixers; i++) {
  1133. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1134. if (err < 0)
  1135. return err;
  1136. }
  1137. if (spec->multiout.dig_out_nid) {
  1138. err = snd_hda_create_spdif_out_ctls(codec,
  1139. spec->multiout.dig_out_nid);
  1140. if (err < 0)
  1141. return err;
  1142. }
  1143. if (spec->dig_in_nid) {
  1144. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1145. if (err < 0)
  1146. return err;
  1147. }
  1148. return 0;
  1149. }
  1150. /*
  1151. * initialize the codec volumes, etc
  1152. */
  1153. /*
  1154. * generic initialization of ADC, input mixers and output mixers
  1155. */
  1156. static struct hda_verb alc880_volume_init_verbs[] = {
  1157. /*
  1158. * Unmute ADC0-2 and set the default input to mic-in
  1159. */
  1160. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1161. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1162. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1167. * mixer widget
  1168. * Note: PASD motherboards uses the Line In 2 as the input for front
  1169. * panel mic (mic 2)
  1170. */
  1171. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1179. /*
  1180. * Set up output mixers (0x0c - 0x0f)
  1181. */
  1182. /* set vol=0 to output mixers */
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. /* set up input amps for analog loopback */
  1188. /* Amp Indices: DAC = 0, mixer = 1 */
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. { }
  1198. };
  1199. /*
  1200. * 3-stack pin configuration:
  1201. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1202. */
  1203. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1204. /*
  1205. * preset connection lists of input pins
  1206. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1207. */
  1208. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1209. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1210. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1211. /*
  1212. * Set pin mode and muting
  1213. */
  1214. /* set front pin widgets 0x14 for output */
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1218. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1220. /* Mic2 (as headphone out) for HP output */
  1221. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1223. /* Line In pin widget for input */
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1227. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. /* CD pin widget for input */
  1230. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1231. { }
  1232. };
  1233. /*
  1234. * 5-stack pin configuration:
  1235. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1236. * line-in/side = 0x1a, f-mic = 0x1b
  1237. */
  1238. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1239. /*
  1240. * preset connection lists of input pins
  1241. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1242. */
  1243. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1244. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1245. /*
  1246. * Set pin mode and muting
  1247. */
  1248. /* set pin widgets 0x14-0x17 for output */
  1249. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. /* unmute pins for output (no gain on this amp) */
  1254. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. /* Mic2 (as headphone out) for HP output */
  1262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1264. /* Line In pin widget for input */
  1265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1267. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1270. /* CD pin widget for input */
  1271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. { }
  1273. };
  1274. /*
  1275. * W810 pin configuration:
  1276. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1277. */
  1278. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1279. /* hphone/speaker input selector: front DAC */
  1280. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1281. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. { }
  1290. };
  1291. /*
  1292. * Z71V pin configuration:
  1293. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1294. */
  1295. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1296. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1299. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. { }
  1305. };
  1306. /*
  1307. * 6-stack pin configuration:
  1308. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1309. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1310. */
  1311. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1312. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1326. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1330. { }
  1331. };
  1332. /*
  1333. * Uniwill pin configuration:
  1334. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1335. * line = 0x1a
  1336. */
  1337. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1338. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1339. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1346. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1360. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1361. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1363. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1364. { }
  1365. };
  1366. /*
  1367. * Uniwill P53
  1368. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1369. */
  1370. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1371. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1391. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1392. { }
  1393. };
  1394. static struct hda_verb alc880_beep_init_verbs[] = {
  1395. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1396. { }
  1397. };
  1398. /* toggle speaker-output according to the hp-jack state */
  1399. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1400. {
  1401. unsigned int present;
  1402. unsigned char bits;
  1403. present = snd_hda_codec_read(codec, 0x14, 0,
  1404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1405. bits = present ? HDA_AMP_MUTE : 0;
  1406. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1407. HDA_AMP_MUTE, bits);
  1408. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1409. HDA_AMP_MUTE, bits);
  1410. }
  1411. /* auto-toggle front mic */
  1412. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1413. {
  1414. unsigned int present;
  1415. unsigned char bits;
  1416. present = snd_hda_codec_read(codec, 0x18, 0,
  1417. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1418. bits = present ? HDA_AMP_MUTE : 0;
  1419. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1420. }
  1421. static void alc880_uniwill_automute(struct hda_codec *codec)
  1422. {
  1423. alc880_uniwill_hp_automute(codec);
  1424. alc880_uniwill_mic_automute(codec);
  1425. }
  1426. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1427. unsigned int res)
  1428. {
  1429. /* Looks like the unsol event is incompatible with the standard
  1430. * definition. 4bit tag is placed at 28 bit!
  1431. */
  1432. switch (res >> 28) {
  1433. case ALC880_HP_EVENT:
  1434. alc880_uniwill_hp_automute(codec);
  1435. break;
  1436. case ALC880_MIC_EVENT:
  1437. alc880_uniwill_mic_automute(codec);
  1438. break;
  1439. }
  1440. }
  1441. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1442. {
  1443. unsigned int present;
  1444. unsigned char bits;
  1445. present = snd_hda_codec_read(codec, 0x14, 0,
  1446. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1447. bits = present ? HDA_AMP_MUTE : 0;
  1448. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1449. }
  1450. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1451. {
  1452. unsigned int present;
  1453. present = snd_hda_codec_read(codec, 0x21, 0,
  1454. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1455. present &= HDA_AMP_VOLMASK;
  1456. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1457. HDA_AMP_VOLMASK, present);
  1458. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1459. HDA_AMP_VOLMASK, present);
  1460. }
  1461. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1462. unsigned int res)
  1463. {
  1464. /* Looks like the unsol event is incompatible with the standard
  1465. * definition. 4bit tag is placed at 28 bit!
  1466. */
  1467. if ((res >> 28) == ALC880_HP_EVENT)
  1468. alc880_uniwill_p53_hp_automute(codec);
  1469. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1470. alc880_uniwill_p53_dcvol_automute(codec);
  1471. }
  1472. /* FIXME! */
  1473. /*
  1474. * F1734 pin configuration:
  1475. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1476. */
  1477. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1478. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1479. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1480. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1481. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1482. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1483. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1487. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1488. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1489. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1490. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. { }
  1496. };
  1497. /* FIXME! */
  1498. /*
  1499. * ASUS pin configuration:
  1500. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1501. */
  1502. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1503. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1504. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1505. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1506. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1507. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1521. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1522. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. { }
  1525. };
  1526. /* Enable GPIO mask and set output */
  1527. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1528. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1529. /* Clevo m520g init */
  1530. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1531. /* headphone output */
  1532. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1533. /* line-out */
  1534. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1535. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. /* Line-in */
  1537. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1538. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1539. /* CD */
  1540. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1541. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1542. /* Mic1 (rear panel) */
  1543. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1544. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1545. /* Mic2 (front panel) */
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1547. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1548. /* headphone */
  1549. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1550. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1551. /* change to EAPD mode */
  1552. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1553. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1554. { }
  1555. };
  1556. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1557. /* change to EAPD mode */
  1558. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1559. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1560. /* Headphone output */
  1561. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1562. /* Front output*/
  1563. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1564. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1565. /* Line In pin widget for input */
  1566. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1567. /* CD pin widget for input */
  1568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1569. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1570. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1571. /* change to EAPD mode */
  1572. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1573. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1574. { }
  1575. };
  1576. /*
  1577. * LG m1 express dual
  1578. *
  1579. * Pin assignment:
  1580. * Rear Line-In/Out (blue): 0x14
  1581. * Build-in Mic-In: 0x15
  1582. * Speaker-out: 0x17
  1583. * HP-Out (green): 0x1b
  1584. * Mic-In/Out (red): 0x19
  1585. * SPDIF-Out: 0x1e
  1586. */
  1587. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1588. static hda_nid_t alc880_lg_dac_nids[3] = {
  1589. 0x05, 0x02, 0x03
  1590. };
  1591. /* seems analog CD is not working */
  1592. static struct hda_input_mux alc880_lg_capture_source = {
  1593. .num_items = 3,
  1594. .items = {
  1595. { "Mic", 0x1 },
  1596. { "Line", 0x5 },
  1597. { "Internal Mic", 0x6 },
  1598. },
  1599. };
  1600. /* 2,4,6 channel modes */
  1601. static struct hda_verb alc880_lg_ch2_init[] = {
  1602. /* set line-in and mic-in to input */
  1603. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1604. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1605. { }
  1606. };
  1607. static struct hda_verb alc880_lg_ch4_init[] = {
  1608. /* set line-in to out and mic-in to input */
  1609. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1610. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1611. { }
  1612. };
  1613. static struct hda_verb alc880_lg_ch6_init[] = {
  1614. /* set line-in and mic-in to output */
  1615. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1616. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1617. { }
  1618. };
  1619. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1620. { 2, alc880_lg_ch2_init },
  1621. { 4, alc880_lg_ch4_init },
  1622. { 6, alc880_lg_ch6_init },
  1623. };
  1624. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1625. /* FIXME: it's not really "master" but front channels */
  1626. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1628. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1629. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1630. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1631. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1632. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1633. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1634. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1635. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1638. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1639. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1640. {
  1641. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1642. .name = "Channel Mode",
  1643. .info = alc_ch_mode_info,
  1644. .get = alc_ch_mode_get,
  1645. .put = alc_ch_mode_put,
  1646. },
  1647. { } /* end */
  1648. };
  1649. static struct hda_verb alc880_lg_init_verbs[] = {
  1650. /* set capture source to mic-in */
  1651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. /* mute all amp mixer inputs */
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1658. /* line-in to input */
  1659. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1660. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1661. /* built-in mic */
  1662. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1663. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1664. /* speaker-out */
  1665. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1666. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1667. /* mic-in to input */
  1668. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1671. /* HP-out */
  1672. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1673. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1674. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1675. /* jack sense */
  1676. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1677. { }
  1678. };
  1679. /* toggle speaker-output according to the hp-jack state */
  1680. static void alc880_lg_automute(struct hda_codec *codec)
  1681. {
  1682. unsigned int present;
  1683. unsigned char bits;
  1684. present = snd_hda_codec_read(codec, 0x1b, 0,
  1685. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1686. bits = present ? HDA_AMP_MUTE : 0;
  1687. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1688. HDA_AMP_MUTE, bits);
  1689. }
  1690. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1691. {
  1692. /* Looks like the unsol event is incompatible with the standard
  1693. * definition. 4bit tag is placed at 28 bit!
  1694. */
  1695. if ((res >> 28) == 0x01)
  1696. alc880_lg_automute(codec);
  1697. }
  1698. /*
  1699. * LG LW20
  1700. *
  1701. * Pin assignment:
  1702. * Speaker-out: 0x14
  1703. * Mic-In: 0x18
  1704. * Built-in Mic-In: 0x19
  1705. * Line-In: 0x1b
  1706. * HP-Out: 0x1a
  1707. * SPDIF-Out: 0x1e
  1708. */
  1709. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1710. .num_items = 3,
  1711. .items = {
  1712. { "Mic", 0x0 },
  1713. { "Internal Mic", 0x1 },
  1714. { "Line In", 0x2 },
  1715. },
  1716. };
  1717. #define alc880_lg_lw_modes alc880_threestack_modes
  1718. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1719. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1720. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1721. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1722. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1723. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1724. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1725. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1726. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1730. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1732. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1733. {
  1734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1735. .name = "Channel Mode",
  1736. .info = alc_ch_mode_info,
  1737. .get = alc_ch_mode_get,
  1738. .put = alc_ch_mode_put,
  1739. },
  1740. { } /* end */
  1741. };
  1742. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1743. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1744. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1745. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1746. /* set capture source to mic-in */
  1747. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1748. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1751. /* speaker-out */
  1752. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1753. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1754. /* HP-out */
  1755. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1756. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1757. /* mic-in to input */
  1758. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1759. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1760. /* built-in mic */
  1761. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1762. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1763. /* jack sense */
  1764. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1765. { }
  1766. };
  1767. /* toggle speaker-output according to the hp-jack state */
  1768. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1769. {
  1770. unsigned int present;
  1771. unsigned char bits;
  1772. present = snd_hda_codec_read(codec, 0x1b, 0,
  1773. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1774. bits = present ? HDA_AMP_MUTE : 0;
  1775. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1776. HDA_AMP_MUTE, bits);
  1777. }
  1778. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1779. {
  1780. /* Looks like the unsol event is incompatible with the standard
  1781. * definition. 4bit tag is placed at 28 bit!
  1782. */
  1783. if ((res >> 28) == 0x01)
  1784. alc880_lg_lw_automute(codec);
  1785. }
  1786. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1787. static struct hda_amp_list alc880_loopbacks[] = {
  1788. { 0x0b, HDA_INPUT, 0 },
  1789. { 0x0b, HDA_INPUT, 1 },
  1790. { 0x0b, HDA_INPUT, 2 },
  1791. { 0x0b, HDA_INPUT, 3 },
  1792. { 0x0b, HDA_INPUT, 4 },
  1793. { } /* end */
  1794. };
  1795. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1796. { 0x0b, HDA_INPUT, 1 },
  1797. { 0x0b, HDA_INPUT, 6 },
  1798. { 0x0b, HDA_INPUT, 7 },
  1799. { } /* end */
  1800. };
  1801. #endif
  1802. /*
  1803. * Common callbacks
  1804. */
  1805. static int alc_init(struct hda_codec *codec)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. unsigned int i;
  1809. for (i = 0; i < spec->num_init_verbs; i++)
  1810. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1811. if (spec->init_hook)
  1812. spec->init_hook(codec);
  1813. return 0;
  1814. }
  1815. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1816. {
  1817. struct alc_spec *spec = codec->spec;
  1818. if (spec->unsol_event)
  1819. spec->unsol_event(codec, res);
  1820. }
  1821. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1822. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1823. {
  1824. struct alc_spec *spec = codec->spec;
  1825. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1826. }
  1827. #endif
  1828. /*
  1829. * Analog playback callbacks
  1830. */
  1831. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1832. struct hda_codec *codec,
  1833. struct snd_pcm_substream *substream)
  1834. {
  1835. struct alc_spec *spec = codec->spec;
  1836. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1837. }
  1838. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1839. struct hda_codec *codec,
  1840. unsigned int stream_tag,
  1841. unsigned int format,
  1842. struct snd_pcm_substream *substream)
  1843. {
  1844. struct alc_spec *spec = codec->spec;
  1845. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1846. stream_tag, format, substream);
  1847. }
  1848. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1849. struct hda_codec *codec,
  1850. struct snd_pcm_substream *substream)
  1851. {
  1852. struct alc_spec *spec = codec->spec;
  1853. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1854. }
  1855. /*
  1856. * Digital out
  1857. */
  1858. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1859. struct hda_codec *codec,
  1860. struct snd_pcm_substream *substream)
  1861. {
  1862. struct alc_spec *spec = codec->spec;
  1863. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1864. }
  1865. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1866. struct hda_codec *codec,
  1867. unsigned int stream_tag,
  1868. unsigned int format,
  1869. struct snd_pcm_substream *substream)
  1870. {
  1871. struct alc_spec *spec = codec->spec;
  1872. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1873. stream_tag, format, substream);
  1874. }
  1875. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1876. struct hda_codec *codec,
  1877. struct snd_pcm_substream *substream)
  1878. {
  1879. struct alc_spec *spec = codec->spec;
  1880. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1881. }
  1882. /*
  1883. * Analog capture
  1884. */
  1885. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1886. struct hda_codec *codec,
  1887. unsigned int stream_tag,
  1888. unsigned int format,
  1889. struct snd_pcm_substream *substream)
  1890. {
  1891. struct alc_spec *spec = codec->spec;
  1892. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1893. stream_tag, 0, format);
  1894. return 0;
  1895. }
  1896. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1897. struct hda_codec *codec,
  1898. struct snd_pcm_substream *substream)
  1899. {
  1900. struct alc_spec *spec = codec->spec;
  1901. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1902. 0, 0, 0);
  1903. return 0;
  1904. }
  1905. /*
  1906. */
  1907. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1908. .substreams = 1,
  1909. .channels_min = 2,
  1910. .channels_max = 8,
  1911. /* NID is set in alc_build_pcms */
  1912. .ops = {
  1913. .open = alc880_playback_pcm_open,
  1914. .prepare = alc880_playback_pcm_prepare,
  1915. .cleanup = alc880_playback_pcm_cleanup
  1916. },
  1917. };
  1918. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1919. .substreams = 2,
  1920. .channels_min = 2,
  1921. .channels_max = 2,
  1922. /* NID is set in alc_build_pcms */
  1923. .ops = {
  1924. .prepare = alc880_capture_pcm_prepare,
  1925. .cleanup = alc880_capture_pcm_cleanup
  1926. },
  1927. };
  1928. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1929. .substreams = 1,
  1930. .channels_min = 2,
  1931. .channels_max = 2,
  1932. /* NID is set in alc_build_pcms */
  1933. .ops = {
  1934. .open = alc880_dig_playback_pcm_open,
  1935. .close = alc880_dig_playback_pcm_close,
  1936. .prepare = alc880_dig_playback_pcm_prepare
  1937. },
  1938. };
  1939. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1940. .substreams = 1,
  1941. .channels_min = 2,
  1942. .channels_max = 2,
  1943. /* NID is set in alc_build_pcms */
  1944. };
  1945. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1946. static struct hda_pcm_stream alc_pcm_null_playback = {
  1947. .substreams = 0,
  1948. .channels_min = 0,
  1949. .channels_max = 0,
  1950. };
  1951. static int alc_build_pcms(struct hda_codec *codec)
  1952. {
  1953. struct alc_spec *spec = codec->spec;
  1954. struct hda_pcm *info = spec->pcm_rec;
  1955. int i;
  1956. codec->num_pcms = 1;
  1957. codec->pcm_info = info;
  1958. info->name = spec->stream_name_analog;
  1959. if (spec->stream_analog_playback) {
  1960. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1961. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1962. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1963. }
  1964. if (spec->stream_analog_capture) {
  1965. snd_assert(spec->adc_nids, return -EINVAL);
  1966. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1967. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1968. }
  1969. if (spec->channel_mode) {
  1970. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1971. for (i = 0; i < spec->num_channel_mode; i++) {
  1972. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1974. }
  1975. }
  1976. }
  1977. /* SPDIF for stream index #1 */
  1978. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1979. codec->num_pcms = 2;
  1980. info = spec->pcm_rec + 1;
  1981. info->name = spec->stream_name_digital;
  1982. if (spec->multiout.dig_out_nid &&
  1983. spec->stream_digital_playback) {
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1986. }
  1987. if (spec->dig_in_nid &&
  1988. spec->stream_digital_capture) {
  1989. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1991. }
  1992. }
  1993. /* If the use of more than one ADC is requested for the current
  1994. * model, configure a second analog capture-only PCM.
  1995. */
  1996. /* Additional Analaog capture for index #2 */
  1997. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1998. spec->adc_nids) {
  1999. codec->num_pcms = 3;
  2000. info = spec->pcm_rec + 2;
  2001. info->name = spec->stream_name_analog;
  2002. /* No playback stream for second PCM */
  2003. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2004. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2005. if (spec->stream_analog_capture) {
  2006. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2007. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2008. }
  2009. }
  2010. return 0;
  2011. }
  2012. static void alc_free(struct hda_codec *codec)
  2013. {
  2014. struct alc_spec *spec = codec->spec;
  2015. unsigned int i;
  2016. if (!spec)
  2017. return;
  2018. if (spec->kctl_alloc) {
  2019. for (i = 0; i < spec->num_kctl_used; i++)
  2020. kfree(spec->kctl_alloc[i].name);
  2021. kfree(spec->kctl_alloc);
  2022. }
  2023. kfree(spec);
  2024. }
  2025. /*
  2026. */
  2027. static struct hda_codec_ops alc_patch_ops = {
  2028. .build_controls = alc_build_controls,
  2029. .build_pcms = alc_build_pcms,
  2030. .init = alc_init,
  2031. .free = alc_free,
  2032. .unsol_event = alc_unsol_event,
  2033. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2034. .check_power_status = alc_check_power_status,
  2035. #endif
  2036. };
  2037. /*
  2038. * Test configuration for debugging
  2039. *
  2040. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2041. * enum controls.
  2042. */
  2043. #ifdef CONFIG_SND_DEBUG
  2044. static hda_nid_t alc880_test_dac_nids[4] = {
  2045. 0x02, 0x03, 0x04, 0x05
  2046. };
  2047. static struct hda_input_mux alc880_test_capture_source = {
  2048. .num_items = 7,
  2049. .items = {
  2050. { "In-1", 0x0 },
  2051. { "In-2", 0x1 },
  2052. { "In-3", 0x2 },
  2053. { "In-4", 0x3 },
  2054. { "CD", 0x4 },
  2055. { "Front", 0x5 },
  2056. { "Surround", 0x6 },
  2057. },
  2058. };
  2059. static struct hda_channel_mode alc880_test_modes[4] = {
  2060. { 2, NULL },
  2061. { 4, NULL },
  2062. { 6, NULL },
  2063. { 8, NULL },
  2064. };
  2065. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2066. struct snd_ctl_elem_info *uinfo)
  2067. {
  2068. static char *texts[] = {
  2069. "N/A", "Line Out", "HP Out",
  2070. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2071. };
  2072. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2073. uinfo->count = 1;
  2074. uinfo->value.enumerated.items = 8;
  2075. if (uinfo->value.enumerated.item >= 8)
  2076. uinfo->value.enumerated.item = 7;
  2077. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2078. return 0;
  2079. }
  2080. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2081. struct snd_ctl_elem_value *ucontrol)
  2082. {
  2083. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2084. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2085. unsigned int pin_ctl, item = 0;
  2086. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2087. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2088. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2089. if (pin_ctl & AC_PINCTL_HP_EN)
  2090. item = 2;
  2091. else
  2092. item = 1;
  2093. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2094. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2095. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2096. case AC_PINCTL_VREF_50: item = 4; break;
  2097. case AC_PINCTL_VREF_GRD: item = 5; break;
  2098. case AC_PINCTL_VREF_80: item = 6; break;
  2099. case AC_PINCTL_VREF_100: item = 7; break;
  2100. }
  2101. }
  2102. ucontrol->value.enumerated.item[0] = item;
  2103. return 0;
  2104. }
  2105. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2106. struct snd_ctl_elem_value *ucontrol)
  2107. {
  2108. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2109. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2110. static unsigned int ctls[] = {
  2111. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2117. };
  2118. unsigned int old_ctl, new_ctl;
  2119. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2120. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2121. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2122. if (old_ctl != new_ctl) {
  2123. int val;
  2124. snd_hda_codec_write_cache(codec, nid, 0,
  2125. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2126. new_ctl);
  2127. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2128. HDA_AMP_MUTE : 0;
  2129. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2130. HDA_AMP_MUTE, val);
  2131. return 1;
  2132. }
  2133. return 0;
  2134. }
  2135. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2136. struct snd_ctl_elem_info *uinfo)
  2137. {
  2138. static char *texts[] = {
  2139. "Front", "Surround", "CLFE", "Side"
  2140. };
  2141. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2142. uinfo->count = 1;
  2143. uinfo->value.enumerated.items = 4;
  2144. if (uinfo->value.enumerated.item >= 4)
  2145. uinfo->value.enumerated.item = 3;
  2146. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2147. return 0;
  2148. }
  2149. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2150. struct snd_ctl_elem_value *ucontrol)
  2151. {
  2152. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2153. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2154. unsigned int sel;
  2155. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2156. ucontrol->value.enumerated.item[0] = sel & 3;
  2157. return 0;
  2158. }
  2159. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2160. struct snd_ctl_elem_value *ucontrol)
  2161. {
  2162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2163. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2164. unsigned int sel;
  2165. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2166. if (ucontrol->value.enumerated.item[0] != sel) {
  2167. sel = ucontrol->value.enumerated.item[0] & 3;
  2168. snd_hda_codec_write_cache(codec, nid, 0,
  2169. AC_VERB_SET_CONNECT_SEL, sel);
  2170. return 1;
  2171. }
  2172. return 0;
  2173. }
  2174. #define PIN_CTL_TEST(xname,nid) { \
  2175. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2176. .name = xname, \
  2177. .info = alc_test_pin_ctl_info, \
  2178. .get = alc_test_pin_ctl_get, \
  2179. .put = alc_test_pin_ctl_put, \
  2180. .private_value = nid \
  2181. }
  2182. #define PIN_SRC_TEST(xname,nid) { \
  2183. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2184. .name = xname, \
  2185. .info = alc_test_pin_src_info, \
  2186. .get = alc_test_pin_src_get, \
  2187. .put = alc_test_pin_src_put, \
  2188. .private_value = nid \
  2189. }
  2190. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2191. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2195. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2196. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2199. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2200. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2201. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2202. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2203. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2204. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2205. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2206. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2207. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2208. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2209. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2210. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2211. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2212. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2213. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2214. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2215. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2216. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2217. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2218. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2219. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2220. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2221. {
  2222. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2223. .name = "Channel Mode",
  2224. .info = alc_ch_mode_info,
  2225. .get = alc_ch_mode_get,
  2226. .put = alc_ch_mode_put,
  2227. },
  2228. { } /* end */
  2229. };
  2230. static struct hda_verb alc880_test_init_verbs[] = {
  2231. /* Unmute inputs of 0x0c - 0x0f */
  2232. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2234. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2240. /* Vol output for 0x0c-0x0f */
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. /* Set output pins 0x14-0x17 */
  2246. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. /* Unmute output pins 0x14-0x17 */
  2251. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2252. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. /* Set input pins 0x18-0x1c */
  2256. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2258. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2259. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. /* Mute input pins 0x18-0x1b */
  2262. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. /* ADC set up */
  2267. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2268. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2269. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2272. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2273. /* Analog input/passthru */
  2274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2279. { }
  2280. };
  2281. #endif
  2282. /*
  2283. */
  2284. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2285. [ALC880_3ST] = "3stack",
  2286. [ALC880_TCL_S700] = "tcl",
  2287. [ALC880_3ST_DIG] = "3stack-digout",
  2288. [ALC880_CLEVO] = "clevo",
  2289. [ALC880_5ST] = "5stack",
  2290. [ALC880_5ST_DIG] = "5stack-digout",
  2291. [ALC880_W810] = "w810",
  2292. [ALC880_Z71V] = "z71v",
  2293. [ALC880_6ST] = "6stack",
  2294. [ALC880_6ST_DIG] = "6stack-digout",
  2295. [ALC880_ASUS] = "asus",
  2296. [ALC880_ASUS_W1V] = "asus-w1v",
  2297. [ALC880_ASUS_DIG] = "asus-dig",
  2298. [ALC880_ASUS_DIG2] = "asus-dig2",
  2299. [ALC880_UNIWILL_DIG] = "uniwill",
  2300. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2301. [ALC880_FUJITSU] = "fujitsu",
  2302. [ALC880_F1734] = "F1734",
  2303. [ALC880_LG] = "lg",
  2304. [ALC880_LG_LW] = "lg-lw",
  2305. #ifdef CONFIG_SND_DEBUG
  2306. [ALC880_TEST] = "test",
  2307. #endif
  2308. [ALC880_AUTO] = "auto",
  2309. };
  2310. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2311. /* Broken BIOS configuration */
  2312. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2315. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2316. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2317. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2318. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2323. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2324. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2325. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2326. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2332. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2333. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2334. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2336. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2338. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2339. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2340. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2341. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2342. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2343. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2346. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2347. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2348. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2349. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2350. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2351. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2352. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2353. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2358. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2359. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2360. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2361. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2362. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2363. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2364. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2365. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2366. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2367. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2368. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2369. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2370. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2381. {}
  2382. };
  2383. /*
  2384. * ALC880 codec presets
  2385. */
  2386. static struct alc_config_preset alc880_presets[] = {
  2387. [ALC880_3ST] = {
  2388. .mixers = { alc880_three_stack_mixer },
  2389. .init_verbs = { alc880_volume_init_verbs,
  2390. alc880_pin_3stack_init_verbs },
  2391. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2392. .dac_nids = alc880_dac_nids,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2394. .channel_mode = alc880_threestack_modes,
  2395. .need_dac_fix = 1,
  2396. .input_mux = &alc880_capture_source,
  2397. },
  2398. [ALC880_3ST_DIG] = {
  2399. .mixers = { alc880_three_stack_mixer },
  2400. .init_verbs = { alc880_volume_init_verbs,
  2401. alc880_pin_3stack_init_verbs },
  2402. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2403. .dac_nids = alc880_dac_nids,
  2404. .dig_out_nid = ALC880_DIGOUT_NID,
  2405. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2406. .channel_mode = alc880_threestack_modes,
  2407. .need_dac_fix = 1,
  2408. .input_mux = &alc880_capture_source,
  2409. },
  2410. [ALC880_TCL_S700] = {
  2411. .mixers = { alc880_tcl_s700_mixer },
  2412. .init_verbs = { alc880_volume_init_verbs,
  2413. alc880_pin_tcl_S700_init_verbs,
  2414. alc880_gpio2_init_verbs },
  2415. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2416. .dac_nids = alc880_dac_nids,
  2417. .hp_nid = 0x03,
  2418. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2419. .channel_mode = alc880_2_jack_modes,
  2420. .input_mux = &alc880_capture_source,
  2421. },
  2422. [ALC880_5ST] = {
  2423. .mixers = { alc880_three_stack_mixer,
  2424. alc880_five_stack_mixer},
  2425. .init_verbs = { alc880_volume_init_verbs,
  2426. alc880_pin_5stack_init_verbs },
  2427. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2428. .dac_nids = alc880_dac_nids,
  2429. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2430. .channel_mode = alc880_fivestack_modes,
  2431. .input_mux = &alc880_capture_source,
  2432. },
  2433. [ALC880_5ST_DIG] = {
  2434. .mixers = { alc880_three_stack_mixer,
  2435. alc880_five_stack_mixer },
  2436. .init_verbs = { alc880_volume_init_verbs,
  2437. alc880_pin_5stack_init_verbs },
  2438. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2439. .dac_nids = alc880_dac_nids,
  2440. .dig_out_nid = ALC880_DIGOUT_NID,
  2441. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2442. .channel_mode = alc880_fivestack_modes,
  2443. .input_mux = &alc880_capture_source,
  2444. },
  2445. [ALC880_6ST] = {
  2446. .mixers = { alc880_six_stack_mixer },
  2447. .init_verbs = { alc880_volume_init_verbs,
  2448. alc880_pin_6stack_init_verbs },
  2449. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2450. .dac_nids = alc880_6st_dac_nids,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2452. .channel_mode = alc880_sixstack_modes,
  2453. .input_mux = &alc880_6stack_capture_source,
  2454. },
  2455. [ALC880_6ST_DIG] = {
  2456. .mixers = { alc880_six_stack_mixer },
  2457. .init_verbs = { alc880_volume_init_verbs,
  2458. alc880_pin_6stack_init_verbs },
  2459. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2460. .dac_nids = alc880_6st_dac_nids,
  2461. .dig_out_nid = ALC880_DIGOUT_NID,
  2462. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2463. .channel_mode = alc880_sixstack_modes,
  2464. .input_mux = &alc880_6stack_capture_source,
  2465. },
  2466. [ALC880_W810] = {
  2467. .mixers = { alc880_w810_base_mixer },
  2468. .init_verbs = { alc880_volume_init_verbs,
  2469. alc880_pin_w810_init_verbs,
  2470. alc880_gpio2_init_verbs },
  2471. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2472. .dac_nids = alc880_w810_dac_nids,
  2473. .dig_out_nid = ALC880_DIGOUT_NID,
  2474. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2475. .channel_mode = alc880_w810_modes,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_Z71V] = {
  2479. .mixers = { alc880_z71v_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_z71v_init_verbs },
  2482. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2483. .dac_nids = alc880_z71v_dac_nids,
  2484. .dig_out_nid = ALC880_DIGOUT_NID,
  2485. .hp_nid = 0x03,
  2486. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2487. .channel_mode = alc880_2_jack_modes,
  2488. .input_mux = &alc880_capture_source,
  2489. },
  2490. [ALC880_F1734] = {
  2491. .mixers = { alc880_f1734_mixer },
  2492. .init_verbs = { alc880_volume_init_verbs,
  2493. alc880_pin_f1734_init_verbs },
  2494. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2495. .dac_nids = alc880_f1734_dac_nids,
  2496. .hp_nid = 0x02,
  2497. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2498. .channel_mode = alc880_2_jack_modes,
  2499. .input_mux = &alc880_capture_source,
  2500. },
  2501. [ALC880_ASUS] = {
  2502. .mixers = { alc880_asus_mixer },
  2503. .init_verbs = { alc880_volume_init_verbs,
  2504. alc880_pin_asus_init_verbs,
  2505. alc880_gpio1_init_verbs },
  2506. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2507. .dac_nids = alc880_asus_dac_nids,
  2508. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2509. .channel_mode = alc880_asus_modes,
  2510. .need_dac_fix = 1,
  2511. .input_mux = &alc880_capture_source,
  2512. },
  2513. [ALC880_ASUS_DIG] = {
  2514. .mixers = { alc880_asus_mixer },
  2515. .init_verbs = { alc880_volume_init_verbs,
  2516. alc880_pin_asus_init_verbs,
  2517. alc880_gpio1_init_verbs },
  2518. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2519. .dac_nids = alc880_asus_dac_nids,
  2520. .dig_out_nid = ALC880_DIGOUT_NID,
  2521. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2522. .channel_mode = alc880_asus_modes,
  2523. .need_dac_fix = 1,
  2524. .input_mux = &alc880_capture_source,
  2525. },
  2526. [ALC880_ASUS_DIG2] = {
  2527. .mixers = { alc880_asus_mixer },
  2528. .init_verbs = { alc880_volume_init_verbs,
  2529. alc880_pin_asus_init_verbs,
  2530. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2531. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2532. .dac_nids = alc880_asus_dac_nids,
  2533. .dig_out_nid = ALC880_DIGOUT_NID,
  2534. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2535. .channel_mode = alc880_asus_modes,
  2536. .need_dac_fix = 1,
  2537. .input_mux = &alc880_capture_source,
  2538. },
  2539. [ALC880_ASUS_W1V] = {
  2540. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2541. .init_verbs = { alc880_volume_init_verbs,
  2542. alc880_pin_asus_init_verbs,
  2543. alc880_gpio1_init_verbs },
  2544. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2545. .dac_nids = alc880_asus_dac_nids,
  2546. .dig_out_nid = ALC880_DIGOUT_NID,
  2547. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2548. .channel_mode = alc880_asus_modes,
  2549. .need_dac_fix = 1,
  2550. .input_mux = &alc880_capture_source,
  2551. },
  2552. [ALC880_UNIWILL_DIG] = {
  2553. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2554. .init_verbs = { alc880_volume_init_verbs,
  2555. alc880_pin_asus_init_verbs },
  2556. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2557. .dac_nids = alc880_asus_dac_nids,
  2558. .dig_out_nid = ALC880_DIGOUT_NID,
  2559. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2560. .channel_mode = alc880_asus_modes,
  2561. .need_dac_fix = 1,
  2562. .input_mux = &alc880_capture_source,
  2563. },
  2564. [ALC880_UNIWILL] = {
  2565. .mixers = { alc880_uniwill_mixer },
  2566. .init_verbs = { alc880_volume_init_verbs,
  2567. alc880_uniwill_init_verbs },
  2568. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2569. .dac_nids = alc880_asus_dac_nids,
  2570. .dig_out_nid = ALC880_DIGOUT_NID,
  2571. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2572. .channel_mode = alc880_threestack_modes,
  2573. .need_dac_fix = 1,
  2574. .input_mux = &alc880_capture_source,
  2575. .unsol_event = alc880_uniwill_unsol_event,
  2576. .init_hook = alc880_uniwill_automute,
  2577. },
  2578. [ALC880_UNIWILL_P53] = {
  2579. .mixers = { alc880_uniwill_p53_mixer },
  2580. .init_verbs = { alc880_volume_init_verbs,
  2581. alc880_uniwill_p53_init_verbs },
  2582. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2583. .dac_nids = alc880_asus_dac_nids,
  2584. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2585. .channel_mode = alc880_threestack_modes,
  2586. .input_mux = &alc880_capture_source,
  2587. .unsol_event = alc880_uniwill_p53_unsol_event,
  2588. .init_hook = alc880_uniwill_p53_hp_automute,
  2589. },
  2590. [ALC880_FUJITSU] = {
  2591. .mixers = { alc880_fujitsu_mixer,
  2592. alc880_pcbeep_mixer, },
  2593. .init_verbs = { alc880_volume_init_verbs,
  2594. alc880_uniwill_p53_init_verbs,
  2595. alc880_beep_init_verbs },
  2596. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2597. .dac_nids = alc880_dac_nids,
  2598. .dig_out_nid = ALC880_DIGOUT_NID,
  2599. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2600. .channel_mode = alc880_2_jack_modes,
  2601. .input_mux = &alc880_capture_source,
  2602. .unsol_event = alc880_uniwill_p53_unsol_event,
  2603. .init_hook = alc880_uniwill_p53_hp_automute,
  2604. },
  2605. [ALC880_CLEVO] = {
  2606. .mixers = { alc880_three_stack_mixer },
  2607. .init_verbs = { alc880_volume_init_verbs,
  2608. alc880_pin_clevo_init_verbs },
  2609. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2610. .dac_nids = alc880_dac_nids,
  2611. .hp_nid = 0x03,
  2612. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2613. .channel_mode = alc880_threestack_modes,
  2614. .need_dac_fix = 1,
  2615. .input_mux = &alc880_capture_source,
  2616. },
  2617. [ALC880_LG] = {
  2618. .mixers = { alc880_lg_mixer },
  2619. .init_verbs = { alc880_volume_init_verbs,
  2620. alc880_lg_init_verbs },
  2621. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2622. .dac_nids = alc880_lg_dac_nids,
  2623. .dig_out_nid = ALC880_DIGOUT_NID,
  2624. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2625. .channel_mode = alc880_lg_ch_modes,
  2626. .need_dac_fix = 1,
  2627. .input_mux = &alc880_lg_capture_source,
  2628. .unsol_event = alc880_lg_unsol_event,
  2629. .init_hook = alc880_lg_automute,
  2630. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2631. .loopbacks = alc880_lg_loopbacks,
  2632. #endif
  2633. },
  2634. [ALC880_LG_LW] = {
  2635. .mixers = { alc880_lg_lw_mixer },
  2636. .init_verbs = { alc880_volume_init_verbs,
  2637. alc880_lg_lw_init_verbs },
  2638. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2639. .dac_nids = alc880_dac_nids,
  2640. .dig_out_nid = ALC880_DIGOUT_NID,
  2641. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2642. .channel_mode = alc880_lg_lw_modes,
  2643. .input_mux = &alc880_lg_lw_capture_source,
  2644. .unsol_event = alc880_lg_lw_unsol_event,
  2645. .init_hook = alc880_lg_lw_automute,
  2646. },
  2647. #ifdef CONFIG_SND_DEBUG
  2648. [ALC880_TEST] = {
  2649. .mixers = { alc880_test_mixer },
  2650. .init_verbs = { alc880_test_init_verbs },
  2651. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2652. .dac_nids = alc880_test_dac_nids,
  2653. .dig_out_nid = ALC880_DIGOUT_NID,
  2654. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2655. .channel_mode = alc880_test_modes,
  2656. .input_mux = &alc880_test_capture_source,
  2657. },
  2658. #endif
  2659. };
  2660. /*
  2661. * Automatic parse of I/O pins from the BIOS configuration
  2662. */
  2663. #define NUM_CONTROL_ALLOC 32
  2664. #define NUM_VERB_ALLOC 32
  2665. enum {
  2666. ALC_CTL_WIDGET_VOL,
  2667. ALC_CTL_WIDGET_MUTE,
  2668. ALC_CTL_BIND_MUTE,
  2669. };
  2670. static struct snd_kcontrol_new alc880_control_templates[] = {
  2671. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2672. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2673. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2674. };
  2675. /* add dynamic controls */
  2676. static int add_control(struct alc_spec *spec, int type, const char *name,
  2677. unsigned long val)
  2678. {
  2679. struct snd_kcontrol_new *knew;
  2680. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2681. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2682. /* array + terminator */
  2683. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2684. if (!knew)
  2685. return -ENOMEM;
  2686. if (spec->kctl_alloc) {
  2687. memcpy(knew, spec->kctl_alloc,
  2688. sizeof(*knew) * spec->num_kctl_alloc);
  2689. kfree(spec->kctl_alloc);
  2690. }
  2691. spec->kctl_alloc = knew;
  2692. spec->num_kctl_alloc = num;
  2693. }
  2694. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2695. *knew = alc880_control_templates[type];
  2696. knew->name = kstrdup(name, GFP_KERNEL);
  2697. if (!knew->name)
  2698. return -ENOMEM;
  2699. knew->private_value = val;
  2700. spec->num_kctl_used++;
  2701. return 0;
  2702. }
  2703. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2704. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2705. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2706. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2707. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2708. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2709. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2710. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2711. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2712. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2713. #define ALC880_PIN_CD_NID 0x1c
  2714. /* fill in the dac_nids table from the parsed pin configuration */
  2715. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2716. const struct auto_pin_cfg *cfg)
  2717. {
  2718. hda_nid_t nid;
  2719. int assigned[4];
  2720. int i, j;
  2721. memset(assigned, 0, sizeof(assigned));
  2722. spec->multiout.dac_nids = spec->private_dac_nids;
  2723. /* check the pins hardwired to audio widget */
  2724. for (i = 0; i < cfg->line_outs; i++) {
  2725. nid = cfg->line_out_pins[i];
  2726. if (alc880_is_fixed_pin(nid)) {
  2727. int idx = alc880_fixed_pin_idx(nid);
  2728. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2729. assigned[idx] = 1;
  2730. }
  2731. }
  2732. /* left pins can be connect to any audio widget */
  2733. for (i = 0; i < cfg->line_outs; i++) {
  2734. nid = cfg->line_out_pins[i];
  2735. if (alc880_is_fixed_pin(nid))
  2736. continue;
  2737. /* search for an empty channel */
  2738. for (j = 0; j < cfg->line_outs; j++) {
  2739. if (!assigned[j]) {
  2740. spec->multiout.dac_nids[i] =
  2741. alc880_idx_to_dac(j);
  2742. assigned[j] = 1;
  2743. break;
  2744. }
  2745. }
  2746. }
  2747. spec->multiout.num_dacs = cfg->line_outs;
  2748. return 0;
  2749. }
  2750. /* add playback controls from the parsed DAC table */
  2751. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2752. const struct auto_pin_cfg *cfg)
  2753. {
  2754. char name[32];
  2755. static const char *chname[4] = {
  2756. "Front", "Surround", NULL /*CLFE*/, "Side"
  2757. };
  2758. hda_nid_t nid;
  2759. int i, err;
  2760. for (i = 0; i < cfg->line_outs; i++) {
  2761. if (!spec->multiout.dac_nids[i])
  2762. continue;
  2763. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2764. if (i == 2) {
  2765. /* Center/LFE */
  2766. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2767. "Center Playback Volume",
  2768. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2769. HDA_OUTPUT));
  2770. if (err < 0)
  2771. return err;
  2772. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2773. "LFE Playback Volume",
  2774. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2775. HDA_OUTPUT));
  2776. if (err < 0)
  2777. return err;
  2778. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2779. "Center Playback Switch",
  2780. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2781. HDA_INPUT));
  2782. if (err < 0)
  2783. return err;
  2784. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2785. "LFE Playback Switch",
  2786. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2787. HDA_INPUT));
  2788. if (err < 0)
  2789. return err;
  2790. } else {
  2791. sprintf(name, "%s Playback Volume", chname[i]);
  2792. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2793. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2794. HDA_OUTPUT));
  2795. if (err < 0)
  2796. return err;
  2797. sprintf(name, "%s Playback Switch", chname[i]);
  2798. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2799. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2800. HDA_INPUT));
  2801. if (err < 0)
  2802. return err;
  2803. }
  2804. }
  2805. return 0;
  2806. }
  2807. /* add playback controls for speaker and HP outputs */
  2808. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2809. const char *pfx)
  2810. {
  2811. hda_nid_t nid;
  2812. int err;
  2813. char name[32];
  2814. if (!pin)
  2815. return 0;
  2816. if (alc880_is_fixed_pin(pin)) {
  2817. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2818. /* specify the DAC as the extra output */
  2819. if (!spec->multiout.hp_nid)
  2820. spec->multiout.hp_nid = nid;
  2821. else
  2822. spec->multiout.extra_out_nid[0] = nid;
  2823. /* control HP volume/switch on the output mixer amp */
  2824. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2825. sprintf(name, "%s Playback Volume", pfx);
  2826. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2827. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2828. if (err < 0)
  2829. return err;
  2830. sprintf(name, "%s Playback Switch", pfx);
  2831. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2832. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2833. if (err < 0)
  2834. return err;
  2835. } else if (alc880_is_multi_pin(pin)) {
  2836. /* set manual connection */
  2837. /* we have only a switch on HP-out PIN */
  2838. sprintf(name, "%s Playback Switch", pfx);
  2839. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2840. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2841. if (err < 0)
  2842. return err;
  2843. }
  2844. return 0;
  2845. }
  2846. /* create input playback/capture controls for the given pin */
  2847. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2848. const char *ctlname,
  2849. int idx, hda_nid_t mix_nid)
  2850. {
  2851. char name[32];
  2852. int err;
  2853. sprintf(name, "%s Playback Volume", ctlname);
  2854. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2855. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2856. if (err < 0)
  2857. return err;
  2858. sprintf(name, "%s Playback Switch", ctlname);
  2859. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2860. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2861. if (err < 0)
  2862. return err;
  2863. return 0;
  2864. }
  2865. /* create playback/capture controls for input pins */
  2866. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2867. const struct auto_pin_cfg *cfg)
  2868. {
  2869. struct hda_input_mux *imux = &spec->private_imux;
  2870. int i, err, idx;
  2871. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2872. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2873. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2874. err = new_analog_input(spec, cfg->input_pins[i],
  2875. auto_pin_cfg_labels[i],
  2876. idx, 0x0b);
  2877. if (err < 0)
  2878. return err;
  2879. imux->items[imux->num_items].label =
  2880. auto_pin_cfg_labels[i];
  2881. imux->items[imux->num_items].index =
  2882. alc880_input_pin_idx(cfg->input_pins[i]);
  2883. imux->num_items++;
  2884. }
  2885. }
  2886. return 0;
  2887. }
  2888. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2889. hda_nid_t nid, int pin_type,
  2890. int dac_idx)
  2891. {
  2892. /* set as output */
  2893. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2894. pin_type);
  2895. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2896. AMP_OUT_UNMUTE);
  2897. /* need the manual connection? */
  2898. if (alc880_is_multi_pin(nid)) {
  2899. struct alc_spec *spec = codec->spec;
  2900. int idx = alc880_multi_pin_idx(nid);
  2901. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2902. AC_VERB_SET_CONNECT_SEL,
  2903. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2904. }
  2905. }
  2906. static int get_pin_type(int line_out_type)
  2907. {
  2908. if (line_out_type == AUTO_PIN_HP_OUT)
  2909. return PIN_HP;
  2910. else
  2911. return PIN_OUT;
  2912. }
  2913. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2914. {
  2915. struct alc_spec *spec = codec->spec;
  2916. int i;
  2917. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2918. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2919. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2920. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2921. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2922. }
  2923. }
  2924. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2925. {
  2926. struct alc_spec *spec = codec->spec;
  2927. hda_nid_t pin;
  2928. pin = spec->autocfg.speaker_pins[0];
  2929. if (pin) /* connect to front */
  2930. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2931. pin = spec->autocfg.hp_pins[0];
  2932. if (pin) /* connect to front */
  2933. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2934. }
  2935. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2936. {
  2937. struct alc_spec *spec = codec->spec;
  2938. int i;
  2939. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2940. hda_nid_t nid = spec->autocfg.input_pins[i];
  2941. if (alc880_is_input_pin(nid)) {
  2942. snd_hda_codec_write(codec, nid, 0,
  2943. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2944. i <= AUTO_PIN_FRONT_MIC ?
  2945. PIN_VREF80 : PIN_IN);
  2946. if (nid != ALC880_PIN_CD_NID)
  2947. snd_hda_codec_write(codec, nid, 0,
  2948. AC_VERB_SET_AMP_GAIN_MUTE,
  2949. AMP_OUT_MUTE);
  2950. }
  2951. }
  2952. }
  2953. /* parse the BIOS configuration and set up the alc_spec */
  2954. /* return 1 if successful, 0 if the proper config is not found,
  2955. * or a negative error code
  2956. */
  2957. static int alc880_parse_auto_config(struct hda_codec *codec)
  2958. {
  2959. struct alc_spec *spec = codec->spec;
  2960. int err;
  2961. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2962. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2963. alc880_ignore);
  2964. if (err < 0)
  2965. return err;
  2966. if (!spec->autocfg.line_outs)
  2967. return 0; /* can't find valid BIOS pin config */
  2968. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2969. if (err < 0)
  2970. return err;
  2971. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2972. if (err < 0)
  2973. return err;
  2974. err = alc880_auto_create_extra_out(spec,
  2975. spec->autocfg.speaker_pins[0],
  2976. "Speaker");
  2977. if (err < 0)
  2978. return err;
  2979. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2980. "Headphone");
  2981. if (err < 0)
  2982. return err;
  2983. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2984. if (err < 0)
  2985. return err;
  2986. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2987. if (spec->autocfg.dig_out_pin)
  2988. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2989. if (spec->autocfg.dig_in_pin)
  2990. spec->dig_in_nid = ALC880_DIGIN_NID;
  2991. if (spec->kctl_alloc)
  2992. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2993. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2994. spec->num_mux_defs = 1;
  2995. spec->input_mux = &spec->private_imux;
  2996. return 1;
  2997. }
  2998. /* additional initialization for auto-configuration model */
  2999. static void alc880_auto_init(struct hda_codec *codec)
  3000. {
  3001. alc880_auto_init_multi_out(codec);
  3002. alc880_auto_init_extra_out(codec);
  3003. alc880_auto_init_analog_input(codec);
  3004. }
  3005. /*
  3006. * OK, here we have finally the patch for ALC880
  3007. */
  3008. static int patch_alc880(struct hda_codec *codec)
  3009. {
  3010. struct alc_spec *spec;
  3011. int board_config;
  3012. int err;
  3013. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3014. if (spec == NULL)
  3015. return -ENOMEM;
  3016. codec->spec = spec;
  3017. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3018. alc880_models,
  3019. alc880_cfg_tbl);
  3020. if (board_config < 0) {
  3021. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3022. "trying auto-probe from BIOS...\n");
  3023. board_config = ALC880_AUTO;
  3024. }
  3025. if (board_config == ALC880_AUTO) {
  3026. /* automatic parse from the BIOS config */
  3027. err = alc880_parse_auto_config(codec);
  3028. if (err < 0) {
  3029. alc_free(codec);
  3030. return err;
  3031. } else if (!err) {
  3032. printk(KERN_INFO
  3033. "hda_codec: Cannot set up configuration "
  3034. "from BIOS. Using 3-stack mode...\n");
  3035. board_config = ALC880_3ST;
  3036. }
  3037. }
  3038. if (board_config != ALC880_AUTO)
  3039. setup_preset(spec, &alc880_presets[board_config]);
  3040. spec->stream_name_analog = "ALC880 Analog";
  3041. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3042. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3043. spec->stream_name_digital = "ALC880 Digital";
  3044. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3045. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3046. if (!spec->adc_nids && spec->input_mux) {
  3047. /* check whether NID 0x07 is valid */
  3048. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3049. /* get type */
  3050. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3051. if (wcap != AC_WID_AUD_IN) {
  3052. spec->adc_nids = alc880_adc_nids_alt;
  3053. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3054. spec->mixers[spec->num_mixers] =
  3055. alc880_capture_alt_mixer;
  3056. spec->num_mixers++;
  3057. } else {
  3058. spec->adc_nids = alc880_adc_nids;
  3059. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3060. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3061. spec->num_mixers++;
  3062. }
  3063. }
  3064. codec->patch_ops = alc_patch_ops;
  3065. if (board_config == ALC880_AUTO)
  3066. spec->init_hook = alc880_auto_init;
  3067. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3068. if (!spec->loopback.amplist)
  3069. spec->loopback.amplist = alc880_loopbacks;
  3070. #endif
  3071. return 0;
  3072. }
  3073. /*
  3074. * ALC260 support
  3075. */
  3076. static hda_nid_t alc260_dac_nids[1] = {
  3077. /* front */
  3078. 0x02,
  3079. };
  3080. static hda_nid_t alc260_adc_nids[1] = {
  3081. /* ADC0 */
  3082. 0x04,
  3083. };
  3084. static hda_nid_t alc260_adc_nids_alt[1] = {
  3085. /* ADC1 */
  3086. 0x05,
  3087. };
  3088. static hda_nid_t alc260_hp_adc_nids[2] = {
  3089. /* ADC1, 0 */
  3090. 0x05, 0x04
  3091. };
  3092. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3093. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3094. */
  3095. static hda_nid_t alc260_dual_adc_nids[2] = {
  3096. /* ADC0, ADC1 */
  3097. 0x04, 0x05
  3098. };
  3099. #define ALC260_DIGOUT_NID 0x03
  3100. #define ALC260_DIGIN_NID 0x06
  3101. static struct hda_input_mux alc260_capture_source = {
  3102. .num_items = 4,
  3103. .items = {
  3104. { "Mic", 0x0 },
  3105. { "Front Mic", 0x1 },
  3106. { "Line", 0x2 },
  3107. { "CD", 0x4 },
  3108. },
  3109. };
  3110. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3111. * headphone jack and the internal CD lines since these are the only pins at
  3112. * which audio can appear. For flexibility, also allow the option of
  3113. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3114. * connection to the mixer output).
  3115. */
  3116. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3117. {
  3118. .num_items = 3,
  3119. .items = {
  3120. { "Mic/Line", 0x0 },
  3121. { "CD", 0x4 },
  3122. { "Headphone", 0x2 },
  3123. },
  3124. },
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic/Line", 0x0 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x2 },
  3131. { "Mixer", 0x5 },
  3132. },
  3133. },
  3134. };
  3135. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3136. * the Fujitsu S702x, but jacks are marked differently.
  3137. */
  3138. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3139. {
  3140. .num_items = 4,
  3141. .items = {
  3142. { "Mic", 0x0 },
  3143. { "Line", 0x2 },
  3144. { "CD", 0x4 },
  3145. { "Headphone", 0x5 },
  3146. },
  3147. },
  3148. {
  3149. .num_items = 5,
  3150. .items = {
  3151. { "Mic", 0x0 },
  3152. { "Line", 0x2 },
  3153. { "CD", 0x4 },
  3154. { "Headphone", 0x6 },
  3155. { "Mixer", 0x5 },
  3156. },
  3157. },
  3158. };
  3159. /*
  3160. * This is just place-holder, so there's something for alc_build_pcms to look
  3161. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3162. * element which allows changing the channel mode, so the verb list is
  3163. * never used.
  3164. */
  3165. static struct hda_channel_mode alc260_modes[1] = {
  3166. { 2, NULL },
  3167. };
  3168. /* Mixer combinations
  3169. *
  3170. * basic: base_output + input + pc_beep + capture
  3171. * HP: base_output + input + capture_alt
  3172. * HP_3013: hp_3013 + input + capture
  3173. * fujitsu: fujitsu + capture
  3174. * acer: acer + capture
  3175. */
  3176. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3177. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3183. { } /* end */
  3184. };
  3185. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3186. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3194. { } /* end */
  3195. };
  3196. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3197. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3199. { } /* end */
  3200. };
  3201. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3202. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3210. { } /* end */
  3211. };
  3212. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3213. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3214. */
  3215. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3217. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3218. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3223. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3224. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3228. { } /* end */
  3229. };
  3230. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3231. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3232. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3233. * datasheet doesn't mention this restriction. At this stage it's not clear
  3234. * whether this behaviour is intentional or is a hardware bug in chip
  3235. * revisions available in early 2006. Therefore for now allow the
  3236. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3237. * that the lack of mic bias for this NID is intentional we could change the
  3238. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3239. *
  3240. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3241. * don't appear to make the mic bias available from the "line" jack, even
  3242. * though the NID used for this jack (0x14) can supply it. The theory is
  3243. * that perhaps Acer have included blocking capacitors between the ALC260
  3244. * and the output jack. If this turns out to be the case for all such
  3245. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3246. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3247. *
  3248. * The C20x Tablet series have a mono internal speaker which is controlled
  3249. * via the chip's Mono sum widget and pin complex, so include the necessary
  3250. * controls for such models. On models without a "mono speaker" the control
  3251. * won't do anything.
  3252. */
  3253. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3254. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3255. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3256. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3258. HDA_OUTPUT),
  3259. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3260. HDA_INPUT),
  3261. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3265. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3266. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3268. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3269. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3271. { } /* end */
  3272. };
  3273. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3274. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3275. */
  3276. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3277. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3278. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3281. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3282. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3284. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3285. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3289. { } /* end */
  3290. };
  3291. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3292. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3293. */
  3294. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3295. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3296. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3299. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3303. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3304. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3305. { } /* end */
  3306. };
  3307. /* capture mixer elements */
  3308. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3309. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3313. {
  3314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3315. /* The multiple "Capture Source" controls confuse alsamixer
  3316. * So call somewhat different..
  3317. * FIXME: the controls appear in the "playback" view!
  3318. */
  3319. /* .name = "Capture Source", */
  3320. .name = "Input Source",
  3321. .count = 2,
  3322. .info = alc_mux_enum_info,
  3323. .get = alc_mux_enum_get,
  3324. .put = alc_mux_enum_put,
  3325. },
  3326. { } /* end */
  3327. };
  3328. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3329. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3331. {
  3332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3333. /* The multiple "Capture Source" controls confuse alsamixer
  3334. * So call somewhat different..
  3335. * FIXME: the controls appear in the "playback" view!
  3336. */
  3337. /* .name = "Capture Source", */
  3338. .name = "Input Source",
  3339. .count = 1,
  3340. .info = alc_mux_enum_info,
  3341. .get = alc_mux_enum_get,
  3342. .put = alc_mux_enum_put,
  3343. },
  3344. { } /* end */
  3345. };
  3346. /*
  3347. * initialization verbs
  3348. */
  3349. static struct hda_verb alc260_init_verbs[] = {
  3350. /* Line In pin widget for input */
  3351. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* CD pin widget for input */
  3353. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* LINE-2 is used for line-out in rear */
  3359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3360. /* select line-out */
  3361. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3362. /* LINE-OUT pin */
  3363. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3364. /* enable HP */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3366. /* enable Mono */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3368. /* mute capture amp left and right */
  3369. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3370. /* set connection select to line in (default select for this ADC) */
  3371. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3372. /* mute capture amp left and right */
  3373. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* set vol=0 Line-Out mixer amp left and right */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. /* unmute pin widget amp left and right (no gain on this amp) */
  3379. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3380. /* set vol=0 HP mixer amp left and right */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3382. /* unmute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* set vol=0 Mono mixer amp left and right */
  3385. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3386. /* unmute pin widget amp left and right (no gain on this amp) */
  3387. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* unmute LINE-2 out pin */
  3389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* mute analog inputs */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* mute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. /* mute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3409. { }
  3410. };
  3411. #if 0 /* should be identical with alc260_init_verbs? */
  3412. static struct hda_verb alc260_hp_init_verbs[] = {
  3413. /* Headphone and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Line-2 pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* mute analog inputs */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. #endif
  3461. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3462. /* Line out and output */
  3463. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* mono output */
  3465. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3467. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3469. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Line In pin widget for input */
  3471. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3472. /* Headphone pin widget for output */
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3474. /* CD pin widget for input */
  3475. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3476. /* unmute amp left and right */
  3477. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3478. /* set connection select to line in (default select for this ADC) */
  3479. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3480. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3482. /* mute pin widget amp left and right (no gain on this amp) */
  3483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3484. /* unmute HP mixer amp left and right (volume = 0) */
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3486. /* mute pin widget amp left and right (no gain on this amp) */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3488. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3489. * Line In 2 = 0x03
  3490. */
  3491. /* mute analog inputs */
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3497. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3498. /* Unmute Front out path */
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Headphone out path */
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. /* Unmute Mono out path */
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3507. { }
  3508. };
  3509. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3510. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3511. * audio = 0x16, internal speaker = 0x10.
  3512. */
  3513. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3514. /* Disable all GPIOs */
  3515. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3516. /* Internal speaker is connected to headphone pin */
  3517. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3518. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3520. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3521. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3522. /* Ensure all other unused pins are disabled and muted. */
  3523. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Disable digital (SPDIF) pins */
  3532. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3535. * when acting as an output.
  3536. */
  3537. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3538. /* Start with output sum widgets muted and their output gains at min */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3549. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3550. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3551. * If the pin mode is changed by the user the pin mode control will
  3552. * take care of enabling the pin's input/output buffers as needed.
  3553. * Therefore there's no need to enable the input buffer at this
  3554. * stage.
  3555. */
  3556. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3557. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3558. * mixer ctrl)
  3559. */
  3560. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* Mute capture amp left and right */
  3562. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. /* Set ADC connection select to match default mixer setting - line
  3564. * in (on mic1 pin)
  3565. */
  3566. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3567. /* Do the same for the second ADC: mute capture input amp and
  3568. * set ADC connection to line in (on mic1 pin)
  3569. */
  3570. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3571. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3572. /* Mute all inputs to mixer widget (even unconnected ones) */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3581. { }
  3582. };
  3583. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3584. * similar laptops (adapted from Fujitsu init verbs).
  3585. */
  3586. static struct hda_verb alc260_acer_init_verbs[] = {
  3587. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3588. * the headphone jack. Turn this on and rely on the standard mute
  3589. * methods whenever the user wants to turn these outputs off.
  3590. */
  3591. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3594. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3595. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3597. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3598. /* Line In jack is connected to Line1 pin */
  3599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3600. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3601. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3602. /* Ensure all other unused pins are disabled and muted. */
  3603. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. /* Disable digital (SPDIF) pins */
  3610. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3613. * bus when acting as outputs.
  3614. */
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3617. /* Start with output sum widgets muted and their output gains at min */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3627. /* Unmute Line-out pin widget amp left and right
  3628. * (no equiv mixer ctrl)
  3629. */
  3630. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3632. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3634. * inputs. If the pin mode is changed by the user the pin mode control
  3635. * will take care of enabling the pin's input/output buffers as needed.
  3636. * Therefore there's no need to enable the input buffer at this
  3637. * stage.
  3638. */
  3639. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. /* Mute capture amp left and right */
  3642. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3643. /* Set ADC connection select to match default mixer setting - mic
  3644. * (on mic1 pin)
  3645. */
  3646. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3647. /* Do similar with the second ADC: mute capture input amp and
  3648. * set ADC connection to mic to match ALSA's default state.
  3649. */
  3650. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3651. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. /* Mute all inputs to mixer widget (even unconnected ones) */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3661. { }
  3662. };
  3663. static struct hda_verb alc260_will_verbs[] = {
  3664. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3665. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3670. {}
  3671. };
  3672. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3673. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3674. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3675. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3676. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3679. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3680. {}
  3681. };
  3682. /* toggle speaker-output according to the hp-jack state */
  3683. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3684. {
  3685. unsigned int present;
  3686. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3687. present = snd_hda_codec_read(codec, 0x0f, 0,
  3688. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3689. if (present) {
  3690. snd_hda_codec_write_cache(codec, 0x01, 0,
  3691. AC_VERB_SET_GPIO_DATA, 1);
  3692. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3693. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3694. PIN_HP);
  3695. } else {
  3696. snd_hda_codec_write_cache(codec, 0x01, 0,
  3697. AC_VERB_SET_GPIO_DATA, 0);
  3698. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3699. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3700. PIN_OUT);
  3701. }
  3702. }
  3703. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3704. unsigned int res)
  3705. {
  3706. if ((res >> 26) == ALC880_HP_EVENT)
  3707. alc260_replacer_672v_automute(codec);
  3708. }
  3709. /* Test configuration for debugging, modelled after the ALC880 test
  3710. * configuration.
  3711. */
  3712. #ifdef CONFIG_SND_DEBUG
  3713. static hda_nid_t alc260_test_dac_nids[1] = {
  3714. 0x02,
  3715. };
  3716. static hda_nid_t alc260_test_adc_nids[2] = {
  3717. 0x04, 0x05,
  3718. };
  3719. /* For testing the ALC260, each input MUX needs its own definition since
  3720. * the signal assignments are different. This assumes that the first ADC
  3721. * is NID 0x04.
  3722. */
  3723. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3724. {
  3725. .num_items = 7,
  3726. .items = {
  3727. { "MIC1 pin", 0x0 },
  3728. { "MIC2 pin", 0x1 },
  3729. { "LINE1 pin", 0x2 },
  3730. { "LINE2 pin", 0x3 },
  3731. { "CD pin", 0x4 },
  3732. { "LINE-OUT pin", 0x5 },
  3733. { "HP-OUT pin", 0x6 },
  3734. },
  3735. },
  3736. {
  3737. .num_items = 8,
  3738. .items = {
  3739. { "MIC1 pin", 0x0 },
  3740. { "MIC2 pin", 0x1 },
  3741. { "LINE1 pin", 0x2 },
  3742. { "LINE2 pin", 0x3 },
  3743. { "CD pin", 0x4 },
  3744. { "Mixer", 0x5 },
  3745. { "LINE-OUT pin", 0x6 },
  3746. { "HP-OUT pin", 0x7 },
  3747. },
  3748. },
  3749. };
  3750. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3751. /* Output driver widgets */
  3752. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3754. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3755. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3756. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3757. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3758. /* Modes for retasking pin widgets
  3759. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3760. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3761. * mention this restriction. At this stage it's not clear whether
  3762. * this behaviour is intentional or is a hardware bug in chip
  3763. * revisions available at least up until early 2006. Therefore for
  3764. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3765. * choices, but if it turns out that the lack of mic bias for these
  3766. * NIDs is intentional we could change their modes from
  3767. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3768. */
  3769. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3775. /* Loopback mixer controls */
  3776. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3777. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3779. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3781. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3783. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3785. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3787. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3788. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3789. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3790. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3791. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3792. /* Controls for GPIO pins, assuming they are configured as outputs */
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3797. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3798. * is ambigious as to which NID is which; testing on laptops which
  3799. * make this output available should provide clarification.
  3800. */
  3801. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3802. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3803. { } /* end */
  3804. };
  3805. static struct hda_verb alc260_test_init_verbs[] = {
  3806. /* Enable all GPIOs as outputs with an initial value of 0 */
  3807. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3808. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3809. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3810. /* Enable retasking pins as output, initially without power amp */
  3811. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. /* Disable digital (SPDIF) pins initially, but users can enable
  3818. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3819. * payload also sets the generation to 0, output to be in "consumer"
  3820. * PCM format, copyright asserted, no pre-emphasis and no validity
  3821. * control.
  3822. */
  3823. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3824. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3825. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3826. * OUT1 sum bus when acting as an output.
  3827. */
  3828. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3829. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3830. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3832. /* Start with output sum widgets muted and their output gains at min */
  3833. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3837. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3839. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3840. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3842. /* Unmute retasking pin widget output buffers since the default
  3843. * state appears to be output. As the pin mode is changed by the
  3844. * user the pin mode control will take care of enabling the pin's
  3845. * input/output buffers as needed.
  3846. */
  3847. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. /* Also unmute the mono-out pin widget */
  3854. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3855. /* Mute capture amp left and right */
  3856. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3857. /* Set ADC connection select to match default mixer setting (mic1
  3858. * pin)
  3859. */
  3860. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3861. /* Do the same for the second ADC: mute capture input amp and
  3862. * set ADC connection to mic1 pin
  3863. */
  3864. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3865. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3866. /* Mute all inputs to mixer widget (even unconnected ones) */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3875. { }
  3876. };
  3877. #endif
  3878. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3879. .substreams = 1,
  3880. .channels_min = 2,
  3881. .channels_max = 2,
  3882. };
  3883. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3884. .substreams = 1,
  3885. .channels_min = 2,
  3886. .channels_max = 2,
  3887. };
  3888. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3889. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3890. /*
  3891. * for BIOS auto-configuration
  3892. */
  3893. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3894. const char *pfx)
  3895. {
  3896. hda_nid_t nid_vol;
  3897. unsigned long vol_val, sw_val;
  3898. char name[32];
  3899. int err;
  3900. if (nid >= 0x0f && nid < 0x11) {
  3901. nid_vol = nid - 0x7;
  3902. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3903. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3904. } else if (nid == 0x11) {
  3905. nid_vol = nid - 0x7;
  3906. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3907. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3908. } else if (nid >= 0x12 && nid <= 0x15) {
  3909. nid_vol = 0x08;
  3910. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3911. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3912. } else
  3913. return 0; /* N/A */
  3914. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3915. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3916. if (err < 0)
  3917. return err;
  3918. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3919. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3920. if (err < 0)
  3921. return err;
  3922. return 1;
  3923. }
  3924. /* add playback controls from the parsed DAC table */
  3925. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3926. const struct auto_pin_cfg *cfg)
  3927. {
  3928. hda_nid_t nid;
  3929. int err;
  3930. spec->multiout.num_dacs = 1;
  3931. spec->multiout.dac_nids = spec->private_dac_nids;
  3932. spec->multiout.dac_nids[0] = 0x02;
  3933. nid = cfg->line_out_pins[0];
  3934. if (nid) {
  3935. err = alc260_add_playback_controls(spec, nid, "Front");
  3936. if (err < 0)
  3937. return err;
  3938. }
  3939. nid = cfg->speaker_pins[0];
  3940. if (nid) {
  3941. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3942. if (err < 0)
  3943. return err;
  3944. }
  3945. nid = cfg->hp_pins[0];
  3946. if (nid) {
  3947. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3948. if (err < 0)
  3949. return err;
  3950. }
  3951. return 0;
  3952. }
  3953. /* create playback/capture controls for input pins */
  3954. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3955. const struct auto_pin_cfg *cfg)
  3956. {
  3957. struct hda_input_mux *imux = &spec->private_imux;
  3958. int i, err, idx;
  3959. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3960. if (cfg->input_pins[i] >= 0x12) {
  3961. idx = cfg->input_pins[i] - 0x12;
  3962. err = new_analog_input(spec, cfg->input_pins[i],
  3963. auto_pin_cfg_labels[i], idx,
  3964. 0x07);
  3965. if (err < 0)
  3966. return err;
  3967. imux->items[imux->num_items].label =
  3968. auto_pin_cfg_labels[i];
  3969. imux->items[imux->num_items].index = idx;
  3970. imux->num_items++;
  3971. }
  3972. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3973. idx = cfg->input_pins[i] - 0x09;
  3974. err = new_analog_input(spec, cfg->input_pins[i],
  3975. auto_pin_cfg_labels[i], idx,
  3976. 0x07);
  3977. if (err < 0)
  3978. return err;
  3979. imux->items[imux->num_items].label =
  3980. auto_pin_cfg_labels[i];
  3981. imux->items[imux->num_items].index = idx;
  3982. imux->num_items++;
  3983. }
  3984. }
  3985. return 0;
  3986. }
  3987. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3988. hda_nid_t nid, int pin_type,
  3989. int sel_idx)
  3990. {
  3991. /* set as output */
  3992. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3993. pin_type);
  3994. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3995. AMP_OUT_UNMUTE);
  3996. /* need the manual connection? */
  3997. if (nid >= 0x12) {
  3998. int idx = nid - 0x12;
  3999. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4000. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4001. }
  4002. }
  4003. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4004. {
  4005. struct alc_spec *spec = codec->spec;
  4006. hda_nid_t nid;
  4007. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4008. nid = spec->autocfg.line_out_pins[0];
  4009. if (nid) {
  4010. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4011. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4012. }
  4013. nid = spec->autocfg.speaker_pins[0];
  4014. if (nid)
  4015. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4016. nid = spec->autocfg.hp_pins[0];
  4017. if (nid)
  4018. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4019. }
  4020. #define ALC260_PIN_CD_NID 0x16
  4021. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4022. {
  4023. struct alc_spec *spec = codec->spec;
  4024. int i;
  4025. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4026. hda_nid_t nid = spec->autocfg.input_pins[i];
  4027. if (nid >= 0x12) {
  4028. snd_hda_codec_write(codec, nid, 0,
  4029. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4030. i <= AUTO_PIN_FRONT_MIC ?
  4031. PIN_VREF80 : PIN_IN);
  4032. if (nid != ALC260_PIN_CD_NID)
  4033. snd_hda_codec_write(codec, nid, 0,
  4034. AC_VERB_SET_AMP_GAIN_MUTE,
  4035. AMP_OUT_MUTE);
  4036. }
  4037. }
  4038. }
  4039. /*
  4040. * generic initialization of ADC, input mixers and output mixers
  4041. */
  4042. static struct hda_verb alc260_volume_init_verbs[] = {
  4043. /*
  4044. * Unmute ADC0-1 and set the default input to mic-in
  4045. */
  4046. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4047. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4048. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4049. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4050. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4051. * mixer widget
  4052. * Note: PASD motherboards uses the Line In 2 as the input for
  4053. * front panel mic (mic 2)
  4054. */
  4055. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4056. /* mute analog inputs */
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4062. /*
  4063. * Set up output mixers (0x08 - 0x0a)
  4064. */
  4065. /* set vol=0 to output mixers */
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4068. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. /* set up input amps for analog loopback */
  4070. /* Amp Indices: DAC = 0, mixer = 1 */
  4071. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4072. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4073. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4074. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4075. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4076. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4077. { }
  4078. };
  4079. static int alc260_parse_auto_config(struct hda_codec *codec)
  4080. {
  4081. struct alc_spec *spec = codec->spec;
  4082. unsigned int wcap;
  4083. int err;
  4084. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4085. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4086. alc260_ignore);
  4087. if (err < 0)
  4088. return err;
  4089. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4090. if (err < 0)
  4091. return err;
  4092. if (!spec->kctl_alloc)
  4093. return 0; /* can't find valid BIOS pin config */
  4094. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4095. if (err < 0)
  4096. return err;
  4097. spec->multiout.max_channels = 2;
  4098. if (spec->autocfg.dig_out_pin)
  4099. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4100. if (spec->kctl_alloc)
  4101. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4102. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4103. spec->num_mux_defs = 1;
  4104. spec->input_mux = &spec->private_imux;
  4105. /* check whether NID 0x04 is valid */
  4106. wcap = get_wcaps(codec, 0x04);
  4107. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4108. if (wcap != AC_WID_AUD_IN) {
  4109. spec->adc_nids = alc260_adc_nids_alt;
  4110. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4111. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4112. } else {
  4113. spec->adc_nids = alc260_adc_nids;
  4114. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4115. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4116. }
  4117. spec->num_mixers++;
  4118. return 1;
  4119. }
  4120. /* additional initialization for auto-configuration model */
  4121. static void alc260_auto_init(struct hda_codec *codec)
  4122. {
  4123. alc260_auto_init_multi_out(codec);
  4124. alc260_auto_init_analog_input(codec);
  4125. }
  4126. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4127. static struct hda_amp_list alc260_loopbacks[] = {
  4128. { 0x07, HDA_INPUT, 0 },
  4129. { 0x07, HDA_INPUT, 1 },
  4130. { 0x07, HDA_INPUT, 2 },
  4131. { 0x07, HDA_INPUT, 3 },
  4132. { 0x07, HDA_INPUT, 4 },
  4133. { } /* end */
  4134. };
  4135. #endif
  4136. /*
  4137. * ALC260 configurations
  4138. */
  4139. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4140. [ALC260_BASIC] = "basic",
  4141. [ALC260_HP] = "hp",
  4142. [ALC260_HP_3013] = "hp-3013",
  4143. [ALC260_FUJITSU_S702X] = "fujitsu",
  4144. [ALC260_ACER] = "acer",
  4145. [ALC260_WILL] = "will",
  4146. [ALC260_REPLACER_672V] = "replacer",
  4147. #ifdef CONFIG_SND_DEBUG
  4148. [ALC260_TEST] = "test",
  4149. #endif
  4150. [ALC260_AUTO] = "auto",
  4151. };
  4152. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4153. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4154. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4155. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4156. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4159. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4160. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4161. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4162. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4163. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4165. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4168. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4169. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4170. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4171. {}
  4172. };
  4173. static struct alc_config_preset alc260_presets[] = {
  4174. [ALC260_BASIC] = {
  4175. .mixers = { alc260_base_output_mixer,
  4176. alc260_input_mixer,
  4177. alc260_pc_beep_mixer,
  4178. alc260_capture_mixer },
  4179. .init_verbs = { alc260_init_verbs },
  4180. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4181. .dac_nids = alc260_dac_nids,
  4182. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4183. .adc_nids = alc260_adc_nids,
  4184. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4185. .channel_mode = alc260_modes,
  4186. .input_mux = &alc260_capture_source,
  4187. },
  4188. [ALC260_HP] = {
  4189. .mixers = { alc260_base_output_mixer,
  4190. alc260_input_mixer,
  4191. alc260_capture_alt_mixer },
  4192. .init_verbs = { alc260_init_verbs },
  4193. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4194. .dac_nids = alc260_dac_nids,
  4195. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4196. .adc_nids = alc260_hp_adc_nids,
  4197. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4198. .channel_mode = alc260_modes,
  4199. .input_mux = &alc260_capture_source,
  4200. },
  4201. [ALC260_HP_3013] = {
  4202. .mixers = { alc260_hp_3013_mixer,
  4203. alc260_input_mixer,
  4204. alc260_capture_alt_mixer },
  4205. .init_verbs = { alc260_hp_3013_init_verbs },
  4206. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4207. .dac_nids = alc260_dac_nids,
  4208. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4209. .adc_nids = alc260_hp_adc_nids,
  4210. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4211. .channel_mode = alc260_modes,
  4212. .input_mux = &alc260_capture_source,
  4213. },
  4214. [ALC260_FUJITSU_S702X] = {
  4215. .mixers = { alc260_fujitsu_mixer,
  4216. alc260_capture_mixer },
  4217. .init_verbs = { alc260_fujitsu_init_verbs },
  4218. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4219. .dac_nids = alc260_dac_nids,
  4220. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4221. .adc_nids = alc260_dual_adc_nids,
  4222. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4223. .channel_mode = alc260_modes,
  4224. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4225. .input_mux = alc260_fujitsu_capture_sources,
  4226. },
  4227. [ALC260_ACER] = {
  4228. .mixers = { alc260_acer_mixer,
  4229. alc260_capture_mixer },
  4230. .init_verbs = { alc260_acer_init_verbs },
  4231. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4232. .dac_nids = alc260_dac_nids,
  4233. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4234. .adc_nids = alc260_dual_adc_nids,
  4235. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4236. .channel_mode = alc260_modes,
  4237. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4238. .input_mux = alc260_acer_capture_sources,
  4239. },
  4240. [ALC260_WILL] = {
  4241. .mixers = { alc260_will_mixer,
  4242. alc260_capture_mixer },
  4243. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4244. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4245. .dac_nids = alc260_dac_nids,
  4246. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4247. .adc_nids = alc260_adc_nids,
  4248. .dig_out_nid = ALC260_DIGOUT_NID,
  4249. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4250. .channel_mode = alc260_modes,
  4251. .input_mux = &alc260_capture_source,
  4252. },
  4253. [ALC260_REPLACER_672V] = {
  4254. .mixers = { alc260_replacer_672v_mixer,
  4255. alc260_capture_mixer },
  4256. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4257. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4258. .dac_nids = alc260_dac_nids,
  4259. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4260. .adc_nids = alc260_adc_nids,
  4261. .dig_out_nid = ALC260_DIGOUT_NID,
  4262. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4263. .channel_mode = alc260_modes,
  4264. .input_mux = &alc260_capture_source,
  4265. .unsol_event = alc260_replacer_672v_unsol_event,
  4266. .init_hook = alc260_replacer_672v_automute,
  4267. },
  4268. #ifdef CONFIG_SND_DEBUG
  4269. [ALC260_TEST] = {
  4270. .mixers = { alc260_test_mixer,
  4271. alc260_capture_mixer },
  4272. .init_verbs = { alc260_test_init_verbs },
  4273. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4274. .dac_nids = alc260_test_dac_nids,
  4275. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4276. .adc_nids = alc260_test_adc_nids,
  4277. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4278. .channel_mode = alc260_modes,
  4279. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4280. .input_mux = alc260_test_capture_sources,
  4281. },
  4282. #endif
  4283. };
  4284. static int patch_alc260(struct hda_codec *codec)
  4285. {
  4286. struct alc_spec *spec;
  4287. int err, board_config;
  4288. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4289. if (spec == NULL)
  4290. return -ENOMEM;
  4291. codec->spec = spec;
  4292. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4293. alc260_models,
  4294. alc260_cfg_tbl);
  4295. if (board_config < 0) {
  4296. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4297. "trying auto-probe from BIOS...\n");
  4298. board_config = ALC260_AUTO;
  4299. }
  4300. if (board_config == ALC260_AUTO) {
  4301. /* automatic parse from the BIOS config */
  4302. err = alc260_parse_auto_config(codec);
  4303. if (err < 0) {
  4304. alc_free(codec);
  4305. return err;
  4306. } else if (!err) {
  4307. printk(KERN_INFO
  4308. "hda_codec: Cannot set up configuration "
  4309. "from BIOS. Using base mode...\n");
  4310. board_config = ALC260_BASIC;
  4311. }
  4312. }
  4313. if (board_config != ALC260_AUTO)
  4314. setup_preset(spec, &alc260_presets[board_config]);
  4315. spec->stream_name_analog = "ALC260 Analog";
  4316. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4317. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4318. spec->stream_name_digital = "ALC260 Digital";
  4319. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4320. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4321. codec->patch_ops = alc_patch_ops;
  4322. if (board_config == ALC260_AUTO)
  4323. spec->init_hook = alc260_auto_init;
  4324. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4325. if (!spec->loopback.amplist)
  4326. spec->loopback.amplist = alc260_loopbacks;
  4327. #endif
  4328. return 0;
  4329. }
  4330. /*
  4331. * ALC882 support
  4332. *
  4333. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4334. * configuration. Each pin widget can choose any input DACs and a mixer.
  4335. * Each ADC is connected from a mixer of all inputs. This makes possible
  4336. * 6-channel independent captures.
  4337. *
  4338. * In addition, an independent DAC for the multi-playback (not used in this
  4339. * driver yet).
  4340. */
  4341. #define ALC882_DIGOUT_NID 0x06
  4342. #define ALC882_DIGIN_NID 0x0a
  4343. static struct hda_channel_mode alc882_ch_modes[1] = {
  4344. { 8, NULL }
  4345. };
  4346. static hda_nid_t alc882_dac_nids[4] = {
  4347. /* front, rear, clfe, rear_surr */
  4348. 0x02, 0x03, 0x04, 0x05
  4349. };
  4350. /* identical with ALC880 */
  4351. #define alc882_adc_nids alc880_adc_nids
  4352. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4353. /* input MUX */
  4354. /* FIXME: should be a matrix-type input source selection */
  4355. static struct hda_input_mux alc882_capture_source = {
  4356. .num_items = 4,
  4357. .items = {
  4358. { "Mic", 0x0 },
  4359. { "Front Mic", 0x1 },
  4360. { "Line", 0x2 },
  4361. { "CD", 0x4 },
  4362. },
  4363. };
  4364. #define alc882_mux_enum_info alc_mux_enum_info
  4365. #define alc882_mux_enum_get alc_mux_enum_get
  4366. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4367. struct snd_ctl_elem_value *ucontrol)
  4368. {
  4369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4370. struct alc_spec *spec = codec->spec;
  4371. const struct hda_input_mux *imux = spec->input_mux;
  4372. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4373. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4374. hda_nid_t nid = capture_mixers[adc_idx];
  4375. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4376. unsigned int i, idx;
  4377. idx = ucontrol->value.enumerated.item[0];
  4378. if (idx >= imux->num_items)
  4379. idx = imux->num_items - 1;
  4380. if (*cur_val == idx)
  4381. return 0;
  4382. for (i = 0; i < imux->num_items; i++) {
  4383. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4384. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4385. imux->items[i].index,
  4386. HDA_AMP_MUTE, v);
  4387. }
  4388. *cur_val = idx;
  4389. return 1;
  4390. }
  4391. /*
  4392. * 2ch mode
  4393. */
  4394. static struct hda_verb alc882_3ST_ch2_init[] = {
  4395. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4396. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4397. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4398. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4399. { } /* end */
  4400. };
  4401. /*
  4402. * 6ch mode
  4403. */
  4404. static struct hda_verb alc882_3ST_ch6_init[] = {
  4405. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4406. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4407. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4408. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4409. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4410. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4411. { } /* end */
  4412. };
  4413. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4414. { 2, alc882_3ST_ch2_init },
  4415. { 6, alc882_3ST_ch6_init },
  4416. };
  4417. /*
  4418. * 6ch mode
  4419. */
  4420. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4421. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4422. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4423. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4424. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { } /* end */
  4426. };
  4427. /*
  4428. * 8ch mode
  4429. */
  4430. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4431. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4432. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { } /* end */
  4436. };
  4437. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4438. { 6, alc882_sixstack_ch6_init },
  4439. { 8, alc882_sixstack_ch8_init },
  4440. };
  4441. /*
  4442. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4443. */
  4444. /*
  4445. * 2ch mode
  4446. */
  4447. static struct hda_verb alc885_mbp_ch2_init[] = {
  4448. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4449. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4450. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4451. { } /* end */
  4452. };
  4453. /*
  4454. * 6ch mode
  4455. */
  4456. static struct hda_verb alc885_mbp_ch6_init[] = {
  4457. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4458. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4459. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4460. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4461. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4462. { } /* end */
  4463. };
  4464. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4465. { 2, alc885_mbp_ch2_init },
  4466. { 6, alc885_mbp_ch6_init },
  4467. };
  4468. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4469. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4470. */
  4471. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4472. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4473. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4475. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4476. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4477. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4478. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4479. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4480. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4481. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4482. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4484. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4485. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4486. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4493. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4494. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4495. { } /* end */
  4496. };
  4497. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4498. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4499. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4500. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4501. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4502. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4503. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4505. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4506. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4508. { } /* end */
  4509. };
  4510. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4511. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4512. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4513. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4514. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4515. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4516. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4517. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4519. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4520. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4521. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4522. { } /* end */
  4523. };
  4524. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4525. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4526. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4527. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4528. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4529. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4530. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4531. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4532. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4533. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4534. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4535. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4536. { } /* end */
  4537. };
  4538. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4539. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4540. */
  4541. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4542. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4545. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4546. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4547. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4548. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4549. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4550. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4552. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4553. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4554. { } /* end */
  4555. };
  4556. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4557. {
  4558. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4559. .name = "Channel Mode",
  4560. .info = alc_ch_mode_info,
  4561. .get = alc_ch_mode_get,
  4562. .put = alc_ch_mode_put,
  4563. },
  4564. { } /* end */
  4565. };
  4566. static struct hda_verb alc882_init_verbs[] = {
  4567. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4569. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4570. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4571. /* Rear mixer */
  4572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4573. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4574. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4575. /* CLFE mixer */
  4576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4577. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4578. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4579. /* Side mixer */
  4580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4581. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4582. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4583. /* Front Pin: output 0 (0x0c) */
  4584. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4585. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4586. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4587. /* Rear Pin: output 1 (0x0d) */
  4588. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4589. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4590. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4591. /* CLFE Pin: output 2 (0x0e) */
  4592. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4593. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4594. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4595. /* Side Pin: output 3 (0x0f) */
  4596. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4597. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4598. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4599. /* Mic (rear) pin: input vref at 80% */
  4600. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4601. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4602. /* Front Mic pin: input vref at 80% */
  4603. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4604. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4605. /* Line In pin: input */
  4606. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4607. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4608. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4609. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4610. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4611. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4612. /* CD pin widget for input */
  4613. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4614. /* FIXME: use matrix-type input source selection */
  4615. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4616. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4617. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4618. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4619. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4620. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4621. /* Input mixer2 */
  4622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4623. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4624. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4625. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4626. /* Input mixer3 */
  4627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4629. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4630. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4631. /* ADC1: mute amp left and right */
  4632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4633. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4634. /* ADC2: mute amp left and right */
  4635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4636. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4637. /* ADC3: mute amp left and right */
  4638. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4639. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4640. { }
  4641. };
  4642. static struct hda_verb alc882_eapd_verbs[] = {
  4643. /* change to EAPD mode */
  4644. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4645. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4646. { }
  4647. };
  4648. /* Mac Pro test */
  4649. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4650. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4651. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4652. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4656. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4657. { } /* end */
  4658. };
  4659. static struct hda_verb alc882_macpro_init_verbs[] = {
  4660. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4661. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4662. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4663. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4664. /* Front Pin: output 0 (0x0c) */
  4665. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4666. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4667. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4668. /* Front Mic pin: input vref at 80% */
  4669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4671. /* Speaker: output */
  4672. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4673. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4674. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4675. /* Headphone output (output 0 - 0x0c) */
  4676. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4677. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4678. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4679. /* FIXME: use matrix-type input source selection */
  4680. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4681. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4682. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4684. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4685. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4686. /* Input mixer2 */
  4687. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4688. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4689. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4690. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4691. /* Input mixer3 */
  4692. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4693. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4694. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4695. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4696. /* ADC1: mute amp left and right */
  4697. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4698. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4699. /* ADC2: mute amp left and right */
  4700. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4701. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4702. /* ADC3: mute amp left and right */
  4703. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4704. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4705. { }
  4706. };
  4707. /* Macbook Pro rev3 */
  4708. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4709. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4712. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4713. /* Rear mixer */
  4714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4715. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4716. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4717. /* Front Pin: output 0 (0x0c) */
  4718. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4719. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4720. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4721. /* HP Pin: output 0 (0x0d) */
  4722. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4723. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4724. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4725. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4726. /* Mic (rear) pin: input vref at 80% */
  4727. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4728. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4729. /* Front Mic pin: input vref at 80% */
  4730. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4731. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4732. /* Line In pin: use output 1 when in LineOut mode */
  4733. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4734. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4735. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4736. /* FIXME: use matrix-type input source selection */
  4737. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4738. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4741. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4742. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4743. /* Input mixer2 */
  4744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4748. /* Input mixer3 */
  4749. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4751. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4753. /* ADC1: mute amp left and right */
  4754. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4755. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4756. /* ADC2: mute amp left and right */
  4757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4758. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4759. /* ADC3: mute amp left and right */
  4760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4761. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4762. { }
  4763. };
  4764. /* iMac 24 mixer. */
  4765. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4766. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4767. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4768. { } /* end */
  4769. };
  4770. /* iMac 24 init verbs. */
  4771. static struct hda_verb alc885_imac24_init_verbs[] = {
  4772. /* Internal speakers: output 0 (0x0c) */
  4773. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4774. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4775. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4776. /* Internal speakers: output 0 (0x0c) */
  4777. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4778. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4779. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4780. /* Headphone: output 0 (0x0c) */
  4781. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4782. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4783. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4784. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4785. /* Front Mic: input vref at 80% */
  4786. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4787. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4788. { }
  4789. };
  4790. /* Toggle speaker-output according to the hp-jack state */
  4791. static void alc885_imac24_automute(struct hda_codec *codec)
  4792. {
  4793. unsigned int present;
  4794. present = snd_hda_codec_read(codec, 0x14, 0,
  4795. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4796. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4797. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4798. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4799. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4800. }
  4801. /* Processes unsolicited events. */
  4802. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4803. unsigned int res)
  4804. {
  4805. /* Headphone insertion or removal. */
  4806. if ((res >> 26) == ALC880_HP_EVENT)
  4807. alc885_imac24_automute(codec);
  4808. }
  4809. static void alc885_mbp3_automute(struct hda_codec *codec)
  4810. {
  4811. unsigned int present;
  4812. present = snd_hda_codec_read(codec, 0x15, 0,
  4813. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4814. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4815. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4816. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4817. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4818. }
  4819. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4820. unsigned int res)
  4821. {
  4822. /* Headphone insertion or removal. */
  4823. if ((res >> 26) == ALC880_HP_EVENT)
  4824. alc885_mbp3_automute(codec);
  4825. }
  4826. static struct hda_verb alc882_targa_verbs[] = {
  4827. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4828. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4829. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4830. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4831. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4832. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4833. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4834. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4835. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4836. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4837. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4838. { } /* end */
  4839. };
  4840. /* toggle speaker-output according to the hp-jack state */
  4841. static void alc882_targa_automute(struct hda_codec *codec)
  4842. {
  4843. unsigned int present;
  4844. present = snd_hda_codec_read(codec, 0x14, 0,
  4845. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4846. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4847. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4848. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4849. present ? 1 : 3);
  4850. }
  4851. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4852. {
  4853. /* Looks like the unsol event is incompatible with the standard
  4854. * definition. 4bit tag is placed at 26 bit!
  4855. */
  4856. if (((res >> 26) == ALC880_HP_EVENT)) {
  4857. alc882_targa_automute(codec);
  4858. }
  4859. }
  4860. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4863. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4864. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4866. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4867. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4868. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4869. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4870. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4871. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4872. { } /* end */
  4873. };
  4874. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4875. {
  4876. unsigned int gpiostate, gpiomask, gpiodir;
  4877. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4878. AC_VERB_GET_GPIO_DATA, 0);
  4879. if (!muted)
  4880. gpiostate |= (1 << pin);
  4881. else
  4882. gpiostate &= ~(1 << pin);
  4883. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4884. AC_VERB_GET_GPIO_MASK, 0);
  4885. gpiomask |= (1 << pin);
  4886. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4887. AC_VERB_GET_GPIO_DIRECTION, 0);
  4888. gpiodir |= (1 << pin);
  4889. snd_hda_codec_write(codec, codec->afg, 0,
  4890. AC_VERB_SET_GPIO_MASK, gpiomask);
  4891. snd_hda_codec_write(codec, codec->afg, 0,
  4892. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4893. msleep(1);
  4894. snd_hda_codec_write(codec, codec->afg, 0,
  4895. AC_VERB_SET_GPIO_DATA, gpiostate);
  4896. }
  4897. /* set up GPIO at initialization */
  4898. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4899. {
  4900. alc882_gpio_mute(codec, 0, 0);
  4901. alc882_gpio_mute(codec, 1, 0);
  4902. }
  4903. /* set up GPIO and update auto-muting at initialization */
  4904. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4905. {
  4906. alc885_macpro_init_hook(codec);
  4907. alc885_imac24_automute(codec);
  4908. }
  4909. /*
  4910. * generic initialization of ADC, input mixers and output mixers
  4911. */
  4912. static struct hda_verb alc882_auto_init_verbs[] = {
  4913. /*
  4914. * Unmute ADC0-2 and set the default input to mic-in
  4915. */
  4916. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4918. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4920. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4921. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4922. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4923. * mixer widget
  4924. * Note: PASD motherboards uses the Line In 2 as the input for
  4925. * front panel mic (mic 2)
  4926. */
  4927. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4928. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4929. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4933. /*
  4934. * Set up output mixers (0x0c - 0x0f)
  4935. */
  4936. /* set vol=0 to output mixers */
  4937. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4938. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4939. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4940. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4941. /* set up input amps for analog loopback */
  4942. /* Amp Indices: DAC = 0, mixer = 1 */
  4943. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4944. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4945. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4946. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4947. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4948. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4949. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4950. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4951. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4952. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4953. /* FIXME: use matrix-type input source selection */
  4954. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4955. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4956. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4957. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4958. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4959. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4960. /* Input mixer2 */
  4961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4962. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4963. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4964. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4965. /* Input mixer3 */
  4966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4967. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4968. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4969. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4970. { }
  4971. };
  4972. /* capture mixer elements */
  4973. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4974. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4975. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4976. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4977. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4978. {
  4979. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4980. /* The multiple "Capture Source" controls confuse alsamixer
  4981. * So call somewhat different..
  4982. * FIXME: the controls appear in the "playback" view!
  4983. */
  4984. /* .name = "Capture Source", */
  4985. .name = "Input Source",
  4986. .count = 2,
  4987. .info = alc882_mux_enum_info,
  4988. .get = alc882_mux_enum_get,
  4989. .put = alc882_mux_enum_put,
  4990. },
  4991. { } /* end */
  4992. };
  4993. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4994. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4995. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4996. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4997. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4998. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4999. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5000. {
  5001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5002. /* The multiple "Capture Source" controls confuse alsamixer
  5003. * So call somewhat different..
  5004. * FIXME: the controls appear in the "playback" view!
  5005. */
  5006. /* .name = "Capture Source", */
  5007. .name = "Input Source",
  5008. .count = 3,
  5009. .info = alc882_mux_enum_info,
  5010. .get = alc882_mux_enum_get,
  5011. .put = alc882_mux_enum_put,
  5012. },
  5013. { } /* end */
  5014. };
  5015. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5016. #define alc882_loopbacks alc880_loopbacks
  5017. #endif
  5018. /* pcm configuration: identiacal with ALC880 */
  5019. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5020. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5021. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5022. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5023. /*
  5024. * configuration and preset
  5025. */
  5026. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5027. [ALC882_3ST_DIG] = "3stack-dig",
  5028. [ALC882_6ST_DIG] = "6stack-dig",
  5029. [ALC882_ARIMA] = "arima",
  5030. [ALC882_W2JC] = "w2jc",
  5031. [ALC885_MACPRO] = "macpro",
  5032. [ALC885_MBP3] = "mbp3",
  5033. [ALC885_IMAC24] = "imac24",
  5034. [ALC882_AUTO] = "auto",
  5035. };
  5036. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5037. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5038. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5039. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5040. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5041. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5042. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5043. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5044. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5045. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5046. {}
  5047. };
  5048. static struct alc_config_preset alc882_presets[] = {
  5049. [ALC882_3ST_DIG] = {
  5050. .mixers = { alc882_base_mixer },
  5051. .init_verbs = { alc882_init_verbs },
  5052. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5053. .dac_nids = alc882_dac_nids,
  5054. .dig_out_nid = ALC882_DIGOUT_NID,
  5055. .dig_in_nid = ALC882_DIGIN_NID,
  5056. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5057. .channel_mode = alc882_ch_modes,
  5058. .need_dac_fix = 1,
  5059. .input_mux = &alc882_capture_source,
  5060. },
  5061. [ALC882_6ST_DIG] = {
  5062. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5063. .init_verbs = { alc882_init_verbs },
  5064. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5065. .dac_nids = alc882_dac_nids,
  5066. .dig_out_nid = ALC882_DIGOUT_NID,
  5067. .dig_in_nid = ALC882_DIGIN_NID,
  5068. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5069. .channel_mode = alc882_sixstack_modes,
  5070. .input_mux = &alc882_capture_source,
  5071. },
  5072. [ALC882_ARIMA] = {
  5073. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5074. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5075. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5076. .dac_nids = alc882_dac_nids,
  5077. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5078. .channel_mode = alc882_sixstack_modes,
  5079. .input_mux = &alc882_capture_source,
  5080. },
  5081. [ALC882_W2JC] = {
  5082. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5083. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5084. alc880_gpio1_init_verbs },
  5085. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5086. .dac_nids = alc882_dac_nids,
  5087. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5088. .channel_mode = alc880_threestack_modes,
  5089. .need_dac_fix = 1,
  5090. .input_mux = &alc882_capture_source,
  5091. .dig_out_nid = ALC882_DIGOUT_NID,
  5092. },
  5093. [ALC885_MBP3] = {
  5094. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5095. .init_verbs = { alc885_mbp3_init_verbs,
  5096. alc880_gpio1_init_verbs },
  5097. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5098. .dac_nids = alc882_dac_nids,
  5099. .channel_mode = alc885_mbp_6ch_modes,
  5100. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5101. .input_mux = &alc882_capture_source,
  5102. .dig_out_nid = ALC882_DIGOUT_NID,
  5103. .dig_in_nid = ALC882_DIGIN_NID,
  5104. .unsol_event = alc885_mbp3_unsol_event,
  5105. .init_hook = alc885_mbp3_automute,
  5106. },
  5107. [ALC885_MACPRO] = {
  5108. .mixers = { alc882_macpro_mixer },
  5109. .init_verbs = { alc882_macpro_init_verbs },
  5110. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5111. .dac_nids = alc882_dac_nids,
  5112. .dig_out_nid = ALC882_DIGOUT_NID,
  5113. .dig_in_nid = ALC882_DIGIN_NID,
  5114. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5115. .channel_mode = alc882_ch_modes,
  5116. .input_mux = &alc882_capture_source,
  5117. .init_hook = alc885_macpro_init_hook,
  5118. },
  5119. [ALC885_IMAC24] = {
  5120. .mixers = { alc885_imac24_mixer },
  5121. .init_verbs = { alc885_imac24_init_verbs },
  5122. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5123. .dac_nids = alc882_dac_nids,
  5124. .dig_out_nid = ALC882_DIGOUT_NID,
  5125. .dig_in_nid = ALC882_DIGIN_NID,
  5126. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5127. .channel_mode = alc882_ch_modes,
  5128. .input_mux = &alc882_capture_source,
  5129. .unsol_event = alc885_imac24_unsol_event,
  5130. .init_hook = alc885_imac24_init_hook,
  5131. },
  5132. [ALC882_TARGA] = {
  5133. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5134. alc882_capture_mixer },
  5135. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5136. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5137. .dac_nids = alc882_dac_nids,
  5138. .dig_out_nid = ALC882_DIGOUT_NID,
  5139. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5140. .adc_nids = alc882_adc_nids,
  5141. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5142. .channel_mode = alc882_3ST_6ch_modes,
  5143. .need_dac_fix = 1,
  5144. .input_mux = &alc882_capture_source,
  5145. .unsol_event = alc882_targa_unsol_event,
  5146. .init_hook = alc882_targa_automute,
  5147. },
  5148. [ALC882_ASUS_A7J] = {
  5149. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5150. alc882_capture_mixer },
  5151. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5152. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5153. .dac_nids = alc882_dac_nids,
  5154. .dig_out_nid = ALC882_DIGOUT_NID,
  5155. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5156. .adc_nids = alc882_adc_nids,
  5157. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5158. .channel_mode = alc882_3ST_6ch_modes,
  5159. .need_dac_fix = 1,
  5160. .input_mux = &alc882_capture_source,
  5161. },
  5162. };
  5163. /*
  5164. * Pin config fixes
  5165. */
  5166. enum {
  5167. PINFIX_ABIT_AW9D_MAX
  5168. };
  5169. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5170. { 0x15, 0x01080104 }, /* side */
  5171. { 0x16, 0x01011012 }, /* rear */
  5172. { 0x17, 0x01016011 }, /* clfe */
  5173. { }
  5174. };
  5175. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5176. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5177. };
  5178. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5179. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5180. {}
  5181. };
  5182. /*
  5183. * BIOS auto configuration
  5184. */
  5185. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5186. hda_nid_t nid, int pin_type,
  5187. int dac_idx)
  5188. {
  5189. /* set as output */
  5190. struct alc_spec *spec = codec->spec;
  5191. int idx;
  5192. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5193. idx = 4;
  5194. else
  5195. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5196. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5197. pin_type);
  5198. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5199. AMP_OUT_UNMUTE);
  5200. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5201. }
  5202. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5203. {
  5204. struct alc_spec *spec = codec->spec;
  5205. int i;
  5206. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5207. for (i = 0; i <= HDA_SIDE; i++) {
  5208. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5209. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5210. if (nid)
  5211. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5212. i);
  5213. }
  5214. }
  5215. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5216. {
  5217. struct alc_spec *spec = codec->spec;
  5218. hda_nid_t pin;
  5219. pin = spec->autocfg.hp_pins[0];
  5220. if (pin) /* connect to front */
  5221. /* use dac 0 */
  5222. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5223. }
  5224. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5225. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5226. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5227. {
  5228. struct alc_spec *spec = codec->spec;
  5229. int i;
  5230. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5231. hda_nid_t nid = spec->autocfg.input_pins[i];
  5232. if (alc882_is_input_pin(nid)) {
  5233. snd_hda_codec_write(codec, nid, 0,
  5234. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5235. i <= AUTO_PIN_FRONT_MIC ?
  5236. PIN_VREF80 : PIN_IN);
  5237. if (nid != ALC882_PIN_CD_NID)
  5238. snd_hda_codec_write(codec, nid, 0,
  5239. AC_VERB_SET_AMP_GAIN_MUTE,
  5240. AMP_OUT_MUTE);
  5241. }
  5242. }
  5243. }
  5244. /* add mic boosts if needed */
  5245. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5246. {
  5247. struct alc_spec *spec = codec->spec;
  5248. int err;
  5249. hda_nid_t nid;
  5250. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5251. if (nid) {
  5252. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5253. "Mic Boost",
  5254. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5255. if (err < 0)
  5256. return err;
  5257. }
  5258. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5259. if (nid) {
  5260. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5261. "Front Mic Boost",
  5262. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5263. if (err < 0)
  5264. return err;
  5265. }
  5266. return 0;
  5267. }
  5268. /* almost identical with ALC880 parser... */
  5269. static int alc882_parse_auto_config(struct hda_codec *codec)
  5270. {
  5271. struct alc_spec *spec = codec->spec;
  5272. int err = alc880_parse_auto_config(codec);
  5273. if (err < 0)
  5274. return err;
  5275. else if (!err)
  5276. return 0; /* no config found */
  5277. err = alc_auto_add_mic_boost(codec);
  5278. if (err < 0)
  5279. return err;
  5280. /* hack - override the init verbs */
  5281. spec->init_verbs[0] = alc882_auto_init_verbs;
  5282. return 1; /* config found */
  5283. }
  5284. /* additional initialization for auto-configuration model */
  5285. static void alc882_auto_init(struct hda_codec *codec)
  5286. {
  5287. alc882_auto_init_multi_out(codec);
  5288. alc882_auto_init_hp_out(codec);
  5289. alc882_auto_init_analog_input(codec);
  5290. }
  5291. static int patch_alc882(struct hda_codec *codec)
  5292. {
  5293. struct alc_spec *spec;
  5294. int err, board_config;
  5295. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5296. if (spec == NULL)
  5297. return -ENOMEM;
  5298. codec->spec = spec;
  5299. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5300. alc882_models,
  5301. alc882_cfg_tbl);
  5302. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5303. /* Pick up systems that don't supply PCI SSID */
  5304. switch (codec->subsystem_id) {
  5305. case 0x106b0c00: /* Mac Pro */
  5306. board_config = ALC885_MACPRO;
  5307. break;
  5308. case 0x106b1000: /* iMac 24 */
  5309. board_config = ALC885_IMAC24;
  5310. break;
  5311. case 0x106b2c00: /* Macbook Pro rev3 */
  5312. board_config = ALC885_MBP3;
  5313. break;
  5314. default:
  5315. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5316. "trying auto-probe from BIOS...\n");
  5317. board_config = ALC882_AUTO;
  5318. }
  5319. }
  5320. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5321. if (board_config == ALC882_AUTO) {
  5322. /* automatic parse from the BIOS config */
  5323. err = alc882_parse_auto_config(codec);
  5324. if (err < 0) {
  5325. alc_free(codec);
  5326. return err;
  5327. } else if (!err) {
  5328. printk(KERN_INFO
  5329. "hda_codec: Cannot set up configuration "
  5330. "from BIOS. Using base mode...\n");
  5331. board_config = ALC882_3ST_DIG;
  5332. }
  5333. }
  5334. if (board_config != ALC882_AUTO)
  5335. setup_preset(spec, &alc882_presets[board_config]);
  5336. spec->stream_name_analog = "ALC882 Analog";
  5337. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5338. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5339. spec->stream_name_digital = "ALC882 Digital";
  5340. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5341. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5342. if (!spec->adc_nids && spec->input_mux) {
  5343. /* check whether NID 0x07 is valid */
  5344. unsigned int wcap = get_wcaps(codec, 0x07);
  5345. /* get type */
  5346. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5347. if (wcap != AC_WID_AUD_IN) {
  5348. spec->adc_nids = alc882_adc_nids_alt;
  5349. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5350. spec->mixers[spec->num_mixers] =
  5351. alc882_capture_alt_mixer;
  5352. spec->num_mixers++;
  5353. } else {
  5354. spec->adc_nids = alc882_adc_nids;
  5355. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5356. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5357. spec->num_mixers++;
  5358. }
  5359. }
  5360. codec->patch_ops = alc_patch_ops;
  5361. if (board_config == ALC882_AUTO)
  5362. spec->init_hook = alc882_auto_init;
  5363. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5364. if (!spec->loopback.amplist)
  5365. spec->loopback.amplist = alc882_loopbacks;
  5366. #endif
  5367. return 0;
  5368. }
  5369. /*
  5370. * ALC883 support
  5371. *
  5372. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5373. * configuration. Each pin widget can choose any input DACs and a mixer.
  5374. * Each ADC is connected from a mixer of all inputs. This makes possible
  5375. * 6-channel independent captures.
  5376. *
  5377. * In addition, an independent DAC for the multi-playback (not used in this
  5378. * driver yet).
  5379. */
  5380. #define ALC883_DIGOUT_NID 0x06
  5381. #define ALC883_DIGIN_NID 0x0a
  5382. static hda_nid_t alc883_dac_nids[4] = {
  5383. /* front, rear, clfe, rear_surr */
  5384. 0x02, 0x04, 0x03, 0x05
  5385. };
  5386. static hda_nid_t alc883_adc_nids[2] = {
  5387. /* ADC1-2 */
  5388. 0x08, 0x09,
  5389. };
  5390. /* input MUX */
  5391. /* FIXME: should be a matrix-type input source selection */
  5392. static struct hda_input_mux alc883_capture_source = {
  5393. .num_items = 4,
  5394. .items = {
  5395. { "Mic", 0x0 },
  5396. { "Front Mic", 0x1 },
  5397. { "Line", 0x2 },
  5398. { "CD", 0x4 },
  5399. },
  5400. };
  5401. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5402. .num_items = 2,
  5403. .items = {
  5404. { "Mic", 0x1 },
  5405. { "Line", 0x2 },
  5406. },
  5407. };
  5408. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5409. .num_items = 4,
  5410. .items = {
  5411. { "Mic", 0x0 },
  5412. { "iMic", 0x1 },
  5413. { "Line", 0x2 },
  5414. { "CD", 0x4 },
  5415. },
  5416. };
  5417. #define alc883_mux_enum_info alc_mux_enum_info
  5418. #define alc883_mux_enum_get alc_mux_enum_get
  5419. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5420. struct snd_ctl_elem_value *ucontrol)
  5421. {
  5422. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5423. struct alc_spec *spec = codec->spec;
  5424. const struct hda_input_mux *imux = spec->input_mux;
  5425. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5426. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5427. hda_nid_t nid = capture_mixers[adc_idx];
  5428. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5429. unsigned int i, idx;
  5430. idx = ucontrol->value.enumerated.item[0];
  5431. if (idx >= imux->num_items)
  5432. idx = imux->num_items - 1;
  5433. if (*cur_val == idx)
  5434. return 0;
  5435. for (i = 0; i < imux->num_items; i++) {
  5436. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5437. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5438. imux->items[i].index,
  5439. HDA_AMP_MUTE, v);
  5440. }
  5441. *cur_val = idx;
  5442. return 1;
  5443. }
  5444. /*
  5445. * 2ch mode
  5446. */
  5447. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5448. { 2, NULL }
  5449. };
  5450. /*
  5451. * 2ch mode
  5452. */
  5453. static struct hda_verb alc883_3ST_ch2_init[] = {
  5454. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5455. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5456. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5457. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5458. { } /* end */
  5459. };
  5460. /*
  5461. * 6ch mode
  5462. */
  5463. static struct hda_verb alc883_3ST_ch6_init[] = {
  5464. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5465. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5466. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5467. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5468. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5469. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5470. { } /* end */
  5471. };
  5472. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5473. { 2, alc883_3ST_ch2_init },
  5474. { 6, alc883_3ST_ch6_init },
  5475. };
  5476. /*
  5477. * 6ch mode
  5478. */
  5479. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5480. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5481. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5482. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5483. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5484. { } /* end */
  5485. };
  5486. /*
  5487. * 8ch mode
  5488. */
  5489. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5490. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5491. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5492. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5493. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5494. { } /* end */
  5495. };
  5496. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5497. { 6, alc883_sixstack_ch6_init },
  5498. { 8, alc883_sixstack_ch8_init },
  5499. };
  5500. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5501. /* eanable EAPD on medion laptop */
  5502. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5503. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5504. { }
  5505. };
  5506. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5507. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5508. */
  5509. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5510. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5511. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5512. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5513. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5514. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5515. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5516. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5517. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5518. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5519. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5520. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5521. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5522. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5524. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5525. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5527. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5531. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5532. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5533. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5534. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5535. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5536. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5537. {
  5538. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5539. /* .name = "Capture Source", */
  5540. .name = "Input Source",
  5541. .count = 2,
  5542. .info = alc883_mux_enum_info,
  5543. .get = alc883_mux_enum_get,
  5544. .put = alc883_mux_enum_put,
  5545. },
  5546. { } /* end */
  5547. };
  5548. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5549. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5550. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5551. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5552. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5553. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5554. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5555. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5556. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5557. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5558. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5559. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5560. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5561. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5562. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5563. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5564. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5565. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5566. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5567. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5568. {
  5569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5570. /* .name = "Capture Source", */
  5571. .name = "Input Source",
  5572. .count = 2,
  5573. .info = alc883_mux_enum_info,
  5574. .get = alc883_mux_enum_get,
  5575. .put = alc883_mux_enum_put,
  5576. },
  5577. { } /* end */
  5578. };
  5579. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5580. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5581. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5582. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5583. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5584. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5585. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5586. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5587. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5588. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5589. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5590. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5592. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5594. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5595. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5596. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5598. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5599. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5600. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5601. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5602. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5603. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5604. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5605. {
  5606. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5607. /* .name = "Capture Source", */
  5608. .name = "Input Source",
  5609. .count = 2,
  5610. .info = alc883_mux_enum_info,
  5611. .get = alc883_mux_enum_get,
  5612. .put = alc883_mux_enum_put,
  5613. },
  5614. { } /* end */
  5615. };
  5616. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5617. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5618. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5619. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5620. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5621. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5622. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5623. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5624. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5625. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5626. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5627. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5628. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5629. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5630. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5631. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5632. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5634. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5635. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5636. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5637. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5638. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5639. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5640. {
  5641. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5642. /* .name = "Capture Source", */
  5643. .name = "Input Source",
  5644. .count = 1,
  5645. .info = alc883_mux_enum_info,
  5646. .get = alc883_mux_enum_get,
  5647. .put = alc883_mux_enum_put,
  5648. },
  5649. { } /* end */
  5650. };
  5651. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5652. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5653. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5654. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5655. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5656. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5657. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5658. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5659. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5660. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5662. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5664. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5665. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5666. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5667. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5668. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5669. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5670. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5671. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5672. {
  5673. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5674. /* .name = "Capture Source", */
  5675. .name = "Input Source",
  5676. .count = 2,
  5677. .info = alc883_mux_enum_info,
  5678. .get = alc883_mux_enum_get,
  5679. .put = alc883_mux_enum_put,
  5680. },
  5681. { } /* end */
  5682. };
  5683. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5684. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5686. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5687. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5688. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5689. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5690. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5691. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5692. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5693. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5694. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5695. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5696. {
  5697. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5698. /* .name = "Capture Source", */
  5699. .name = "Input Source",
  5700. .count = 2,
  5701. .info = alc883_mux_enum_info,
  5702. .get = alc883_mux_enum_get,
  5703. .put = alc883_mux_enum_put,
  5704. },
  5705. { } /* end */
  5706. };
  5707. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5708. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5709. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5710. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5711. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5712. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5713. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5714. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5715. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5716. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5717. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5718. {
  5719. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5720. /* .name = "Capture Source", */
  5721. .name = "Input Source",
  5722. .count = 1,
  5723. .info = alc883_mux_enum_info,
  5724. .get = alc883_mux_enum_get,
  5725. .put = alc883_mux_enum_put,
  5726. },
  5727. { } /* end */
  5728. };
  5729. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5730. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5731. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5732. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5733. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5734. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5735. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5736. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5737. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5738. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5739. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5740. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5741. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5742. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5743. {
  5744. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5745. /* .name = "Capture Source", */
  5746. .name = "Input Source",
  5747. .count = 2,
  5748. .info = alc883_mux_enum_info,
  5749. .get = alc883_mux_enum_get,
  5750. .put = alc883_mux_enum_put,
  5751. },
  5752. { } /* end */
  5753. };
  5754. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5755. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5757. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5758. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5759. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5761. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5762. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5763. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5764. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5765. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5766. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5767. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5768. {
  5769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5770. /* .name = "Capture Source", */
  5771. .name = "Input Source",
  5772. .count = 2,
  5773. .info = alc883_mux_enum_info,
  5774. .get = alc883_mux_enum_get,
  5775. .put = alc883_mux_enum_put,
  5776. },
  5777. { } /* end */
  5778. };
  5779. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5780. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5781. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5782. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5783. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5784. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5785. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5786. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5787. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5788. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5789. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5790. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5791. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5792. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5796. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5797. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5800. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5802. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, 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 alc888_3st_hp_mixer[] = {
  5819. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5820. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5821. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5822. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5823. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5825. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5826. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5827. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5828. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5829. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5830. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5831. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5834. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5836. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5837. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5838. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5839. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5840. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5841. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5842. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5843. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5844. {
  5845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5846. /* .name = "Capture Source", */
  5847. .name = "Input Source",
  5848. .count = 2,
  5849. .info = alc883_mux_enum_info,
  5850. .get = alc883_mux_enum_get,
  5851. .put = alc883_mux_enum_put,
  5852. },
  5853. { } /* end */
  5854. };
  5855. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5856. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5857. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5858. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5859. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5860. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5861. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5863. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5864. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5865. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5866. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5867. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5868. {
  5869. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5870. /* .name = "Capture Source", */
  5871. .name = "Input Source",
  5872. .count = 2,
  5873. .info = alc883_mux_enum_info,
  5874. .get = alc883_mux_enum_get,
  5875. .put = alc883_mux_enum_put,
  5876. },
  5877. { } /* end */
  5878. };
  5879. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5880. {
  5881. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5882. .name = "Channel Mode",
  5883. .info = alc_ch_mode_info,
  5884. .get = alc_ch_mode_get,
  5885. .put = alc_ch_mode_put,
  5886. },
  5887. { } /* end */
  5888. };
  5889. static struct hda_verb alc883_init_verbs[] = {
  5890. /* ADC1: mute amp left and right */
  5891. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5892. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5893. /* ADC2: mute amp left and right */
  5894. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5895. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5896. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5897. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5898. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5899. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5900. /* Rear mixer */
  5901. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5902. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5903. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5904. /* CLFE mixer */
  5905. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5906. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5907. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5908. /* Side mixer */
  5909. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5910. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5911. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5912. /* mute analog input loopbacks */
  5913. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5914. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5916. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5918. /* Front Pin: output 0 (0x0c) */
  5919. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5920. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5921. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5922. /* Rear Pin: output 1 (0x0d) */
  5923. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5924. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5925. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5926. /* CLFE Pin: output 2 (0x0e) */
  5927. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5928. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5929. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5930. /* Side Pin: output 3 (0x0f) */
  5931. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5932. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5933. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5934. /* Mic (rear) pin: input vref at 80% */
  5935. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5936. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5937. /* Front Mic pin: input vref at 80% */
  5938. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5939. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5940. /* Line In pin: input */
  5941. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5942. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5943. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5944. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5945. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5946. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5947. /* CD pin widget for input */
  5948. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5949. /* FIXME: use matrix-type input source selection */
  5950. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5951. /* Input mixer2 */
  5952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5954. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5955. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5956. /* Input mixer3 */
  5957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5960. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5961. { }
  5962. };
  5963. static struct hda_verb alc883_tagra_verbs[] = {
  5964. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5965. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5966. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5967. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5968. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5969. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5970. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5971. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5972. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5973. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5974. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5975. { } /* end */
  5976. };
  5977. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5978. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5979. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5980. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5981. { } /* end */
  5982. };
  5983. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5984. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5985. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5986. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5987. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5988. { } /* end */
  5989. };
  5990. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5991. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5992. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5993. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5994. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5995. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5996. { } /* end */
  5997. };
  5998. static struct hda_verb alc883_haier_w66_verbs[] = {
  5999. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6000. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6001. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6002. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6003. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6004. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6005. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6006. { } /* end */
  6007. };
  6008. static struct hda_verb alc888_6st_hp_verbs[] = {
  6009. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6010. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6011. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6012. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6013. { }
  6014. };
  6015. static struct hda_verb alc888_3st_hp_verbs[] = {
  6016. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6017. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6018. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6019. { }
  6020. };
  6021. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6022. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6023. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6024. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6025. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6026. { }
  6027. };
  6028. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6029. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6030. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6031. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6032. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6033. { }
  6034. };
  6035. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6036. { 2, alc888_3st_hp_2ch_init },
  6037. { 6, alc888_3st_hp_6ch_init },
  6038. };
  6039. /* toggle front-jack and RCA according to the hp-jack state */
  6040. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6041. {
  6042. unsigned int present;
  6043. present = snd_hda_codec_read(codec, 0x1b, 0,
  6044. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6045. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6046. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6047. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6048. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6049. }
  6050. /* toggle RCA according to the front-jack state */
  6051. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6052. {
  6053. unsigned int present;
  6054. present = snd_hda_codec_read(codec, 0x14, 0,
  6055. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6056. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6057. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6058. }
  6059. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6060. unsigned int res)
  6061. {
  6062. if ((res >> 26) == ALC880_HP_EVENT)
  6063. alc888_lenovo_ms7195_front_automute(codec);
  6064. if ((res >> 26) == ALC880_FRONT_EVENT)
  6065. alc888_lenovo_ms7195_rca_automute(codec);
  6066. }
  6067. static struct hda_verb alc883_medion_md2_verbs[] = {
  6068. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6069. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6071. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6072. { } /* end */
  6073. };
  6074. /* toggle speaker-output according to the hp-jack state */
  6075. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6076. {
  6077. unsigned int present;
  6078. present = snd_hda_codec_read(codec, 0x14, 0,
  6079. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6080. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6081. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6082. }
  6083. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6084. unsigned int res)
  6085. {
  6086. if ((res >> 26) == ALC880_HP_EVENT)
  6087. alc883_medion_md2_automute(codec);
  6088. }
  6089. /* toggle speaker-output according to the hp-jack state */
  6090. static void alc883_tagra_automute(struct hda_codec *codec)
  6091. {
  6092. unsigned int present;
  6093. unsigned char bits;
  6094. present = snd_hda_codec_read(codec, 0x14, 0,
  6095. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6096. bits = present ? HDA_AMP_MUTE : 0;
  6097. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6098. HDA_AMP_MUTE, bits);
  6099. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6100. present ? 1 : 3);
  6101. }
  6102. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6103. {
  6104. if ((res >> 26) == ALC880_HP_EVENT)
  6105. alc883_tagra_automute(codec);
  6106. }
  6107. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6108. {
  6109. unsigned int present;
  6110. unsigned char bits;
  6111. present = snd_hda_codec_read(codec, 0x1b, 0,
  6112. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6113. bits = present ? 0x80 : 0;
  6114. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6115. 0x80, bits);
  6116. }
  6117. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6118. unsigned int res)
  6119. {
  6120. if ((res >> 26) == ALC880_HP_EVENT)
  6121. alc883_haier_w66_automute(codec);
  6122. }
  6123. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6124. {
  6125. unsigned int present;
  6126. unsigned char bits;
  6127. present = snd_hda_codec_read(codec, 0x14, 0,
  6128. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6129. bits = present ? HDA_AMP_MUTE : 0;
  6130. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6131. HDA_AMP_MUTE, bits);
  6132. }
  6133. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6134. {
  6135. unsigned int present;
  6136. unsigned char bits;
  6137. present = snd_hda_codec_read(codec, 0x1b, 0,
  6138. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6139. bits = present ? HDA_AMP_MUTE : 0;
  6140. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6141. HDA_AMP_MUTE, bits);
  6142. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6143. HDA_AMP_MUTE, bits);
  6144. }
  6145. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6146. unsigned int res)
  6147. {
  6148. if ((res >> 26) == ALC880_HP_EVENT)
  6149. alc883_lenovo_101e_all_automute(codec);
  6150. if ((res >> 26) == ALC880_FRONT_EVENT)
  6151. alc883_lenovo_101e_ispeaker_automute(codec);
  6152. }
  6153. /* toggle speaker-output according to the hp-jack state */
  6154. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6155. {
  6156. unsigned int present;
  6157. present = snd_hda_codec_read(codec, 0x14, 0,
  6158. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6159. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6160. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6161. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6162. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6163. }
  6164. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6165. unsigned int res)
  6166. {
  6167. if ((res >> 26) == ALC880_HP_EVENT)
  6168. alc883_acer_aspire_automute(codec);
  6169. }
  6170. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6171. /* HP Pin: output 0 (0x0c) */
  6172. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6173. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6174. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6175. /* Front Pin: output 0 (0x0c) */
  6176. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6177. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6178. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6179. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6180. /* eanable EAPD on medion laptop */
  6181. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6182. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6183. /* enable unsolicited event */
  6184. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6185. { }
  6186. };
  6187. /*
  6188. * generic initialization of ADC, input mixers and output mixers
  6189. */
  6190. static struct hda_verb alc883_auto_init_verbs[] = {
  6191. /*
  6192. * Unmute ADC0-2 and set the default input to mic-in
  6193. */
  6194. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6195. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6196. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6197. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6198. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6199. * mixer widget
  6200. * Note: PASD motherboards uses the Line In 2 as the input for
  6201. * front panel mic (mic 2)
  6202. */
  6203. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6204. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6205. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6206. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6207. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6208. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6209. /*
  6210. * Set up output mixers (0x0c - 0x0f)
  6211. */
  6212. /* set vol=0 to output mixers */
  6213. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6215. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6216. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6217. /* set up input amps for analog loopback */
  6218. /* Amp Indices: DAC = 0, mixer = 1 */
  6219. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6220. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6221. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6222. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6223. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6224. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6225. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6226. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6227. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6228. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6229. /* FIXME: use matrix-type input source selection */
  6230. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6231. /* Input mixer1 */
  6232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6233. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6234. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6235. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6236. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6237. /* Input mixer2 */
  6238. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6239. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6240. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6241. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6242. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6243. { }
  6244. };
  6245. /* capture mixer elements */
  6246. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6247. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6248. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6249. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6250. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6251. {
  6252. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6253. /* The multiple "Capture Source" controls confuse alsamixer
  6254. * So call somewhat different..
  6255. * FIXME: the controls appear in the "playback" view!
  6256. */
  6257. /* .name = "Capture Source", */
  6258. .name = "Input Source",
  6259. .count = 2,
  6260. .info = alc882_mux_enum_info,
  6261. .get = alc882_mux_enum_get,
  6262. .put = alc882_mux_enum_put,
  6263. },
  6264. { } /* end */
  6265. };
  6266. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6267. #define alc883_loopbacks alc880_loopbacks
  6268. #endif
  6269. /* pcm configuration: identiacal with ALC880 */
  6270. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6271. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6272. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6273. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6274. /*
  6275. * configuration and preset
  6276. */
  6277. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6278. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6279. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6280. [ALC883_3ST_6ch] = "3stack-6ch",
  6281. [ALC883_6ST_DIG] = "6stack-dig",
  6282. [ALC883_TARGA_DIG] = "targa-dig",
  6283. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6284. [ALC883_ACER] = "acer",
  6285. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6286. [ALC883_MEDION] = "medion",
  6287. [ALC883_MEDION_MD2] = "medion-md2",
  6288. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6289. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6290. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6291. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6292. [ALC883_HAIER_W66] = "haier-w66",
  6293. [ALC888_6ST_HP] = "6stack-hp",
  6294. [ALC888_3ST_HP] = "3stack-hp",
  6295. [ALC883_AUTO] = "auto",
  6296. };
  6297. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6298. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6299. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6300. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6301. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6302. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6303. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6304. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6305. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6306. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6307. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6308. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6309. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6310. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6311. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6312. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6313. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6314. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6315. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6316. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6317. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6318. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6319. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6320. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6321. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6322. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6323. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6324. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6325. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6326. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6327. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6328. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6329. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6330. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6331. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6332. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6333. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6334. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6335. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6336. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6337. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6338. {}
  6339. };
  6340. static struct alc_config_preset alc883_presets[] = {
  6341. [ALC883_3ST_2ch_DIG] = {
  6342. .mixers = { alc883_3ST_2ch_mixer },
  6343. .init_verbs = { alc883_init_verbs },
  6344. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6345. .dac_nids = alc883_dac_nids,
  6346. .dig_out_nid = ALC883_DIGOUT_NID,
  6347. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6348. .adc_nids = alc883_adc_nids,
  6349. .dig_in_nid = ALC883_DIGIN_NID,
  6350. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6351. .channel_mode = alc883_3ST_2ch_modes,
  6352. .input_mux = &alc883_capture_source,
  6353. },
  6354. [ALC883_3ST_6ch_DIG] = {
  6355. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6356. .init_verbs = { alc883_init_verbs },
  6357. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6358. .dac_nids = alc883_dac_nids,
  6359. .dig_out_nid = ALC883_DIGOUT_NID,
  6360. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6361. .adc_nids = alc883_adc_nids,
  6362. .dig_in_nid = ALC883_DIGIN_NID,
  6363. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6364. .channel_mode = alc883_3ST_6ch_modes,
  6365. .need_dac_fix = 1,
  6366. .input_mux = &alc883_capture_source,
  6367. },
  6368. [ALC883_3ST_6ch] = {
  6369. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6370. .init_verbs = { alc883_init_verbs },
  6371. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6372. .dac_nids = alc883_dac_nids,
  6373. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6374. .adc_nids = alc883_adc_nids,
  6375. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6376. .channel_mode = alc883_3ST_6ch_modes,
  6377. .need_dac_fix = 1,
  6378. .input_mux = &alc883_capture_source,
  6379. },
  6380. [ALC883_6ST_DIG] = {
  6381. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6382. .init_verbs = { alc883_init_verbs },
  6383. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6384. .dac_nids = alc883_dac_nids,
  6385. .dig_out_nid = ALC883_DIGOUT_NID,
  6386. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6387. .adc_nids = alc883_adc_nids,
  6388. .dig_in_nid = ALC883_DIGIN_NID,
  6389. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6390. .channel_mode = alc883_sixstack_modes,
  6391. .input_mux = &alc883_capture_source,
  6392. },
  6393. [ALC883_TARGA_DIG] = {
  6394. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6395. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6396. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6397. .dac_nids = alc883_dac_nids,
  6398. .dig_out_nid = ALC883_DIGOUT_NID,
  6399. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6400. .adc_nids = alc883_adc_nids,
  6401. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6402. .channel_mode = alc883_3ST_6ch_modes,
  6403. .need_dac_fix = 1,
  6404. .input_mux = &alc883_capture_source,
  6405. .unsol_event = alc883_tagra_unsol_event,
  6406. .init_hook = alc883_tagra_automute,
  6407. },
  6408. [ALC883_TARGA_2ch_DIG] = {
  6409. .mixers = { alc883_tagra_2ch_mixer},
  6410. .init_verbs = { alc883_init_verbs, alc883_tagra_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. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6417. .channel_mode = alc883_3ST_2ch_modes,
  6418. .input_mux = &alc883_capture_source,
  6419. .unsol_event = alc883_tagra_unsol_event,
  6420. .init_hook = alc883_tagra_automute,
  6421. },
  6422. [ALC883_ACER] = {
  6423. .mixers = { alc883_base_mixer },
  6424. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6425. * and the headphone jack. Turn this on and rely on the
  6426. * standard mute methods whenever the user wants to turn
  6427. * these outputs off.
  6428. */
  6429. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6430. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6431. .dac_nids = alc883_dac_nids,
  6432. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6433. .adc_nids = alc883_adc_nids,
  6434. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6435. .channel_mode = alc883_3ST_2ch_modes,
  6436. .input_mux = &alc883_capture_source,
  6437. },
  6438. [ALC883_ACER_ASPIRE] = {
  6439. .mixers = { alc883_acer_aspire_mixer },
  6440. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6441. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6442. .dac_nids = alc883_dac_nids,
  6443. .dig_out_nid = ALC883_DIGOUT_NID,
  6444. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6445. .adc_nids = alc883_adc_nids,
  6446. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6447. .channel_mode = alc883_3ST_2ch_modes,
  6448. .input_mux = &alc883_capture_source,
  6449. .unsol_event = alc883_acer_aspire_unsol_event,
  6450. .init_hook = alc883_acer_aspire_automute,
  6451. },
  6452. [ALC883_MEDION] = {
  6453. .mixers = { alc883_fivestack_mixer,
  6454. alc883_chmode_mixer },
  6455. .init_verbs = { alc883_init_verbs,
  6456. alc883_medion_eapd_verbs },
  6457. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6458. .dac_nids = alc883_dac_nids,
  6459. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6460. .adc_nids = alc883_adc_nids,
  6461. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6462. .channel_mode = alc883_sixstack_modes,
  6463. .input_mux = &alc883_capture_source,
  6464. },
  6465. [ALC883_MEDION_MD2] = {
  6466. .mixers = { alc883_medion_md2_mixer},
  6467. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6468. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6469. .dac_nids = alc883_dac_nids,
  6470. .dig_out_nid = ALC883_DIGOUT_NID,
  6471. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6472. .adc_nids = alc883_adc_nids,
  6473. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6474. .channel_mode = alc883_3ST_2ch_modes,
  6475. .input_mux = &alc883_capture_source,
  6476. .unsol_event = alc883_medion_md2_unsol_event,
  6477. .init_hook = alc883_medion_md2_automute,
  6478. },
  6479. [ALC883_LAPTOP_EAPD] = {
  6480. .mixers = { alc883_base_mixer },
  6481. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6482. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6483. .dac_nids = alc883_dac_nids,
  6484. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6485. .adc_nids = alc883_adc_nids,
  6486. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6487. .channel_mode = alc883_3ST_2ch_modes,
  6488. .input_mux = &alc883_capture_source,
  6489. },
  6490. [ALC883_LENOVO_101E_2ch] = {
  6491. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6492. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6493. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6494. .dac_nids = alc883_dac_nids,
  6495. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6496. .adc_nids = alc883_adc_nids,
  6497. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6498. .channel_mode = alc883_3ST_2ch_modes,
  6499. .input_mux = &alc883_lenovo_101e_capture_source,
  6500. .unsol_event = alc883_lenovo_101e_unsol_event,
  6501. .init_hook = alc883_lenovo_101e_all_automute,
  6502. },
  6503. [ALC883_LENOVO_NB0763] = {
  6504. .mixers = { alc883_lenovo_nb0763_mixer },
  6505. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6506. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6507. .dac_nids = alc883_dac_nids,
  6508. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6509. .adc_nids = alc883_adc_nids,
  6510. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6511. .channel_mode = alc883_3ST_2ch_modes,
  6512. .need_dac_fix = 1,
  6513. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6514. .unsol_event = alc883_medion_md2_unsol_event,
  6515. .init_hook = alc883_medion_md2_automute,
  6516. },
  6517. [ALC888_LENOVO_MS7195_DIG] = {
  6518. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6519. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6520. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6521. .dac_nids = alc883_dac_nids,
  6522. .dig_out_nid = ALC883_DIGOUT_NID,
  6523. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6524. .adc_nids = alc883_adc_nids,
  6525. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6526. .channel_mode = alc883_3ST_6ch_modes,
  6527. .need_dac_fix = 1,
  6528. .input_mux = &alc883_capture_source,
  6529. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6530. .init_hook = alc888_lenovo_ms7195_front_automute,
  6531. },
  6532. [ALC883_HAIER_W66] = {
  6533. .mixers = { alc883_tagra_2ch_mixer},
  6534. .init_verbs = { alc883_init_verbs, alc883_haier_w66_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_haier_w66_unsol_event,
  6544. .init_hook = alc883_haier_w66_automute,
  6545. },
  6546. [ALC888_6ST_HP] = {
  6547. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6548. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6549. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6550. .dac_nids = alc883_dac_nids,
  6551. .dig_out_nid = ALC883_DIGOUT_NID,
  6552. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6553. .adc_nids = alc883_adc_nids,
  6554. .dig_in_nid = ALC883_DIGIN_NID,
  6555. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6556. .channel_mode = alc883_sixstack_modes,
  6557. .input_mux = &alc883_capture_source,
  6558. },
  6559. [ALC888_3ST_HP] = {
  6560. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6561. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6562. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6563. .dac_nids = alc883_dac_nids,
  6564. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6565. .adc_nids = alc883_adc_nids,
  6566. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6567. .channel_mode = alc888_3st_hp_modes,
  6568. .need_dac_fix = 1,
  6569. .input_mux = &alc883_capture_source,
  6570. },
  6571. };
  6572. /*
  6573. * BIOS auto configuration
  6574. */
  6575. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6576. hda_nid_t nid, int pin_type,
  6577. int dac_idx)
  6578. {
  6579. /* set as output */
  6580. struct alc_spec *spec = codec->spec;
  6581. int idx;
  6582. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6583. idx = 4;
  6584. else
  6585. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6586. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6587. pin_type);
  6588. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6589. AMP_OUT_UNMUTE);
  6590. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6591. }
  6592. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6593. {
  6594. struct alc_spec *spec = codec->spec;
  6595. int i;
  6596. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6597. for (i = 0; i <= HDA_SIDE; i++) {
  6598. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6599. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6600. if (nid)
  6601. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6602. i);
  6603. }
  6604. }
  6605. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6606. {
  6607. struct alc_spec *spec = codec->spec;
  6608. hda_nid_t pin;
  6609. pin = spec->autocfg.hp_pins[0];
  6610. if (pin) /* connect to front */
  6611. /* use dac 0 */
  6612. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6613. }
  6614. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6615. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6616. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6617. {
  6618. struct alc_spec *spec = codec->spec;
  6619. int i;
  6620. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6621. hda_nid_t nid = spec->autocfg.input_pins[i];
  6622. if (alc883_is_input_pin(nid)) {
  6623. snd_hda_codec_write(codec, nid, 0,
  6624. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6625. (i <= AUTO_PIN_FRONT_MIC ?
  6626. PIN_VREF80 : PIN_IN));
  6627. if (nid != ALC883_PIN_CD_NID)
  6628. snd_hda_codec_write(codec, nid, 0,
  6629. AC_VERB_SET_AMP_GAIN_MUTE,
  6630. AMP_OUT_MUTE);
  6631. }
  6632. }
  6633. }
  6634. /* almost identical with ALC880 parser... */
  6635. static int alc883_parse_auto_config(struct hda_codec *codec)
  6636. {
  6637. struct alc_spec *spec = codec->spec;
  6638. int err = alc880_parse_auto_config(codec);
  6639. if (err < 0)
  6640. return err;
  6641. else if (!err)
  6642. return 0; /* no config found */
  6643. err = alc_auto_add_mic_boost(codec);
  6644. if (err < 0)
  6645. return err;
  6646. /* hack - override the init verbs */
  6647. spec->init_verbs[0] = alc883_auto_init_verbs;
  6648. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6649. spec->num_mixers++;
  6650. return 1; /* config found */
  6651. }
  6652. /* additional initialization for auto-configuration model */
  6653. static void alc883_auto_init(struct hda_codec *codec)
  6654. {
  6655. alc883_auto_init_multi_out(codec);
  6656. alc883_auto_init_hp_out(codec);
  6657. alc883_auto_init_analog_input(codec);
  6658. }
  6659. static int patch_alc883(struct hda_codec *codec)
  6660. {
  6661. struct alc_spec *spec;
  6662. int err, board_config;
  6663. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6664. if (spec == NULL)
  6665. return -ENOMEM;
  6666. codec->spec = spec;
  6667. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6668. alc883_models,
  6669. alc883_cfg_tbl);
  6670. if (board_config < 0) {
  6671. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6672. "trying auto-probe from BIOS...\n");
  6673. board_config = ALC883_AUTO;
  6674. }
  6675. if (board_config == ALC883_AUTO) {
  6676. /* automatic parse from the BIOS config */
  6677. err = alc883_parse_auto_config(codec);
  6678. if (err < 0) {
  6679. alc_free(codec);
  6680. return err;
  6681. } else if (!err) {
  6682. printk(KERN_INFO
  6683. "hda_codec: Cannot set up configuration "
  6684. "from BIOS. Using base mode...\n");
  6685. board_config = ALC883_3ST_2ch_DIG;
  6686. }
  6687. }
  6688. if (board_config != ALC883_AUTO)
  6689. setup_preset(spec, &alc883_presets[board_config]);
  6690. spec->stream_name_analog = "ALC883 Analog";
  6691. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6692. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6693. spec->stream_name_digital = "ALC883 Digital";
  6694. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6695. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6696. if (!spec->adc_nids && spec->input_mux) {
  6697. spec->adc_nids = alc883_adc_nids;
  6698. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6699. }
  6700. codec->patch_ops = alc_patch_ops;
  6701. if (board_config == ALC883_AUTO)
  6702. spec->init_hook = alc883_auto_init;
  6703. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6704. if (!spec->loopback.amplist)
  6705. spec->loopback.amplist = alc883_loopbacks;
  6706. #endif
  6707. return 0;
  6708. }
  6709. /*
  6710. * ALC262 support
  6711. */
  6712. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6713. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6714. #define alc262_dac_nids alc260_dac_nids
  6715. #define alc262_adc_nids alc882_adc_nids
  6716. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6717. #define alc262_modes alc260_modes
  6718. #define alc262_capture_source alc882_capture_source
  6719. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6720. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6721. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6722. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6723. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6724. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6725. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6726. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6727. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6728. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6729. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6730. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6731. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6732. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6733. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6734. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6735. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6736. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6737. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6738. { } /* end */
  6739. };
  6740. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6741. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6742. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6743. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6744. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6745. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6746. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6747. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6748. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6749. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6750. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6751. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6752. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6753. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6754. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6755. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6757. { } /* end */
  6758. };
  6759. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6760. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6761. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6762. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6763. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6764. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6765. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6766. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6767. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6768. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6769. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6770. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6771. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6772. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6773. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6774. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6775. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6776. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6777. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6778. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6779. { } /* end */
  6780. };
  6781. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6782. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6783. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6784. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6785. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6786. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6787. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6788. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6789. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6790. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6791. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6792. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6793. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6794. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6795. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6796. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6797. { } /* end */
  6798. };
  6799. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6800. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6801. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6802. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6803. { } /* end */
  6804. };
  6805. /* bind hp and internal speaker mute (with plug check) */
  6806. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6807. struct snd_ctl_elem_value *ucontrol)
  6808. {
  6809. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6810. long *valp = ucontrol->value.integer.value;
  6811. int change;
  6812. /* change hp mute */
  6813. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6814. HDA_AMP_MUTE,
  6815. valp[0] ? 0 : HDA_AMP_MUTE);
  6816. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6817. HDA_AMP_MUTE,
  6818. valp[1] ? 0 : HDA_AMP_MUTE);
  6819. if (change) {
  6820. /* change speaker according to HP jack state */
  6821. struct alc_spec *spec = codec->spec;
  6822. unsigned int mute;
  6823. if (spec->jack_present)
  6824. mute = HDA_AMP_MUTE;
  6825. else
  6826. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6827. HDA_OUTPUT, 0);
  6828. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6829. HDA_AMP_MUTE, mute);
  6830. }
  6831. return change;
  6832. }
  6833. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6834. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6835. {
  6836. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6837. .name = "Master Playback Switch",
  6838. .info = snd_hda_mixer_amp_switch_info,
  6839. .get = snd_hda_mixer_amp_switch_get,
  6840. .put = alc262_sony_master_sw_put,
  6841. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6842. },
  6843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6844. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6845. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6846. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6847. { } /* end */
  6848. };
  6849. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6850. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6851. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6853. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6854. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6855. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6856. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6857. { } /* end */
  6858. };
  6859. #define alc262_capture_mixer alc882_capture_mixer
  6860. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6861. /*
  6862. * generic initialization of ADC, input mixers and output mixers
  6863. */
  6864. static struct hda_verb alc262_init_verbs[] = {
  6865. /*
  6866. * Unmute ADC0-2 and set the default input to mic-in
  6867. */
  6868. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6870. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6871. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6872. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6873. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6874. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6875. * mixer widget
  6876. * Note: PASD motherboards uses the Line In 2 as the input for
  6877. * front panel mic (mic 2)
  6878. */
  6879. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6881. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6882. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6883. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6884. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6885. /*
  6886. * Set up output mixers (0x0c - 0x0e)
  6887. */
  6888. /* set vol=0 to output mixers */
  6889. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6890. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6891. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6892. /* set up input amps for analog loopback */
  6893. /* Amp Indices: DAC = 0, mixer = 1 */
  6894. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6896. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6897. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6898. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6899. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6900. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6901. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6902. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6903. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6904. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6905. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6906. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6908. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6909. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6910. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6911. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6912. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6913. /* FIXME: use matrix-type input source selection */
  6914. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6915. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6916. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6917. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6918. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6919. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6920. /* Input mixer2 */
  6921. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6922. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6923. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6924. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6925. /* Input mixer3 */
  6926. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6927. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6928. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6929. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6930. { }
  6931. };
  6932. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6933. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6934. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6935. {}
  6936. };
  6937. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6938. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6939. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6940. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6941. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6942. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6943. {}
  6944. };
  6945. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6946. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6947. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6948. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6949. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6950. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6951. };
  6952. /* mute/unmute internal speaker according to the hp jack and mute state */
  6953. static void alc262_hippo_automute(struct hda_codec *codec)
  6954. {
  6955. struct alc_spec *spec = codec->spec;
  6956. unsigned int mute;
  6957. unsigned int present;
  6958. /* need to execute and sync at first */
  6959. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6960. present = snd_hda_codec_read(codec, 0x15, 0,
  6961. AC_VERB_GET_PIN_SENSE, 0);
  6962. spec->jack_present = (present & 0x80000000) != 0;
  6963. if (spec->jack_present) {
  6964. /* mute internal speaker */
  6965. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6966. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6967. } else {
  6968. /* unmute internal speaker if necessary */
  6969. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6970. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6971. HDA_AMP_MUTE, mute);
  6972. }
  6973. }
  6974. /* unsolicited event for HP jack sensing */
  6975. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6976. unsigned int res)
  6977. {
  6978. if ((res >> 26) != ALC880_HP_EVENT)
  6979. return;
  6980. alc262_hippo_automute(codec);
  6981. }
  6982. static void alc262_hippo1_automute(struct hda_codec *codec)
  6983. {
  6984. unsigned int mute;
  6985. unsigned int present;
  6986. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6987. present = snd_hda_codec_read(codec, 0x1b, 0,
  6988. AC_VERB_GET_PIN_SENSE, 0);
  6989. present = (present & 0x80000000) != 0;
  6990. if (present) {
  6991. /* mute internal speaker */
  6992. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6993. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6994. } else {
  6995. /* unmute internal speaker if necessary */
  6996. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6997. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6998. HDA_AMP_MUTE, mute);
  6999. }
  7000. }
  7001. /* unsolicited event for HP jack sensing */
  7002. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7003. unsigned int res)
  7004. {
  7005. if ((res >> 26) != ALC880_HP_EVENT)
  7006. return;
  7007. alc262_hippo1_automute(codec);
  7008. }
  7009. /*
  7010. * fujitsu model
  7011. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7012. */
  7013. #define ALC_HP_EVENT 0x37
  7014. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7015. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7016. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7017. {}
  7018. };
  7019. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7020. .num_items = 2,
  7021. .items = {
  7022. { "Mic", 0x0 },
  7023. { "CD", 0x4 },
  7024. },
  7025. };
  7026. static struct hda_input_mux alc262_HP_capture_source = {
  7027. .num_items = 5,
  7028. .items = {
  7029. { "Mic", 0x0 },
  7030. { "Front Mic", 0x3 },
  7031. { "Line", 0x2 },
  7032. { "CD", 0x4 },
  7033. { "AUX IN", 0x6 },
  7034. },
  7035. };
  7036. /* mute/unmute internal speaker according to the hp jack and mute state */
  7037. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7038. {
  7039. struct alc_spec *spec = codec->spec;
  7040. unsigned int mute;
  7041. if (force || !spec->sense_updated) {
  7042. unsigned int present;
  7043. /* need to execute and sync at first */
  7044. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7045. present = snd_hda_codec_read(codec, 0x14, 0,
  7046. AC_VERB_GET_PIN_SENSE, 0);
  7047. spec->jack_present = (present & 0x80000000) != 0;
  7048. spec->sense_updated = 1;
  7049. }
  7050. if (spec->jack_present) {
  7051. /* mute internal speaker */
  7052. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7053. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7054. } else {
  7055. /* unmute internal speaker if necessary */
  7056. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7057. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7058. HDA_AMP_MUTE, mute);
  7059. }
  7060. }
  7061. /* unsolicited event for HP jack sensing */
  7062. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7063. unsigned int res)
  7064. {
  7065. if ((res >> 26) != ALC_HP_EVENT)
  7066. return;
  7067. alc262_fujitsu_automute(codec, 1);
  7068. }
  7069. /* bind volumes of both NID 0x0c and 0x0d */
  7070. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7071. .ops = &snd_hda_bind_vol,
  7072. .values = {
  7073. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7074. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7075. 0
  7076. },
  7077. };
  7078. /* bind hp and internal speaker mute (with plug check) */
  7079. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7080. struct snd_ctl_elem_value *ucontrol)
  7081. {
  7082. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7083. long *valp = ucontrol->value.integer.value;
  7084. int change;
  7085. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7086. HDA_AMP_MUTE,
  7087. valp[0] ? 0 : HDA_AMP_MUTE);
  7088. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7089. HDA_AMP_MUTE,
  7090. valp[1] ? 0 : HDA_AMP_MUTE);
  7091. if (change)
  7092. alc262_fujitsu_automute(codec, 0);
  7093. return change;
  7094. }
  7095. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7096. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7097. {
  7098. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7099. .name = "Master Playback Switch",
  7100. .info = snd_hda_mixer_amp_switch_info,
  7101. .get = snd_hda_mixer_amp_switch_get,
  7102. .put = alc262_fujitsu_master_sw_put,
  7103. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7104. },
  7105. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7106. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7107. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7108. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7109. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7110. { } /* end */
  7111. };
  7112. /* additional init verbs for Benq laptops */
  7113. static struct hda_verb alc262_EAPD_verbs[] = {
  7114. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7115. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7116. {}
  7117. };
  7118. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7119. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7120. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7121. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7122. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7123. {}
  7124. };
  7125. /* add playback controls from the parsed DAC table */
  7126. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7127. const struct auto_pin_cfg *cfg)
  7128. {
  7129. hda_nid_t nid;
  7130. int err;
  7131. spec->multiout.num_dacs = 1; /* only use one dac */
  7132. spec->multiout.dac_nids = spec->private_dac_nids;
  7133. spec->multiout.dac_nids[0] = 2;
  7134. nid = cfg->line_out_pins[0];
  7135. if (nid) {
  7136. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7137. "Front Playback Volume",
  7138. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7139. if (err < 0)
  7140. return err;
  7141. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7142. "Front Playback Switch",
  7143. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7144. if (err < 0)
  7145. return err;
  7146. }
  7147. nid = cfg->speaker_pins[0];
  7148. if (nid) {
  7149. if (nid == 0x16) {
  7150. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7151. "Speaker Playback Volume",
  7152. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7153. HDA_OUTPUT));
  7154. if (err < 0)
  7155. return err;
  7156. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7157. "Speaker Playback Switch",
  7158. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7159. HDA_OUTPUT));
  7160. if (err < 0)
  7161. return err;
  7162. } else {
  7163. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7164. "Speaker Playback Switch",
  7165. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7166. HDA_OUTPUT));
  7167. if (err < 0)
  7168. return err;
  7169. }
  7170. }
  7171. nid = cfg->hp_pins[0];
  7172. if (nid) {
  7173. /* spec->multiout.hp_nid = 2; */
  7174. if (nid == 0x16) {
  7175. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7176. "Headphone Playback Volume",
  7177. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7178. HDA_OUTPUT));
  7179. if (err < 0)
  7180. return err;
  7181. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7182. "Headphone Playback Switch",
  7183. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7184. HDA_OUTPUT));
  7185. if (err < 0)
  7186. return err;
  7187. } else {
  7188. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7189. "Headphone Playback Switch",
  7190. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7191. HDA_OUTPUT));
  7192. if (err < 0)
  7193. return err;
  7194. }
  7195. }
  7196. return 0;
  7197. }
  7198. /* identical with ALC880 */
  7199. #define alc262_auto_create_analog_input_ctls \
  7200. alc880_auto_create_analog_input_ctls
  7201. /*
  7202. * generic initialization of ADC, input mixers and output mixers
  7203. */
  7204. static struct hda_verb alc262_volume_init_verbs[] = {
  7205. /*
  7206. * Unmute ADC0-2 and set the default input to mic-in
  7207. */
  7208. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7209. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7210. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7211. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7212. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7213. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7214. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7215. * mixer widget
  7216. * Note: PASD motherboards uses the Line In 2 as the input for
  7217. * front panel mic (mic 2)
  7218. */
  7219. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7220. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7221. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7222. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7223. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7224. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7225. /*
  7226. * Set up output mixers (0x0c - 0x0f)
  7227. */
  7228. /* set vol=0 to output mixers */
  7229. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7230. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7231. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7232. /* set up input amps for analog loopback */
  7233. /* Amp Indices: DAC = 0, mixer = 1 */
  7234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7235. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7237. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7238. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7239. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7240. /* FIXME: use matrix-type input source selection */
  7241. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7242. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7243. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7244. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7245. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7246. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7247. /* Input mixer2 */
  7248. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7249. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7250. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7251. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7252. /* Input mixer3 */
  7253. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7254. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7255. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7256. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7257. { }
  7258. };
  7259. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7260. /*
  7261. * Unmute ADC0-2 and set the default input to mic-in
  7262. */
  7263. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7264. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7265. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7266. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7267. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7268. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7269. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7270. * mixer widget
  7271. * Note: PASD motherboards uses the Line In 2 as the input for
  7272. * front panel mic (mic 2)
  7273. */
  7274. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7280. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7281. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7282. /*
  7283. * Set up output mixers (0x0c - 0x0e)
  7284. */
  7285. /* set vol=0 to output mixers */
  7286. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7287. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7288. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7289. /* set up input amps for analog loopback */
  7290. /* Amp Indices: DAC = 0, mixer = 1 */
  7291. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7292. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7293. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7294. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7295. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7296. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7297. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7299. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7300. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7301. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7302. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7303. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7304. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7305. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7306. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7307. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7308. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7309. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7310. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7311. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7312. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7313. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7314. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7315. /* FIXME: use matrix-type input source selection */
  7316. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7317. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7318. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7319. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7320. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7321. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7322. /* Input mixer2 */
  7323. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7324. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7325. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7326. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7327. /* Input mixer3 */
  7328. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7329. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7330. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7331. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7332. { }
  7333. };
  7334. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7335. /*
  7336. * Unmute ADC0-2 and set the default input to mic-in
  7337. */
  7338. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7339. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7340. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7341. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7342. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7343. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7344. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7345. * mixer widget
  7346. * Note: PASD motherboards uses the Line In 2 as the input for front
  7347. * panel mic (mic 2)
  7348. */
  7349. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7350. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7351. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7352. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7353. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7354. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7355. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7356. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7357. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7358. /*
  7359. * Set up output mixers (0x0c - 0x0e)
  7360. */
  7361. /* set vol=0 to output mixers */
  7362. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7363. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7364. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7365. /* set up input amps for analog loopback */
  7366. /* Amp Indices: DAC = 0, mixer = 1 */
  7367. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7368. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7369. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7370. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7371. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7372. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7373. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7374. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7375. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7376. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7377. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7378. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7379. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  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, 0x01},
  7384. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7386. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7387. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7388. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7389. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7390. /* FIXME: use matrix-type input source selection */
  7391. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7392. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7394. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7395. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7396. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7397. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7398. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7399. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7400. /* Input mixer2 */
  7401. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7402. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7403. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7404. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7405. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7406. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7407. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7408. /* Input mixer3 */
  7409. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7410. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7411. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7412. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7413. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7414. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7415. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7416. { }
  7417. };
  7418. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7419. #define alc262_loopbacks alc880_loopbacks
  7420. #endif
  7421. /* pcm configuration: identiacal with ALC880 */
  7422. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7423. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7424. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7425. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7426. /*
  7427. * BIOS auto configuration
  7428. */
  7429. static int alc262_parse_auto_config(struct hda_codec *codec)
  7430. {
  7431. struct alc_spec *spec = codec->spec;
  7432. int err;
  7433. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7434. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7435. alc262_ignore);
  7436. if (err < 0)
  7437. return err;
  7438. if (!spec->autocfg.line_outs)
  7439. return 0; /* can't find valid BIOS pin config */
  7440. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7441. if (err < 0)
  7442. return err;
  7443. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7444. if (err < 0)
  7445. return err;
  7446. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7447. if (spec->autocfg.dig_out_pin)
  7448. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7449. if (spec->autocfg.dig_in_pin)
  7450. spec->dig_in_nid = ALC262_DIGIN_NID;
  7451. if (spec->kctl_alloc)
  7452. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7453. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7454. spec->num_mux_defs = 1;
  7455. spec->input_mux = &spec->private_imux;
  7456. err = alc_auto_add_mic_boost(codec);
  7457. if (err < 0)
  7458. return err;
  7459. return 1;
  7460. }
  7461. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7462. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7463. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7464. /* init callback for auto-configuration model -- overriding the default init */
  7465. static void alc262_auto_init(struct hda_codec *codec)
  7466. {
  7467. alc262_auto_init_multi_out(codec);
  7468. alc262_auto_init_hp_out(codec);
  7469. alc262_auto_init_analog_input(codec);
  7470. }
  7471. /*
  7472. * configuration and preset
  7473. */
  7474. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7475. [ALC262_BASIC] = "basic",
  7476. [ALC262_HIPPO] = "hippo",
  7477. [ALC262_HIPPO_1] = "hippo_1",
  7478. [ALC262_FUJITSU] = "fujitsu",
  7479. [ALC262_HP_BPC] = "hp-bpc",
  7480. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7481. [ALC262_BENQ_ED8] = "benq",
  7482. [ALC262_BENQ_T31] = "benq-t31",
  7483. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7484. [ALC262_AUTO] = "auto",
  7485. };
  7486. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7487. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7488. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7489. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7490. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7491. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7492. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7493. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7494. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7495. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7496. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7497. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7498. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7499. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7500. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7501. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7502. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7503. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7504. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7505. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7506. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7507. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7508. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7509. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7510. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7511. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7512. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7513. {}
  7514. };
  7515. static struct alc_config_preset alc262_presets[] = {
  7516. [ALC262_BASIC] = {
  7517. .mixers = { alc262_base_mixer },
  7518. .init_verbs = { alc262_init_verbs },
  7519. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7520. .dac_nids = alc262_dac_nids,
  7521. .hp_nid = 0x03,
  7522. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7523. .channel_mode = alc262_modes,
  7524. .input_mux = &alc262_capture_source,
  7525. },
  7526. [ALC262_HIPPO] = {
  7527. .mixers = { alc262_base_mixer },
  7528. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7529. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7530. .dac_nids = alc262_dac_nids,
  7531. .hp_nid = 0x03,
  7532. .dig_out_nid = ALC262_DIGOUT_NID,
  7533. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7534. .channel_mode = alc262_modes,
  7535. .input_mux = &alc262_capture_source,
  7536. .unsol_event = alc262_hippo_unsol_event,
  7537. .init_hook = alc262_hippo_automute,
  7538. },
  7539. [ALC262_HIPPO_1] = {
  7540. .mixers = { alc262_hippo1_mixer },
  7541. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7542. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7543. .dac_nids = alc262_dac_nids,
  7544. .hp_nid = 0x02,
  7545. .dig_out_nid = ALC262_DIGOUT_NID,
  7546. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7547. .channel_mode = alc262_modes,
  7548. .input_mux = &alc262_capture_source,
  7549. .unsol_event = alc262_hippo1_unsol_event,
  7550. .init_hook = alc262_hippo1_automute,
  7551. },
  7552. [ALC262_FUJITSU] = {
  7553. .mixers = { alc262_fujitsu_mixer },
  7554. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7555. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7556. .dac_nids = alc262_dac_nids,
  7557. .hp_nid = 0x03,
  7558. .dig_out_nid = ALC262_DIGOUT_NID,
  7559. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7560. .channel_mode = alc262_modes,
  7561. .input_mux = &alc262_fujitsu_capture_source,
  7562. .unsol_event = alc262_fujitsu_unsol_event,
  7563. },
  7564. [ALC262_HP_BPC] = {
  7565. .mixers = { alc262_HP_BPC_mixer },
  7566. .init_verbs = { alc262_HP_BPC_init_verbs },
  7567. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7568. .dac_nids = alc262_dac_nids,
  7569. .hp_nid = 0x03,
  7570. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7571. .channel_mode = alc262_modes,
  7572. .input_mux = &alc262_HP_capture_source,
  7573. },
  7574. [ALC262_HP_BPC_D7000_WF] = {
  7575. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7576. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7577. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7578. .dac_nids = alc262_dac_nids,
  7579. .hp_nid = 0x03,
  7580. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7581. .channel_mode = alc262_modes,
  7582. .input_mux = &alc262_HP_capture_source,
  7583. },
  7584. [ALC262_HP_BPC_D7000_WL] = {
  7585. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7586. alc262_HP_BPC_WildWest_option_mixer },
  7587. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7588. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7589. .dac_nids = alc262_dac_nids,
  7590. .hp_nid = 0x03,
  7591. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7592. .channel_mode = alc262_modes,
  7593. .input_mux = &alc262_HP_capture_source,
  7594. },
  7595. [ALC262_BENQ_ED8] = {
  7596. .mixers = { alc262_base_mixer },
  7597. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7598. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7599. .dac_nids = alc262_dac_nids,
  7600. .hp_nid = 0x03,
  7601. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7602. .channel_mode = alc262_modes,
  7603. .input_mux = &alc262_capture_source,
  7604. },
  7605. [ALC262_SONY_ASSAMD] = {
  7606. .mixers = { alc262_sony_mixer },
  7607. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7608. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7609. .dac_nids = alc262_dac_nids,
  7610. .hp_nid = 0x02,
  7611. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7612. .channel_mode = alc262_modes,
  7613. .input_mux = &alc262_capture_source,
  7614. .unsol_event = alc262_hippo_unsol_event,
  7615. .init_hook = alc262_hippo_automute,
  7616. },
  7617. [ALC262_BENQ_T31] = {
  7618. .mixers = { alc262_benq_t31_mixer },
  7619. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7620. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7621. .dac_nids = alc262_dac_nids,
  7622. .hp_nid = 0x03,
  7623. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7624. .channel_mode = alc262_modes,
  7625. .input_mux = &alc262_capture_source,
  7626. .unsol_event = alc262_hippo_unsol_event,
  7627. .init_hook = alc262_hippo_automute,
  7628. },
  7629. };
  7630. static int patch_alc262(struct hda_codec *codec)
  7631. {
  7632. struct alc_spec *spec;
  7633. int board_config;
  7634. int err;
  7635. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7636. if (spec == NULL)
  7637. return -ENOMEM;
  7638. codec->spec = spec;
  7639. #if 0
  7640. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7641. * under-run
  7642. */
  7643. {
  7644. int tmp;
  7645. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7646. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7649. }
  7650. #endif
  7651. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7652. alc262_models,
  7653. alc262_cfg_tbl);
  7654. if (board_config < 0) {
  7655. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7656. "trying auto-probe from BIOS...\n");
  7657. board_config = ALC262_AUTO;
  7658. }
  7659. if (board_config == ALC262_AUTO) {
  7660. /* automatic parse from the BIOS config */
  7661. err = alc262_parse_auto_config(codec);
  7662. if (err < 0) {
  7663. alc_free(codec);
  7664. return err;
  7665. } else if (!err) {
  7666. printk(KERN_INFO
  7667. "hda_codec: Cannot set up configuration "
  7668. "from BIOS. Using base mode...\n");
  7669. board_config = ALC262_BASIC;
  7670. }
  7671. }
  7672. if (board_config != ALC262_AUTO)
  7673. setup_preset(spec, &alc262_presets[board_config]);
  7674. spec->stream_name_analog = "ALC262 Analog";
  7675. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7676. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7677. spec->stream_name_digital = "ALC262 Digital";
  7678. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7679. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7680. if (!spec->adc_nids && spec->input_mux) {
  7681. /* check whether NID 0x07 is valid */
  7682. unsigned int wcap = get_wcaps(codec, 0x07);
  7683. /* get type */
  7684. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7685. if (wcap != AC_WID_AUD_IN) {
  7686. spec->adc_nids = alc262_adc_nids_alt;
  7687. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7688. spec->mixers[spec->num_mixers] =
  7689. alc262_capture_alt_mixer;
  7690. spec->num_mixers++;
  7691. } else {
  7692. spec->adc_nids = alc262_adc_nids;
  7693. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7694. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7695. spec->num_mixers++;
  7696. }
  7697. }
  7698. codec->patch_ops = alc_patch_ops;
  7699. if (board_config == ALC262_AUTO)
  7700. spec->init_hook = alc262_auto_init;
  7701. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7702. if (!spec->loopback.amplist)
  7703. spec->loopback.amplist = alc262_loopbacks;
  7704. #endif
  7705. return 0;
  7706. }
  7707. /*
  7708. * ALC268 channel source setting (2 channel)
  7709. */
  7710. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7711. #define alc268_modes alc260_modes
  7712. static hda_nid_t alc268_dac_nids[2] = {
  7713. /* front, hp */
  7714. 0x02, 0x03
  7715. };
  7716. static hda_nid_t alc268_adc_nids[2] = {
  7717. /* ADC0-1 */
  7718. 0x08, 0x07
  7719. };
  7720. static hda_nid_t alc268_adc_nids_alt[1] = {
  7721. /* ADC0 */
  7722. 0x08
  7723. };
  7724. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7725. /* output mixer control */
  7726. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7727. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7728. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7729. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7730. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7731. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7732. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7733. { }
  7734. };
  7735. static struct hda_verb alc268_eapd_verbs[] = {
  7736. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7737. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7738. { }
  7739. };
  7740. /* Toshiba specific */
  7741. #define alc268_toshiba_automute alc262_hippo_automute
  7742. static struct hda_verb alc268_toshiba_verbs[] = {
  7743. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7744. { } /* end */
  7745. };
  7746. /* Acer specific */
  7747. /* bind volumes of both NID 0x02 and 0x03 */
  7748. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7749. .ops = &snd_hda_bind_vol,
  7750. .values = {
  7751. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7752. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7753. 0
  7754. },
  7755. };
  7756. /* mute/unmute internal speaker according to the hp jack and mute state */
  7757. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7758. {
  7759. struct alc_spec *spec = codec->spec;
  7760. unsigned int mute;
  7761. if (force || !spec->sense_updated) {
  7762. unsigned int present;
  7763. present = snd_hda_codec_read(codec, 0x14, 0,
  7764. AC_VERB_GET_PIN_SENSE, 0);
  7765. spec->jack_present = (present & 0x80000000) != 0;
  7766. spec->sense_updated = 1;
  7767. }
  7768. if (spec->jack_present)
  7769. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7770. else /* unmute internal speaker if necessary */
  7771. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7772. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7773. HDA_AMP_MUTE, mute);
  7774. }
  7775. /* bind hp and internal speaker mute (with plug check) */
  7776. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7777. struct snd_ctl_elem_value *ucontrol)
  7778. {
  7779. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7780. long *valp = ucontrol->value.integer.value;
  7781. int change;
  7782. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7783. HDA_AMP_MUTE,
  7784. valp[0] ? 0 : HDA_AMP_MUTE);
  7785. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7786. HDA_AMP_MUTE,
  7787. valp[1] ? 0 : HDA_AMP_MUTE);
  7788. if (change)
  7789. alc268_acer_automute(codec, 0);
  7790. return change;
  7791. }
  7792. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7793. /* output mixer control */
  7794. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7795. {
  7796. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7797. .name = "Master Playback Switch",
  7798. .info = snd_hda_mixer_amp_switch_info,
  7799. .get = snd_hda_mixer_amp_switch_get,
  7800. .put = alc268_acer_master_sw_put,
  7801. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7802. },
  7803. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7804. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7805. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7806. { }
  7807. };
  7808. static struct hda_verb alc268_acer_verbs[] = {
  7809. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7810. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7811. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7812. { }
  7813. };
  7814. /* unsolicited event for HP jack sensing */
  7815. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7816. unsigned int res)
  7817. {
  7818. if ((res >> 26) != ALC880_HP_EVENT)
  7819. return;
  7820. alc268_toshiba_automute(codec);
  7821. }
  7822. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7823. unsigned int res)
  7824. {
  7825. if ((res >> 26) != ALC880_HP_EVENT)
  7826. return;
  7827. alc268_acer_automute(codec, 1);
  7828. }
  7829. static void alc268_acer_init_hook(struct hda_codec *codec)
  7830. {
  7831. alc268_acer_automute(codec, 1);
  7832. }
  7833. /*
  7834. * generic initialization of ADC, input mixers and output mixers
  7835. */
  7836. static struct hda_verb alc268_base_init_verbs[] = {
  7837. /* Unmute DAC0-1 and set vol = 0 */
  7838. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7839. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7840. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7841. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7842. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7843. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7844. /*
  7845. * Set up output mixers (0x0c - 0x0e)
  7846. */
  7847. /* set vol=0 to output mixers */
  7848. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7849. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7850. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7851. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7852. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7853. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7854. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7855. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7856. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7857. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7858. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7859. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7860. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7861. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7862. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7863. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7864. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7865. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7866. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7867. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7868. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7869. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7870. /* FIXME: use matrix-type input source selection */
  7871. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7872. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7873. /* Input mixer2 */
  7874. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7875. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7876. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7877. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7878. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7879. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7880. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7881. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7882. { }
  7883. };
  7884. /*
  7885. * generic initialization of ADC, input mixers and output mixers
  7886. */
  7887. static struct hda_verb alc268_volume_init_verbs[] = {
  7888. /* set output DAC */
  7889. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7890. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7891. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7892. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7893. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7894. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7895. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7896. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7897. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7898. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7899. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7900. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7901. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7902. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7903. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7904. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7905. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7906. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7907. /* set PCBEEP vol = 0 */
  7908. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7909. { }
  7910. };
  7911. #define alc268_mux_enum_info alc_mux_enum_info
  7912. #define alc268_mux_enum_get alc_mux_enum_get
  7913. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7914. struct snd_ctl_elem_value *ucontrol)
  7915. {
  7916. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7917. struct alc_spec *spec = codec->spec;
  7918. const struct hda_input_mux *imux = spec->input_mux;
  7919. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7920. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7921. hda_nid_t nid = capture_mixers[adc_idx];
  7922. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7923. unsigned int i, idx;
  7924. idx = ucontrol->value.enumerated.item[0];
  7925. if (idx >= imux->num_items)
  7926. idx = imux->num_items - 1;
  7927. if (*cur_val == idx)
  7928. return 0;
  7929. for (i = 0; i < imux->num_items; i++) {
  7930. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7931. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7932. imux->items[i].index,
  7933. HDA_AMP_MUTE, v);
  7934. snd_hda_codec_write_cache(codec, nid, 0,
  7935. AC_VERB_SET_CONNECT_SEL,
  7936. idx );
  7937. }
  7938. *cur_val = idx;
  7939. return 1;
  7940. }
  7941. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7942. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7943. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7944. {
  7945. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7946. /* The multiple "Capture Source" controls confuse alsamixer
  7947. * So call somewhat different..
  7948. * FIXME: the controls appear in the "playback" view!
  7949. */
  7950. /* .name = "Capture Source", */
  7951. .name = "Input Source",
  7952. .count = 1,
  7953. .info = alc268_mux_enum_info,
  7954. .get = alc268_mux_enum_get,
  7955. .put = alc268_mux_enum_put,
  7956. },
  7957. { } /* end */
  7958. };
  7959. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7960. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7961. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7962. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7963. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7964. {
  7965. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7966. /* The multiple "Capture Source" controls confuse alsamixer
  7967. * So call somewhat different..
  7968. * FIXME: the controls appear in the "playback" view!
  7969. */
  7970. /* .name = "Capture Source", */
  7971. .name = "Input Source",
  7972. .count = 2,
  7973. .info = alc268_mux_enum_info,
  7974. .get = alc268_mux_enum_get,
  7975. .put = alc268_mux_enum_put,
  7976. },
  7977. { } /* end */
  7978. };
  7979. static struct hda_input_mux alc268_capture_source = {
  7980. .num_items = 4,
  7981. .items = {
  7982. { "Mic", 0x0 },
  7983. { "Front Mic", 0x1 },
  7984. { "Line", 0x2 },
  7985. { "CD", 0x3 },
  7986. },
  7987. };
  7988. /* create input playback/capture controls for the given pin */
  7989. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7990. const char *ctlname, int idx)
  7991. {
  7992. char name[32];
  7993. int err;
  7994. sprintf(name, "%s Playback Volume", ctlname);
  7995. if (nid == 0x14) {
  7996. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7997. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7998. HDA_OUTPUT));
  7999. if (err < 0)
  8000. return err;
  8001. } else if (nid == 0x15) {
  8002. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8003. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8004. HDA_OUTPUT));
  8005. if (err < 0)
  8006. return err;
  8007. } else
  8008. return -1;
  8009. sprintf(name, "%s Playback Switch", ctlname);
  8010. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8011. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8012. if (err < 0)
  8013. return err;
  8014. return 0;
  8015. }
  8016. /* add playback controls from the parsed DAC table */
  8017. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8018. const struct auto_pin_cfg *cfg)
  8019. {
  8020. hda_nid_t nid;
  8021. int err;
  8022. spec->multiout.num_dacs = 2; /* only use one dac */
  8023. spec->multiout.dac_nids = spec->private_dac_nids;
  8024. spec->multiout.dac_nids[0] = 2;
  8025. spec->multiout.dac_nids[1] = 3;
  8026. nid = cfg->line_out_pins[0];
  8027. if (nid)
  8028. alc268_new_analog_output(spec, nid, "Front", 0);
  8029. nid = cfg->speaker_pins[0];
  8030. if (nid == 0x1d) {
  8031. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8032. "Speaker Playback Volume",
  8033. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8034. if (err < 0)
  8035. return err;
  8036. }
  8037. nid = cfg->hp_pins[0];
  8038. if (nid)
  8039. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8040. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8041. if (nid == 0x16) {
  8042. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8043. "Mono Playback Switch",
  8044. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8045. if (err < 0)
  8046. return err;
  8047. }
  8048. return 0;
  8049. }
  8050. /* create playback/capture controls for input pins */
  8051. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8052. const struct auto_pin_cfg *cfg)
  8053. {
  8054. struct hda_input_mux *imux = &spec->private_imux;
  8055. int i, idx1;
  8056. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8057. switch(cfg->input_pins[i]) {
  8058. case 0x18:
  8059. idx1 = 0; /* Mic 1 */
  8060. break;
  8061. case 0x19:
  8062. idx1 = 1; /* Mic 2 */
  8063. break;
  8064. case 0x1a:
  8065. idx1 = 2; /* Line In */
  8066. break;
  8067. case 0x1c:
  8068. idx1 = 3; /* CD */
  8069. break;
  8070. default:
  8071. continue;
  8072. }
  8073. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8074. imux->items[imux->num_items].index = idx1;
  8075. imux->num_items++;
  8076. }
  8077. return 0;
  8078. }
  8079. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8080. {
  8081. struct alc_spec *spec = codec->spec;
  8082. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8083. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8084. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8085. unsigned int dac_vol1, dac_vol2;
  8086. if (speaker_nid) {
  8087. snd_hda_codec_write(codec, speaker_nid, 0,
  8088. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8089. snd_hda_codec_write(codec, 0x0f, 0,
  8090. AC_VERB_SET_AMP_GAIN_MUTE,
  8091. AMP_IN_UNMUTE(1));
  8092. snd_hda_codec_write(codec, 0x10, 0,
  8093. AC_VERB_SET_AMP_GAIN_MUTE,
  8094. AMP_IN_UNMUTE(1));
  8095. } else {
  8096. snd_hda_codec_write(codec, 0x0f, 0,
  8097. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8098. snd_hda_codec_write(codec, 0x10, 0,
  8099. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8100. }
  8101. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8102. if (line_nid == 0x14)
  8103. dac_vol2 = AMP_OUT_ZERO;
  8104. else if (line_nid == 0x15)
  8105. dac_vol1 = AMP_OUT_ZERO;
  8106. if (hp_nid == 0x14)
  8107. dac_vol2 = AMP_OUT_ZERO;
  8108. else if (hp_nid == 0x15)
  8109. dac_vol1 = AMP_OUT_ZERO;
  8110. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8111. spec->autocfg.line_out_pins[1] != 0x16 ||
  8112. spec->autocfg.line_out_pins[2] != 0x16)
  8113. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8114. snd_hda_codec_write(codec, 0x02, 0,
  8115. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8116. snd_hda_codec_write(codec, 0x03, 0,
  8117. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8118. }
  8119. /* pcm configuration: identiacal with ALC880 */
  8120. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8121. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8122. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8123. /*
  8124. * BIOS auto configuration
  8125. */
  8126. static int alc268_parse_auto_config(struct hda_codec *codec)
  8127. {
  8128. struct alc_spec *spec = codec->spec;
  8129. int err;
  8130. static hda_nid_t alc268_ignore[] = { 0 };
  8131. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8132. alc268_ignore);
  8133. if (err < 0)
  8134. return err;
  8135. if (!spec->autocfg.line_outs)
  8136. return 0; /* can't find valid BIOS pin config */
  8137. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8138. if (err < 0)
  8139. return err;
  8140. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8141. if (err < 0)
  8142. return err;
  8143. spec->multiout.max_channels = 2;
  8144. /* digital only support output */
  8145. if (spec->autocfg.dig_out_pin)
  8146. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8147. if (spec->kctl_alloc)
  8148. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8149. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8150. spec->num_mux_defs = 1;
  8151. spec->input_mux = &spec->private_imux;
  8152. err = alc_auto_add_mic_boost(codec);
  8153. if (err < 0)
  8154. return err;
  8155. return 1;
  8156. }
  8157. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8158. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8159. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8160. /* init callback for auto-configuration model -- overriding the default init */
  8161. static void alc268_auto_init(struct hda_codec *codec)
  8162. {
  8163. alc268_auto_init_multi_out(codec);
  8164. alc268_auto_init_hp_out(codec);
  8165. alc268_auto_init_mono_speaker_out(codec);
  8166. alc268_auto_init_analog_input(codec);
  8167. }
  8168. /*
  8169. * configuration and preset
  8170. */
  8171. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8172. [ALC268_3ST] = "3stack",
  8173. [ALC268_TOSHIBA] = "toshiba",
  8174. [ALC268_ACER] = "acer",
  8175. [ALC268_AUTO] = "auto",
  8176. };
  8177. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8178. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8179. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8180. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8181. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8182. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8183. {}
  8184. };
  8185. static struct alc_config_preset alc268_presets[] = {
  8186. [ALC268_3ST] = {
  8187. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8188. .init_verbs = { alc268_base_init_verbs },
  8189. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8190. .dac_nids = alc268_dac_nids,
  8191. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8192. .adc_nids = alc268_adc_nids_alt,
  8193. .hp_nid = 0x03,
  8194. .dig_out_nid = ALC268_DIGOUT_NID,
  8195. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8196. .channel_mode = alc268_modes,
  8197. .input_mux = &alc268_capture_source,
  8198. },
  8199. [ALC268_TOSHIBA] = {
  8200. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8201. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8202. alc268_toshiba_verbs },
  8203. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8204. .dac_nids = alc268_dac_nids,
  8205. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8206. .adc_nids = alc268_adc_nids_alt,
  8207. .hp_nid = 0x03,
  8208. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8209. .channel_mode = alc268_modes,
  8210. .input_mux = &alc268_capture_source,
  8211. .input_mux = &alc268_capture_source,
  8212. .unsol_event = alc268_toshiba_unsol_event,
  8213. .init_hook = alc268_toshiba_automute,
  8214. },
  8215. [ALC268_ACER] = {
  8216. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8217. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8218. alc268_acer_verbs },
  8219. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8220. .dac_nids = alc268_dac_nids,
  8221. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8222. .adc_nids = alc268_adc_nids_alt,
  8223. .hp_nid = 0x02,
  8224. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8225. .channel_mode = alc268_modes,
  8226. .input_mux = &alc268_capture_source,
  8227. .unsol_event = alc268_acer_unsol_event,
  8228. .init_hook = alc268_acer_init_hook,
  8229. },
  8230. };
  8231. static int patch_alc268(struct hda_codec *codec)
  8232. {
  8233. struct alc_spec *spec;
  8234. int board_config;
  8235. int err;
  8236. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8237. if (spec == NULL)
  8238. return -ENOMEM;
  8239. codec->spec = spec;
  8240. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8241. alc268_models,
  8242. alc268_cfg_tbl);
  8243. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8244. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8245. "trying auto-probe from BIOS...\n");
  8246. board_config = ALC268_AUTO;
  8247. }
  8248. if (board_config == ALC268_AUTO) {
  8249. /* automatic parse from the BIOS config */
  8250. err = alc268_parse_auto_config(codec);
  8251. if (err < 0) {
  8252. alc_free(codec);
  8253. return err;
  8254. } else if (!err) {
  8255. printk(KERN_INFO
  8256. "hda_codec: Cannot set up configuration "
  8257. "from BIOS. Using base mode...\n");
  8258. board_config = ALC268_3ST;
  8259. }
  8260. }
  8261. if (board_config != ALC268_AUTO)
  8262. setup_preset(spec, &alc268_presets[board_config]);
  8263. spec->stream_name_analog = "ALC268 Analog";
  8264. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8265. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8266. spec->stream_name_digital = "ALC268 Digital";
  8267. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8268. if (board_config == ALC268_AUTO) {
  8269. if (!spec->adc_nids && spec->input_mux) {
  8270. /* check whether NID 0x07 is valid */
  8271. unsigned int wcap = get_wcaps(codec, 0x07);
  8272. /* get type */
  8273. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8274. if (wcap != AC_WID_AUD_IN) {
  8275. spec->adc_nids = alc268_adc_nids_alt;
  8276. spec->num_adc_nids =
  8277. ARRAY_SIZE(alc268_adc_nids_alt);
  8278. spec->mixers[spec->num_mixers] =
  8279. alc268_capture_alt_mixer;
  8280. spec->num_mixers++;
  8281. } else {
  8282. spec->adc_nids = alc268_adc_nids;
  8283. spec->num_adc_nids =
  8284. ARRAY_SIZE(alc268_adc_nids);
  8285. spec->mixers[spec->num_mixers] =
  8286. alc268_capture_mixer;
  8287. spec->num_mixers++;
  8288. }
  8289. }
  8290. }
  8291. codec->patch_ops = alc_patch_ops;
  8292. if (board_config == ALC268_AUTO)
  8293. spec->init_hook = alc268_auto_init;
  8294. return 0;
  8295. }
  8296. /*
  8297. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8298. */
  8299. /*
  8300. * set the path ways for 2 channel output
  8301. * need to set the codec line out and mic 1 pin widgets to inputs
  8302. */
  8303. static struct hda_verb alc861_threestack_ch2_init[] = {
  8304. /* set pin widget 1Ah (line in) for input */
  8305. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8306. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8307. * the vref
  8308. */
  8309. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8310. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8311. #if 0
  8312. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8313. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8314. #endif
  8315. { } /* end */
  8316. };
  8317. /*
  8318. * 6ch mode
  8319. * need to set the codec line out and mic 1 pin widgets to outputs
  8320. */
  8321. static struct hda_verb alc861_threestack_ch6_init[] = {
  8322. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8323. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8324. /* set pin widget 18h (mic1) for output (CLFE)*/
  8325. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8326. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8327. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8328. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8329. #if 0
  8330. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8331. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8332. #endif
  8333. { } /* end */
  8334. };
  8335. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8336. { 2, alc861_threestack_ch2_init },
  8337. { 6, alc861_threestack_ch6_init },
  8338. };
  8339. /* Set mic1 as input and unmute the mixer */
  8340. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8341. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8342. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8343. { } /* end */
  8344. };
  8345. /* Set mic1 as output and mute mixer */
  8346. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8347. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8348. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8349. { } /* end */
  8350. };
  8351. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8352. { 2, alc861_uniwill_m31_ch2_init },
  8353. { 4, alc861_uniwill_m31_ch4_init },
  8354. };
  8355. /* Set mic1 and line-in as input and unmute the mixer */
  8356. static struct hda_verb alc861_asus_ch2_init[] = {
  8357. /* set pin widget 1Ah (line in) for input */
  8358. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8359. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8360. * the vref
  8361. */
  8362. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8363. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8364. #if 0
  8365. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8366. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8367. #endif
  8368. { } /* end */
  8369. };
  8370. /* Set mic1 nad line-in as output and mute mixer */
  8371. static struct hda_verb alc861_asus_ch6_init[] = {
  8372. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8373. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8374. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8375. /* set pin widget 18h (mic1) for output (CLFE)*/
  8376. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8377. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8378. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8379. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8380. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8381. #if 0
  8382. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8383. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8384. #endif
  8385. { } /* end */
  8386. };
  8387. static struct hda_channel_mode alc861_asus_modes[2] = {
  8388. { 2, alc861_asus_ch2_init },
  8389. { 6, alc861_asus_ch6_init },
  8390. };
  8391. /* patch-ALC861 */
  8392. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8393. /* output mixer control */
  8394. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8395. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8396. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8397. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8398. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8399. /*Input mixer control */
  8400. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8401. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8402. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8403. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8404. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8405. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8407. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8408. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8409. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8410. /* Capture mixer control */
  8411. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8412. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8413. {
  8414. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8415. .name = "Capture Source",
  8416. .count = 1,
  8417. .info = alc_mux_enum_info,
  8418. .get = alc_mux_enum_get,
  8419. .put = alc_mux_enum_put,
  8420. },
  8421. { } /* end */
  8422. };
  8423. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8424. /* output mixer control */
  8425. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8426. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8427. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8428. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8429. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8430. /* Input mixer control */
  8431. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8432. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8433. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8434. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8435. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8436. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8437. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8438. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8439. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8440. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8441. /* Capture mixer control */
  8442. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8443. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8444. {
  8445. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8446. .name = "Capture Source",
  8447. .count = 1,
  8448. .info = alc_mux_enum_info,
  8449. .get = alc_mux_enum_get,
  8450. .put = alc_mux_enum_put,
  8451. },
  8452. {
  8453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8454. .name = "Channel Mode",
  8455. .info = alc_ch_mode_info,
  8456. .get = alc_ch_mode_get,
  8457. .put = alc_ch_mode_put,
  8458. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8459. },
  8460. { } /* end */
  8461. };
  8462. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8463. /* output mixer control */
  8464. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8465. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8466. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8467. /*Capture mixer control */
  8468. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8469. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8470. {
  8471. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8472. .name = "Capture Source",
  8473. .count = 1,
  8474. .info = alc_mux_enum_info,
  8475. .get = alc_mux_enum_get,
  8476. .put = alc_mux_enum_put,
  8477. },
  8478. { } /* end */
  8479. };
  8480. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8481. /* output mixer control */
  8482. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8483. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8484. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8485. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8486. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8487. /* Input mixer control */
  8488. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8489. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8490. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8491. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8492. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8493. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8494. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8495. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8496. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8497. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8498. /* Capture mixer control */
  8499. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8500. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8501. {
  8502. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8503. .name = "Capture Source",
  8504. .count = 1,
  8505. .info = alc_mux_enum_info,
  8506. .get = alc_mux_enum_get,
  8507. .put = alc_mux_enum_put,
  8508. },
  8509. {
  8510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8511. .name = "Channel Mode",
  8512. .info = alc_ch_mode_info,
  8513. .get = alc_ch_mode_get,
  8514. .put = alc_ch_mode_put,
  8515. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8516. },
  8517. { } /* end */
  8518. };
  8519. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8520. /* output mixer control */
  8521. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8522. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8523. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8524. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8525. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8526. /* Input mixer control */
  8527. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8528. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8529. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8530. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8531. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8532. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8533. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8534. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8535. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8536. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8537. /* Capture mixer control */
  8538. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8539. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8540. {
  8541. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8542. .name = "Capture Source",
  8543. .count = 1,
  8544. .info = alc_mux_enum_info,
  8545. .get = alc_mux_enum_get,
  8546. .put = alc_mux_enum_put,
  8547. },
  8548. {
  8549. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8550. .name = "Channel Mode",
  8551. .info = alc_ch_mode_info,
  8552. .get = alc_ch_mode_get,
  8553. .put = alc_ch_mode_put,
  8554. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8555. },
  8556. { }
  8557. };
  8558. /* additional mixer */
  8559. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8560. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8561. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8562. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8563. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8564. { }
  8565. };
  8566. /*
  8567. * generic initialization of ADC, input mixers and output mixers
  8568. */
  8569. static struct hda_verb alc861_base_init_verbs[] = {
  8570. /*
  8571. * Unmute ADC0 and set the default input to mic-in
  8572. */
  8573. /* port-A for surround (rear panel) */
  8574. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8575. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8576. /* port-B for mic-in (rear panel) with vref */
  8577. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8578. /* port-C for line-in (rear panel) */
  8579. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8580. /* port-D for Front */
  8581. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8582. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8583. /* port-E for HP out (front panel) */
  8584. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8585. /* route front PCM to HP */
  8586. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8587. /* port-F for mic-in (front panel) with vref */
  8588. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8589. /* port-G for CLFE (rear panel) */
  8590. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8591. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8592. /* port-H for side (rear panel) */
  8593. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8594. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8595. /* CD-in */
  8596. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8597. /* route front mic to ADC1*/
  8598. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8599. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8600. /* Unmute DAC0~3 & spdif out*/
  8601. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8602. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8603. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8604. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8606. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8607. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8608. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8609. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8610. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8611. /* Unmute Stereo Mixer 15 */
  8612. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8613. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8614. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8615. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8616. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8617. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8618. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8619. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8620. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8621. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8622. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8623. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8624. /* hp used DAC 3 (Front) */
  8625. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8626. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8627. { }
  8628. };
  8629. static struct hda_verb alc861_threestack_init_verbs[] = {
  8630. /*
  8631. * Unmute ADC0 and set the default input to mic-in
  8632. */
  8633. /* port-A for surround (rear panel) */
  8634. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8635. /* port-B for mic-in (rear panel) with vref */
  8636. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8637. /* port-C for line-in (rear panel) */
  8638. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8639. /* port-D for Front */
  8640. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8641. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8642. /* port-E for HP out (front panel) */
  8643. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8644. /* route front PCM to HP */
  8645. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8646. /* port-F for mic-in (front panel) with vref */
  8647. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8648. /* port-G for CLFE (rear panel) */
  8649. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8650. /* port-H for side (rear panel) */
  8651. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8652. /* CD-in */
  8653. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8654. /* route front mic to ADC1*/
  8655. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8656. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8657. /* Unmute DAC0~3 & spdif out*/
  8658. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8659. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8660. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8661. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8662. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8663. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8664. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8665. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8666. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8667. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8668. /* Unmute Stereo Mixer 15 */
  8669. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8670. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8671. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8672. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8673. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8674. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8675. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8676. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8677. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8678. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8679. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8680. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8681. /* hp used DAC 3 (Front) */
  8682. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8683. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8684. { }
  8685. };
  8686. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8687. /*
  8688. * Unmute ADC0 and set the default input to mic-in
  8689. */
  8690. /* port-A for surround (rear panel) */
  8691. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8692. /* port-B for mic-in (rear panel) with vref */
  8693. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8694. /* port-C for line-in (rear panel) */
  8695. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8696. /* port-D for Front */
  8697. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8698. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8699. /* port-E for HP out (front panel) */
  8700. /* this has to be set to VREF80 */
  8701. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8702. /* route front PCM to HP */
  8703. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8704. /* port-F for mic-in (front panel) with vref */
  8705. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8706. /* port-G for CLFE (rear panel) */
  8707. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8708. /* port-H for side (rear panel) */
  8709. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8710. /* CD-in */
  8711. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8712. /* route front mic to ADC1*/
  8713. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8714. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8715. /* Unmute DAC0~3 & spdif out*/
  8716. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8717. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8718. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8719. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8720. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8721. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8722. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8723. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8724. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8725. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8726. /* Unmute Stereo Mixer 15 */
  8727. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8728. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8729. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8730. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8731. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8732. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8733. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8734. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8735. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8736. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8737. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8738. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8739. /* hp used DAC 3 (Front) */
  8740. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8741. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8742. { }
  8743. };
  8744. static struct hda_verb alc861_asus_init_verbs[] = {
  8745. /*
  8746. * Unmute ADC0 and set the default input to mic-in
  8747. */
  8748. /* port-A for surround (rear panel)
  8749. * according to codec#0 this is the HP jack
  8750. */
  8751. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8752. /* route front PCM to HP */
  8753. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8754. /* port-B for mic-in (rear panel) with vref */
  8755. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8756. /* port-C for line-in (rear panel) */
  8757. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8758. /* port-D for Front */
  8759. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8760. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8761. /* port-E for HP out (front panel) */
  8762. /* this has to be set to VREF80 */
  8763. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8764. /* route front PCM to HP */
  8765. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8766. /* port-F for mic-in (front panel) with vref */
  8767. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8768. /* port-G for CLFE (rear panel) */
  8769. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8770. /* port-H for side (rear panel) */
  8771. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8772. /* CD-in */
  8773. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8774. /* route front mic to ADC1*/
  8775. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8776. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8777. /* Unmute DAC0~3 & spdif out*/
  8778. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8779. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8780. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8781. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8782. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8783. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8784. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8785. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8786. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8787. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8788. /* Unmute Stereo Mixer 15 */
  8789. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8790. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8791. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8792. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8793. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8794. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8795. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8796. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8797. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8798. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8799. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8800. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8801. /* hp used DAC 3 (Front) */
  8802. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8803. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8804. { }
  8805. };
  8806. /* additional init verbs for ASUS laptops */
  8807. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8808. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8809. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8810. { }
  8811. };
  8812. /*
  8813. * generic initialization of ADC, input mixers and output mixers
  8814. */
  8815. static struct hda_verb alc861_auto_init_verbs[] = {
  8816. /*
  8817. * Unmute ADC0 and set the default input to mic-in
  8818. */
  8819. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8820. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8821. /* Unmute DAC0~3 & spdif out*/
  8822. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8823. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8824. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8825. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8826. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8827. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8828. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8829. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8830. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8831. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8832. /* Unmute Stereo Mixer 15 */
  8833. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8834. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8835. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8836. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8837. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8838. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8839. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8840. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8841. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8842. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8843. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8844. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8845. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8846. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8847. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8848. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8849. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8850. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8851. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8852. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8853. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8854. { }
  8855. };
  8856. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8857. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8858. { }
  8859. };
  8860. /* toggle speaker-output according to the hp-jack state */
  8861. static void alc861_toshiba_automute(struct hda_codec *codec)
  8862. {
  8863. unsigned int present;
  8864. present = snd_hda_codec_read(codec, 0x0f, 0,
  8865. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8866. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8867. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8868. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8869. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8870. }
  8871. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8872. unsigned int res)
  8873. {
  8874. if ((res >> 26) == ALC880_HP_EVENT)
  8875. alc861_toshiba_automute(codec);
  8876. }
  8877. /* pcm configuration: identiacal with ALC880 */
  8878. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8879. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8880. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8881. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8882. #define ALC861_DIGOUT_NID 0x07
  8883. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8884. { 8, NULL }
  8885. };
  8886. static hda_nid_t alc861_dac_nids[4] = {
  8887. /* front, surround, clfe, side */
  8888. 0x03, 0x06, 0x05, 0x04
  8889. };
  8890. static hda_nid_t alc660_dac_nids[3] = {
  8891. /* front, clfe, surround */
  8892. 0x03, 0x05, 0x06
  8893. };
  8894. static hda_nid_t alc861_adc_nids[1] = {
  8895. /* ADC0-2 */
  8896. 0x08,
  8897. };
  8898. static struct hda_input_mux alc861_capture_source = {
  8899. .num_items = 5,
  8900. .items = {
  8901. { "Mic", 0x0 },
  8902. { "Front Mic", 0x3 },
  8903. { "Line", 0x1 },
  8904. { "CD", 0x4 },
  8905. { "Mixer", 0x5 },
  8906. },
  8907. };
  8908. /* fill in the dac_nids table from the parsed pin configuration */
  8909. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8910. const struct auto_pin_cfg *cfg)
  8911. {
  8912. int i;
  8913. hda_nid_t nid;
  8914. spec->multiout.dac_nids = spec->private_dac_nids;
  8915. for (i = 0; i < cfg->line_outs; i++) {
  8916. nid = cfg->line_out_pins[i];
  8917. if (nid) {
  8918. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8919. continue;
  8920. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8921. }
  8922. }
  8923. spec->multiout.num_dacs = cfg->line_outs;
  8924. return 0;
  8925. }
  8926. /* add playback controls from the parsed DAC table */
  8927. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8928. const struct auto_pin_cfg *cfg)
  8929. {
  8930. char name[32];
  8931. static const char *chname[4] = {
  8932. "Front", "Surround", NULL /*CLFE*/, "Side"
  8933. };
  8934. hda_nid_t nid;
  8935. int i, idx, err;
  8936. for (i = 0; i < cfg->line_outs; i++) {
  8937. nid = spec->multiout.dac_nids[i];
  8938. if (!nid)
  8939. continue;
  8940. if (nid == 0x05) {
  8941. /* Center/LFE */
  8942. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8943. "Center Playback Switch",
  8944. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8945. HDA_OUTPUT));
  8946. if (err < 0)
  8947. return err;
  8948. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8949. "LFE Playback Switch",
  8950. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8951. HDA_OUTPUT));
  8952. if (err < 0)
  8953. return err;
  8954. } else {
  8955. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8956. idx++)
  8957. if (nid == alc861_dac_nids[idx])
  8958. break;
  8959. sprintf(name, "%s Playback Switch", chname[idx]);
  8960. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8961. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8962. HDA_OUTPUT));
  8963. if (err < 0)
  8964. return err;
  8965. }
  8966. }
  8967. return 0;
  8968. }
  8969. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8970. {
  8971. int err;
  8972. hda_nid_t nid;
  8973. if (!pin)
  8974. return 0;
  8975. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8976. nid = 0x03;
  8977. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8978. "Headphone Playback Switch",
  8979. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8980. if (err < 0)
  8981. return err;
  8982. spec->multiout.hp_nid = nid;
  8983. }
  8984. return 0;
  8985. }
  8986. /* create playback/capture controls for input pins */
  8987. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8988. const struct auto_pin_cfg *cfg)
  8989. {
  8990. struct hda_input_mux *imux = &spec->private_imux;
  8991. int i, err, idx, idx1;
  8992. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8993. switch (cfg->input_pins[i]) {
  8994. case 0x0c:
  8995. idx1 = 1;
  8996. idx = 2; /* Line In */
  8997. break;
  8998. case 0x0f:
  8999. idx1 = 2;
  9000. idx = 2; /* Line In */
  9001. break;
  9002. case 0x0d:
  9003. idx1 = 0;
  9004. idx = 1; /* Mic In */
  9005. break;
  9006. case 0x10:
  9007. idx1 = 3;
  9008. idx = 1; /* Mic In */
  9009. break;
  9010. case 0x11:
  9011. idx1 = 4;
  9012. idx = 0; /* CD */
  9013. break;
  9014. default:
  9015. continue;
  9016. }
  9017. err = new_analog_input(spec, cfg->input_pins[i],
  9018. auto_pin_cfg_labels[i], idx, 0x15);
  9019. if (err < 0)
  9020. return err;
  9021. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9022. imux->items[imux->num_items].index = idx1;
  9023. imux->num_items++;
  9024. }
  9025. return 0;
  9026. }
  9027. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9028. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9029. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9030. {
  9031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9032. /* The multiple "Capture Source" controls confuse alsamixer
  9033. * So call somewhat different..
  9034. *FIXME: the controls appear in the "playback" view!
  9035. */
  9036. /* .name = "Capture Source", */
  9037. .name = "Input Source",
  9038. .count = 1,
  9039. .info = alc_mux_enum_info,
  9040. .get = alc_mux_enum_get,
  9041. .put = alc_mux_enum_put,
  9042. },
  9043. { } /* end */
  9044. };
  9045. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9046. hda_nid_t nid,
  9047. int pin_type, int dac_idx)
  9048. {
  9049. /* set as output */
  9050. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9051. pin_type);
  9052. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9053. AMP_OUT_UNMUTE);
  9054. }
  9055. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9056. {
  9057. struct alc_spec *spec = codec->spec;
  9058. int i;
  9059. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9060. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9061. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9062. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9063. if (nid)
  9064. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9065. spec->multiout.dac_nids[i]);
  9066. }
  9067. }
  9068. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9069. {
  9070. struct alc_spec *spec = codec->spec;
  9071. hda_nid_t pin;
  9072. pin = spec->autocfg.hp_pins[0];
  9073. if (pin) /* connect to front */
  9074. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9075. spec->multiout.dac_nids[0]);
  9076. }
  9077. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9078. {
  9079. struct alc_spec *spec = codec->spec;
  9080. int i;
  9081. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9082. hda_nid_t nid = spec->autocfg.input_pins[i];
  9083. if (nid >= 0x0c && nid <= 0x11) {
  9084. snd_hda_codec_write(codec, nid, 0,
  9085. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9086. i <= AUTO_PIN_FRONT_MIC ?
  9087. PIN_VREF80 : PIN_IN);
  9088. }
  9089. }
  9090. }
  9091. /* parse the BIOS configuration and set up the alc_spec */
  9092. /* return 1 if successful, 0 if the proper config is not found,
  9093. * or a negative error code
  9094. */
  9095. static int alc861_parse_auto_config(struct hda_codec *codec)
  9096. {
  9097. struct alc_spec *spec = codec->spec;
  9098. int err;
  9099. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9100. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9101. alc861_ignore);
  9102. if (err < 0)
  9103. return err;
  9104. if (!spec->autocfg.line_outs)
  9105. return 0; /* can't find valid BIOS pin config */
  9106. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9107. if (err < 0)
  9108. return err;
  9109. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9110. if (err < 0)
  9111. return err;
  9112. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9113. if (err < 0)
  9114. return err;
  9115. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9116. if (err < 0)
  9117. return err;
  9118. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9119. if (spec->autocfg.dig_out_pin)
  9120. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9121. if (spec->kctl_alloc)
  9122. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9123. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9124. spec->num_mux_defs = 1;
  9125. spec->input_mux = &spec->private_imux;
  9126. spec->adc_nids = alc861_adc_nids;
  9127. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9128. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9129. spec->num_mixers++;
  9130. return 1;
  9131. }
  9132. /* additional initialization for auto-configuration model */
  9133. static void alc861_auto_init(struct hda_codec *codec)
  9134. {
  9135. alc861_auto_init_multi_out(codec);
  9136. alc861_auto_init_hp_out(codec);
  9137. alc861_auto_init_analog_input(codec);
  9138. }
  9139. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9140. static struct hda_amp_list alc861_loopbacks[] = {
  9141. { 0x15, HDA_INPUT, 0 },
  9142. { 0x15, HDA_INPUT, 1 },
  9143. { 0x15, HDA_INPUT, 2 },
  9144. { 0x15, HDA_INPUT, 3 },
  9145. { } /* end */
  9146. };
  9147. #endif
  9148. /*
  9149. * configuration and preset
  9150. */
  9151. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9152. [ALC861_3ST] = "3stack",
  9153. [ALC660_3ST] = "3stack-660",
  9154. [ALC861_3ST_DIG] = "3stack-dig",
  9155. [ALC861_6ST_DIG] = "6stack-dig",
  9156. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9157. [ALC861_TOSHIBA] = "toshiba",
  9158. [ALC861_ASUS] = "asus",
  9159. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9160. [ALC861_AUTO] = "auto",
  9161. };
  9162. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9163. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9164. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9165. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9166. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9167. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9168. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9169. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9170. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9171. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9172. * Any other models that need this preset?
  9173. */
  9174. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9175. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9176. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9177. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9178. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9179. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9180. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9181. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9182. {}
  9183. };
  9184. static struct alc_config_preset alc861_presets[] = {
  9185. [ALC861_3ST] = {
  9186. .mixers = { alc861_3ST_mixer },
  9187. .init_verbs = { alc861_threestack_init_verbs },
  9188. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9189. .dac_nids = alc861_dac_nids,
  9190. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9191. .channel_mode = alc861_threestack_modes,
  9192. .need_dac_fix = 1,
  9193. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9194. .adc_nids = alc861_adc_nids,
  9195. .input_mux = &alc861_capture_source,
  9196. },
  9197. [ALC861_3ST_DIG] = {
  9198. .mixers = { alc861_base_mixer },
  9199. .init_verbs = { alc861_threestack_init_verbs },
  9200. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9201. .dac_nids = alc861_dac_nids,
  9202. .dig_out_nid = ALC861_DIGOUT_NID,
  9203. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9204. .channel_mode = alc861_threestack_modes,
  9205. .need_dac_fix = 1,
  9206. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9207. .adc_nids = alc861_adc_nids,
  9208. .input_mux = &alc861_capture_source,
  9209. },
  9210. [ALC861_6ST_DIG] = {
  9211. .mixers = { alc861_base_mixer },
  9212. .init_verbs = { alc861_base_init_verbs },
  9213. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9214. .dac_nids = alc861_dac_nids,
  9215. .dig_out_nid = ALC861_DIGOUT_NID,
  9216. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9217. .channel_mode = alc861_8ch_modes,
  9218. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9219. .adc_nids = alc861_adc_nids,
  9220. .input_mux = &alc861_capture_source,
  9221. },
  9222. [ALC660_3ST] = {
  9223. .mixers = { alc861_3ST_mixer },
  9224. .init_verbs = { alc861_threestack_init_verbs },
  9225. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9226. .dac_nids = alc660_dac_nids,
  9227. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9228. .channel_mode = alc861_threestack_modes,
  9229. .need_dac_fix = 1,
  9230. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9231. .adc_nids = alc861_adc_nids,
  9232. .input_mux = &alc861_capture_source,
  9233. },
  9234. [ALC861_UNIWILL_M31] = {
  9235. .mixers = { alc861_uniwill_m31_mixer },
  9236. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9237. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9238. .dac_nids = alc861_dac_nids,
  9239. .dig_out_nid = ALC861_DIGOUT_NID,
  9240. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9241. .channel_mode = alc861_uniwill_m31_modes,
  9242. .need_dac_fix = 1,
  9243. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9244. .adc_nids = alc861_adc_nids,
  9245. .input_mux = &alc861_capture_source,
  9246. },
  9247. [ALC861_TOSHIBA] = {
  9248. .mixers = { alc861_toshiba_mixer },
  9249. .init_verbs = { alc861_base_init_verbs,
  9250. alc861_toshiba_init_verbs },
  9251. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9252. .dac_nids = alc861_dac_nids,
  9253. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9254. .channel_mode = alc883_3ST_2ch_modes,
  9255. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9256. .adc_nids = alc861_adc_nids,
  9257. .input_mux = &alc861_capture_source,
  9258. .unsol_event = alc861_toshiba_unsol_event,
  9259. .init_hook = alc861_toshiba_automute,
  9260. },
  9261. [ALC861_ASUS] = {
  9262. .mixers = { alc861_asus_mixer },
  9263. .init_verbs = { alc861_asus_init_verbs },
  9264. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9265. .dac_nids = alc861_dac_nids,
  9266. .dig_out_nid = ALC861_DIGOUT_NID,
  9267. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9268. .channel_mode = alc861_asus_modes,
  9269. .need_dac_fix = 1,
  9270. .hp_nid = 0x06,
  9271. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9272. .adc_nids = alc861_adc_nids,
  9273. .input_mux = &alc861_capture_source,
  9274. },
  9275. [ALC861_ASUS_LAPTOP] = {
  9276. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9277. .init_verbs = { alc861_asus_init_verbs,
  9278. alc861_asus_laptop_init_verbs },
  9279. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9280. .dac_nids = alc861_dac_nids,
  9281. .dig_out_nid = ALC861_DIGOUT_NID,
  9282. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9283. .channel_mode = alc883_3ST_2ch_modes,
  9284. .need_dac_fix = 1,
  9285. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9286. .adc_nids = alc861_adc_nids,
  9287. .input_mux = &alc861_capture_source,
  9288. },
  9289. };
  9290. static int patch_alc861(struct hda_codec *codec)
  9291. {
  9292. struct alc_spec *spec;
  9293. int board_config;
  9294. int err;
  9295. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9296. if (spec == NULL)
  9297. return -ENOMEM;
  9298. codec->spec = spec;
  9299. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9300. alc861_models,
  9301. alc861_cfg_tbl);
  9302. if (board_config < 0) {
  9303. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9304. "trying auto-probe from BIOS...\n");
  9305. board_config = ALC861_AUTO;
  9306. }
  9307. if (board_config == ALC861_AUTO) {
  9308. /* automatic parse from the BIOS config */
  9309. err = alc861_parse_auto_config(codec);
  9310. if (err < 0) {
  9311. alc_free(codec);
  9312. return err;
  9313. } else if (!err) {
  9314. printk(KERN_INFO
  9315. "hda_codec: Cannot set up configuration "
  9316. "from BIOS. Using base mode...\n");
  9317. board_config = ALC861_3ST_DIG;
  9318. }
  9319. }
  9320. if (board_config != ALC861_AUTO)
  9321. setup_preset(spec, &alc861_presets[board_config]);
  9322. spec->stream_name_analog = "ALC861 Analog";
  9323. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9324. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9325. spec->stream_name_digital = "ALC861 Digital";
  9326. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9327. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9328. codec->patch_ops = alc_patch_ops;
  9329. if (board_config == ALC861_AUTO)
  9330. spec->init_hook = alc861_auto_init;
  9331. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9332. if (!spec->loopback.amplist)
  9333. spec->loopback.amplist = alc861_loopbacks;
  9334. #endif
  9335. return 0;
  9336. }
  9337. /*
  9338. * ALC861-VD support
  9339. *
  9340. * Based on ALC882
  9341. *
  9342. * In addition, an independent DAC
  9343. */
  9344. #define ALC861VD_DIGOUT_NID 0x06
  9345. static hda_nid_t alc861vd_dac_nids[4] = {
  9346. /* front, surr, clfe, side surr */
  9347. 0x02, 0x03, 0x04, 0x05
  9348. };
  9349. /* dac_nids for ALC660vd are in a different order - according to
  9350. * Realtek's driver.
  9351. * This should probably tesult in a different mixer for 6stack models
  9352. * of ALC660vd codecs, but for now there is only 3stack mixer
  9353. * - and it is the same as in 861vd.
  9354. * adc_nids in ALC660vd are (is) the same as in 861vd
  9355. */
  9356. static hda_nid_t alc660vd_dac_nids[3] = {
  9357. /* front, rear, clfe, rear_surr */
  9358. 0x02, 0x04, 0x03
  9359. };
  9360. static hda_nid_t alc861vd_adc_nids[1] = {
  9361. /* ADC0 */
  9362. 0x09,
  9363. };
  9364. /* input MUX */
  9365. /* FIXME: should be a matrix-type input source selection */
  9366. static struct hda_input_mux alc861vd_capture_source = {
  9367. .num_items = 4,
  9368. .items = {
  9369. { "Mic", 0x0 },
  9370. { "Front Mic", 0x1 },
  9371. { "Line", 0x2 },
  9372. { "CD", 0x4 },
  9373. },
  9374. };
  9375. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9376. .num_items = 3,
  9377. .items = {
  9378. { "Front Mic", 0x0 },
  9379. { "ATAPI Mic", 0x1 },
  9380. { "Line In", 0x5 },
  9381. },
  9382. };
  9383. static struct hda_input_mux alc861vd_hp_capture_source = {
  9384. .num_items = 2,
  9385. .items = {
  9386. { "Front Mic", 0x0 },
  9387. { "ATAPI Mic", 0x1 },
  9388. },
  9389. };
  9390. #define alc861vd_mux_enum_info alc_mux_enum_info
  9391. #define alc861vd_mux_enum_get alc_mux_enum_get
  9392. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9393. struct snd_ctl_elem_value *ucontrol)
  9394. {
  9395. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9396. struct alc_spec *spec = codec->spec;
  9397. const struct hda_input_mux *imux = spec->input_mux;
  9398. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9399. static hda_nid_t capture_mixers[1] = { 0x22 };
  9400. hda_nid_t nid = capture_mixers[adc_idx];
  9401. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9402. unsigned int i, idx;
  9403. idx = ucontrol->value.enumerated.item[0];
  9404. if (idx >= imux->num_items)
  9405. idx = imux->num_items - 1;
  9406. if (*cur_val == idx)
  9407. return 0;
  9408. for (i = 0; i < imux->num_items; i++) {
  9409. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9410. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9411. imux->items[i].index,
  9412. HDA_AMP_MUTE, v);
  9413. }
  9414. *cur_val = idx;
  9415. return 1;
  9416. }
  9417. /*
  9418. * 2ch mode
  9419. */
  9420. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9421. { 2, NULL }
  9422. };
  9423. /*
  9424. * 6ch mode
  9425. */
  9426. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9427. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9428. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9429. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9430. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9431. { } /* end */
  9432. };
  9433. /*
  9434. * 8ch mode
  9435. */
  9436. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9437. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9438. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9439. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9440. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9441. { } /* end */
  9442. };
  9443. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9444. { 6, alc861vd_6stack_ch6_init },
  9445. { 8, alc861vd_6stack_ch8_init },
  9446. };
  9447. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9448. {
  9449. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9450. .name = "Channel Mode",
  9451. .info = alc_ch_mode_info,
  9452. .get = alc_ch_mode_get,
  9453. .put = alc_ch_mode_put,
  9454. },
  9455. { } /* end */
  9456. };
  9457. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9458. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9459. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9460. {
  9461. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9462. /* The multiple "Capture Source" controls confuse alsamixer
  9463. * So call somewhat different..
  9464. *FIXME: the controls appear in the "playback" view!
  9465. */
  9466. /* .name = "Capture Source", */
  9467. .name = "Input Source",
  9468. .count = 1,
  9469. .info = alc861vd_mux_enum_info,
  9470. .get = alc861vd_mux_enum_get,
  9471. .put = alc861vd_mux_enum_put,
  9472. },
  9473. { } /* end */
  9474. };
  9475. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9476. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9477. */
  9478. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9479. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9480. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9481. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9482. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9483. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9484. HDA_OUTPUT),
  9485. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9486. HDA_OUTPUT),
  9487. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9488. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9489. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9490. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9491. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9492. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9493. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9494. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9495. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9496. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9497. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9498. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9499. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9500. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9501. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9502. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9503. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9504. { } /* end */
  9505. };
  9506. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9507. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9508. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9509. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9510. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9511. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9512. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9513. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9514. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9515. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9516. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9517. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9518. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9519. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9520. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9521. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9522. { } /* end */
  9523. };
  9524. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9525. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9526. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9527. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9528. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9529. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9530. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9531. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9532. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9533. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9534. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9535. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9536. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9537. { } /* end */
  9538. };
  9539. /* Pin assignment: Front=0x14, HP = 0x15,
  9540. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9541. */
  9542. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9543. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9544. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9545. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9546. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9547. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9548. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9549. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9550. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9551. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9552. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9553. { } /* end */
  9554. };
  9555. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9556. * Front Mic=0x18, ATAPI Mic = 0x19,
  9557. */
  9558. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9559. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9560. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9561. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9562. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9563. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9564. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9565. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9566. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9567. { } /* end */
  9568. };
  9569. /*
  9570. * generic initialization of ADC, input mixers and output mixers
  9571. */
  9572. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9573. /*
  9574. * Unmute ADC0 and set the default input to mic-in
  9575. */
  9576. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9577. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9578. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9579. * the analog-loopback mixer widget
  9580. */
  9581. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9582. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9583. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9584. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9586. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9587. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9588. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9589. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9590. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9591. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9592. /*
  9593. * Set up output mixers (0x02 - 0x05)
  9594. */
  9595. /* set vol=0 to output mixers */
  9596. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9597. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9598. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9599. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9600. /* set up input amps for analog loopback */
  9601. /* Amp Indices: DAC = 0, mixer = 1 */
  9602. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9604. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9605. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9606. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9607. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9608. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9609. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9610. { }
  9611. };
  9612. /*
  9613. * 3-stack pin configuration:
  9614. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9615. */
  9616. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9617. /*
  9618. * Set pin mode and muting
  9619. */
  9620. /* set front pin widgets 0x14 for output */
  9621. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9622. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9623. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9624. /* Mic (rear) pin: input vref at 80% */
  9625. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9626. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9627. /* Front Mic pin: input vref at 80% */
  9628. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9629. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9630. /* Line In pin: input */
  9631. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9632. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9633. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9634. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9635. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9636. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9637. /* CD pin widget for input */
  9638. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9639. { }
  9640. };
  9641. /*
  9642. * 6-stack pin configuration:
  9643. */
  9644. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9645. /*
  9646. * Set pin mode and muting
  9647. */
  9648. /* set front pin widgets 0x14 for output */
  9649. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9650. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9651. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9652. /* Rear Pin: output 1 (0x0d) */
  9653. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9654. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9655. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9656. /* CLFE Pin: output 2 (0x0e) */
  9657. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9658. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9659. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9660. /* Side Pin: output 3 (0x0f) */
  9661. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9662. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9663. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9664. /* Mic (rear) pin: input vref at 80% */
  9665. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9666. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9667. /* Front Mic pin: input vref at 80% */
  9668. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9669. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9670. /* Line In pin: input */
  9671. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9672. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9673. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9674. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9675. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9676. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9677. /* CD pin widget for input */
  9678. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9679. { }
  9680. };
  9681. static struct hda_verb alc861vd_eapd_verbs[] = {
  9682. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9683. { }
  9684. };
  9685. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9686. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9687. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9688. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9689. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9690. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9691. {}
  9692. };
  9693. /* toggle speaker-output according to the hp-jack state */
  9694. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9695. {
  9696. unsigned int present;
  9697. unsigned char bits;
  9698. present = snd_hda_codec_read(codec, 0x1b, 0,
  9699. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9700. bits = present ? HDA_AMP_MUTE : 0;
  9701. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9702. HDA_AMP_MUTE, bits);
  9703. }
  9704. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9705. {
  9706. unsigned int present;
  9707. unsigned char bits;
  9708. present = snd_hda_codec_read(codec, 0x18, 0,
  9709. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9710. bits = present ? HDA_AMP_MUTE : 0;
  9711. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9712. HDA_AMP_MUTE, bits);
  9713. }
  9714. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9715. {
  9716. alc861vd_lenovo_hp_automute(codec);
  9717. alc861vd_lenovo_mic_automute(codec);
  9718. }
  9719. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9720. unsigned int res)
  9721. {
  9722. switch (res >> 26) {
  9723. case ALC880_HP_EVENT:
  9724. alc861vd_lenovo_hp_automute(codec);
  9725. break;
  9726. case ALC880_MIC_EVENT:
  9727. alc861vd_lenovo_mic_automute(codec);
  9728. break;
  9729. }
  9730. }
  9731. static struct hda_verb alc861vd_dallas_verbs[] = {
  9732. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9733. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9734. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9735. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9736. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9737. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9738. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9739. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9740. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9741. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9742. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9743. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9744. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9745. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9746. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9748. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9750. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9751. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9752. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9753. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9754. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9755. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9756. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9757. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9758. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9759. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9760. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9761. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9762. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9763. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9764. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9765. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9766. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9767. { } /* end */
  9768. };
  9769. /* toggle speaker-output according to the hp-jack state */
  9770. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9771. {
  9772. unsigned int present;
  9773. present = snd_hda_codec_read(codec, 0x15, 0,
  9774. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9775. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9776. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9777. }
  9778. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9779. {
  9780. if ((res >> 26) == ALC880_HP_EVENT)
  9781. alc861vd_dallas_automute(codec);
  9782. }
  9783. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9784. #define alc861vd_loopbacks alc880_loopbacks
  9785. #endif
  9786. /* pcm configuration: identiacal with ALC880 */
  9787. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9788. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9789. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9790. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9791. /*
  9792. * configuration and preset
  9793. */
  9794. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9795. [ALC660VD_3ST] = "3stack-660",
  9796. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9797. [ALC861VD_3ST] = "3stack",
  9798. [ALC861VD_3ST_DIG] = "3stack-digout",
  9799. [ALC861VD_6ST_DIG] = "6stack-digout",
  9800. [ALC861VD_LENOVO] = "lenovo",
  9801. [ALC861VD_DALLAS] = "dallas",
  9802. [ALC861VD_HP] = "hp",
  9803. [ALC861VD_AUTO] = "auto",
  9804. };
  9805. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9806. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9807. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9808. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9809. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9810. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9811. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9812. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9813. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9814. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9815. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9816. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9817. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9818. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9819. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9820. {}
  9821. };
  9822. static struct alc_config_preset alc861vd_presets[] = {
  9823. [ALC660VD_3ST] = {
  9824. .mixers = { alc861vd_3st_mixer },
  9825. .init_verbs = { alc861vd_volume_init_verbs,
  9826. alc861vd_3stack_init_verbs },
  9827. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9828. .dac_nids = alc660vd_dac_nids,
  9829. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9830. .adc_nids = alc861vd_adc_nids,
  9831. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9832. .channel_mode = alc861vd_3stack_2ch_modes,
  9833. .input_mux = &alc861vd_capture_source,
  9834. },
  9835. [ALC660VD_3ST_DIG] = {
  9836. .mixers = { alc861vd_3st_mixer },
  9837. .init_verbs = { alc861vd_volume_init_verbs,
  9838. alc861vd_3stack_init_verbs },
  9839. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9840. .dac_nids = alc660vd_dac_nids,
  9841. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9842. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9843. .adc_nids = alc861vd_adc_nids,
  9844. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9845. .channel_mode = alc861vd_3stack_2ch_modes,
  9846. .input_mux = &alc861vd_capture_source,
  9847. },
  9848. [ALC861VD_3ST] = {
  9849. .mixers = { alc861vd_3st_mixer },
  9850. .init_verbs = { alc861vd_volume_init_verbs,
  9851. alc861vd_3stack_init_verbs },
  9852. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9853. .dac_nids = alc861vd_dac_nids,
  9854. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9855. .channel_mode = alc861vd_3stack_2ch_modes,
  9856. .input_mux = &alc861vd_capture_source,
  9857. },
  9858. [ALC861VD_3ST_DIG] = {
  9859. .mixers = { alc861vd_3st_mixer },
  9860. .init_verbs = { alc861vd_volume_init_verbs,
  9861. alc861vd_3stack_init_verbs },
  9862. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9863. .dac_nids = alc861vd_dac_nids,
  9864. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9865. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9866. .channel_mode = alc861vd_3stack_2ch_modes,
  9867. .input_mux = &alc861vd_capture_source,
  9868. },
  9869. [ALC861VD_6ST_DIG] = {
  9870. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9871. .init_verbs = { alc861vd_volume_init_verbs,
  9872. alc861vd_6stack_init_verbs },
  9873. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9874. .dac_nids = alc861vd_dac_nids,
  9875. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9876. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9877. .channel_mode = alc861vd_6stack_modes,
  9878. .input_mux = &alc861vd_capture_source,
  9879. },
  9880. [ALC861VD_LENOVO] = {
  9881. .mixers = { alc861vd_lenovo_mixer },
  9882. .init_verbs = { alc861vd_volume_init_verbs,
  9883. alc861vd_3stack_init_verbs,
  9884. alc861vd_eapd_verbs,
  9885. alc861vd_lenovo_unsol_verbs },
  9886. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9887. .dac_nids = alc660vd_dac_nids,
  9888. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9889. .adc_nids = alc861vd_adc_nids,
  9890. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9891. .channel_mode = alc861vd_3stack_2ch_modes,
  9892. .input_mux = &alc861vd_capture_source,
  9893. .unsol_event = alc861vd_lenovo_unsol_event,
  9894. .init_hook = alc861vd_lenovo_automute,
  9895. },
  9896. [ALC861VD_DALLAS] = {
  9897. .mixers = { alc861vd_dallas_mixer },
  9898. .init_verbs = { alc861vd_dallas_verbs },
  9899. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9900. .dac_nids = alc861vd_dac_nids,
  9901. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9902. .adc_nids = alc861vd_adc_nids,
  9903. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9904. .channel_mode = alc861vd_3stack_2ch_modes,
  9905. .input_mux = &alc861vd_dallas_capture_source,
  9906. .unsol_event = alc861vd_dallas_unsol_event,
  9907. .init_hook = alc861vd_dallas_automute,
  9908. },
  9909. [ALC861VD_HP] = {
  9910. .mixers = { alc861vd_hp_mixer },
  9911. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9912. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9913. .dac_nids = alc861vd_dac_nids,
  9914. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9915. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9916. .adc_nids = alc861vd_adc_nids,
  9917. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9918. .channel_mode = alc861vd_3stack_2ch_modes,
  9919. .input_mux = &alc861vd_hp_capture_source,
  9920. .unsol_event = alc861vd_dallas_unsol_event,
  9921. .init_hook = alc861vd_dallas_automute,
  9922. },
  9923. };
  9924. /*
  9925. * BIOS auto configuration
  9926. */
  9927. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9928. hda_nid_t nid, int pin_type, int dac_idx)
  9929. {
  9930. /* set as output */
  9931. snd_hda_codec_write(codec, nid, 0,
  9932. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9933. snd_hda_codec_write(codec, nid, 0,
  9934. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9935. }
  9936. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9937. {
  9938. struct alc_spec *spec = codec->spec;
  9939. int i;
  9940. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9941. for (i = 0; i <= HDA_SIDE; i++) {
  9942. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9943. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9944. if (nid)
  9945. alc861vd_auto_set_output_and_unmute(codec, nid,
  9946. pin_type, i);
  9947. }
  9948. }
  9949. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9950. {
  9951. struct alc_spec *spec = codec->spec;
  9952. hda_nid_t pin;
  9953. pin = spec->autocfg.hp_pins[0];
  9954. if (pin) /* connect to front and use dac 0 */
  9955. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9956. }
  9957. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9958. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9959. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9960. {
  9961. struct alc_spec *spec = codec->spec;
  9962. int i;
  9963. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9964. hda_nid_t nid = spec->autocfg.input_pins[i];
  9965. if (alc861vd_is_input_pin(nid)) {
  9966. snd_hda_codec_write(codec, nid, 0,
  9967. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9968. i <= AUTO_PIN_FRONT_MIC ?
  9969. PIN_VREF80 : PIN_IN);
  9970. if (nid != ALC861VD_PIN_CD_NID)
  9971. snd_hda_codec_write(codec, nid, 0,
  9972. AC_VERB_SET_AMP_GAIN_MUTE,
  9973. AMP_OUT_MUTE);
  9974. }
  9975. }
  9976. }
  9977. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9978. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9979. /* add playback controls from the parsed DAC table */
  9980. /* Based on ALC880 version. But ALC861VD has separate,
  9981. * different NIDs for mute/unmute switch and volume control */
  9982. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9983. const struct auto_pin_cfg *cfg)
  9984. {
  9985. char name[32];
  9986. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9987. hda_nid_t nid_v, nid_s;
  9988. int i, err;
  9989. for (i = 0; i < cfg->line_outs; i++) {
  9990. if (!spec->multiout.dac_nids[i])
  9991. continue;
  9992. nid_v = alc861vd_idx_to_mixer_vol(
  9993. alc880_dac_to_idx(
  9994. spec->multiout.dac_nids[i]));
  9995. nid_s = alc861vd_idx_to_mixer_switch(
  9996. alc880_dac_to_idx(
  9997. spec->multiout.dac_nids[i]));
  9998. if (i == 2) {
  9999. /* Center/LFE */
  10000. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10001. "Center Playback Volume",
  10002. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10003. HDA_OUTPUT));
  10004. if (err < 0)
  10005. return err;
  10006. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10007. "LFE Playback Volume",
  10008. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10009. HDA_OUTPUT));
  10010. if (err < 0)
  10011. return err;
  10012. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10013. "Center Playback Switch",
  10014. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10015. HDA_INPUT));
  10016. if (err < 0)
  10017. return err;
  10018. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10019. "LFE Playback Switch",
  10020. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10021. HDA_INPUT));
  10022. if (err < 0)
  10023. return err;
  10024. } else {
  10025. sprintf(name, "%s Playback Volume", chname[i]);
  10026. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10027. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10028. HDA_OUTPUT));
  10029. if (err < 0)
  10030. return err;
  10031. sprintf(name, "%s Playback Switch", chname[i]);
  10032. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10033. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10034. HDA_INPUT));
  10035. if (err < 0)
  10036. return err;
  10037. }
  10038. }
  10039. return 0;
  10040. }
  10041. /* add playback controls for speaker and HP outputs */
  10042. /* Based on ALC880 version. But ALC861VD has separate,
  10043. * different NIDs for mute/unmute switch and volume control */
  10044. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10045. hda_nid_t pin, const char *pfx)
  10046. {
  10047. hda_nid_t nid_v, nid_s;
  10048. int err;
  10049. char name[32];
  10050. if (!pin)
  10051. return 0;
  10052. if (alc880_is_fixed_pin(pin)) {
  10053. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10054. /* specify the DAC as the extra output */
  10055. if (!spec->multiout.hp_nid)
  10056. spec->multiout.hp_nid = nid_v;
  10057. else
  10058. spec->multiout.extra_out_nid[0] = nid_v;
  10059. /* control HP volume/switch on the output mixer amp */
  10060. nid_v = alc861vd_idx_to_mixer_vol(
  10061. alc880_fixed_pin_idx(pin));
  10062. nid_s = alc861vd_idx_to_mixer_switch(
  10063. alc880_fixed_pin_idx(pin));
  10064. sprintf(name, "%s Playback Volume", pfx);
  10065. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10066. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10067. if (err < 0)
  10068. return err;
  10069. sprintf(name, "%s Playback Switch", pfx);
  10070. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10071. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10072. if (err < 0)
  10073. return err;
  10074. } else if (alc880_is_multi_pin(pin)) {
  10075. /* set manual connection */
  10076. /* we have only a switch on HP-out PIN */
  10077. sprintf(name, "%s Playback Switch", pfx);
  10078. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10079. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10080. if (err < 0)
  10081. return err;
  10082. }
  10083. return 0;
  10084. }
  10085. /* parse the BIOS configuration and set up the alc_spec
  10086. * return 1 if successful, 0 if the proper config is not found,
  10087. * or a negative error code
  10088. * Based on ALC880 version - had to change it to override
  10089. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10090. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10091. {
  10092. struct alc_spec *spec = codec->spec;
  10093. int err;
  10094. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10095. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10096. alc861vd_ignore);
  10097. if (err < 0)
  10098. return err;
  10099. if (!spec->autocfg.line_outs)
  10100. return 0; /* can't find valid BIOS pin config */
  10101. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10102. if (err < 0)
  10103. return err;
  10104. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10105. if (err < 0)
  10106. return err;
  10107. err = alc861vd_auto_create_extra_out(spec,
  10108. spec->autocfg.speaker_pins[0],
  10109. "Speaker");
  10110. if (err < 0)
  10111. return err;
  10112. err = alc861vd_auto_create_extra_out(spec,
  10113. spec->autocfg.hp_pins[0],
  10114. "Headphone");
  10115. if (err < 0)
  10116. return err;
  10117. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10118. if (err < 0)
  10119. return err;
  10120. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10121. if (spec->autocfg.dig_out_pin)
  10122. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10123. if (spec->kctl_alloc)
  10124. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10125. spec->init_verbs[spec->num_init_verbs++]
  10126. = alc861vd_volume_init_verbs;
  10127. spec->num_mux_defs = 1;
  10128. spec->input_mux = &spec->private_imux;
  10129. err = alc_auto_add_mic_boost(codec);
  10130. if (err < 0)
  10131. return err;
  10132. return 1;
  10133. }
  10134. /* additional initialization for auto-configuration model */
  10135. static void alc861vd_auto_init(struct hda_codec *codec)
  10136. {
  10137. alc861vd_auto_init_multi_out(codec);
  10138. alc861vd_auto_init_hp_out(codec);
  10139. alc861vd_auto_init_analog_input(codec);
  10140. }
  10141. static int patch_alc861vd(struct hda_codec *codec)
  10142. {
  10143. struct alc_spec *spec;
  10144. int err, board_config;
  10145. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10146. if (spec == NULL)
  10147. return -ENOMEM;
  10148. codec->spec = spec;
  10149. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10150. alc861vd_models,
  10151. alc861vd_cfg_tbl);
  10152. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10153. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10154. "ALC861VD, trying auto-probe from BIOS...\n");
  10155. board_config = ALC861VD_AUTO;
  10156. }
  10157. if (board_config == ALC861VD_AUTO) {
  10158. /* automatic parse from the BIOS config */
  10159. err = alc861vd_parse_auto_config(codec);
  10160. if (err < 0) {
  10161. alc_free(codec);
  10162. return err;
  10163. } else if (!err) {
  10164. printk(KERN_INFO
  10165. "hda_codec: Cannot set up configuration "
  10166. "from BIOS. Using base mode...\n");
  10167. board_config = ALC861VD_3ST;
  10168. }
  10169. }
  10170. if (board_config != ALC861VD_AUTO)
  10171. setup_preset(spec, &alc861vd_presets[board_config]);
  10172. spec->stream_name_analog = "ALC861VD Analog";
  10173. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10174. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10175. spec->stream_name_digital = "ALC861VD Digital";
  10176. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10177. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10178. spec->adc_nids = alc861vd_adc_nids;
  10179. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10180. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10181. spec->num_mixers++;
  10182. codec->patch_ops = alc_patch_ops;
  10183. if (board_config == ALC861VD_AUTO)
  10184. spec->init_hook = alc861vd_auto_init;
  10185. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10186. if (!spec->loopback.amplist)
  10187. spec->loopback.amplist = alc861vd_loopbacks;
  10188. #endif
  10189. return 0;
  10190. }
  10191. /*
  10192. * ALC662 support
  10193. *
  10194. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10195. * configuration. Each pin widget can choose any input DACs and a mixer.
  10196. * Each ADC is connected from a mixer of all inputs. This makes possible
  10197. * 6-channel independent captures.
  10198. *
  10199. * In addition, an independent DAC for the multi-playback (not used in this
  10200. * driver yet).
  10201. */
  10202. #define ALC662_DIGOUT_NID 0x06
  10203. #define ALC662_DIGIN_NID 0x0a
  10204. static hda_nid_t alc662_dac_nids[4] = {
  10205. /* front, rear, clfe, rear_surr */
  10206. 0x02, 0x03, 0x04
  10207. };
  10208. static hda_nid_t alc662_adc_nids[1] = {
  10209. /* ADC1-2 */
  10210. 0x09,
  10211. };
  10212. /* input MUX */
  10213. /* FIXME: should be a matrix-type input source selection */
  10214. static struct hda_input_mux alc662_capture_source = {
  10215. .num_items = 4,
  10216. .items = {
  10217. { "Mic", 0x0 },
  10218. { "Front Mic", 0x1 },
  10219. { "Line", 0x2 },
  10220. { "CD", 0x4 },
  10221. },
  10222. };
  10223. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10224. .num_items = 2,
  10225. .items = {
  10226. { "Mic", 0x1 },
  10227. { "Line", 0x2 },
  10228. },
  10229. };
  10230. #define alc662_mux_enum_info alc_mux_enum_info
  10231. #define alc662_mux_enum_get alc_mux_enum_get
  10232. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10233. struct snd_ctl_elem_value *ucontrol)
  10234. {
  10235. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10236. struct alc_spec *spec = codec->spec;
  10237. const struct hda_input_mux *imux = spec->input_mux;
  10238. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10239. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10240. hda_nid_t nid = capture_mixers[adc_idx];
  10241. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10242. unsigned int i, idx;
  10243. idx = ucontrol->value.enumerated.item[0];
  10244. if (idx >= imux->num_items)
  10245. idx = imux->num_items - 1;
  10246. if (*cur_val == idx)
  10247. return 0;
  10248. for (i = 0; i < imux->num_items; i++) {
  10249. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10250. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10251. imux->items[i].index,
  10252. HDA_AMP_MUTE, v);
  10253. }
  10254. *cur_val = idx;
  10255. return 1;
  10256. }
  10257. /*
  10258. * 2ch mode
  10259. */
  10260. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10261. { 2, NULL }
  10262. };
  10263. /*
  10264. * 2ch mode
  10265. */
  10266. static struct hda_verb alc662_3ST_ch2_init[] = {
  10267. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10268. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10269. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10270. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10271. { } /* end */
  10272. };
  10273. /*
  10274. * 6ch mode
  10275. */
  10276. static struct hda_verb alc662_3ST_ch6_init[] = {
  10277. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10278. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10279. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10280. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10281. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10282. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10283. { } /* end */
  10284. };
  10285. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10286. { 2, alc662_3ST_ch2_init },
  10287. { 6, alc662_3ST_ch6_init },
  10288. };
  10289. /*
  10290. * 2ch mode
  10291. */
  10292. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10293. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10294. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10295. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10296. { } /* end */
  10297. };
  10298. /*
  10299. * 6ch mode
  10300. */
  10301. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10302. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10303. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10304. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10305. { } /* end */
  10306. };
  10307. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10308. { 2, alc662_sixstack_ch6_init },
  10309. { 6, alc662_sixstack_ch8_init },
  10310. };
  10311. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10312. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10313. */
  10314. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10315. /* output mixer control */
  10316. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10317. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10318. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10319. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10320. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10321. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10322. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10323. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10324. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10325. /*Input mixer control */
  10326. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10327. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10328. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10329. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10330. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10331. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10332. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10333. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10334. /* Capture mixer control */
  10335. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10336. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10337. {
  10338. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10339. .name = "Capture Source",
  10340. .count = 1,
  10341. .info = alc_mux_enum_info,
  10342. .get = alc_mux_enum_get,
  10343. .put = alc_mux_enum_put,
  10344. },
  10345. { } /* end */
  10346. };
  10347. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10348. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10349. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10350. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10351. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10352. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10353. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10354. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10355. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10356. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10357. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10358. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10359. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10360. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10361. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10362. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10363. {
  10364. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10365. /* .name = "Capture Source", */
  10366. .name = "Input Source",
  10367. .count = 1,
  10368. .info = alc662_mux_enum_info,
  10369. .get = alc662_mux_enum_get,
  10370. .put = alc662_mux_enum_put,
  10371. },
  10372. { } /* end */
  10373. };
  10374. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10375. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10376. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10377. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10378. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10379. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10380. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10381. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10382. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10383. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10384. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10385. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10386. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10387. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10388. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10389. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10390. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10391. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10392. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10393. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10394. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10395. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10396. {
  10397. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10398. /* .name = "Capture Source", */
  10399. .name = "Input Source",
  10400. .count = 1,
  10401. .info = alc662_mux_enum_info,
  10402. .get = alc662_mux_enum_get,
  10403. .put = alc662_mux_enum_put,
  10404. },
  10405. { } /* end */
  10406. };
  10407. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10408. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10409. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10410. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10411. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10412. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10413. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10414. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10415. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10416. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10417. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10418. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10419. {
  10420. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10421. /* .name = "Capture Source", */
  10422. .name = "Input Source",
  10423. .count = 1,
  10424. .info = alc662_mux_enum_info,
  10425. .get = alc662_mux_enum_get,
  10426. .put = alc662_mux_enum_put,
  10427. },
  10428. { } /* end */
  10429. };
  10430. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10431. {
  10432. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10433. .name = "Channel Mode",
  10434. .info = alc_ch_mode_info,
  10435. .get = alc_ch_mode_get,
  10436. .put = alc_ch_mode_put,
  10437. },
  10438. { } /* end */
  10439. };
  10440. static struct hda_verb alc662_init_verbs[] = {
  10441. /* ADC: mute amp left and right */
  10442. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10443. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10444. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10445. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10446. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10447. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10448. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10449. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10450. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10451. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10452. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10453. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10454. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10455. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10456. /* Front Pin: output 0 (0x0c) */
  10457. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10458. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10459. /* Rear Pin: output 1 (0x0d) */
  10460. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10461. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10462. /* CLFE Pin: output 2 (0x0e) */
  10463. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10464. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10465. /* Mic (rear) pin: input vref at 80% */
  10466. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10467. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10468. /* Front Mic pin: input vref at 80% */
  10469. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10470. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10471. /* Line In pin: input */
  10472. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10473. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10474. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10475. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10476. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10477. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10478. /* CD pin widget for input */
  10479. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10480. /* FIXME: use matrix-type input source selection */
  10481. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10482. /* Input mixer */
  10483. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10484. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10485. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10486. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10487. { }
  10488. };
  10489. static struct hda_verb alc662_sue_init_verbs[] = {
  10490. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10491. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10492. {}
  10493. };
  10494. /*
  10495. * generic initialization of ADC, input mixers and output mixers
  10496. */
  10497. static struct hda_verb alc662_auto_init_verbs[] = {
  10498. /*
  10499. * Unmute ADC and set the default input to mic-in
  10500. */
  10501. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10503. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10504. * mixer widget
  10505. * Note: PASD motherboards uses the Line In 2 as the input for front
  10506. * panel mic (mic 2)
  10507. */
  10508. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10509. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10510. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10511. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10512. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10513. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10514. /*
  10515. * Set up output mixers (0x0c - 0x0f)
  10516. */
  10517. /* set vol=0 to output mixers */
  10518. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10519. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10520. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10521. /* set up input amps for analog loopback */
  10522. /* Amp Indices: DAC = 0, mixer = 1 */
  10523. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10524. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10525. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10526. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10527. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10528. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10529. /* FIXME: use matrix-type input source selection */
  10530. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10531. /* Input mixer */
  10532. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10533. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10534. { }
  10535. };
  10536. /* capture mixer elements */
  10537. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10538. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10539. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10540. {
  10541. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10542. /* The multiple "Capture Source" controls confuse alsamixer
  10543. * So call somewhat different..
  10544. * FIXME: the controls appear in the "playback" view!
  10545. */
  10546. /* .name = "Capture Source", */
  10547. .name = "Input Source",
  10548. .count = 1,
  10549. .info = alc882_mux_enum_info,
  10550. .get = alc882_mux_enum_get,
  10551. .put = alc882_mux_enum_put,
  10552. },
  10553. { } /* end */
  10554. };
  10555. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10556. {
  10557. unsigned int present;
  10558. unsigned char bits;
  10559. present = snd_hda_codec_read(codec, 0x14, 0,
  10560. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10561. bits = present ? HDA_AMP_MUTE : 0;
  10562. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10563. HDA_AMP_MUTE, bits);
  10564. }
  10565. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10566. {
  10567. unsigned int present;
  10568. unsigned char bits;
  10569. present = snd_hda_codec_read(codec, 0x1b, 0,
  10570. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10571. bits = present ? HDA_AMP_MUTE : 0;
  10572. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10573. HDA_AMP_MUTE, bits);
  10574. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10575. HDA_AMP_MUTE, bits);
  10576. }
  10577. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10578. unsigned int res)
  10579. {
  10580. if ((res >> 26) == ALC880_HP_EVENT)
  10581. alc662_lenovo_101e_all_automute(codec);
  10582. if ((res >> 26) == ALC880_FRONT_EVENT)
  10583. alc662_lenovo_101e_ispeaker_automute(codec);
  10584. }
  10585. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10586. #define alc662_loopbacks alc880_loopbacks
  10587. #endif
  10588. /* pcm configuration: identiacal with ALC880 */
  10589. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10590. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10591. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10592. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10593. /*
  10594. * configuration and preset
  10595. */
  10596. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10597. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10598. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10599. [ALC662_3ST_6ch] = "3stack-6ch",
  10600. [ALC662_5ST_DIG] = "6stack-dig",
  10601. [ALC662_LENOVO_101E] = "lenovo-101e",
  10602. [ALC662_AUTO] = "auto",
  10603. };
  10604. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10605. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10606. {}
  10607. };
  10608. static struct alc_config_preset alc662_presets[] = {
  10609. [ALC662_3ST_2ch_DIG] = {
  10610. .mixers = { alc662_3ST_2ch_mixer },
  10611. .init_verbs = { alc662_init_verbs },
  10612. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10613. .dac_nids = alc662_dac_nids,
  10614. .dig_out_nid = ALC662_DIGOUT_NID,
  10615. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10616. .adc_nids = alc662_adc_nids,
  10617. .dig_in_nid = ALC662_DIGIN_NID,
  10618. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10619. .channel_mode = alc662_3ST_2ch_modes,
  10620. .input_mux = &alc662_capture_source,
  10621. },
  10622. [ALC662_3ST_6ch_DIG] = {
  10623. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10624. .init_verbs = { alc662_init_verbs },
  10625. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10626. .dac_nids = alc662_dac_nids,
  10627. .dig_out_nid = ALC662_DIGOUT_NID,
  10628. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10629. .adc_nids = alc662_adc_nids,
  10630. .dig_in_nid = ALC662_DIGIN_NID,
  10631. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10632. .channel_mode = alc662_3ST_6ch_modes,
  10633. .need_dac_fix = 1,
  10634. .input_mux = &alc662_capture_source,
  10635. },
  10636. [ALC662_3ST_6ch] = {
  10637. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10638. .init_verbs = { alc662_init_verbs },
  10639. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10640. .dac_nids = alc662_dac_nids,
  10641. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10642. .adc_nids = alc662_adc_nids,
  10643. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10644. .channel_mode = alc662_3ST_6ch_modes,
  10645. .need_dac_fix = 1,
  10646. .input_mux = &alc662_capture_source,
  10647. },
  10648. [ALC662_5ST_DIG] = {
  10649. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10650. .init_verbs = { alc662_init_verbs },
  10651. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10652. .dac_nids = alc662_dac_nids,
  10653. .dig_out_nid = ALC662_DIGOUT_NID,
  10654. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10655. .adc_nids = alc662_adc_nids,
  10656. .dig_in_nid = ALC662_DIGIN_NID,
  10657. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10658. .channel_mode = alc662_5stack_modes,
  10659. .input_mux = &alc662_capture_source,
  10660. },
  10661. [ALC662_LENOVO_101E] = {
  10662. .mixers = { alc662_lenovo_101e_mixer },
  10663. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10664. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10665. .dac_nids = alc662_dac_nids,
  10666. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10667. .adc_nids = alc662_adc_nids,
  10668. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10669. .channel_mode = alc662_3ST_2ch_modes,
  10670. .input_mux = &alc662_lenovo_101e_capture_source,
  10671. .unsol_event = alc662_lenovo_101e_unsol_event,
  10672. .init_hook = alc662_lenovo_101e_all_automute,
  10673. },
  10674. };
  10675. /*
  10676. * BIOS auto configuration
  10677. */
  10678. /* add playback controls from the parsed DAC table */
  10679. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10680. const struct auto_pin_cfg *cfg)
  10681. {
  10682. char name[32];
  10683. static const char *chname[4] = {
  10684. "Front", "Surround", NULL /*CLFE*/, "Side"
  10685. };
  10686. hda_nid_t nid;
  10687. int i, err;
  10688. for (i = 0; i < cfg->line_outs; i++) {
  10689. if (!spec->multiout.dac_nids[i])
  10690. continue;
  10691. nid = alc880_idx_to_mixer(i);
  10692. if (i == 2) {
  10693. /* Center/LFE */
  10694. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10695. "Center Playback Volume",
  10696. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10697. HDA_OUTPUT));
  10698. if (err < 0)
  10699. return err;
  10700. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10701. "LFE Playback Volume",
  10702. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10703. HDA_OUTPUT));
  10704. if (err < 0)
  10705. return err;
  10706. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10707. "Center Playback Switch",
  10708. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10709. HDA_INPUT));
  10710. if (err < 0)
  10711. return err;
  10712. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10713. "LFE Playback Switch",
  10714. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10715. HDA_INPUT));
  10716. if (err < 0)
  10717. return err;
  10718. } else {
  10719. sprintf(name, "%s Playback Volume", chname[i]);
  10720. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10721. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10722. HDA_OUTPUT));
  10723. if (err < 0)
  10724. return err;
  10725. sprintf(name, "%s Playback Switch", chname[i]);
  10726. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10727. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10728. HDA_INPUT));
  10729. if (err < 0)
  10730. return err;
  10731. }
  10732. }
  10733. return 0;
  10734. }
  10735. /* add playback controls for speaker and HP outputs */
  10736. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10737. const char *pfx)
  10738. {
  10739. hda_nid_t nid;
  10740. int err;
  10741. char name[32];
  10742. if (!pin)
  10743. return 0;
  10744. if (alc880_is_fixed_pin(pin)) {
  10745. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10746. /* printk("DAC nid=%x\n",nid); */
  10747. /* specify the DAC as the extra output */
  10748. if (!spec->multiout.hp_nid)
  10749. spec->multiout.hp_nid = nid;
  10750. else
  10751. spec->multiout.extra_out_nid[0] = nid;
  10752. /* control HP volume/switch on the output mixer amp */
  10753. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10754. sprintf(name, "%s Playback Volume", pfx);
  10755. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10756. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10757. if (err < 0)
  10758. return err;
  10759. sprintf(name, "%s Playback Switch", pfx);
  10760. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10761. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10762. if (err < 0)
  10763. return err;
  10764. } else if (alc880_is_multi_pin(pin)) {
  10765. /* set manual connection */
  10766. /* we have only a switch on HP-out PIN */
  10767. sprintf(name, "%s Playback Switch", pfx);
  10768. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10769. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10770. if (err < 0)
  10771. return err;
  10772. }
  10773. return 0;
  10774. }
  10775. /* create playback/capture controls for input pins */
  10776. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10777. const struct auto_pin_cfg *cfg)
  10778. {
  10779. struct hda_input_mux *imux = &spec->private_imux;
  10780. int i, err, idx;
  10781. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10782. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10783. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10784. err = new_analog_input(spec, cfg->input_pins[i],
  10785. auto_pin_cfg_labels[i],
  10786. idx, 0x0b);
  10787. if (err < 0)
  10788. return err;
  10789. imux->items[imux->num_items].label =
  10790. auto_pin_cfg_labels[i];
  10791. imux->items[imux->num_items].index =
  10792. alc880_input_pin_idx(cfg->input_pins[i]);
  10793. imux->num_items++;
  10794. }
  10795. }
  10796. return 0;
  10797. }
  10798. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10799. hda_nid_t nid, int pin_type,
  10800. int dac_idx)
  10801. {
  10802. /* set as output */
  10803. snd_hda_codec_write(codec, nid, 0,
  10804. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10805. snd_hda_codec_write(codec, nid, 0,
  10806. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10807. /* need the manual connection? */
  10808. if (alc880_is_multi_pin(nid)) {
  10809. struct alc_spec *spec = codec->spec;
  10810. int idx = alc880_multi_pin_idx(nid);
  10811. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10812. AC_VERB_SET_CONNECT_SEL,
  10813. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10814. }
  10815. }
  10816. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10817. {
  10818. struct alc_spec *spec = codec->spec;
  10819. int i;
  10820. for (i = 0; i <= HDA_SIDE; i++) {
  10821. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10822. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10823. if (nid)
  10824. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10825. i);
  10826. }
  10827. }
  10828. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10829. {
  10830. struct alc_spec *spec = codec->spec;
  10831. hda_nid_t pin;
  10832. pin = spec->autocfg.hp_pins[0];
  10833. if (pin) /* connect to front */
  10834. /* use dac 0 */
  10835. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10836. }
  10837. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10838. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10839. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10840. {
  10841. struct alc_spec *spec = codec->spec;
  10842. int i;
  10843. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10844. hda_nid_t nid = spec->autocfg.input_pins[i];
  10845. if (alc662_is_input_pin(nid)) {
  10846. snd_hda_codec_write(codec, nid, 0,
  10847. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10848. (i <= AUTO_PIN_FRONT_MIC ?
  10849. PIN_VREF80 : PIN_IN));
  10850. if (nid != ALC662_PIN_CD_NID)
  10851. snd_hda_codec_write(codec, nid, 0,
  10852. AC_VERB_SET_AMP_GAIN_MUTE,
  10853. AMP_OUT_MUTE);
  10854. }
  10855. }
  10856. }
  10857. static int alc662_parse_auto_config(struct hda_codec *codec)
  10858. {
  10859. struct alc_spec *spec = codec->spec;
  10860. int err;
  10861. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10862. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10863. alc662_ignore);
  10864. if (err < 0)
  10865. return err;
  10866. if (!spec->autocfg.line_outs)
  10867. return 0; /* can't find valid BIOS pin config */
  10868. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10869. if (err < 0)
  10870. return err;
  10871. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10872. if (err < 0)
  10873. return err;
  10874. err = alc662_auto_create_extra_out(spec,
  10875. spec->autocfg.speaker_pins[0],
  10876. "Speaker");
  10877. if (err < 0)
  10878. return err;
  10879. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10880. "Headphone");
  10881. if (err < 0)
  10882. return err;
  10883. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10884. if (err < 0)
  10885. return err;
  10886. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10887. if (spec->autocfg.dig_out_pin)
  10888. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10889. if (spec->kctl_alloc)
  10890. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10891. spec->num_mux_defs = 1;
  10892. spec->input_mux = &spec->private_imux;
  10893. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10894. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10895. spec->num_mixers++;
  10896. return 1;
  10897. }
  10898. /* additional initialization for auto-configuration model */
  10899. static void alc662_auto_init(struct hda_codec *codec)
  10900. {
  10901. alc662_auto_init_multi_out(codec);
  10902. alc662_auto_init_hp_out(codec);
  10903. alc662_auto_init_analog_input(codec);
  10904. }
  10905. static int patch_alc662(struct hda_codec *codec)
  10906. {
  10907. struct alc_spec *spec;
  10908. int err, board_config;
  10909. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10910. if (!spec)
  10911. return -ENOMEM;
  10912. codec->spec = spec;
  10913. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10914. alc662_models,
  10915. alc662_cfg_tbl);
  10916. if (board_config < 0) {
  10917. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10918. "trying auto-probe from BIOS...\n");
  10919. board_config = ALC662_AUTO;
  10920. }
  10921. if (board_config == ALC662_AUTO) {
  10922. /* automatic parse from the BIOS config */
  10923. err = alc662_parse_auto_config(codec);
  10924. if (err < 0) {
  10925. alc_free(codec);
  10926. return err;
  10927. } else if (!err) {
  10928. printk(KERN_INFO
  10929. "hda_codec: Cannot set up configuration "
  10930. "from BIOS. Using base mode...\n");
  10931. board_config = ALC662_3ST_2ch_DIG;
  10932. }
  10933. }
  10934. if (board_config != ALC662_AUTO)
  10935. setup_preset(spec, &alc662_presets[board_config]);
  10936. spec->stream_name_analog = "ALC662 Analog";
  10937. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10938. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10939. spec->stream_name_digital = "ALC662 Digital";
  10940. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10941. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10942. if (!spec->adc_nids && spec->input_mux) {
  10943. spec->adc_nids = alc662_adc_nids;
  10944. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10945. }
  10946. codec->patch_ops = alc_patch_ops;
  10947. if (board_config == ALC662_AUTO)
  10948. spec->init_hook = alc662_auto_init;
  10949. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10950. if (!spec->loopback.amplist)
  10951. spec->loopback.amplist = alc662_loopbacks;
  10952. #endif
  10953. return 0;
  10954. }
  10955. /*
  10956. * patch entries
  10957. */
  10958. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10959. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10960. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10961. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10962. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10963. .patch = patch_alc861 },
  10964. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10965. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10966. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10967. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10968. .patch = patch_alc883 },
  10969. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10970. .patch = patch_alc662 },
  10971. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10972. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10973. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10974. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10975. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10976. {} /* terminator */
  10977. };