patch_realtek.c 386 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686
  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_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC885_IMAC24,
  147. ALC882_AUTO,
  148. ALC882_MODEL_LAST,
  149. };
  150. /* ALC883 models */
  151. enum {
  152. ALC883_3ST_2ch_DIG,
  153. ALC883_3ST_6ch_DIG,
  154. ALC883_3ST_6ch,
  155. ALC883_6ST_DIG,
  156. ALC883_TARGA_DIG,
  157. ALC883_TARGA_2ch_DIG,
  158. ALC883_ACER,
  159. ALC883_ACER_ASPIRE,
  160. ALC883_MEDION,
  161. ALC883_MEDION_MD2,
  162. ALC883_LAPTOP_EAPD,
  163. ALC883_LENOVO_101E_2ch,
  164. ALC883_LENOVO_NB0763,
  165. ALC888_LENOVO_MS7195_DIG,
  166. ALC888_6ST_HP,
  167. ALC888_3ST_HP,
  168. ALC883_AUTO,
  169. ALC883_MODEL_LAST,
  170. };
  171. /* for GPIO Poll */
  172. #define GPIO_MASK 0x03
  173. struct alc_spec {
  174. /* codec parameterization */
  175. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  176. unsigned int num_mixers;
  177. const struct hda_verb *init_verbs[5]; /* initialization verbs
  178. * don't forget NULL
  179. * termination!
  180. */
  181. unsigned int num_init_verbs;
  182. char *stream_name_analog; /* analog PCM stream */
  183. struct hda_pcm_stream *stream_analog_playback;
  184. struct hda_pcm_stream *stream_analog_capture;
  185. char *stream_name_digital; /* digital PCM stream */
  186. struct hda_pcm_stream *stream_digital_playback;
  187. struct hda_pcm_stream *stream_digital_capture;
  188. /* playback */
  189. struct hda_multi_out multiout; /* playback set-up
  190. * max_channels, dacs must be set
  191. * dig_out_nid and hp_nid are optional
  192. */
  193. /* capture */
  194. unsigned int num_adc_nids;
  195. hda_nid_t *adc_nids;
  196. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  197. /* capture source */
  198. unsigned int num_mux_defs;
  199. const struct hda_input_mux *input_mux;
  200. unsigned int cur_mux[3];
  201. /* channel model */
  202. const struct hda_channel_mode *channel_mode;
  203. int num_channel_mode;
  204. int need_dac_fix;
  205. /* PCM information */
  206. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  207. /* dynamic controls, init_verbs and input_mux */
  208. struct auto_pin_cfg autocfg;
  209. unsigned int num_kctl_alloc, num_kctl_used;
  210. struct snd_kcontrol_new *kctl_alloc;
  211. struct hda_input_mux private_imux;
  212. hda_nid_t private_dac_nids[5];
  213. /* hooks */
  214. void (*init_hook)(struct hda_codec *codec);
  215. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  216. /* for pin sensing */
  217. unsigned int sense_updated: 1;
  218. unsigned int jack_present: 1;
  219. #ifdef CONFIG_SND_HDA_POWER_SAVE
  220. struct hda_loopback_check loopback;
  221. #endif
  222. };
  223. /*
  224. * configuration template - to be copied to the spec instance
  225. */
  226. struct alc_config_preset {
  227. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  228. * with spec
  229. */
  230. const struct hda_verb *init_verbs[5];
  231. unsigned int num_dacs;
  232. hda_nid_t *dac_nids;
  233. hda_nid_t dig_out_nid; /* optional */
  234. hda_nid_t hp_nid; /* optional */
  235. unsigned int num_adc_nids;
  236. hda_nid_t *adc_nids;
  237. hda_nid_t dig_in_nid;
  238. unsigned int num_channel_mode;
  239. const struct hda_channel_mode *channel_mode;
  240. int need_dac_fix;
  241. unsigned int num_mux_defs;
  242. const struct hda_input_mux *input_mux;
  243. void (*unsol_event)(struct hda_codec *, unsigned int);
  244. void (*init_hook)(struct hda_codec *);
  245. #ifdef CONFIG_SND_HDA_POWER_SAVE
  246. struct hda_amp_list *loopbacks;
  247. #endif
  248. };
  249. /*
  250. * input MUX handling
  251. */
  252. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  253. struct snd_ctl_elem_info *uinfo)
  254. {
  255. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  256. struct alc_spec *spec = codec->spec;
  257. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  258. if (mux_idx >= spec->num_mux_defs)
  259. mux_idx = 0;
  260. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  261. }
  262. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  263. struct snd_ctl_elem_value *ucontrol)
  264. {
  265. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  266. struct alc_spec *spec = codec->spec;
  267. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  268. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  269. return 0;
  270. }
  271. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  272. struct snd_ctl_elem_value *ucontrol)
  273. {
  274. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  275. struct alc_spec *spec = codec->spec;
  276. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  277. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  278. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  279. spec->adc_nids[adc_idx],
  280. &spec->cur_mux[adc_idx]);
  281. }
  282. /*
  283. * channel mode setting
  284. */
  285. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  286. struct snd_ctl_elem_info *uinfo)
  287. {
  288. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  289. struct alc_spec *spec = codec->spec;
  290. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  291. spec->num_channel_mode);
  292. }
  293. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  294. struct snd_ctl_elem_value *ucontrol)
  295. {
  296. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  297. struct alc_spec *spec = codec->spec;
  298. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  299. spec->num_channel_mode,
  300. spec->multiout.max_channels);
  301. }
  302. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  303. struct snd_ctl_elem_value *ucontrol)
  304. {
  305. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  306. struct alc_spec *spec = codec->spec;
  307. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  308. spec->num_channel_mode,
  309. &spec->multiout.max_channels);
  310. if (err >= 0 && spec->need_dac_fix)
  311. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  312. return err;
  313. }
  314. /*
  315. * Control the mode of pin widget settings via the mixer. "pc" is used
  316. * instead of "%" to avoid consequences of accidently treating the % as
  317. * being part of a format specifier. Maximum allowed length of a value is
  318. * 63 characters plus NULL terminator.
  319. *
  320. * Note: some retasking pin complexes seem to ignore requests for input
  321. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  322. * are requested. Therefore order this list so that this behaviour will not
  323. * cause problems when mixer clients move through the enum sequentially.
  324. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  325. * March 2006.
  326. */
  327. static char *alc_pin_mode_names[] = {
  328. "Mic 50pc bias", "Mic 80pc bias",
  329. "Line in", "Line out", "Headphone out",
  330. };
  331. static unsigned char alc_pin_mode_values[] = {
  332. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  333. };
  334. /* The control can present all 5 options, or it can limit the options based
  335. * in the pin being assumed to be exclusively an input or an output pin. In
  336. * addition, "input" pins may or may not process the mic bias option
  337. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  338. * accept requests for bias as of chip versions up to March 2006) and/or
  339. * wiring in the computer.
  340. */
  341. #define ALC_PIN_DIR_IN 0x00
  342. #define ALC_PIN_DIR_OUT 0x01
  343. #define ALC_PIN_DIR_INOUT 0x02
  344. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  345. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  346. /* Info about the pin modes supported by the different pin direction modes.
  347. * For each direction the minimum and maximum values are given.
  348. */
  349. static signed char alc_pin_mode_dir_info[5][2] = {
  350. { 0, 2 }, /* ALC_PIN_DIR_IN */
  351. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  352. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  353. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  354. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  355. };
  356. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  357. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  358. #define alc_pin_mode_n_items(_dir) \
  359. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  360. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  361. struct snd_ctl_elem_info *uinfo)
  362. {
  363. unsigned int item_num = uinfo->value.enumerated.item;
  364. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  365. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  366. uinfo->count = 1;
  367. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  368. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  369. item_num = alc_pin_mode_min(dir);
  370. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  371. return 0;
  372. }
  373. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  374. struct snd_ctl_elem_value *ucontrol)
  375. {
  376. unsigned int i;
  377. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  378. hda_nid_t nid = kcontrol->private_value & 0xffff;
  379. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  380. long *valp = ucontrol->value.integer.value;
  381. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  382. AC_VERB_GET_PIN_WIDGET_CONTROL,
  383. 0x00);
  384. /* Find enumerated value for current pinctl setting */
  385. i = alc_pin_mode_min(dir);
  386. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  387. i++;
  388. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  389. return 0;
  390. }
  391. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  392. struct snd_ctl_elem_value *ucontrol)
  393. {
  394. signed int change;
  395. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  396. hda_nid_t nid = kcontrol->private_value & 0xffff;
  397. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  398. long val = *ucontrol->value.integer.value;
  399. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  400. AC_VERB_GET_PIN_WIDGET_CONTROL,
  401. 0x00);
  402. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  403. val = alc_pin_mode_min(dir);
  404. change = pinctl != alc_pin_mode_values[val];
  405. if (change) {
  406. /* Set pin mode to that requested */
  407. snd_hda_codec_write_cache(codec, nid, 0,
  408. AC_VERB_SET_PIN_WIDGET_CONTROL,
  409. alc_pin_mode_values[val]);
  410. /* Also enable the retasking pin's input/output as required
  411. * for the requested pin mode. Enum values of 2 or less are
  412. * input modes.
  413. *
  414. * Dynamically switching the input/output buffers probably
  415. * reduces noise slightly (particularly on input) so we'll
  416. * do it. However, having both input and output buffers
  417. * enabled simultaneously doesn't seem to be problematic if
  418. * this turns out to be necessary in the future.
  419. */
  420. if (val <= 2) {
  421. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  422. HDA_AMP_MUTE, HDA_AMP_MUTE);
  423. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  424. HDA_AMP_MUTE, 0);
  425. } else {
  426. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  427. HDA_AMP_MUTE, HDA_AMP_MUTE);
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  429. HDA_AMP_MUTE, 0);
  430. }
  431. }
  432. return change;
  433. }
  434. #define ALC_PIN_MODE(xname, nid, dir) \
  435. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  436. .info = alc_pin_mode_info, \
  437. .get = alc_pin_mode_get, \
  438. .put = alc_pin_mode_put, \
  439. .private_value = nid | (dir<<16) }
  440. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  441. * together using a mask with more than one bit set. This control is
  442. * currently used only by the ALC260 test model. At this stage they are not
  443. * needed for any "production" models.
  444. */
  445. #ifdef CONFIG_SND_DEBUG
  446. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  447. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  448. struct snd_ctl_elem_value *ucontrol)
  449. {
  450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  451. hda_nid_t nid = kcontrol->private_value & 0xffff;
  452. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  453. long *valp = ucontrol->value.integer.value;
  454. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_GPIO_DATA, 0x00);
  456. *valp = (val & mask) != 0;
  457. return 0;
  458. }
  459. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  460. struct snd_ctl_elem_value *ucontrol)
  461. {
  462. signed int change;
  463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  464. hda_nid_t nid = kcontrol->private_value & 0xffff;
  465. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  466. long val = *ucontrol->value.integer.value;
  467. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_GPIO_DATA,
  469. 0x00);
  470. /* Set/unset the masked GPIO bit(s) as needed */
  471. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  472. if (val == 0)
  473. gpio_data &= ~mask;
  474. else
  475. gpio_data |= mask;
  476. snd_hda_codec_write_cache(codec, nid, 0,
  477. AC_VERB_SET_GPIO_DATA, gpio_data);
  478. return change;
  479. }
  480. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  481. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  482. .info = alc_gpio_data_info, \
  483. .get = alc_gpio_data_get, \
  484. .put = alc_gpio_data_put, \
  485. .private_value = nid | (mask<<16) }
  486. #endif /* CONFIG_SND_DEBUG */
  487. /* A switch control to allow the enabling of the digital IO pins on the
  488. * ALC260. This is incredibly simplistic; the intention of this control is
  489. * to provide something in the test model allowing digital outputs to be
  490. * identified if present. If models are found which can utilise these
  491. * outputs a more complete mixer control can be devised for those models if
  492. * necessary.
  493. */
  494. #ifdef CONFIG_SND_DEBUG
  495. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  496. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  497. struct snd_ctl_elem_value *ucontrol)
  498. {
  499. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  500. hda_nid_t nid = kcontrol->private_value & 0xffff;
  501. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  502. long *valp = ucontrol->value.integer.value;
  503. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  504. AC_VERB_GET_DIGI_CONVERT, 0x00);
  505. *valp = (val & mask) != 0;
  506. return 0;
  507. }
  508. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  509. struct snd_ctl_elem_value *ucontrol)
  510. {
  511. signed int change;
  512. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  513. hda_nid_t nid = kcontrol->private_value & 0xffff;
  514. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  515. long val = *ucontrol->value.integer.value;
  516. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  517. AC_VERB_GET_DIGI_CONVERT,
  518. 0x00);
  519. /* Set/unset the masked control bit(s) as needed */
  520. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  521. if (val==0)
  522. ctrl_data &= ~mask;
  523. else
  524. ctrl_data |= mask;
  525. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  526. ctrl_data);
  527. return change;
  528. }
  529. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  530. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  531. .info = alc_spdif_ctrl_info, \
  532. .get = alc_spdif_ctrl_get, \
  533. .put = alc_spdif_ctrl_put, \
  534. .private_value = nid | (mask<<16) }
  535. #endif /* CONFIG_SND_DEBUG */
  536. /*
  537. * set up from the preset table
  538. */
  539. static void setup_preset(struct alc_spec *spec,
  540. const struct alc_config_preset *preset)
  541. {
  542. int i;
  543. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  544. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  545. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  546. i++)
  547. spec->init_verbs[spec->num_init_verbs++] =
  548. preset->init_verbs[i];
  549. spec->channel_mode = preset->channel_mode;
  550. spec->num_channel_mode = preset->num_channel_mode;
  551. spec->need_dac_fix = preset->need_dac_fix;
  552. spec->multiout.max_channels = spec->channel_mode[0].channels;
  553. spec->multiout.num_dacs = preset->num_dacs;
  554. spec->multiout.dac_nids = preset->dac_nids;
  555. spec->multiout.dig_out_nid = preset->dig_out_nid;
  556. spec->multiout.hp_nid = preset->hp_nid;
  557. spec->num_mux_defs = preset->num_mux_defs;
  558. if (!spec->num_mux_defs)
  559. spec->num_mux_defs = 1;
  560. spec->input_mux = preset->input_mux;
  561. spec->num_adc_nids = preset->num_adc_nids;
  562. spec->adc_nids = preset->adc_nids;
  563. spec->dig_in_nid = preset->dig_in_nid;
  564. spec->unsol_event = preset->unsol_event;
  565. spec->init_hook = preset->init_hook;
  566. #ifdef CONFIG_SND_HDA_POWER_SAVE
  567. spec->loopback.amplist = preset->loopbacks;
  568. #endif
  569. }
  570. /* Enable GPIO mask and set output */
  571. static struct hda_verb alc_gpio1_init_verbs[] = {
  572. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  573. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  574. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  575. { }
  576. };
  577. static struct hda_verb alc_gpio2_init_verbs[] = {
  578. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  579. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  580. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  581. { }
  582. };
  583. static struct hda_verb alc_gpio3_init_verbs[] = {
  584. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  585. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  586. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  587. { }
  588. };
  589. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  590. * 31 ~ 16 : Manufacture ID
  591. * 15 ~ 8 : SKU ID
  592. * 7 ~ 0 : Assembly ID
  593. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  594. */
  595. static void alc_subsystem_id(struct hda_codec *codec,
  596. unsigned int porta, unsigned int porte,
  597. unsigned int portd)
  598. {
  599. unsigned int ass, tmp;
  600. ass = codec->subsystem_id;
  601. if (!(ass & 1))
  602. return;
  603. /* Override */
  604. tmp = (ass & 0x38) >> 3; /* external Amp control */
  605. switch (tmp) {
  606. case 1:
  607. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  608. break;
  609. case 3:
  610. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  611. break;
  612. case 7:
  613. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  614. break;
  615. case 5:
  616. switch (codec->vendor_id) {
  617. case 0x10ec0862:
  618. case 0x10ec0660:
  619. case 0x10ec0662:
  620. case 0x10ec0267:
  621. case 0x10ec0268:
  622. snd_hda_codec_write(codec, 0x14, 0,
  623. AC_VERB_SET_EAPD_BTLENABLE, 2);
  624. snd_hda_codec_write(codec, 0x15, 0,
  625. AC_VERB_SET_EAPD_BTLENABLE, 2);
  626. return;
  627. }
  628. case 6:
  629. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  630. hda_nid_t port = 0;
  631. tmp = (ass & 0x1800) >> 11;
  632. switch (tmp) {
  633. case 0: port = porta; break;
  634. case 1: port = porte; break;
  635. case 2: port = portd; break;
  636. }
  637. if (port)
  638. snd_hda_codec_write(codec, port, 0,
  639. AC_VERB_SET_EAPD_BTLENABLE,
  640. 2);
  641. }
  642. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  643. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  644. (tmp == 5 ? 0x3040 : 0x3050));
  645. break;
  646. }
  647. }
  648. /*
  649. * Fix-up pin default configurations
  650. */
  651. struct alc_pincfg {
  652. hda_nid_t nid;
  653. u32 val;
  654. };
  655. static void alc_fix_pincfg(struct hda_codec *codec,
  656. const struct snd_pci_quirk *quirk,
  657. const struct alc_pincfg **pinfix)
  658. {
  659. const struct alc_pincfg *cfg;
  660. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  661. if (!quirk)
  662. return;
  663. cfg = pinfix[quirk->value];
  664. for (; cfg->nid; cfg++) {
  665. int i;
  666. u32 val = cfg->val;
  667. for (i = 0; i < 4; i++) {
  668. snd_hda_codec_write(codec, cfg->nid, 0,
  669. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  670. val & 0xff);
  671. val >>= 8;
  672. }
  673. }
  674. }
  675. /*
  676. * ALC880 3-stack model
  677. *
  678. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  679. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  680. * F-Mic = 0x1b, HP = 0x19
  681. */
  682. static hda_nid_t alc880_dac_nids[4] = {
  683. /* front, rear, clfe, rear_surr */
  684. 0x02, 0x05, 0x04, 0x03
  685. };
  686. static hda_nid_t alc880_adc_nids[3] = {
  687. /* ADC0-2 */
  688. 0x07, 0x08, 0x09,
  689. };
  690. /* The datasheet says the node 0x07 is connected from inputs,
  691. * but it shows zero connection in the real implementation on some devices.
  692. * Note: this is a 915GAV bug, fixed on 915GLV
  693. */
  694. static hda_nid_t alc880_adc_nids_alt[2] = {
  695. /* ADC1-2 */
  696. 0x08, 0x09,
  697. };
  698. #define ALC880_DIGOUT_NID 0x06
  699. #define ALC880_DIGIN_NID 0x0a
  700. static struct hda_input_mux alc880_capture_source = {
  701. .num_items = 4,
  702. .items = {
  703. { "Mic", 0x0 },
  704. { "Front Mic", 0x3 },
  705. { "Line", 0x2 },
  706. { "CD", 0x4 },
  707. },
  708. };
  709. /* channel source setting (2/6 channel selection for 3-stack) */
  710. /* 2ch mode */
  711. static struct hda_verb alc880_threestack_ch2_init[] = {
  712. /* set line-in to input, mute it */
  713. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  714. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  715. /* set mic-in to input vref 80%, mute it */
  716. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  717. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  718. { } /* end */
  719. };
  720. /* 6ch mode */
  721. static struct hda_verb alc880_threestack_ch6_init[] = {
  722. /* set line-in to output, unmute it */
  723. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  724. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  725. /* set mic-in to output, unmute it */
  726. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  727. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  728. { } /* end */
  729. };
  730. static struct hda_channel_mode alc880_threestack_modes[2] = {
  731. { 2, alc880_threestack_ch2_init },
  732. { 6, alc880_threestack_ch6_init },
  733. };
  734. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  735. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  736. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  737. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  738. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  739. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  740. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  741. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  742. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  743. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  744. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  745. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  746. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  747. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  748. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  749. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  750. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  751. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  752. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  753. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  754. {
  755. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  756. .name = "Channel Mode",
  757. .info = alc_ch_mode_info,
  758. .get = alc_ch_mode_get,
  759. .put = alc_ch_mode_put,
  760. },
  761. { } /* end */
  762. };
  763. /* capture mixer elements */
  764. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  765. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  766. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  767. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  768. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  769. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  770. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  771. {
  772. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  773. /* The multiple "Capture Source" controls confuse alsamixer
  774. * So call somewhat different..
  775. * FIXME: the controls appear in the "playback" view!
  776. */
  777. /* .name = "Capture Source", */
  778. .name = "Input Source",
  779. .count = 3,
  780. .info = alc_mux_enum_info,
  781. .get = alc_mux_enum_get,
  782. .put = alc_mux_enum_put,
  783. },
  784. { } /* end */
  785. };
  786. /* capture mixer elements (in case NID 0x07 not available) */
  787. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  788. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  789. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  790. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  791. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  792. {
  793. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  794. /* The multiple "Capture Source" controls confuse alsamixer
  795. * So call somewhat different..
  796. * FIXME: the controls appear in the "playback" view!
  797. */
  798. /* .name = "Capture Source", */
  799. .name = "Input Source",
  800. .count = 2,
  801. .info = alc_mux_enum_info,
  802. .get = alc_mux_enum_get,
  803. .put = alc_mux_enum_put,
  804. },
  805. { } /* end */
  806. };
  807. /*
  808. * ALC880 5-stack model
  809. *
  810. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  811. * Side = 0x02 (0xd)
  812. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  813. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  814. */
  815. /* additional mixers to alc880_three_stack_mixer */
  816. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  817. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  818. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  819. { } /* end */
  820. };
  821. /* channel source setting (6/8 channel selection for 5-stack) */
  822. /* 6ch mode */
  823. static struct hda_verb alc880_fivestack_ch6_init[] = {
  824. /* set line-in to input, mute it */
  825. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  826. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  827. { } /* end */
  828. };
  829. /* 8ch mode */
  830. static struct hda_verb alc880_fivestack_ch8_init[] = {
  831. /* set line-in to output, unmute it */
  832. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  833. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  834. { } /* end */
  835. };
  836. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  837. { 6, alc880_fivestack_ch6_init },
  838. { 8, alc880_fivestack_ch8_init },
  839. };
  840. /*
  841. * ALC880 6-stack model
  842. *
  843. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  844. * Side = 0x05 (0x0f)
  845. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  846. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  847. */
  848. static hda_nid_t alc880_6st_dac_nids[4] = {
  849. /* front, rear, clfe, rear_surr */
  850. 0x02, 0x03, 0x04, 0x05
  851. };
  852. static struct hda_input_mux alc880_6stack_capture_source = {
  853. .num_items = 4,
  854. .items = {
  855. { "Mic", 0x0 },
  856. { "Front Mic", 0x1 },
  857. { "Line", 0x2 },
  858. { "CD", 0x4 },
  859. },
  860. };
  861. /* fixed 8-channels */
  862. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  863. { 8, NULL },
  864. };
  865. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  866. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  867. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  868. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  869. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  870. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  871. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  872. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  873. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  875. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  876. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  877. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  878. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  879. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  881. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  882. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  883. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  884. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  885. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  886. {
  887. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  888. .name = "Channel Mode",
  889. .info = alc_ch_mode_info,
  890. .get = alc_ch_mode_get,
  891. .put = alc_ch_mode_put,
  892. },
  893. { } /* end */
  894. };
  895. /*
  896. * ALC880 W810 model
  897. *
  898. * W810 has rear IO for:
  899. * Front (DAC 02)
  900. * Surround (DAC 03)
  901. * Center/LFE (DAC 04)
  902. * Digital out (06)
  903. *
  904. * The system also has a pair of internal speakers, and a headphone jack.
  905. * These are both connected to Line2 on the codec, hence to DAC 02.
  906. *
  907. * There is a variable resistor to control the speaker or headphone
  908. * volume. This is a hardware-only device without a software API.
  909. *
  910. * Plugging headphones in will disable the internal speakers. This is
  911. * implemented in hardware, not via the driver using jack sense. In
  912. * a similar fashion, plugging into the rear socket marked "front" will
  913. * disable both the speakers and headphones.
  914. *
  915. * For input, there's a microphone jack, and an "audio in" jack.
  916. * These may not do anything useful with this driver yet, because I
  917. * haven't setup any initialization verbs for these yet...
  918. */
  919. static hda_nid_t alc880_w810_dac_nids[3] = {
  920. /* front, rear/surround, clfe */
  921. 0x02, 0x03, 0x04
  922. };
  923. /* fixed 6 channels */
  924. static struct hda_channel_mode alc880_w810_modes[1] = {
  925. { 6, NULL }
  926. };
  927. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  928. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  929. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  930. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  931. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  932. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  933. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  934. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  936. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  937. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  938. { } /* end */
  939. };
  940. /*
  941. * Z710V model
  942. *
  943. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  944. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  945. * Line = 0x1a
  946. */
  947. static hda_nid_t alc880_z71v_dac_nids[1] = {
  948. 0x02
  949. };
  950. #define ALC880_Z71V_HP_DAC 0x03
  951. /* fixed 2 channels */
  952. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  953. { 2, NULL }
  954. };
  955. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  956. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  957. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  958. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  959. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  960. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  961. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  962. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  963. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  964. { } /* end */
  965. };
  966. /* FIXME! */
  967. /*
  968. * ALC880 F1734 model
  969. *
  970. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  971. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  972. */
  973. static hda_nid_t alc880_f1734_dac_nids[1] = {
  974. 0x03
  975. };
  976. #define ALC880_F1734_HP_DAC 0x02
  977. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  978. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  979. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  980. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  981. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  982. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  983. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  984. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  985. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  986. { } /* end */
  987. };
  988. /* FIXME! */
  989. /*
  990. * ALC880 ASUS model
  991. *
  992. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  993. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  994. * Mic = 0x18, Line = 0x1a
  995. */
  996. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  997. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  998. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  999. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1000. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1001. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1002. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1003. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1004. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1005. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1006. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1007. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1008. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1009. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1010. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1011. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1012. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1013. {
  1014. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1015. .name = "Channel Mode",
  1016. .info = alc_ch_mode_info,
  1017. .get = alc_ch_mode_get,
  1018. .put = alc_ch_mode_put,
  1019. },
  1020. { } /* end */
  1021. };
  1022. /* FIXME! */
  1023. /*
  1024. * ALC880 ASUS W1V model
  1025. *
  1026. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1027. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1028. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1029. */
  1030. /* additional mixers to alc880_asus_mixer */
  1031. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1032. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1033. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1034. { } /* end */
  1035. };
  1036. /* additional mixers to alc880_asus_mixer */
  1037. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1038. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1039. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1040. { } /* end */
  1041. };
  1042. /* TCL S700 */
  1043. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1044. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1045. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1046. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1047. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1048. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1049. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1050. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1051. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1052. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1053. {
  1054. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1055. /* The multiple "Capture Source" controls confuse alsamixer
  1056. * So call somewhat different..
  1057. * FIXME: the controls appear in the "playback" view!
  1058. */
  1059. /* .name = "Capture Source", */
  1060. .name = "Input Source",
  1061. .count = 1,
  1062. .info = alc_mux_enum_info,
  1063. .get = alc_mux_enum_get,
  1064. .put = alc_mux_enum_put,
  1065. },
  1066. { } /* end */
  1067. };
  1068. /* Uniwill */
  1069. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1070. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1071. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1072. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1073. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1074. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1075. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1077. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1079. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1081. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1082. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1083. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1085. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1087. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1088. {
  1089. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1090. .name = "Channel Mode",
  1091. .info = alc_ch_mode_info,
  1092. .get = alc_ch_mode_get,
  1093. .put = alc_ch_mode_put,
  1094. },
  1095. { } /* end */
  1096. };
  1097. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1098. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1099. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1100. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1101. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1102. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1103. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1104. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1105. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1107. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1108. { } /* end */
  1109. };
  1110. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1111. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1112. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1113. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1114. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1115. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1116. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1117. { } /* end */
  1118. };
  1119. /*
  1120. * build control elements
  1121. */
  1122. static int alc_build_controls(struct hda_codec *codec)
  1123. {
  1124. struct alc_spec *spec = codec->spec;
  1125. int err;
  1126. int i;
  1127. for (i = 0; i < spec->num_mixers; i++) {
  1128. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1129. if (err < 0)
  1130. return err;
  1131. }
  1132. if (spec->multiout.dig_out_nid) {
  1133. err = snd_hda_create_spdif_out_ctls(codec,
  1134. spec->multiout.dig_out_nid);
  1135. if (err < 0)
  1136. return err;
  1137. }
  1138. if (spec->dig_in_nid) {
  1139. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1140. if (err < 0)
  1141. return err;
  1142. }
  1143. return 0;
  1144. }
  1145. /*
  1146. * initialize the codec volumes, etc
  1147. */
  1148. /*
  1149. * generic initialization of ADC, input mixers and output mixers
  1150. */
  1151. static struct hda_verb alc880_volume_init_verbs[] = {
  1152. /*
  1153. * Unmute ADC0-2 and set the default input to mic-in
  1154. */
  1155. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1156. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1157. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1158. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1159. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1160. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1161. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1162. * mixer widget
  1163. * Note: PASD motherboards uses the Line In 2 as the input for front
  1164. * panel mic (mic 2)
  1165. */
  1166. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1167. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1168. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1169. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1170. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1171. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1174. /*
  1175. * Set up output mixers (0x0c - 0x0f)
  1176. */
  1177. /* set vol=0 to output mixers */
  1178. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1179. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1180. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1181. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1182. /* set up input amps for analog loopback */
  1183. /* Amp Indices: DAC = 0, mixer = 1 */
  1184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1189. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1190. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1191. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1192. { }
  1193. };
  1194. /*
  1195. * 3-stack pin configuration:
  1196. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1197. */
  1198. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1199. /*
  1200. * preset connection lists of input pins
  1201. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1202. */
  1203. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1204. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1205. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1206. /*
  1207. * Set pin mode and muting
  1208. */
  1209. /* set front pin widgets 0x14 for output */
  1210. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1211. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1212. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1213. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1214. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1215. /* Mic2 (as headphone out) for HP output */
  1216. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1217. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. /* Line In pin widget for input */
  1219. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1220. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1222. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1223. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1224. /* CD pin widget for input */
  1225. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. { }
  1227. };
  1228. /*
  1229. * 5-stack pin configuration:
  1230. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1231. * line-in/side = 0x1a, f-mic = 0x1b
  1232. */
  1233. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1234. /*
  1235. * preset connection lists of input pins
  1236. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1237. */
  1238. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1239. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1240. /*
  1241. * Set pin mode and muting
  1242. */
  1243. /* set pin widgets 0x14-0x17 for output */
  1244. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1245. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1246. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1247. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1248. /* unmute pins for output (no gain on this amp) */
  1249. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1250. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1251. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1252. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1254. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1255. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1256. /* Mic2 (as headphone out) for HP output */
  1257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1258. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1259. /* Line In pin widget for input */
  1260. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1261. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1262. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1263. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1264. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1265. /* CD pin widget for input */
  1266. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. { }
  1268. };
  1269. /*
  1270. * W810 pin configuration:
  1271. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1272. */
  1273. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1274. /* hphone/speaker input selector: front DAC */
  1275. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1276. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1277. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1278. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1279. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1280. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1281. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1282. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1283. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1284. { }
  1285. };
  1286. /*
  1287. * Z71V pin configuration:
  1288. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1289. */
  1290. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1291. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1292. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1293. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1294. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1295. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1296. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1297. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1298. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1299. { }
  1300. };
  1301. /*
  1302. * 6-stack pin configuration:
  1303. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1304. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1305. */
  1306. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1307. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1308. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1309. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1311. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1312. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1313. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1317. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1318. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1320. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1321. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1323. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1324. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1325. { }
  1326. };
  1327. /*
  1328. * Uniwill pin configuration:
  1329. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1330. * line = 0x1a
  1331. */
  1332. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1333. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1334. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1335. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1336. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1337. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1338. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1339. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1341. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1342. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1343. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1344. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1345. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1346. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1347. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1348. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1349. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1350. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1351. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1352. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1353. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1354. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1355. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1356. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1357. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1358. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1359. { }
  1360. };
  1361. /*
  1362. * Uniwill P53
  1363. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1364. */
  1365. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1366. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1367. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1368. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1369. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1370. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1371. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1372. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1373. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1374. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1375. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1376. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1377. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1378. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1379. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1380. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1381. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1382. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1383. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1384. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1385. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1386. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1387. { }
  1388. };
  1389. static struct hda_verb alc880_beep_init_verbs[] = {
  1390. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1391. { }
  1392. };
  1393. /* toggle speaker-output according to the hp-jack state */
  1394. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1395. {
  1396. unsigned int present;
  1397. unsigned char bits;
  1398. present = snd_hda_codec_read(codec, 0x14, 0,
  1399. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1400. bits = present ? HDA_AMP_MUTE : 0;
  1401. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1402. HDA_AMP_MUTE, bits);
  1403. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1404. HDA_AMP_MUTE, bits);
  1405. }
  1406. /* auto-toggle front mic */
  1407. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1408. {
  1409. unsigned int present;
  1410. unsigned char bits;
  1411. present = snd_hda_codec_read(codec, 0x18, 0,
  1412. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1413. bits = present ? HDA_AMP_MUTE : 0;
  1414. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1415. }
  1416. static void alc880_uniwill_automute(struct hda_codec *codec)
  1417. {
  1418. alc880_uniwill_hp_automute(codec);
  1419. alc880_uniwill_mic_automute(codec);
  1420. }
  1421. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1422. unsigned int res)
  1423. {
  1424. /* Looks like the unsol event is incompatible with the standard
  1425. * definition. 4bit tag is placed at 28 bit!
  1426. */
  1427. switch (res >> 28) {
  1428. case ALC880_HP_EVENT:
  1429. alc880_uniwill_hp_automute(codec);
  1430. break;
  1431. case ALC880_MIC_EVENT:
  1432. alc880_uniwill_mic_automute(codec);
  1433. break;
  1434. }
  1435. }
  1436. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1437. {
  1438. unsigned int present;
  1439. unsigned char bits;
  1440. present = snd_hda_codec_read(codec, 0x14, 0,
  1441. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1442. bits = present ? HDA_AMP_MUTE : 0;
  1443. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1444. }
  1445. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1446. {
  1447. unsigned int present;
  1448. present = snd_hda_codec_read(codec, 0x21, 0,
  1449. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1450. present &= HDA_AMP_VOLMASK;
  1451. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1452. HDA_AMP_VOLMASK, present);
  1453. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1454. HDA_AMP_VOLMASK, present);
  1455. }
  1456. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1457. unsigned int res)
  1458. {
  1459. /* Looks like the unsol event is incompatible with the standard
  1460. * definition. 4bit tag is placed at 28 bit!
  1461. */
  1462. if ((res >> 28) == ALC880_HP_EVENT)
  1463. alc880_uniwill_p53_hp_automute(codec);
  1464. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1465. alc880_uniwill_p53_dcvol_automute(codec);
  1466. }
  1467. /* FIXME! */
  1468. /*
  1469. * F1734 pin configuration:
  1470. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1471. */
  1472. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1473. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1474. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1475. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1476. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1477. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1478. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1481. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1482. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1483. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1484. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1485. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1486. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1487. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1488. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1489. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1490. { }
  1491. };
  1492. /* FIXME! */
  1493. /*
  1494. * ASUS pin configuration:
  1495. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1496. */
  1497. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1498. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1499. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1500. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1501. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1502. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1504. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1505. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1506. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1507. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1508. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1510. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1512. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1513. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1514. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1515. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1516. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1518. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1519. { }
  1520. };
  1521. /* Enable GPIO mask and set output */
  1522. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1523. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1524. /* Clevo m520g init */
  1525. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1526. /* headphone output */
  1527. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1528. /* line-out */
  1529. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1530. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1531. /* Line-in */
  1532. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1533. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* CD */
  1535. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1536. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* Mic1 (rear panel) */
  1538. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1539. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* Mic2 (front panel) */
  1541. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1542. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1543. /* headphone */
  1544. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1545. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1546. /* change to EAPD mode */
  1547. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1548. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1549. { }
  1550. };
  1551. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1552. /* change to EAPD mode */
  1553. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1554. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1555. /* Headphone output */
  1556. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1557. /* Front output*/
  1558. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1559. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1560. /* Line In pin widget for input */
  1561. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1562. /* CD pin widget for input */
  1563. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1564. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1565. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1566. /* change to EAPD mode */
  1567. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1568. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1569. { }
  1570. };
  1571. /*
  1572. * LG m1 express dual
  1573. *
  1574. * Pin assignment:
  1575. * Rear Line-In/Out (blue): 0x14
  1576. * Build-in Mic-In: 0x15
  1577. * Speaker-out: 0x17
  1578. * HP-Out (green): 0x1b
  1579. * Mic-In/Out (red): 0x19
  1580. * SPDIF-Out: 0x1e
  1581. */
  1582. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1583. static hda_nid_t alc880_lg_dac_nids[3] = {
  1584. 0x05, 0x02, 0x03
  1585. };
  1586. /* seems analog CD is not working */
  1587. static struct hda_input_mux alc880_lg_capture_source = {
  1588. .num_items = 3,
  1589. .items = {
  1590. { "Mic", 0x1 },
  1591. { "Line", 0x5 },
  1592. { "Internal Mic", 0x6 },
  1593. },
  1594. };
  1595. /* 2,4,6 channel modes */
  1596. static struct hda_verb alc880_lg_ch2_init[] = {
  1597. /* set line-in and mic-in to input */
  1598. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1599. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1600. { }
  1601. };
  1602. static struct hda_verb alc880_lg_ch4_init[] = {
  1603. /* set line-in to out and mic-in to input */
  1604. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1605. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1606. { }
  1607. };
  1608. static struct hda_verb alc880_lg_ch6_init[] = {
  1609. /* set line-in and mic-in to output */
  1610. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1611. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1612. { }
  1613. };
  1614. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1615. { 2, alc880_lg_ch2_init },
  1616. { 4, alc880_lg_ch4_init },
  1617. { 6, alc880_lg_ch6_init },
  1618. };
  1619. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1620. /* FIXME: it's not really "master" but front channels */
  1621. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1622. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1623. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1624. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1625. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1626. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1628. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1629. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1630. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1631. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1632. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1633. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1634. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1635. {
  1636. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1637. .name = "Channel Mode",
  1638. .info = alc_ch_mode_info,
  1639. .get = alc_ch_mode_get,
  1640. .put = alc_ch_mode_put,
  1641. },
  1642. { } /* end */
  1643. };
  1644. static struct hda_verb alc880_lg_init_verbs[] = {
  1645. /* set capture source to mic-in */
  1646. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1647. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1648. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1649. /* mute all amp mixer inputs */
  1650. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1651. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1652. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1653. /* line-in to input */
  1654. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1655. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1656. /* built-in mic */
  1657. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1658. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1659. /* speaker-out */
  1660. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1661. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. /* mic-in to input */
  1663. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1664. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1665. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1666. /* HP-out */
  1667. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1668. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1669. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1670. /* jack sense */
  1671. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1672. { }
  1673. };
  1674. /* toggle speaker-output according to the hp-jack state */
  1675. static void alc880_lg_automute(struct hda_codec *codec)
  1676. {
  1677. unsigned int present;
  1678. unsigned char bits;
  1679. present = snd_hda_codec_read(codec, 0x1b, 0,
  1680. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1681. bits = present ? HDA_AMP_MUTE : 0;
  1682. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1683. HDA_AMP_MUTE, bits);
  1684. }
  1685. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1686. {
  1687. /* Looks like the unsol event is incompatible with the standard
  1688. * definition. 4bit tag is placed at 28 bit!
  1689. */
  1690. if ((res >> 28) == 0x01)
  1691. alc880_lg_automute(codec);
  1692. }
  1693. /*
  1694. * LG LW20
  1695. *
  1696. * Pin assignment:
  1697. * Speaker-out: 0x14
  1698. * Mic-In: 0x18
  1699. * Built-in Mic-In: 0x19
  1700. * Line-In: 0x1b
  1701. * HP-Out: 0x1a
  1702. * SPDIF-Out: 0x1e
  1703. */
  1704. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1705. .num_items = 3,
  1706. .items = {
  1707. { "Mic", 0x0 },
  1708. { "Internal Mic", 0x1 },
  1709. { "Line In", 0x2 },
  1710. },
  1711. };
  1712. #define alc880_lg_lw_modes alc880_threestack_modes
  1713. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1714. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1715. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1716. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1717. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1718. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1719. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1720. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1721. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1725. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1726. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1727. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1728. {
  1729. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1730. .name = "Channel Mode",
  1731. .info = alc_ch_mode_info,
  1732. .get = alc_ch_mode_get,
  1733. .put = alc_ch_mode_put,
  1734. },
  1735. { } /* end */
  1736. };
  1737. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1738. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1739. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1740. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1741. /* set capture source to mic-in */
  1742. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1743. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1744. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1745. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1746. /* speaker-out */
  1747. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1748. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1749. /* HP-out */
  1750. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1751. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1752. /* mic-in to input */
  1753. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1754. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1755. /* built-in mic */
  1756. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1757. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1758. /* jack sense */
  1759. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1760. { }
  1761. };
  1762. /* toggle speaker-output according to the hp-jack state */
  1763. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1764. {
  1765. unsigned int present;
  1766. unsigned char bits;
  1767. present = snd_hda_codec_read(codec, 0x1b, 0,
  1768. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1769. bits = present ? HDA_AMP_MUTE : 0;
  1770. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1771. HDA_AMP_MUTE, bits);
  1772. }
  1773. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1774. {
  1775. /* Looks like the unsol event is incompatible with the standard
  1776. * definition. 4bit tag is placed at 28 bit!
  1777. */
  1778. if ((res >> 28) == 0x01)
  1779. alc880_lg_lw_automute(codec);
  1780. }
  1781. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1782. static struct hda_amp_list alc880_loopbacks[] = {
  1783. { 0x0b, HDA_INPUT, 0 },
  1784. { 0x0b, HDA_INPUT, 1 },
  1785. { 0x0b, HDA_INPUT, 2 },
  1786. { 0x0b, HDA_INPUT, 3 },
  1787. { 0x0b, HDA_INPUT, 4 },
  1788. { } /* end */
  1789. };
  1790. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1791. { 0x0b, HDA_INPUT, 1 },
  1792. { 0x0b, HDA_INPUT, 6 },
  1793. { 0x0b, HDA_INPUT, 7 },
  1794. { } /* end */
  1795. };
  1796. #endif
  1797. /*
  1798. * Common callbacks
  1799. */
  1800. static int alc_init(struct hda_codec *codec)
  1801. {
  1802. struct alc_spec *spec = codec->spec;
  1803. unsigned int i;
  1804. for (i = 0; i < spec->num_init_verbs; i++)
  1805. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1806. if (spec->init_hook)
  1807. spec->init_hook(codec);
  1808. return 0;
  1809. }
  1810. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1811. {
  1812. struct alc_spec *spec = codec->spec;
  1813. if (spec->unsol_event)
  1814. spec->unsol_event(codec, res);
  1815. }
  1816. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1817. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1818. {
  1819. struct alc_spec *spec = codec->spec;
  1820. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1821. }
  1822. #endif
  1823. /*
  1824. * Analog playback callbacks
  1825. */
  1826. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1827. struct hda_codec *codec,
  1828. struct snd_pcm_substream *substream)
  1829. {
  1830. struct alc_spec *spec = codec->spec;
  1831. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1832. }
  1833. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1834. struct hda_codec *codec,
  1835. unsigned int stream_tag,
  1836. unsigned int format,
  1837. struct snd_pcm_substream *substream)
  1838. {
  1839. struct alc_spec *spec = codec->spec;
  1840. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1841. stream_tag, format, substream);
  1842. }
  1843. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1844. struct hda_codec *codec,
  1845. struct snd_pcm_substream *substream)
  1846. {
  1847. struct alc_spec *spec = codec->spec;
  1848. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1849. }
  1850. /*
  1851. * Digital out
  1852. */
  1853. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1854. struct hda_codec *codec,
  1855. struct snd_pcm_substream *substream)
  1856. {
  1857. struct alc_spec *spec = codec->spec;
  1858. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1859. }
  1860. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1861. struct hda_codec *codec,
  1862. unsigned int stream_tag,
  1863. unsigned int format,
  1864. struct snd_pcm_substream *substream)
  1865. {
  1866. struct alc_spec *spec = codec->spec;
  1867. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1868. stream_tag, format, substream);
  1869. }
  1870. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1871. struct hda_codec *codec,
  1872. struct snd_pcm_substream *substream)
  1873. {
  1874. struct alc_spec *spec = codec->spec;
  1875. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1876. }
  1877. /*
  1878. * Analog capture
  1879. */
  1880. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1881. struct hda_codec *codec,
  1882. unsigned int stream_tag,
  1883. unsigned int format,
  1884. struct snd_pcm_substream *substream)
  1885. {
  1886. struct alc_spec *spec = codec->spec;
  1887. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1888. stream_tag, 0, format);
  1889. return 0;
  1890. }
  1891. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1892. struct hda_codec *codec,
  1893. struct snd_pcm_substream *substream)
  1894. {
  1895. struct alc_spec *spec = codec->spec;
  1896. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1897. 0, 0, 0);
  1898. return 0;
  1899. }
  1900. /*
  1901. */
  1902. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1903. .substreams = 1,
  1904. .channels_min = 2,
  1905. .channels_max = 8,
  1906. /* NID is set in alc_build_pcms */
  1907. .ops = {
  1908. .open = alc880_playback_pcm_open,
  1909. .prepare = alc880_playback_pcm_prepare,
  1910. .cleanup = alc880_playback_pcm_cleanup
  1911. },
  1912. };
  1913. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1914. .substreams = 2,
  1915. .channels_min = 2,
  1916. .channels_max = 2,
  1917. /* NID is set in alc_build_pcms */
  1918. .ops = {
  1919. .prepare = alc880_capture_pcm_prepare,
  1920. .cleanup = alc880_capture_pcm_cleanup
  1921. },
  1922. };
  1923. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1924. .substreams = 1,
  1925. .channels_min = 2,
  1926. .channels_max = 2,
  1927. /* NID is set in alc_build_pcms */
  1928. .ops = {
  1929. .open = alc880_dig_playback_pcm_open,
  1930. .close = alc880_dig_playback_pcm_close,
  1931. .prepare = alc880_dig_playback_pcm_prepare
  1932. },
  1933. };
  1934. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1935. .substreams = 1,
  1936. .channels_min = 2,
  1937. .channels_max = 2,
  1938. /* NID is set in alc_build_pcms */
  1939. };
  1940. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1941. static struct hda_pcm_stream alc_pcm_null_playback = {
  1942. .substreams = 0,
  1943. .channels_min = 0,
  1944. .channels_max = 0,
  1945. };
  1946. static int alc_build_pcms(struct hda_codec *codec)
  1947. {
  1948. struct alc_spec *spec = codec->spec;
  1949. struct hda_pcm *info = spec->pcm_rec;
  1950. int i;
  1951. codec->num_pcms = 1;
  1952. codec->pcm_info = info;
  1953. info->name = spec->stream_name_analog;
  1954. if (spec->stream_analog_playback) {
  1955. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1956. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1957. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1958. }
  1959. if (spec->stream_analog_capture) {
  1960. snd_assert(spec->adc_nids, return -EINVAL);
  1961. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1962. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1963. }
  1964. if (spec->channel_mode) {
  1965. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1966. for (i = 0; i < spec->num_channel_mode; i++) {
  1967. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1968. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1969. }
  1970. }
  1971. }
  1972. /* SPDIF for stream index #1 */
  1973. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1974. codec->num_pcms = 2;
  1975. info = spec->pcm_rec + 1;
  1976. info->name = spec->stream_name_digital;
  1977. if (spec->multiout.dig_out_nid &&
  1978. spec->stream_digital_playback) {
  1979. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1980. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1981. }
  1982. if (spec->dig_in_nid &&
  1983. spec->stream_digital_capture) {
  1984. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1985. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1986. }
  1987. }
  1988. /* If the use of more than one ADC is requested for the current
  1989. * model, configure a second analog capture-only PCM.
  1990. */
  1991. /* Additional Analaog capture for index #2 */
  1992. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1993. spec->adc_nids) {
  1994. codec->num_pcms = 3;
  1995. info = spec->pcm_rec + 2;
  1996. info->name = spec->stream_name_analog;
  1997. /* No playback stream for second PCM */
  1998. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1999. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2000. if (spec->stream_analog_capture) {
  2001. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2002. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2003. }
  2004. }
  2005. return 0;
  2006. }
  2007. static void alc_free(struct hda_codec *codec)
  2008. {
  2009. struct alc_spec *spec = codec->spec;
  2010. unsigned int i;
  2011. if (!spec)
  2012. return;
  2013. if (spec->kctl_alloc) {
  2014. for (i = 0; i < spec->num_kctl_used; i++)
  2015. kfree(spec->kctl_alloc[i].name);
  2016. kfree(spec->kctl_alloc);
  2017. }
  2018. kfree(spec);
  2019. }
  2020. /*
  2021. */
  2022. static struct hda_codec_ops alc_patch_ops = {
  2023. .build_controls = alc_build_controls,
  2024. .build_pcms = alc_build_pcms,
  2025. .init = alc_init,
  2026. .free = alc_free,
  2027. .unsol_event = alc_unsol_event,
  2028. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2029. .check_power_status = alc_check_power_status,
  2030. #endif
  2031. };
  2032. /*
  2033. * Test configuration for debugging
  2034. *
  2035. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2036. * enum controls.
  2037. */
  2038. #ifdef CONFIG_SND_DEBUG
  2039. static hda_nid_t alc880_test_dac_nids[4] = {
  2040. 0x02, 0x03, 0x04, 0x05
  2041. };
  2042. static struct hda_input_mux alc880_test_capture_source = {
  2043. .num_items = 7,
  2044. .items = {
  2045. { "In-1", 0x0 },
  2046. { "In-2", 0x1 },
  2047. { "In-3", 0x2 },
  2048. { "In-4", 0x3 },
  2049. { "CD", 0x4 },
  2050. { "Front", 0x5 },
  2051. { "Surround", 0x6 },
  2052. },
  2053. };
  2054. static struct hda_channel_mode alc880_test_modes[4] = {
  2055. { 2, NULL },
  2056. { 4, NULL },
  2057. { 6, NULL },
  2058. { 8, NULL },
  2059. };
  2060. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2061. struct snd_ctl_elem_info *uinfo)
  2062. {
  2063. static char *texts[] = {
  2064. "N/A", "Line Out", "HP Out",
  2065. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2066. };
  2067. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2068. uinfo->count = 1;
  2069. uinfo->value.enumerated.items = 8;
  2070. if (uinfo->value.enumerated.item >= 8)
  2071. uinfo->value.enumerated.item = 7;
  2072. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2073. return 0;
  2074. }
  2075. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2076. struct snd_ctl_elem_value *ucontrol)
  2077. {
  2078. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2079. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2080. unsigned int pin_ctl, item = 0;
  2081. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2082. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2083. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2084. if (pin_ctl & AC_PINCTL_HP_EN)
  2085. item = 2;
  2086. else
  2087. item = 1;
  2088. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2089. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2090. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2091. case AC_PINCTL_VREF_50: item = 4; break;
  2092. case AC_PINCTL_VREF_GRD: item = 5; break;
  2093. case AC_PINCTL_VREF_80: item = 6; break;
  2094. case AC_PINCTL_VREF_100: item = 7; break;
  2095. }
  2096. }
  2097. ucontrol->value.enumerated.item[0] = item;
  2098. return 0;
  2099. }
  2100. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2101. struct snd_ctl_elem_value *ucontrol)
  2102. {
  2103. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2104. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2105. static unsigned int ctls[] = {
  2106. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2107. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2108. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2109. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2110. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2111. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2112. };
  2113. unsigned int old_ctl, new_ctl;
  2114. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2115. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2116. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2117. if (old_ctl != new_ctl) {
  2118. int val;
  2119. snd_hda_codec_write_cache(codec, nid, 0,
  2120. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2121. new_ctl);
  2122. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2123. HDA_AMP_MUTE : 0;
  2124. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2125. HDA_AMP_MUTE, val);
  2126. return 1;
  2127. }
  2128. return 0;
  2129. }
  2130. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2131. struct snd_ctl_elem_info *uinfo)
  2132. {
  2133. static char *texts[] = {
  2134. "Front", "Surround", "CLFE", "Side"
  2135. };
  2136. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2137. uinfo->count = 1;
  2138. uinfo->value.enumerated.items = 4;
  2139. if (uinfo->value.enumerated.item >= 4)
  2140. uinfo->value.enumerated.item = 3;
  2141. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2142. return 0;
  2143. }
  2144. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2145. struct snd_ctl_elem_value *ucontrol)
  2146. {
  2147. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2148. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2149. unsigned int sel;
  2150. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2151. ucontrol->value.enumerated.item[0] = sel & 3;
  2152. return 0;
  2153. }
  2154. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2155. struct snd_ctl_elem_value *ucontrol)
  2156. {
  2157. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2158. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2159. unsigned int sel;
  2160. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2161. if (ucontrol->value.enumerated.item[0] != sel) {
  2162. sel = ucontrol->value.enumerated.item[0] & 3;
  2163. snd_hda_codec_write_cache(codec, nid, 0,
  2164. AC_VERB_SET_CONNECT_SEL, sel);
  2165. return 1;
  2166. }
  2167. return 0;
  2168. }
  2169. #define PIN_CTL_TEST(xname,nid) { \
  2170. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2171. .name = xname, \
  2172. .info = alc_test_pin_ctl_info, \
  2173. .get = alc_test_pin_ctl_get, \
  2174. .put = alc_test_pin_ctl_put, \
  2175. .private_value = nid \
  2176. }
  2177. #define PIN_SRC_TEST(xname,nid) { \
  2178. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2179. .name = xname, \
  2180. .info = alc_test_pin_src_info, \
  2181. .get = alc_test_pin_src_get, \
  2182. .put = alc_test_pin_src_put, \
  2183. .private_value = nid \
  2184. }
  2185. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2186. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2187. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2188. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2189. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2190. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2191. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2192. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2193. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2194. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2195. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2196. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2197. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2198. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2199. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2200. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2201. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2202. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2203. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2204. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2205. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2206. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2207. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2208. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2209. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2210. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2211. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2212. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2213. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2214. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2215. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2216. {
  2217. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2218. .name = "Channel Mode",
  2219. .info = alc_ch_mode_info,
  2220. .get = alc_ch_mode_get,
  2221. .put = alc_ch_mode_put,
  2222. },
  2223. { } /* end */
  2224. };
  2225. static struct hda_verb alc880_test_init_verbs[] = {
  2226. /* Unmute inputs of 0x0c - 0x0f */
  2227. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2228. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2229. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2230. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2231. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2232. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2233. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2234. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2235. /* Vol output for 0x0c-0x0f */
  2236. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2237. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2238. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2240. /* Set output pins 0x14-0x17 */
  2241. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2242. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2243. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2244. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2245. /* Unmute output pins 0x14-0x17 */
  2246. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2247. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2248. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2249. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2250. /* Set input pins 0x18-0x1c */
  2251. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2252. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2253. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2254. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2255. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2256. /* Mute input pins 0x18-0x1b */
  2257. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2258. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2259. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2260. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2261. /* ADC set up */
  2262. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2263. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2264. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2265. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2266. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2267. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2268. /* Analog input/passthru */
  2269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2271. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2272. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2273. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2274. { }
  2275. };
  2276. #endif
  2277. /*
  2278. */
  2279. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2280. [ALC880_3ST] = "3stack",
  2281. [ALC880_TCL_S700] = "tcl",
  2282. [ALC880_3ST_DIG] = "3stack-digout",
  2283. [ALC880_CLEVO] = "clevo",
  2284. [ALC880_5ST] = "5stack",
  2285. [ALC880_5ST_DIG] = "5stack-digout",
  2286. [ALC880_W810] = "w810",
  2287. [ALC880_Z71V] = "z71v",
  2288. [ALC880_6ST] = "6stack",
  2289. [ALC880_6ST_DIG] = "6stack-digout",
  2290. [ALC880_ASUS] = "asus",
  2291. [ALC880_ASUS_W1V] = "asus-w1v",
  2292. [ALC880_ASUS_DIG] = "asus-dig",
  2293. [ALC880_ASUS_DIG2] = "asus-dig2",
  2294. [ALC880_UNIWILL_DIG] = "uniwill",
  2295. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2296. [ALC880_FUJITSU] = "fujitsu",
  2297. [ALC880_F1734] = "F1734",
  2298. [ALC880_LG] = "lg",
  2299. [ALC880_LG_LW] = "lg-lw",
  2300. #ifdef CONFIG_SND_DEBUG
  2301. [ALC880_TEST] = "test",
  2302. #endif
  2303. [ALC880_AUTO] = "auto",
  2304. };
  2305. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2306. /* Broken BIOS configuration */
  2307. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2308. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2309. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2310. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2311. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2312. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2313. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2316. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2317. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2318. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2320. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2321. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2322. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2323. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2324. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2325. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2326. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2327. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2328. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2331. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2332. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2333. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2334. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2335. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2336. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2337. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2338. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2339. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2340. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2341. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2342. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2343. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2344. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2345. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2346. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2347. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2348. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2349. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2350. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2351. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2352. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2353. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2354. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2355. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2356. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2357. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2358. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2359. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2360. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2361. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2362. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2363. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2364. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2365. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2366. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2367. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2368. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2369. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2370. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2376. {}
  2377. };
  2378. /*
  2379. * ALC880 codec presets
  2380. */
  2381. static struct alc_config_preset alc880_presets[] = {
  2382. [ALC880_3ST] = {
  2383. .mixers = { alc880_three_stack_mixer },
  2384. .init_verbs = { alc880_volume_init_verbs,
  2385. alc880_pin_3stack_init_verbs },
  2386. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2387. .dac_nids = alc880_dac_nids,
  2388. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2389. .channel_mode = alc880_threestack_modes,
  2390. .need_dac_fix = 1,
  2391. .input_mux = &alc880_capture_source,
  2392. },
  2393. [ALC880_3ST_DIG] = {
  2394. .mixers = { alc880_three_stack_mixer },
  2395. .init_verbs = { alc880_volume_init_verbs,
  2396. alc880_pin_3stack_init_verbs },
  2397. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2398. .dac_nids = alc880_dac_nids,
  2399. .dig_out_nid = ALC880_DIGOUT_NID,
  2400. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2401. .channel_mode = alc880_threestack_modes,
  2402. .need_dac_fix = 1,
  2403. .input_mux = &alc880_capture_source,
  2404. },
  2405. [ALC880_TCL_S700] = {
  2406. .mixers = { alc880_tcl_s700_mixer },
  2407. .init_verbs = { alc880_volume_init_verbs,
  2408. alc880_pin_tcl_S700_init_verbs,
  2409. alc880_gpio2_init_verbs },
  2410. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2411. .dac_nids = alc880_dac_nids,
  2412. .hp_nid = 0x03,
  2413. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2414. .channel_mode = alc880_2_jack_modes,
  2415. .input_mux = &alc880_capture_source,
  2416. },
  2417. [ALC880_5ST] = {
  2418. .mixers = { alc880_three_stack_mixer,
  2419. alc880_five_stack_mixer},
  2420. .init_verbs = { alc880_volume_init_verbs,
  2421. alc880_pin_5stack_init_verbs },
  2422. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2423. .dac_nids = alc880_dac_nids,
  2424. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2425. .channel_mode = alc880_fivestack_modes,
  2426. .input_mux = &alc880_capture_source,
  2427. },
  2428. [ALC880_5ST_DIG] = {
  2429. .mixers = { alc880_three_stack_mixer,
  2430. alc880_five_stack_mixer },
  2431. .init_verbs = { alc880_volume_init_verbs,
  2432. alc880_pin_5stack_init_verbs },
  2433. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2434. .dac_nids = alc880_dac_nids,
  2435. .dig_out_nid = ALC880_DIGOUT_NID,
  2436. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2437. .channel_mode = alc880_fivestack_modes,
  2438. .input_mux = &alc880_capture_source,
  2439. },
  2440. [ALC880_6ST] = {
  2441. .mixers = { alc880_six_stack_mixer },
  2442. .init_verbs = { alc880_volume_init_verbs,
  2443. alc880_pin_6stack_init_verbs },
  2444. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2445. .dac_nids = alc880_6st_dac_nids,
  2446. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2447. .channel_mode = alc880_sixstack_modes,
  2448. .input_mux = &alc880_6stack_capture_source,
  2449. },
  2450. [ALC880_6ST_DIG] = {
  2451. .mixers = { alc880_six_stack_mixer },
  2452. .init_verbs = { alc880_volume_init_verbs,
  2453. alc880_pin_6stack_init_verbs },
  2454. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2455. .dac_nids = alc880_6st_dac_nids,
  2456. .dig_out_nid = ALC880_DIGOUT_NID,
  2457. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2458. .channel_mode = alc880_sixstack_modes,
  2459. .input_mux = &alc880_6stack_capture_source,
  2460. },
  2461. [ALC880_W810] = {
  2462. .mixers = { alc880_w810_base_mixer },
  2463. .init_verbs = { alc880_volume_init_verbs,
  2464. alc880_pin_w810_init_verbs,
  2465. alc880_gpio2_init_verbs },
  2466. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2467. .dac_nids = alc880_w810_dac_nids,
  2468. .dig_out_nid = ALC880_DIGOUT_NID,
  2469. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2470. .channel_mode = alc880_w810_modes,
  2471. .input_mux = &alc880_capture_source,
  2472. },
  2473. [ALC880_Z71V] = {
  2474. .mixers = { alc880_z71v_mixer },
  2475. .init_verbs = { alc880_volume_init_verbs,
  2476. alc880_pin_z71v_init_verbs },
  2477. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2478. .dac_nids = alc880_z71v_dac_nids,
  2479. .dig_out_nid = ALC880_DIGOUT_NID,
  2480. .hp_nid = 0x03,
  2481. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2482. .channel_mode = alc880_2_jack_modes,
  2483. .input_mux = &alc880_capture_source,
  2484. },
  2485. [ALC880_F1734] = {
  2486. .mixers = { alc880_f1734_mixer },
  2487. .init_verbs = { alc880_volume_init_verbs,
  2488. alc880_pin_f1734_init_verbs },
  2489. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2490. .dac_nids = alc880_f1734_dac_nids,
  2491. .hp_nid = 0x02,
  2492. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2493. .channel_mode = alc880_2_jack_modes,
  2494. .input_mux = &alc880_capture_source,
  2495. },
  2496. [ALC880_ASUS] = {
  2497. .mixers = { alc880_asus_mixer },
  2498. .init_verbs = { alc880_volume_init_verbs,
  2499. alc880_pin_asus_init_verbs,
  2500. alc880_gpio1_init_verbs },
  2501. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2502. .dac_nids = alc880_asus_dac_nids,
  2503. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2504. .channel_mode = alc880_asus_modes,
  2505. .need_dac_fix = 1,
  2506. .input_mux = &alc880_capture_source,
  2507. },
  2508. [ALC880_ASUS_DIG] = {
  2509. .mixers = { alc880_asus_mixer },
  2510. .init_verbs = { alc880_volume_init_verbs,
  2511. alc880_pin_asus_init_verbs,
  2512. alc880_gpio1_init_verbs },
  2513. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2514. .dac_nids = alc880_asus_dac_nids,
  2515. .dig_out_nid = ALC880_DIGOUT_NID,
  2516. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2517. .channel_mode = alc880_asus_modes,
  2518. .need_dac_fix = 1,
  2519. .input_mux = &alc880_capture_source,
  2520. },
  2521. [ALC880_ASUS_DIG2] = {
  2522. .mixers = { alc880_asus_mixer },
  2523. .init_verbs = { alc880_volume_init_verbs,
  2524. alc880_pin_asus_init_verbs,
  2525. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2527. .dac_nids = alc880_asus_dac_nids,
  2528. .dig_out_nid = ALC880_DIGOUT_NID,
  2529. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2530. .channel_mode = alc880_asus_modes,
  2531. .need_dac_fix = 1,
  2532. .input_mux = &alc880_capture_source,
  2533. },
  2534. [ALC880_ASUS_W1V] = {
  2535. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2536. .init_verbs = { alc880_volume_init_verbs,
  2537. alc880_pin_asus_init_verbs,
  2538. alc880_gpio1_init_verbs },
  2539. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2540. .dac_nids = alc880_asus_dac_nids,
  2541. .dig_out_nid = ALC880_DIGOUT_NID,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2543. .channel_mode = alc880_asus_modes,
  2544. .need_dac_fix = 1,
  2545. .input_mux = &alc880_capture_source,
  2546. },
  2547. [ALC880_UNIWILL_DIG] = {
  2548. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2549. .init_verbs = { alc880_volume_init_verbs,
  2550. alc880_pin_asus_init_verbs },
  2551. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2552. .dac_nids = alc880_asus_dac_nids,
  2553. .dig_out_nid = ALC880_DIGOUT_NID,
  2554. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2555. .channel_mode = alc880_asus_modes,
  2556. .need_dac_fix = 1,
  2557. .input_mux = &alc880_capture_source,
  2558. },
  2559. [ALC880_UNIWILL] = {
  2560. .mixers = { alc880_uniwill_mixer },
  2561. .init_verbs = { alc880_volume_init_verbs,
  2562. alc880_uniwill_init_verbs },
  2563. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2564. .dac_nids = alc880_asus_dac_nids,
  2565. .dig_out_nid = ALC880_DIGOUT_NID,
  2566. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2567. .channel_mode = alc880_threestack_modes,
  2568. .need_dac_fix = 1,
  2569. .input_mux = &alc880_capture_source,
  2570. .unsol_event = alc880_uniwill_unsol_event,
  2571. .init_hook = alc880_uniwill_automute,
  2572. },
  2573. [ALC880_UNIWILL_P53] = {
  2574. .mixers = { alc880_uniwill_p53_mixer },
  2575. .init_verbs = { alc880_volume_init_verbs,
  2576. alc880_uniwill_p53_init_verbs },
  2577. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2578. .dac_nids = alc880_asus_dac_nids,
  2579. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2580. .channel_mode = alc880_threestack_modes,
  2581. .input_mux = &alc880_capture_source,
  2582. .unsol_event = alc880_uniwill_p53_unsol_event,
  2583. .init_hook = alc880_uniwill_p53_hp_automute,
  2584. },
  2585. [ALC880_FUJITSU] = {
  2586. .mixers = { alc880_fujitsu_mixer,
  2587. alc880_pcbeep_mixer, },
  2588. .init_verbs = { alc880_volume_init_verbs,
  2589. alc880_uniwill_p53_init_verbs,
  2590. alc880_beep_init_verbs },
  2591. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2592. .dac_nids = alc880_dac_nids,
  2593. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2594. .channel_mode = alc880_2_jack_modes,
  2595. .input_mux = &alc880_capture_source,
  2596. .unsol_event = alc880_uniwill_p53_unsol_event,
  2597. .init_hook = alc880_uniwill_p53_hp_automute,
  2598. },
  2599. [ALC880_CLEVO] = {
  2600. .mixers = { alc880_three_stack_mixer },
  2601. .init_verbs = { alc880_volume_init_verbs,
  2602. alc880_pin_clevo_init_verbs },
  2603. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2604. .dac_nids = alc880_dac_nids,
  2605. .hp_nid = 0x03,
  2606. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2607. .channel_mode = alc880_threestack_modes,
  2608. .need_dac_fix = 1,
  2609. .input_mux = &alc880_capture_source,
  2610. },
  2611. [ALC880_LG] = {
  2612. .mixers = { alc880_lg_mixer },
  2613. .init_verbs = { alc880_volume_init_verbs,
  2614. alc880_lg_init_verbs },
  2615. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2616. .dac_nids = alc880_lg_dac_nids,
  2617. .dig_out_nid = ALC880_DIGOUT_NID,
  2618. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2619. .channel_mode = alc880_lg_ch_modes,
  2620. .need_dac_fix = 1,
  2621. .input_mux = &alc880_lg_capture_source,
  2622. .unsol_event = alc880_lg_unsol_event,
  2623. .init_hook = alc880_lg_automute,
  2624. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2625. .loopbacks = alc880_lg_loopbacks,
  2626. #endif
  2627. },
  2628. [ALC880_LG_LW] = {
  2629. .mixers = { alc880_lg_lw_mixer },
  2630. .init_verbs = { alc880_volume_init_verbs,
  2631. alc880_lg_lw_init_verbs },
  2632. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2633. .dac_nids = alc880_dac_nids,
  2634. .dig_out_nid = ALC880_DIGOUT_NID,
  2635. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2636. .channel_mode = alc880_lg_lw_modes,
  2637. .input_mux = &alc880_lg_lw_capture_source,
  2638. .unsol_event = alc880_lg_lw_unsol_event,
  2639. .init_hook = alc880_lg_lw_automute,
  2640. },
  2641. #ifdef CONFIG_SND_DEBUG
  2642. [ALC880_TEST] = {
  2643. .mixers = { alc880_test_mixer },
  2644. .init_verbs = { alc880_test_init_verbs },
  2645. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2646. .dac_nids = alc880_test_dac_nids,
  2647. .dig_out_nid = ALC880_DIGOUT_NID,
  2648. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2649. .channel_mode = alc880_test_modes,
  2650. .input_mux = &alc880_test_capture_source,
  2651. },
  2652. #endif
  2653. };
  2654. /*
  2655. * Automatic parse of I/O pins from the BIOS configuration
  2656. */
  2657. #define NUM_CONTROL_ALLOC 32
  2658. #define NUM_VERB_ALLOC 32
  2659. enum {
  2660. ALC_CTL_WIDGET_VOL,
  2661. ALC_CTL_WIDGET_MUTE,
  2662. ALC_CTL_BIND_MUTE,
  2663. };
  2664. static struct snd_kcontrol_new alc880_control_templates[] = {
  2665. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2666. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2667. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2668. };
  2669. /* add dynamic controls */
  2670. static int add_control(struct alc_spec *spec, int type, const char *name,
  2671. unsigned long val)
  2672. {
  2673. struct snd_kcontrol_new *knew;
  2674. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2675. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2676. /* array + terminator */
  2677. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2678. if (!knew)
  2679. return -ENOMEM;
  2680. if (spec->kctl_alloc) {
  2681. memcpy(knew, spec->kctl_alloc,
  2682. sizeof(*knew) * spec->num_kctl_alloc);
  2683. kfree(spec->kctl_alloc);
  2684. }
  2685. spec->kctl_alloc = knew;
  2686. spec->num_kctl_alloc = num;
  2687. }
  2688. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2689. *knew = alc880_control_templates[type];
  2690. knew->name = kstrdup(name, GFP_KERNEL);
  2691. if (!knew->name)
  2692. return -ENOMEM;
  2693. knew->private_value = val;
  2694. spec->num_kctl_used++;
  2695. return 0;
  2696. }
  2697. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2698. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2699. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2700. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2701. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2702. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2703. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2704. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2705. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2706. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2707. #define ALC880_PIN_CD_NID 0x1c
  2708. /* fill in the dac_nids table from the parsed pin configuration */
  2709. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2710. const struct auto_pin_cfg *cfg)
  2711. {
  2712. hda_nid_t nid;
  2713. int assigned[4];
  2714. int i, j;
  2715. memset(assigned, 0, sizeof(assigned));
  2716. spec->multiout.dac_nids = spec->private_dac_nids;
  2717. /* check the pins hardwired to audio widget */
  2718. for (i = 0; i < cfg->line_outs; i++) {
  2719. nid = cfg->line_out_pins[i];
  2720. if (alc880_is_fixed_pin(nid)) {
  2721. int idx = alc880_fixed_pin_idx(nid);
  2722. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2723. assigned[idx] = 1;
  2724. }
  2725. }
  2726. /* left pins can be connect to any audio widget */
  2727. for (i = 0; i < cfg->line_outs; i++) {
  2728. nid = cfg->line_out_pins[i];
  2729. if (alc880_is_fixed_pin(nid))
  2730. continue;
  2731. /* search for an empty channel */
  2732. for (j = 0; j < cfg->line_outs; j++) {
  2733. if (!assigned[j]) {
  2734. spec->multiout.dac_nids[i] =
  2735. alc880_idx_to_dac(j);
  2736. assigned[j] = 1;
  2737. break;
  2738. }
  2739. }
  2740. }
  2741. spec->multiout.num_dacs = cfg->line_outs;
  2742. return 0;
  2743. }
  2744. /* add playback controls from the parsed DAC table */
  2745. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2746. const struct auto_pin_cfg *cfg)
  2747. {
  2748. char name[32];
  2749. static const char *chname[4] = {
  2750. "Front", "Surround", NULL /*CLFE*/, "Side"
  2751. };
  2752. hda_nid_t nid;
  2753. int i, err;
  2754. for (i = 0; i < cfg->line_outs; i++) {
  2755. if (!spec->multiout.dac_nids[i])
  2756. continue;
  2757. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2758. if (i == 2) {
  2759. /* Center/LFE */
  2760. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2761. "Center Playback Volume",
  2762. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2763. HDA_OUTPUT));
  2764. if (err < 0)
  2765. return err;
  2766. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2767. "LFE Playback Volume",
  2768. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2769. HDA_OUTPUT));
  2770. if (err < 0)
  2771. return err;
  2772. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2773. "Center Playback Switch",
  2774. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2775. HDA_INPUT));
  2776. if (err < 0)
  2777. return err;
  2778. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2779. "LFE Playback Switch",
  2780. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2781. HDA_INPUT));
  2782. if (err < 0)
  2783. return err;
  2784. } else {
  2785. sprintf(name, "%s Playback Volume", chname[i]);
  2786. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2787. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2788. HDA_OUTPUT));
  2789. if (err < 0)
  2790. return err;
  2791. sprintf(name, "%s Playback Switch", chname[i]);
  2792. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2793. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2794. HDA_INPUT));
  2795. if (err < 0)
  2796. return err;
  2797. }
  2798. }
  2799. return 0;
  2800. }
  2801. /* add playback controls for speaker and HP outputs */
  2802. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2803. const char *pfx)
  2804. {
  2805. hda_nid_t nid;
  2806. int err;
  2807. char name[32];
  2808. if (!pin)
  2809. return 0;
  2810. if (alc880_is_fixed_pin(pin)) {
  2811. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2812. /* specify the DAC as the extra output */
  2813. if (!spec->multiout.hp_nid)
  2814. spec->multiout.hp_nid = nid;
  2815. else
  2816. spec->multiout.extra_out_nid[0] = nid;
  2817. /* control HP volume/switch on the output mixer amp */
  2818. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2819. sprintf(name, "%s Playback Volume", pfx);
  2820. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2821. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2822. if (err < 0)
  2823. return err;
  2824. sprintf(name, "%s Playback Switch", pfx);
  2825. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2826. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2827. if (err < 0)
  2828. return err;
  2829. } else if (alc880_is_multi_pin(pin)) {
  2830. /* set manual connection */
  2831. /* we have only a switch on HP-out PIN */
  2832. sprintf(name, "%s Playback Switch", pfx);
  2833. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2834. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2835. if (err < 0)
  2836. return err;
  2837. }
  2838. return 0;
  2839. }
  2840. /* create input playback/capture controls for the given pin */
  2841. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2842. const char *ctlname,
  2843. int idx, hda_nid_t mix_nid)
  2844. {
  2845. char name[32];
  2846. int err;
  2847. sprintf(name, "%s Playback Volume", ctlname);
  2848. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2849. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2850. if (err < 0)
  2851. return err;
  2852. sprintf(name, "%s Playback Switch", ctlname);
  2853. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2854. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2855. if (err < 0)
  2856. return err;
  2857. return 0;
  2858. }
  2859. /* create playback/capture controls for input pins */
  2860. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2861. const struct auto_pin_cfg *cfg)
  2862. {
  2863. struct hda_input_mux *imux = &spec->private_imux;
  2864. int i, err, idx;
  2865. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2866. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2867. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2868. err = new_analog_input(spec, cfg->input_pins[i],
  2869. auto_pin_cfg_labels[i],
  2870. idx, 0x0b);
  2871. if (err < 0)
  2872. return err;
  2873. imux->items[imux->num_items].label =
  2874. auto_pin_cfg_labels[i];
  2875. imux->items[imux->num_items].index =
  2876. alc880_input_pin_idx(cfg->input_pins[i]);
  2877. imux->num_items++;
  2878. }
  2879. }
  2880. return 0;
  2881. }
  2882. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2883. hda_nid_t nid, int pin_type,
  2884. int dac_idx)
  2885. {
  2886. /* set as output */
  2887. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2888. pin_type);
  2889. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2890. AMP_OUT_UNMUTE);
  2891. /* need the manual connection? */
  2892. if (alc880_is_multi_pin(nid)) {
  2893. struct alc_spec *spec = codec->spec;
  2894. int idx = alc880_multi_pin_idx(nid);
  2895. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2896. AC_VERB_SET_CONNECT_SEL,
  2897. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2898. }
  2899. }
  2900. static int get_pin_type(int line_out_type)
  2901. {
  2902. if (line_out_type == AUTO_PIN_HP_OUT)
  2903. return PIN_HP;
  2904. else
  2905. return PIN_OUT;
  2906. }
  2907. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2908. {
  2909. struct alc_spec *spec = codec->spec;
  2910. int i;
  2911. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2912. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2913. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2914. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2915. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2916. }
  2917. }
  2918. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2919. {
  2920. struct alc_spec *spec = codec->spec;
  2921. hda_nid_t pin;
  2922. pin = spec->autocfg.speaker_pins[0];
  2923. if (pin) /* connect to front */
  2924. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2925. pin = spec->autocfg.hp_pins[0];
  2926. if (pin) /* connect to front */
  2927. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2928. }
  2929. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2930. {
  2931. struct alc_spec *spec = codec->spec;
  2932. int i;
  2933. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2934. hda_nid_t nid = spec->autocfg.input_pins[i];
  2935. if (alc880_is_input_pin(nid)) {
  2936. snd_hda_codec_write(codec, nid, 0,
  2937. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2938. i <= AUTO_PIN_FRONT_MIC ?
  2939. PIN_VREF80 : PIN_IN);
  2940. if (nid != ALC880_PIN_CD_NID)
  2941. snd_hda_codec_write(codec, nid, 0,
  2942. AC_VERB_SET_AMP_GAIN_MUTE,
  2943. AMP_OUT_MUTE);
  2944. }
  2945. }
  2946. }
  2947. /* parse the BIOS configuration and set up the alc_spec */
  2948. /* return 1 if successful, 0 if the proper config is not found,
  2949. * or a negative error code
  2950. */
  2951. static int alc880_parse_auto_config(struct hda_codec *codec)
  2952. {
  2953. struct alc_spec *spec = codec->spec;
  2954. int err;
  2955. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2956. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2957. alc880_ignore);
  2958. if (err < 0)
  2959. return err;
  2960. if (!spec->autocfg.line_outs)
  2961. return 0; /* can't find valid BIOS pin config */
  2962. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2963. if (err < 0)
  2964. return err;
  2965. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2966. if (err < 0)
  2967. return err;
  2968. err = alc880_auto_create_extra_out(spec,
  2969. spec->autocfg.speaker_pins[0],
  2970. "Speaker");
  2971. if (err < 0)
  2972. return err;
  2973. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2974. "Headphone");
  2975. if (err < 0)
  2976. return err;
  2977. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2978. if (err < 0)
  2979. return err;
  2980. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2981. if (spec->autocfg.dig_out_pin)
  2982. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2983. if (spec->autocfg.dig_in_pin)
  2984. spec->dig_in_nid = ALC880_DIGIN_NID;
  2985. if (spec->kctl_alloc)
  2986. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2987. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2988. spec->num_mux_defs = 1;
  2989. spec->input_mux = &spec->private_imux;
  2990. return 1;
  2991. }
  2992. /* additional initialization for auto-configuration model */
  2993. static void alc880_auto_init(struct hda_codec *codec)
  2994. {
  2995. alc880_auto_init_multi_out(codec);
  2996. alc880_auto_init_extra_out(codec);
  2997. alc880_auto_init_analog_input(codec);
  2998. }
  2999. /*
  3000. * OK, here we have finally the patch for ALC880
  3001. */
  3002. static int patch_alc880(struct hda_codec *codec)
  3003. {
  3004. struct alc_spec *spec;
  3005. int board_config;
  3006. int err;
  3007. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3008. if (spec == NULL)
  3009. return -ENOMEM;
  3010. codec->spec = spec;
  3011. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3012. alc880_models,
  3013. alc880_cfg_tbl);
  3014. if (board_config < 0) {
  3015. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3016. "trying auto-probe from BIOS...\n");
  3017. board_config = ALC880_AUTO;
  3018. }
  3019. if (board_config == ALC880_AUTO) {
  3020. /* automatic parse from the BIOS config */
  3021. err = alc880_parse_auto_config(codec);
  3022. if (err < 0) {
  3023. alc_free(codec);
  3024. return err;
  3025. } else if (!err) {
  3026. printk(KERN_INFO
  3027. "hda_codec: Cannot set up configuration "
  3028. "from BIOS. Using 3-stack mode...\n");
  3029. board_config = ALC880_3ST;
  3030. }
  3031. }
  3032. if (board_config != ALC880_AUTO)
  3033. setup_preset(spec, &alc880_presets[board_config]);
  3034. spec->stream_name_analog = "ALC880 Analog";
  3035. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3036. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3037. spec->stream_name_digital = "ALC880 Digital";
  3038. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3039. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3040. if (!spec->adc_nids && spec->input_mux) {
  3041. /* check whether NID 0x07 is valid */
  3042. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3043. /* get type */
  3044. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3045. if (wcap != AC_WID_AUD_IN) {
  3046. spec->adc_nids = alc880_adc_nids_alt;
  3047. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3048. spec->mixers[spec->num_mixers] =
  3049. alc880_capture_alt_mixer;
  3050. spec->num_mixers++;
  3051. } else {
  3052. spec->adc_nids = alc880_adc_nids;
  3053. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3054. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3055. spec->num_mixers++;
  3056. }
  3057. }
  3058. codec->patch_ops = alc_patch_ops;
  3059. if (board_config == ALC880_AUTO)
  3060. spec->init_hook = alc880_auto_init;
  3061. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3062. if (!spec->loopback.amplist)
  3063. spec->loopback.amplist = alc880_loopbacks;
  3064. #endif
  3065. return 0;
  3066. }
  3067. /*
  3068. * ALC260 support
  3069. */
  3070. static hda_nid_t alc260_dac_nids[1] = {
  3071. /* front */
  3072. 0x02,
  3073. };
  3074. static hda_nid_t alc260_adc_nids[1] = {
  3075. /* ADC0 */
  3076. 0x04,
  3077. };
  3078. static hda_nid_t alc260_adc_nids_alt[1] = {
  3079. /* ADC1 */
  3080. 0x05,
  3081. };
  3082. static hda_nid_t alc260_hp_adc_nids[2] = {
  3083. /* ADC1, 0 */
  3084. 0x05, 0x04
  3085. };
  3086. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3087. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3088. */
  3089. static hda_nid_t alc260_dual_adc_nids[2] = {
  3090. /* ADC0, ADC1 */
  3091. 0x04, 0x05
  3092. };
  3093. #define ALC260_DIGOUT_NID 0x03
  3094. #define ALC260_DIGIN_NID 0x06
  3095. static struct hda_input_mux alc260_capture_source = {
  3096. .num_items = 4,
  3097. .items = {
  3098. { "Mic", 0x0 },
  3099. { "Front Mic", 0x1 },
  3100. { "Line", 0x2 },
  3101. { "CD", 0x4 },
  3102. },
  3103. };
  3104. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3105. * headphone jack and the internal CD lines since these are the only pins at
  3106. * which audio can appear. For flexibility, also allow the option of
  3107. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3108. * connection to the mixer output).
  3109. */
  3110. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3111. {
  3112. .num_items = 3,
  3113. .items = {
  3114. { "Mic/Line", 0x0 },
  3115. { "CD", 0x4 },
  3116. { "Headphone", 0x2 },
  3117. },
  3118. },
  3119. {
  3120. .num_items = 4,
  3121. .items = {
  3122. { "Mic/Line", 0x0 },
  3123. { "CD", 0x4 },
  3124. { "Headphone", 0x2 },
  3125. { "Mixer", 0x5 },
  3126. },
  3127. },
  3128. };
  3129. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3130. * the Fujitsu S702x, but jacks are marked differently.
  3131. */
  3132. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3133. {
  3134. .num_items = 4,
  3135. .items = {
  3136. { "Mic", 0x0 },
  3137. { "Line", 0x2 },
  3138. { "CD", 0x4 },
  3139. { "Headphone", 0x5 },
  3140. },
  3141. },
  3142. {
  3143. .num_items = 5,
  3144. .items = {
  3145. { "Mic", 0x0 },
  3146. { "Line", 0x2 },
  3147. { "CD", 0x4 },
  3148. { "Headphone", 0x6 },
  3149. { "Mixer", 0x5 },
  3150. },
  3151. },
  3152. };
  3153. /*
  3154. * This is just place-holder, so there's something for alc_build_pcms to look
  3155. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3156. * element which allows changing the channel mode, so the verb list is
  3157. * never used.
  3158. */
  3159. static struct hda_channel_mode alc260_modes[1] = {
  3160. { 2, NULL },
  3161. };
  3162. /* Mixer combinations
  3163. *
  3164. * basic: base_output + input + pc_beep + capture
  3165. * HP: base_output + input + capture_alt
  3166. * HP_3013: hp_3013 + input + capture
  3167. * fujitsu: fujitsu + capture
  3168. * acer: acer + capture
  3169. */
  3170. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3171. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3172. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3173. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3174. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3175. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3176. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3177. { } /* end */
  3178. };
  3179. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3180. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3181. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3182. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3183. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3184. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3185. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3186. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3187. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3188. { } /* end */
  3189. };
  3190. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3191. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3192. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3193. { } /* end */
  3194. };
  3195. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3196. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3197. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3198. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3199. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3200. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3201. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3202. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3204. { } /* end */
  3205. };
  3206. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3207. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3208. */
  3209. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3210. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3211. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3212. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3213. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3214. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3215. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3216. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3217. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3218. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3219. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3220. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3221. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3222. { } /* end */
  3223. };
  3224. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3225. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3226. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3227. * datasheet doesn't mention this restriction. At this stage it's not clear
  3228. * whether this behaviour is intentional or is a hardware bug in chip
  3229. * revisions available in early 2006. Therefore for now allow the
  3230. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3231. * that the lack of mic bias for this NID is intentional we could change the
  3232. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3233. *
  3234. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3235. * don't appear to make the mic bias available from the "line" jack, even
  3236. * though the NID used for this jack (0x14) can supply it. The theory is
  3237. * that perhaps Acer have included blocking capacitors between the ALC260
  3238. * and the output jack. If this turns out to be the case for all such
  3239. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3240. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3241. *
  3242. * The C20x Tablet series have a mono internal speaker which is controlled
  3243. * via the chip's Mono sum widget and pin complex, so include the necessary
  3244. * controls for such models. On models without a "mono speaker" the control
  3245. * won't do anything.
  3246. */
  3247. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3248. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3249. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3250. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3251. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3252. HDA_OUTPUT),
  3253. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3254. HDA_INPUT),
  3255. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3256. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3257. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3258. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3259. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3260. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3261. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3262. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3263. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3265. { } /* end */
  3266. };
  3267. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3268. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3269. */
  3270. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3271. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3272. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3273. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3274. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3275. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3276. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3277. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3278. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3279. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3280. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3281. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3282. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3283. { } /* end */
  3284. };
  3285. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3286. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3287. */
  3288. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3289. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3290. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3291. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3292. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3293. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3294. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3295. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3296. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3297. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3298. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3299. { } /* end */
  3300. };
  3301. /* capture mixer elements */
  3302. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3303. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3304. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3305. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3306. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3307. {
  3308. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3309. /* The multiple "Capture Source" controls confuse alsamixer
  3310. * So call somewhat different..
  3311. * FIXME: the controls appear in the "playback" view!
  3312. */
  3313. /* .name = "Capture Source", */
  3314. .name = "Input Source",
  3315. .count = 2,
  3316. .info = alc_mux_enum_info,
  3317. .get = alc_mux_enum_get,
  3318. .put = alc_mux_enum_put,
  3319. },
  3320. { } /* end */
  3321. };
  3322. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3323. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3324. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3325. {
  3326. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3327. /* The multiple "Capture Source" controls confuse alsamixer
  3328. * So call somewhat different..
  3329. * FIXME: the controls appear in the "playback" view!
  3330. */
  3331. /* .name = "Capture Source", */
  3332. .name = "Input Source",
  3333. .count = 1,
  3334. .info = alc_mux_enum_info,
  3335. .get = alc_mux_enum_get,
  3336. .put = alc_mux_enum_put,
  3337. },
  3338. { } /* end */
  3339. };
  3340. /*
  3341. * initialization verbs
  3342. */
  3343. static struct hda_verb alc260_init_verbs[] = {
  3344. /* Line In pin widget for input */
  3345. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3346. /* CD pin widget for input */
  3347. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3348. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3349. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3350. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3351. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3352. /* LINE-2 is used for line-out in rear */
  3353. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3354. /* select line-out */
  3355. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3356. /* LINE-OUT pin */
  3357. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3358. /* enable HP */
  3359. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3360. /* enable Mono */
  3361. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3362. /* mute capture amp left and right */
  3363. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3364. /* set connection select to line in (default select for this ADC) */
  3365. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3366. /* mute capture amp left and right */
  3367. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3368. /* set connection select to line in (default select for this ADC) */
  3369. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3370. /* set vol=0 Line-Out mixer amp left and right */
  3371. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3372. /* unmute pin widget amp left and right (no gain on this amp) */
  3373. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3374. /* set vol=0 HP mixer amp left and right */
  3375. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3376. /* unmute pin widget amp left and right (no gain on this amp) */
  3377. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3378. /* set vol=0 Mono mixer amp left and right */
  3379. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3380. /* unmute pin widget amp left and right (no gain on this amp) */
  3381. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3382. /* unmute LINE-2 out pin */
  3383. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3385. * Line In 2 = 0x03
  3386. */
  3387. /* mute analog inputs */
  3388. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3389. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3390. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3391. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3392. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3393. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3394. /* mute Front out path */
  3395. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3396. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3397. /* mute Headphone out path */
  3398. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3399. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3400. /* mute Mono out path */
  3401. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. { }
  3404. };
  3405. #if 0 /* should be identical with alc260_init_verbs? */
  3406. static struct hda_verb alc260_hp_init_verbs[] = {
  3407. /* Headphone and output */
  3408. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3409. /* mono output */
  3410. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3411. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3412. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3413. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3414. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3415. /* Line In pin widget for input */
  3416. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3417. /* Line-2 pin widget for output */
  3418. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3419. /* CD pin widget for input */
  3420. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3421. /* unmute amp left and right */
  3422. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3423. /* set connection select to line in (default select for this ADC) */
  3424. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3425. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3426. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3427. /* mute pin widget amp left and right (no gain on this amp) */
  3428. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3429. /* unmute HP mixer amp left and right (volume = 0) */
  3430. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3431. /* mute pin widget amp left and right (no gain on this amp) */
  3432. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3433. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3434. * Line In 2 = 0x03
  3435. */
  3436. /* mute analog inputs */
  3437. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3438. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3439. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3441. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3442. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3443. /* Unmute Front out path */
  3444. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3445. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3446. /* Unmute Headphone out path */
  3447. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3449. /* Unmute Mono out path */
  3450. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. { }
  3453. };
  3454. #endif
  3455. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3456. /* Line out and output */
  3457. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3458. /* mono output */
  3459. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3460. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3461. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3462. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3463. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3464. /* Line In pin widget for input */
  3465. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3466. /* Headphone pin widget for output */
  3467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3468. /* CD pin widget for input */
  3469. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3470. /* unmute amp left and right */
  3471. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3472. /* set connection select to line in (default select for this ADC) */
  3473. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3474. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3475. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3476. /* mute pin widget amp left and right (no gain on this amp) */
  3477. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3478. /* unmute HP mixer amp left and right (volume = 0) */
  3479. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3480. /* mute pin widget amp left and right (no gain on this amp) */
  3481. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3482. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3483. * Line In 2 = 0x03
  3484. */
  3485. /* mute analog inputs */
  3486. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3487. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3488. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3489. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3490. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3491. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3492. /* Unmute Front out path */
  3493. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3494. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3495. /* Unmute Headphone out path */
  3496. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3497. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3498. /* Unmute Mono out path */
  3499. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. { }
  3502. };
  3503. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3504. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3505. * audio = 0x16, internal speaker = 0x10.
  3506. */
  3507. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3508. /* Disable all GPIOs */
  3509. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3510. /* Internal speaker is connected to headphone pin */
  3511. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3512. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3513. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3514. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3515. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3516. /* Ensure all other unused pins are disabled and muted. */
  3517. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3518. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3519. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3520. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3522. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3523. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. /* Disable digital (SPDIF) pins */
  3526. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3527. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3528. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3529. * when acting as an output.
  3530. */
  3531. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3532. /* Start with output sum widgets muted and their output gains at min */
  3533. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3534. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3535. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3536. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3537. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3538. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3539. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3543. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3544. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3545. * If the pin mode is changed by the user the pin mode control will
  3546. * take care of enabling the pin's input/output buffers as needed.
  3547. * Therefore there's no need to enable the input buffer at this
  3548. * stage.
  3549. */
  3550. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3551. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3552. * mixer ctrl)
  3553. */
  3554. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3555. /* Mute capture amp left and right */
  3556. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3557. /* Set ADC connection select to match default mixer setting - line
  3558. * in (on mic1 pin)
  3559. */
  3560. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3561. /* Do the same for the second ADC: mute capture input amp and
  3562. * set ADC connection to line in (on mic1 pin)
  3563. */
  3564. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3565. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3566. /* Mute all inputs to mixer widget (even unconnected ones) */
  3567. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3568. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3569. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3570. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3571. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3575. { }
  3576. };
  3577. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3578. * similar laptops (adapted from Fujitsu init verbs).
  3579. */
  3580. static struct hda_verb alc260_acer_init_verbs[] = {
  3581. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3582. * the headphone jack. Turn this on and rely on the standard mute
  3583. * methods whenever the user wants to turn these outputs off.
  3584. */
  3585. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3587. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3588. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3589. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3590. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3591. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3592. /* Line In jack is connected to Line1 pin */
  3593. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3594. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3595. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Ensure all other unused pins are disabled and muted. */
  3597. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3598. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3599. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3600. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3601. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3602. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3603. /* Disable digital (SPDIF) pins */
  3604. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3605. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3606. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3607. * bus when acting as outputs.
  3608. */
  3609. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3610. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3611. /* Start with output sum widgets muted and their output gains at min */
  3612. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3613. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3614. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3615. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3616. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3617. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3618. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. /* Unmute Line-out pin widget amp left and right
  3622. * (no equiv mixer ctrl)
  3623. */
  3624. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3625. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3626. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3627. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3628. * inputs. If the pin mode is changed by the user the pin mode control
  3629. * will take care of enabling the pin's input/output buffers as needed.
  3630. * Therefore there's no need to enable the input buffer at this
  3631. * stage.
  3632. */
  3633. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3634. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3635. /* Mute capture amp left and right */
  3636. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3637. /* Set ADC connection select to match default mixer setting - mic
  3638. * (on mic1 pin)
  3639. */
  3640. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3641. /* Do similar with the second ADC: mute capture input amp and
  3642. * set ADC connection to mic to match ALSA's default state.
  3643. */
  3644. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3645. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3646. /* Mute all inputs to mixer widget (even unconnected ones) */
  3647. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3648. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3649. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3650. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3655. { }
  3656. };
  3657. static struct hda_verb alc260_will_verbs[] = {
  3658. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3659. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3660. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3661. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3662. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3663. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3664. {}
  3665. };
  3666. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3670. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3671. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3672. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3673. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3674. {}
  3675. };
  3676. /* toggle speaker-output according to the hp-jack state */
  3677. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3678. {
  3679. unsigned int present;
  3680. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3681. present = snd_hda_codec_read(codec, 0x0f, 0,
  3682. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3683. if (present) {
  3684. snd_hda_codec_write_cache(codec, 0x01, 0,
  3685. AC_VERB_SET_GPIO_DATA, 1);
  3686. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3687. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3688. PIN_HP);
  3689. } else {
  3690. snd_hda_codec_write_cache(codec, 0x01, 0,
  3691. AC_VERB_SET_GPIO_DATA, 0);
  3692. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3693. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3694. PIN_OUT);
  3695. }
  3696. }
  3697. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3698. unsigned int res)
  3699. {
  3700. if ((res >> 26) == ALC880_HP_EVENT)
  3701. alc260_replacer_672v_automute(codec);
  3702. }
  3703. /* Test configuration for debugging, modelled after the ALC880 test
  3704. * configuration.
  3705. */
  3706. #ifdef CONFIG_SND_DEBUG
  3707. static hda_nid_t alc260_test_dac_nids[1] = {
  3708. 0x02,
  3709. };
  3710. static hda_nid_t alc260_test_adc_nids[2] = {
  3711. 0x04, 0x05,
  3712. };
  3713. /* For testing the ALC260, each input MUX needs its own definition since
  3714. * the signal assignments are different. This assumes that the first ADC
  3715. * is NID 0x04.
  3716. */
  3717. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3718. {
  3719. .num_items = 7,
  3720. .items = {
  3721. { "MIC1 pin", 0x0 },
  3722. { "MIC2 pin", 0x1 },
  3723. { "LINE1 pin", 0x2 },
  3724. { "LINE2 pin", 0x3 },
  3725. { "CD pin", 0x4 },
  3726. { "LINE-OUT pin", 0x5 },
  3727. { "HP-OUT pin", 0x6 },
  3728. },
  3729. },
  3730. {
  3731. .num_items = 8,
  3732. .items = {
  3733. { "MIC1 pin", 0x0 },
  3734. { "MIC2 pin", 0x1 },
  3735. { "LINE1 pin", 0x2 },
  3736. { "LINE2 pin", 0x3 },
  3737. { "CD pin", 0x4 },
  3738. { "Mixer", 0x5 },
  3739. { "LINE-OUT pin", 0x6 },
  3740. { "HP-OUT pin", 0x7 },
  3741. },
  3742. },
  3743. };
  3744. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3745. /* Output driver widgets */
  3746. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3747. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3748. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3749. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3750. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3751. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3752. /* Modes for retasking pin widgets
  3753. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3754. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3755. * mention this restriction. At this stage it's not clear whether
  3756. * this behaviour is intentional or is a hardware bug in chip
  3757. * revisions available at least up until early 2006. Therefore for
  3758. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3759. * choices, but if it turns out that the lack of mic bias for these
  3760. * NIDs is intentional we could change their modes from
  3761. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3762. */
  3763. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3764. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3765. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3766. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3769. /* Loopback mixer controls */
  3770. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3771. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3772. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3773. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3774. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3775. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3776. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3777. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3779. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3781. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3783. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3785. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3786. /* Controls for GPIO pins, assuming they are configured as outputs */
  3787. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3788. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3789. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3791. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3792. * is ambigious as to which NID is which; testing on laptops which
  3793. * make this output available should provide clarification.
  3794. */
  3795. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3796. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3797. { } /* end */
  3798. };
  3799. static struct hda_verb alc260_test_init_verbs[] = {
  3800. /* Enable all GPIOs as outputs with an initial value of 0 */
  3801. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3802. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3803. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3804. /* Enable retasking pins as output, initially without power amp */
  3805. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3806. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3807. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3808. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. /* Disable digital (SPDIF) pins initially, but users can enable
  3812. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3813. * payload also sets the generation to 0, output to be in "consumer"
  3814. * PCM format, copyright asserted, no pre-emphasis and no validity
  3815. * control.
  3816. */
  3817. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3818. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3819. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3820. * OUT1 sum bus when acting as an output.
  3821. */
  3822. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3823. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3824. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3825. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3826. /* Start with output sum widgets muted and their output gains at min */
  3827. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3828. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3830. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3831. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3832. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3833. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. /* Unmute retasking pin widget output buffers since the default
  3837. * state appears to be output. As the pin mode is changed by the
  3838. * user the pin mode control will take care of enabling the pin's
  3839. * input/output buffers as needed.
  3840. */
  3841. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3842. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3843. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. /* Also unmute the mono-out pin widget */
  3848. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. /* Mute capture amp left and right */
  3850. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3851. /* Set ADC connection select to match default mixer setting (mic1
  3852. * pin)
  3853. */
  3854. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3855. /* Do the same for the second ADC: mute capture input amp and
  3856. * set ADC connection to mic1 pin
  3857. */
  3858. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3859. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3860. /* Mute all inputs to mixer widget (even unconnected ones) */
  3861. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3862. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3863. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3869. { }
  3870. };
  3871. #endif
  3872. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3873. .substreams = 1,
  3874. .channels_min = 2,
  3875. .channels_max = 2,
  3876. };
  3877. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3878. .substreams = 1,
  3879. .channels_min = 2,
  3880. .channels_max = 2,
  3881. };
  3882. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3883. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3884. /*
  3885. * for BIOS auto-configuration
  3886. */
  3887. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3888. const char *pfx)
  3889. {
  3890. hda_nid_t nid_vol;
  3891. unsigned long vol_val, sw_val;
  3892. char name[32];
  3893. int err;
  3894. if (nid >= 0x0f && nid < 0x11) {
  3895. nid_vol = nid - 0x7;
  3896. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3897. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3898. } else if (nid == 0x11) {
  3899. nid_vol = nid - 0x7;
  3900. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3901. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3902. } else if (nid >= 0x12 && nid <= 0x15) {
  3903. nid_vol = 0x08;
  3904. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3905. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3906. } else
  3907. return 0; /* N/A */
  3908. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3909. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3910. if (err < 0)
  3911. return err;
  3912. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3913. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3914. if (err < 0)
  3915. return err;
  3916. return 1;
  3917. }
  3918. /* add playback controls from the parsed DAC table */
  3919. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3920. const struct auto_pin_cfg *cfg)
  3921. {
  3922. hda_nid_t nid;
  3923. int err;
  3924. spec->multiout.num_dacs = 1;
  3925. spec->multiout.dac_nids = spec->private_dac_nids;
  3926. spec->multiout.dac_nids[0] = 0x02;
  3927. nid = cfg->line_out_pins[0];
  3928. if (nid) {
  3929. err = alc260_add_playback_controls(spec, nid, "Front");
  3930. if (err < 0)
  3931. return err;
  3932. }
  3933. nid = cfg->speaker_pins[0];
  3934. if (nid) {
  3935. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3936. if (err < 0)
  3937. return err;
  3938. }
  3939. nid = cfg->hp_pins[0];
  3940. if (nid) {
  3941. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3942. if (err < 0)
  3943. return err;
  3944. }
  3945. return 0;
  3946. }
  3947. /* create playback/capture controls for input pins */
  3948. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3949. const struct auto_pin_cfg *cfg)
  3950. {
  3951. struct hda_input_mux *imux = &spec->private_imux;
  3952. int i, err, idx;
  3953. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3954. if (cfg->input_pins[i] >= 0x12) {
  3955. idx = cfg->input_pins[i] - 0x12;
  3956. err = new_analog_input(spec, cfg->input_pins[i],
  3957. auto_pin_cfg_labels[i], idx,
  3958. 0x07);
  3959. if (err < 0)
  3960. return err;
  3961. imux->items[imux->num_items].label =
  3962. auto_pin_cfg_labels[i];
  3963. imux->items[imux->num_items].index = idx;
  3964. imux->num_items++;
  3965. }
  3966. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3967. idx = cfg->input_pins[i] - 0x09;
  3968. err = new_analog_input(spec, cfg->input_pins[i],
  3969. auto_pin_cfg_labels[i], idx,
  3970. 0x07);
  3971. if (err < 0)
  3972. return err;
  3973. imux->items[imux->num_items].label =
  3974. auto_pin_cfg_labels[i];
  3975. imux->items[imux->num_items].index = idx;
  3976. imux->num_items++;
  3977. }
  3978. }
  3979. return 0;
  3980. }
  3981. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3982. hda_nid_t nid, int pin_type,
  3983. int sel_idx)
  3984. {
  3985. /* set as output */
  3986. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3987. pin_type);
  3988. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3989. AMP_OUT_UNMUTE);
  3990. /* need the manual connection? */
  3991. if (nid >= 0x12) {
  3992. int idx = nid - 0x12;
  3993. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3994. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3995. }
  3996. }
  3997. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3998. {
  3999. struct alc_spec *spec = codec->spec;
  4000. hda_nid_t nid;
  4001. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4002. nid = spec->autocfg.line_out_pins[0];
  4003. if (nid) {
  4004. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4005. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4006. }
  4007. nid = spec->autocfg.speaker_pins[0];
  4008. if (nid)
  4009. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4010. nid = spec->autocfg.hp_pins[0];
  4011. if (nid)
  4012. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4013. }
  4014. #define ALC260_PIN_CD_NID 0x16
  4015. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4016. {
  4017. struct alc_spec *spec = codec->spec;
  4018. int i;
  4019. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4020. hda_nid_t nid = spec->autocfg.input_pins[i];
  4021. if (nid >= 0x12) {
  4022. snd_hda_codec_write(codec, nid, 0,
  4023. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4024. i <= AUTO_PIN_FRONT_MIC ?
  4025. PIN_VREF80 : PIN_IN);
  4026. if (nid != ALC260_PIN_CD_NID)
  4027. snd_hda_codec_write(codec, nid, 0,
  4028. AC_VERB_SET_AMP_GAIN_MUTE,
  4029. AMP_OUT_MUTE);
  4030. }
  4031. }
  4032. }
  4033. /*
  4034. * generic initialization of ADC, input mixers and output mixers
  4035. */
  4036. static struct hda_verb alc260_volume_init_verbs[] = {
  4037. /*
  4038. * Unmute ADC0-1 and set the default input to mic-in
  4039. */
  4040. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4041. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4042. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4043. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4044. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4045. * mixer widget
  4046. * Note: PASD motherboards uses the Line In 2 as the input for
  4047. * front panel mic (mic 2)
  4048. */
  4049. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4050. /* mute analog inputs */
  4051. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4052. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4053. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4056. /*
  4057. * Set up output mixers (0x08 - 0x0a)
  4058. */
  4059. /* set vol=0 to output mixers */
  4060. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4061. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4062. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4063. /* set up input amps for analog loopback */
  4064. /* Amp Indices: DAC = 0, mixer = 1 */
  4065. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4071. { }
  4072. };
  4073. static int alc260_parse_auto_config(struct hda_codec *codec)
  4074. {
  4075. struct alc_spec *spec = codec->spec;
  4076. unsigned int wcap;
  4077. int err;
  4078. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4079. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4080. alc260_ignore);
  4081. if (err < 0)
  4082. return err;
  4083. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4084. if (err < 0)
  4085. return err;
  4086. if (!spec->kctl_alloc)
  4087. return 0; /* can't find valid BIOS pin config */
  4088. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4089. if (err < 0)
  4090. return err;
  4091. spec->multiout.max_channels = 2;
  4092. if (spec->autocfg.dig_out_pin)
  4093. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4094. if (spec->kctl_alloc)
  4095. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4096. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4097. spec->num_mux_defs = 1;
  4098. spec->input_mux = &spec->private_imux;
  4099. /* check whether NID 0x04 is valid */
  4100. wcap = get_wcaps(codec, 0x04);
  4101. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4102. if (wcap != AC_WID_AUD_IN) {
  4103. spec->adc_nids = alc260_adc_nids_alt;
  4104. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4105. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4106. } else {
  4107. spec->adc_nids = alc260_adc_nids;
  4108. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4109. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4110. }
  4111. spec->num_mixers++;
  4112. return 1;
  4113. }
  4114. /* additional initialization for auto-configuration model */
  4115. static void alc260_auto_init(struct hda_codec *codec)
  4116. {
  4117. alc260_auto_init_multi_out(codec);
  4118. alc260_auto_init_analog_input(codec);
  4119. }
  4120. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4121. static struct hda_amp_list alc260_loopbacks[] = {
  4122. { 0x07, HDA_INPUT, 0 },
  4123. { 0x07, HDA_INPUT, 1 },
  4124. { 0x07, HDA_INPUT, 2 },
  4125. { 0x07, HDA_INPUT, 3 },
  4126. { 0x07, HDA_INPUT, 4 },
  4127. { } /* end */
  4128. };
  4129. #endif
  4130. /*
  4131. * ALC260 configurations
  4132. */
  4133. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4134. [ALC260_BASIC] = "basic",
  4135. [ALC260_HP] = "hp",
  4136. [ALC260_HP_3013] = "hp-3013",
  4137. [ALC260_FUJITSU_S702X] = "fujitsu",
  4138. [ALC260_ACER] = "acer",
  4139. [ALC260_WILL] = "will",
  4140. [ALC260_REPLACER_672V] = "replacer",
  4141. #ifdef CONFIG_SND_DEBUG
  4142. [ALC260_TEST] = "test",
  4143. #endif
  4144. [ALC260_AUTO] = "auto",
  4145. };
  4146. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4147. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4148. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4149. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4150. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4151. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4152. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4153. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4154. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4155. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4156. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4157. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4158. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4159. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4160. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4161. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4162. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4163. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4164. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4165. {}
  4166. };
  4167. static struct alc_config_preset alc260_presets[] = {
  4168. [ALC260_BASIC] = {
  4169. .mixers = { alc260_base_output_mixer,
  4170. alc260_input_mixer,
  4171. alc260_pc_beep_mixer,
  4172. alc260_capture_mixer },
  4173. .init_verbs = { alc260_init_verbs },
  4174. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4175. .dac_nids = alc260_dac_nids,
  4176. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4177. .adc_nids = alc260_adc_nids,
  4178. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4179. .channel_mode = alc260_modes,
  4180. .input_mux = &alc260_capture_source,
  4181. },
  4182. [ALC260_HP] = {
  4183. .mixers = { alc260_base_output_mixer,
  4184. alc260_input_mixer,
  4185. alc260_capture_alt_mixer },
  4186. .init_verbs = { alc260_init_verbs },
  4187. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4188. .dac_nids = alc260_dac_nids,
  4189. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4190. .adc_nids = alc260_hp_adc_nids,
  4191. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4192. .channel_mode = alc260_modes,
  4193. .input_mux = &alc260_capture_source,
  4194. },
  4195. [ALC260_HP_3013] = {
  4196. .mixers = { alc260_hp_3013_mixer,
  4197. alc260_input_mixer,
  4198. alc260_capture_alt_mixer },
  4199. .init_verbs = { alc260_hp_3013_init_verbs },
  4200. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4201. .dac_nids = alc260_dac_nids,
  4202. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4203. .adc_nids = alc260_hp_adc_nids,
  4204. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4205. .channel_mode = alc260_modes,
  4206. .input_mux = &alc260_capture_source,
  4207. },
  4208. [ALC260_FUJITSU_S702X] = {
  4209. .mixers = { alc260_fujitsu_mixer,
  4210. alc260_capture_mixer },
  4211. .init_verbs = { alc260_fujitsu_init_verbs },
  4212. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4213. .dac_nids = alc260_dac_nids,
  4214. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4215. .adc_nids = alc260_dual_adc_nids,
  4216. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4217. .channel_mode = alc260_modes,
  4218. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4219. .input_mux = alc260_fujitsu_capture_sources,
  4220. },
  4221. [ALC260_ACER] = {
  4222. .mixers = { alc260_acer_mixer,
  4223. alc260_capture_mixer },
  4224. .init_verbs = { alc260_acer_init_verbs },
  4225. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4226. .dac_nids = alc260_dac_nids,
  4227. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4228. .adc_nids = alc260_dual_adc_nids,
  4229. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4230. .channel_mode = alc260_modes,
  4231. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4232. .input_mux = alc260_acer_capture_sources,
  4233. },
  4234. [ALC260_WILL] = {
  4235. .mixers = { alc260_will_mixer,
  4236. alc260_capture_mixer },
  4237. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4238. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4239. .dac_nids = alc260_dac_nids,
  4240. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4241. .adc_nids = alc260_adc_nids,
  4242. .dig_out_nid = ALC260_DIGOUT_NID,
  4243. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4244. .channel_mode = alc260_modes,
  4245. .input_mux = &alc260_capture_source,
  4246. },
  4247. [ALC260_REPLACER_672V] = {
  4248. .mixers = { alc260_replacer_672v_mixer,
  4249. alc260_capture_mixer },
  4250. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4251. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4252. .dac_nids = alc260_dac_nids,
  4253. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4254. .adc_nids = alc260_adc_nids,
  4255. .dig_out_nid = ALC260_DIGOUT_NID,
  4256. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4257. .channel_mode = alc260_modes,
  4258. .input_mux = &alc260_capture_source,
  4259. .unsol_event = alc260_replacer_672v_unsol_event,
  4260. .init_hook = alc260_replacer_672v_automute,
  4261. },
  4262. #ifdef CONFIG_SND_DEBUG
  4263. [ALC260_TEST] = {
  4264. .mixers = { alc260_test_mixer,
  4265. alc260_capture_mixer },
  4266. .init_verbs = { alc260_test_init_verbs },
  4267. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4268. .dac_nids = alc260_test_dac_nids,
  4269. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4270. .adc_nids = alc260_test_adc_nids,
  4271. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4272. .channel_mode = alc260_modes,
  4273. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4274. .input_mux = alc260_test_capture_sources,
  4275. },
  4276. #endif
  4277. };
  4278. static int patch_alc260(struct hda_codec *codec)
  4279. {
  4280. struct alc_spec *spec;
  4281. int err, board_config;
  4282. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4283. if (spec == NULL)
  4284. return -ENOMEM;
  4285. codec->spec = spec;
  4286. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4287. alc260_models,
  4288. alc260_cfg_tbl);
  4289. if (board_config < 0) {
  4290. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4291. "trying auto-probe from BIOS...\n");
  4292. board_config = ALC260_AUTO;
  4293. }
  4294. if (board_config == ALC260_AUTO) {
  4295. /* automatic parse from the BIOS config */
  4296. err = alc260_parse_auto_config(codec);
  4297. if (err < 0) {
  4298. alc_free(codec);
  4299. return err;
  4300. } else if (!err) {
  4301. printk(KERN_INFO
  4302. "hda_codec: Cannot set up configuration "
  4303. "from BIOS. Using base mode...\n");
  4304. board_config = ALC260_BASIC;
  4305. }
  4306. }
  4307. if (board_config != ALC260_AUTO)
  4308. setup_preset(spec, &alc260_presets[board_config]);
  4309. spec->stream_name_analog = "ALC260 Analog";
  4310. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4311. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4312. spec->stream_name_digital = "ALC260 Digital";
  4313. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4314. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4315. codec->patch_ops = alc_patch_ops;
  4316. if (board_config == ALC260_AUTO)
  4317. spec->init_hook = alc260_auto_init;
  4318. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4319. if (!spec->loopback.amplist)
  4320. spec->loopback.amplist = alc260_loopbacks;
  4321. #endif
  4322. return 0;
  4323. }
  4324. /*
  4325. * ALC882 support
  4326. *
  4327. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4328. * configuration. Each pin widget can choose any input DACs and a mixer.
  4329. * Each ADC is connected from a mixer of all inputs. This makes possible
  4330. * 6-channel independent captures.
  4331. *
  4332. * In addition, an independent DAC for the multi-playback (not used in this
  4333. * driver yet).
  4334. */
  4335. #define ALC882_DIGOUT_NID 0x06
  4336. #define ALC882_DIGIN_NID 0x0a
  4337. static struct hda_channel_mode alc882_ch_modes[1] = {
  4338. { 8, NULL }
  4339. };
  4340. static hda_nid_t alc882_dac_nids[4] = {
  4341. /* front, rear, clfe, rear_surr */
  4342. 0x02, 0x03, 0x04, 0x05
  4343. };
  4344. /* identical with ALC880 */
  4345. #define alc882_adc_nids alc880_adc_nids
  4346. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4347. /* input MUX */
  4348. /* FIXME: should be a matrix-type input source selection */
  4349. static struct hda_input_mux alc882_capture_source = {
  4350. .num_items = 4,
  4351. .items = {
  4352. { "Mic", 0x0 },
  4353. { "Front Mic", 0x1 },
  4354. { "Line", 0x2 },
  4355. { "CD", 0x4 },
  4356. },
  4357. };
  4358. #define alc882_mux_enum_info alc_mux_enum_info
  4359. #define alc882_mux_enum_get alc_mux_enum_get
  4360. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4361. struct snd_ctl_elem_value *ucontrol)
  4362. {
  4363. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4364. struct alc_spec *spec = codec->spec;
  4365. const struct hda_input_mux *imux = spec->input_mux;
  4366. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4367. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4368. hda_nid_t nid = capture_mixers[adc_idx];
  4369. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4370. unsigned int i, idx;
  4371. idx = ucontrol->value.enumerated.item[0];
  4372. if (idx >= imux->num_items)
  4373. idx = imux->num_items - 1;
  4374. if (*cur_val == idx)
  4375. return 0;
  4376. for (i = 0; i < imux->num_items; i++) {
  4377. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4378. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4379. imux->items[i].index,
  4380. HDA_AMP_MUTE, v);
  4381. }
  4382. *cur_val = idx;
  4383. return 1;
  4384. }
  4385. /*
  4386. * 2ch mode
  4387. */
  4388. static struct hda_verb alc882_3ST_ch2_init[] = {
  4389. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4390. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4391. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4392. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4393. { } /* end */
  4394. };
  4395. /*
  4396. * 6ch mode
  4397. */
  4398. static struct hda_verb alc882_3ST_ch6_init[] = {
  4399. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4400. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4401. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4402. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4403. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4404. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4405. { } /* end */
  4406. };
  4407. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4408. { 2, alc882_3ST_ch2_init },
  4409. { 6, alc882_3ST_ch6_init },
  4410. };
  4411. /*
  4412. * 6ch mode
  4413. */
  4414. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4415. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4416. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4417. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4418. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4419. { } /* end */
  4420. };
  4421. /*
  4422. * 8ch mode
  4423. */
  4424. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4425. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4426. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4427. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4428. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4429. { } /* end */
  4430. };
  4431. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4432. { 6, alc882_sixstack_ch6_init },
  4433. { 8, alc882_sixstack_ch8_init },
  4434. };
  4435. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4436. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4437. */
  4438. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4439. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4440. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4442. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4443. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4444. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4445. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4446. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4447. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4448. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4449. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4450. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4451. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4452. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4453. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4454. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4455. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4456. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4459. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4461. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4462. { } /* end */
  4463. };
  4464. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4465. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4466. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4467. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4468. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4469. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4470. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4471. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4472. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4473. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4475. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4476. { } /* end */
  4477. };
  4478. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4479. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4480. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4481. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4482. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4483. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4484. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4485. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4486. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4487. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4490. { } /* end */
  4491. };
  4492. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4493. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4494. */
  4495. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4496. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4497. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4498. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4499. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4500. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4501. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4502. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4503. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4505. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4506. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4507. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4508. { } /* end */
  4509. };
  4510. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4511. {
  4512. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4513. .name = "Channel Mode",
  4514. .info = alc_ch_mode_info,
  4515. .get = alc_ch_mode_get,
  4516. .put = alc_ch_mode_put,
  4517. },
  4518. { } /* end */
  4519. };
  4520. static struct hda_verb alc882_init_verbs[] = {
  4521. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4522. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4523. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4524. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4525. /* Rear mixer */
  4526. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4527. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4528. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4529. /* CLFE mixer */
  4530. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4531. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4532. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4533. /* Side mixer */
  4534. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4535. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4536. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4537. /* Front Pin: output 0 (0x0c) */
  4538. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4539. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4540. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4541. /* Rear Pin: output 1 (0x0d) */
  4542. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4543. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4544. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4545. /* CLFE Pin: output 2 (0x0e) */
  4546. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4547. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4548. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4549. /* Side Pin: output 3 (0x0f) */
  4550. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4551. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4552. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4553. /* Mic (rear) pin: input vref at 80% */
  4554. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4555. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4556. /* Front Mic pin: input vref at 80% */
  4557. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4558. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4559. /* Line In pin: input */
  4560. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4561. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4562. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4563. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4564. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4565. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4566. /* CD pin widget for input */
  4567. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4568. /* FIXME: use matrix-type input source selection */
  4569. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4570. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4571. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4572. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4573. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4575. /* Input mixer2 */
  4576. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4577. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4578. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4580. /* Input mixer3 */
  4581. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4582. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4585. /* ADC1: mute amp left and right */
  4586. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4587. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4588. /* ADC2: mute amp left and right */
  4589. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4590. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4591. /* ADC3: mute amp left and right */
  4592. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4593. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4594. { }
  4595. };
  4596. static struct hda_verb alc882_eapd_verbs[] = {
  4597. /* change to EAPD mode */
  4598. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4599. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4600. { }
  4601. };
  4602. /* Mac Pro test */
  4603. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4604. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4605. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4606. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4607. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4608. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4609. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4610. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4611. { } /* end */
  4612. };
  4613. static struct hda_verb alc882_macpro_init_verbs[] = {
  4614. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4615. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4616. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4617. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4618. /* Front Pin: output 0 (0x0c) */
  4619. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4620. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4621. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4622. /* Front Mic pin: input vref at 80% */
  4623. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4624. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4625. /* Speaker: output */
  4626. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4627. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4628. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4629. /* Headphone output (output 0 - 0x0c) */
  4630. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4631. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4632. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4633. /* FIXME: use matrix-type input source selection */
  4634. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4635. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4636. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4637. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4638. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4640. /* Input mixer2 */
  4641. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4642. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4643. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4645. /* Input mixer3 */
  4646. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4647. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4648. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4650. /* ADC1: mute amp left and right */
  4651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4652. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4653. /* ADC2: mute amp left and right */
  4654. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4655. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4656. /* ADC3: mute amp left and right */
  4657. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4658. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4659. { }
  4660. };
  4661. /* iMac 24 mixer. */
  4662. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4663. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4664. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4665. { } /* end */
  4666. };
  4667. /* iMac 24 init verbs. */
  4668. static struct hda_verb alc885_imac24_init_verbs[] = {
  4669. /* Internal speakers: output 0 (0x0c) */
  4670. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4671. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4672. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4673. /* Internal speakers: output 0 (0x0c) */
  4674. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4675. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4676. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4677. /* Headphone: output 0 (0x0c) */
  4678. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4679. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4680. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4681. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4682. /* Front Mic: input vref at 80% */
  4683. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4684. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4685. { }
  4686. };
  4687. /* Toggle speaker-output according to the hp-jack state */
  4688. static void alc885_imac24_automute(struct hda_codec *codec)
  4689. {
  4690. unsigned int present;
  4691. present = snd_hda_codec_read(codec, 0x14, 0,
  4692. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4693. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4694. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4695. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4696. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4697. }
  4698. /* Processes unsolicited events. */
  4699. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4700. unsigned int res)
  4701. {
  4702. /* Headphone insertion or removal. */
  4703. if ((res >> 26) == ALC880_HP_EVENT)
  4704. alc885_imac24_automute(codec);
  4705. }
  4706. static struct hda_verb alc882_targa_verbs[] = {
  4707. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4709. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4710. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4711. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4712. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4713. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4714. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4715. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4716. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4717. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4718. { } /* end */
  4719. };
  4720. /* toggle speaker-output according to the hp-jack state */
  4721. static void alc882_targa_automute(struct hda_codec *codec)
  4722. {
  4723. unsigned int present;
  4724. present = snd_hda_codec_read(codec, 0x14, 0,
  4725. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4726. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4727. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4728. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4729. present ? 1 : 3);
  4730. }
  4731. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4732. {
  4733. /* Looks like the unsol event is incompatible with the standard
  4734. * definition. 4bit tag is placed at 26 bit!
  4735. */
  4736. if (((res >> 26) == ALC880_HP_EVENT)) {
  4737. alc882_targa_automute(codec);
  4738. }
  4739. }
  4740. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4741. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4742. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4743. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4744. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4745. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4746. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4747. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4748. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4749. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4750. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4751. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4752. { } /* end */
  4753. };
  4754. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4755. {
  4756. unsigned int gpiostate, gpiomask, gpiodir;
  4757. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4758. AC_VERB_GET_GPIO_DATA, 0);
  4759. if (!muted)
  4760. gpiostate |= (1 << pin);
  4761. else
  4762. gpiostate &= ~(1 << pin);
  4763. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4764. AC_VERB_GET_GPIO_MASK, 0);
  4765. gpiomask |= (1 << pin);
  4766. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4767. AC_VERB_GET_GPIO_DIRECTION, 0);
  4768. gpiodir |= (1 << pin);
  4769. snd_hda_codec_write(codec, codec->afg, 0,
  4770. AC_VERB_SET_GPIO_MASK, gpiomask);
  4771. snd_hda_codec_write(codec, codec->afg, 0,
  4772. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4773. msleep(1);
  4774. snd_hda_codec_write(codec, codec->afg, 0,
  4775. AC_VERB_SET_GPIO_DATA, gpiostate);
  4776. }
  4777. /*
  4778. * generic initialization of ADC, input mixers and output mixers
  4779. */
  4780. static struct hda_verb alc882_auto_init_verbs[] = {
  4781. /*
  4782. * Unmute ADC0-2 and set the default input to mic-in
  4783. */
  4784. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4785. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4786. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4787. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4788. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4789. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4790. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4791. * mixer widget
  4792. * Note: PASD motherboards uses the Line In 2 as the input for
  4793. * front panel mic (mic 2)
  4794. */
  4795. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4796. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4797. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4798. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4799. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4800. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4801. /*
  4802. * Set up output mixers (0x0c - 0x0f)
  4803. */
  4804. /* set vol=0 to output mixers */
  4805. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4806. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4807. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4808. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4809. /* set up input amps for analog loopback */
  4810. /* Amp Indices: DAC = 0, mixer = 1 */
  4811. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4812. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4813. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4814. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4815. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4816. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4817. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4818. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4819. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4820. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4821. /* FIXME: use matrix-type input source selection */
  4822. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4823. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4824. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4825. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4826. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4827. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4828. /* Input mixer2 */
  4829. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4830. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4831. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4832. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4833. /* Input mixer3 */
  4834. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4835. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4837. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4838. { }
  4839. };
  4840. /* capture mixer elements */
  4841. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4842. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4843. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4844. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4845. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4846. {
  4847. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4848. /* The multiple "Capture Source" controls confuse alsamixer
  4849. * So call somewhat different..
  4850. * FIXME: the controls appear in the "playback" view!
  4851. */
  4852. /* .name = "Capture Source", */
  4853. .name = "Input Source",
  4854. .count = 2,
  4855. .info = alc882_mux_enum_info,
  4856. .get = alc882_mux_enum_get,
  4857. .put = alc882_mux_enum_put,
  4858. },
  4859. { } /* end */
  4860. };
  4861. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4862. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4863. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4864. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4865. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4866. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4867. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4868. {
  4869. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4870. /* The multiple "Capture Source" controls confuse alsamixer
  4871. * So call somewhat different..
  4872. * FIXME: the controls appear in the "playback" view!
  4873. */
  4874. /* .name = "Capture Source", */
  4875. .name = "Input Source",
  4876. .count = 3,
  4877. .info = alc882_mux_enum_info,
  4878. .get = alc882_mux_enum_get,
  4879. .put = alc882_mux_enum_put,
  4880. },
  4881. { } /* end */
  4882. };
  4883. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4884. #define alc882_loopbacks alc880_loopbacks
  4885. #endif
  4886. /* pcm configuration: identiacal with ALC880 */
  4887. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4888. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4889. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4890. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4891. /*
  4892. * configuration and preset
  4893. */
  4894. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4895. [ALC882_3ST_DIG] = "3stack-dig",
  4896. [ALC882_6ST_DIG] = "6stack-dig",
  4897. [ALC882_ARIMA] = "arima",
  4898. [ALC882_W2JC] = "w2jc",
  4899. [ALC885_MACPRO] = "macpro",
  4900. [ALC885_IMAC24] = "imac24",
  4901. [ALC882_AUTO] = "auto",
  4902. };
  4903. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4904. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4905. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4906. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4907. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4908. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4909. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4910. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  4911. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4912. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4913. {}
  4914. };
  4915. static struct alc_config_preset alc882_presets[] = {
  4916. [ALC882_3ST_DIG] = {
  4917. .mixers = { alc882_base_mixer },
  4918. .init_verbs = { alc882_init_verbs },
  4919. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4920. .dac_nids = alc882_dac_nids,
  4921. .dig_out_nid = ALC882_DIGOUT_NID,
  4922. .dig_in_nid = ALC882_DIGIN_NID,
  4923. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4924. .channel_mode = alc882_ch_modes,
  4925. .need_dac_fix = 1,
  4926. .input_mux = &alc882_capture_source,
  4927. },
  4928. [ALC882_6ST_DIG] = {
  4929. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4930. .init_verbs = { alc882_init_verbs },
  4931. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4932. .dac_nids = alc882_dac_nids,
  4933. .dig_out_nid = ALC882_DIGOUT_NID,
  4934. .dig_in_nid = ALC882_DIGIN_NID,
  4935. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4936. .channel_mode = alc882_sixstack_modes,
  4937. .input_mux = &alc882_capture_source,
  4938. },
  4939. [ALC882_ARIMA] = {
  4940. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4941. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4942. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4943. .dac_nids = alc882_dac_nids,
  4944. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4945. .channel_mode = alc882_sixstack_modes,
  4946. .input_mux = &alc882_capture_source,
  4947. },
  4948. [ALC882_W2JC] = {
  4949. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4950. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4951. alc880_gpio1_init_verbs },
  4952. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4953. .dac_nids = alc882_dac_nids,
  4954. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4955. .channel_mode = alc880_threestack_modes,
  4956. .need_dac_fix = 1,
  4957. .input_mux = &alc882_capture_source,
  4958. .dig_out_nid = ALC882_DIGOUT_NID,
  4959. },
  4960. [ALC885_MACPRO] = {
  4961. .mixers = { alc882_macpro_mixer },
  4962. .init_verbs = { alc882_macpro_init_verbs },
  4963. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4964. .dac_nids = alc882_dac_nids,
  4965. .dig_out_nid = ALC882_DIGOUT_NID,
  4966. .dig_in_nid = ALC882_DIGIN_NID,
  4967. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4968. .channel_mode = alc882_ch_modes,
  4969. .input_mux = &alc882_capture_source,
  4970. },
  4971. [ALC885_IMAC24] = {
  4972. .mixers = { alc885_imac24_mixer },
  4973. .init_verbs = { alc885_imac24_init_verbs },
  4974. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4975. .dac_nids = alc882_dac_nids,
  4976. .dig_out_nid = ALC882_DIGOUT_NID,
  4977. .dig_in_nid = ALC882_DIGIN_NID,
  4978. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4979. .channel_mode = alc882_ch_modes,
  4980. .input_mux = &alc882_capture_source,
  4981. .unsol_event = alc885_imac24_unsol_event,
  4982. .init_hook = alc885_imac24_automute,
  4983. },
  4984. [ALC882_TARGA] = {
  4985. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4986. alc882_capture_mixer },
  4987. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4988. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4989. .dac_nids = alc882_dac_nids,
  4990. .dig_out_nid = ALC882_DIGOUT_NID,
  4991. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4992. .adc_nids = alc882_adc_nids,
  4993. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4994. .channel_mode = alc882_3ST_6ch_modes,
  4995. .need_dac_fix = 1,
  4996. .input_mux = &alc882_capture_source,
  4997. .unsol_event = alc882_targa_unsol_event,
  4998. .init_hook = alc882_targa_automute,
  4999. },
  5000. [ALC882_ASUS_A7J] = {
  5001. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5002. alc882_capture_mixer },
  5003. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5004. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5005. .dac_nids = alc882_dac_nids,
  5006. .dig_out_nid = ALC882_DIGOUT_NID,
  5007. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5008. .adc_nids = alc882_adc_nids,
  5009. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5010. .channel_mode = alc882_3ST_6ch_modes,
  5011. .need_dac_fix = 1,
  5012. .input_mux = &alc882_capture_source,
  5013. },
  5014. };
  5015. /*
  5016. * Pin config fixes
  5017. */
  5018. enum {
  5019. PINFIX_ABIT_AW9D_MAX
  5020. };
  5021. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5022. { 0x15, 0x01080104 }, /* side */
  5023. { 0x16, 0x01011012 }, /* rear */
  5024. { 0x17, 0x01016011 }, /* clfe */
  5025. { }
  5026. };
  5027. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5028. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5029. };
  5030. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5031. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5032. {}
  5033. };
  5034. /*
  5035. * BIOS auto configuration
  5036. */
  5037. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5038. hda_nid_t nid, int pin_type,
  5039. int dac_idx)
  5040. {
  5041. /* set as output */
  5042. struct alc_spec *spec = codec->spec;
  5043. int idx;
  5044. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5045. idx = 4;
  5046. else
  5047. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5048. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5049. pin_type);
  5050. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5051. AMP_OUT_UNMUTE);
  5052. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5053. }
  5054. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5055. {
  5056. struct alc_spec *spec = codec->spec;
  5057. int i;
  5058. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5059. for (i = 0; i <= HDA_SIDE; i++) {
  5060. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5061. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5062. if (nid)
  5063. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5064. i);
  5065. }
  5066. }
  5067. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5068. {
  5069. struct alc_spec *spec = codec->spec;
  5070. hda_nid_t pin;
  5071. pin = spec->autocfg.hp_pins[0];
  5072. if (pin) /* connect to front */
  5073. /* use dac 0 */
  5074. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5075. }
  5076. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5077. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5078. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5079. {
  5080. struct alc_spec *spec = codec->spec;
  5081. int i;
  5082. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5083. hda_nid_t nid = spec->autocfg.input_pins[i];
  5084. if (alc882_is_input_pin(nid)) {
  5085. snd_hda_codec_write(codec, nid, 0,
  5086. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5087. i <= AUTO_PIN_FRONT_MIC ?
  5088. PIN_VREF80 : PIN_IN);
  5089. if (nid != ALC882_PIN_CD_NID)
  5090. snd_hda_codec_write(codec, nid, 0,
  5091. AC_VERB_SET_AMP_GAIN_MUTE,
  5092. AMP_OUT_MUTE);
  5093. }
  5094. }
  5095. }
  5096. /* almost identical with ALC880 parser... */
  5097. static int alc882_parse_auto_config(struct hda_codec *codec)
  5098. {
  5099. struct alc_spec *spec = codec->spec;
  5100. int err = alc880_parse_auto_config(codec);
  5101. if (err < 0)
  5102. return err;
  5103. else if (err > 0)
  5104. /* hack - override the init verbs */
  5105. spec->init_verbs[0] = alc882_auto_init_verbs;
  5106. return err;
  5107. }
  5108. /* additional initialization for auto-configuration model */
  5109. static void alc882_auto_init(struct hda_codec *codec)
  5110. {
  5111. alc882_auto_init_multi_out(codec);
  5112. alc882_auto_init_hp_out(codec);
  5113. alc882_auto_init_analog_input(codec);
  5114. }
  5115. static int patch_alc882(struct hda_codec *codec)
  5116. {
  5117. struct alc_spec *spec;
  5118. int err, board_config;
  5119. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5120. if (spec == NULL)
  5121. return -ENOMEM;
  5122. codec->spec = spec;
  5123. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5124. alc882_models,
  5125. alc882_cfg_tbl);
  5126. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5127. /* Pick up systems that don't supply PCI SSID */
  5128. switch (codec->subsystem_id) {
  5129. case 0x106b0c00: /* Mac Pro */
  5130. board_config = ALC885_MACPRO;
  5131. break;
  5132. case 0x106b1000: /* iMac 24 */
  5133. board_config = ALC885_IMAC24;
  5134. break;
  5135. default:
  5136. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5137. "trying auto-probe from BIOS...\n");
  5138. board_config = ALC882_AUTO;
  5139. }
  5140. }
  5141. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5142. if (board_config == ALC882_AUTO) {
  5143. /* automatic parse from the BIOS config */
  5144. err = alc882_parse_auto_config(codec);
  5145. if (err < 0) {
  5146. alc_free(codec);
  5147. return err;
  5148. } else if (!err) {
  5149. printk(KERN_INFO
  5150. "hda_codec: Cannot set up configuration "
  5151. "from BIOS. Using base mode...\n");
  5152. board_config = ALC882_3ST_DIG;
  5153. }
  5154. }
  5155. if (board_config != ALC882_AUTO)
  5156. setup_preset(spec, &alc882_presets[board_config]);
  5157. if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
  5158. alc882_gpio_mute(codec, 0, 0);
  5159. alc882_gpio_mute(codec, 1, 0);
  5160. }
  5161. spec->stream_name_analog = "ALC882 Analog";
  5162. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5163. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5164. spec->stream_name_digital = "ALC882 Digital";
  5165. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5166. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5167. if (!spec->adc_nids && spec->input_mux) {
  5168. /* check whether NID 0x07 is valid */
  5169. unsigned int wcap = get_wcaps(codec, 0x07);
  5170. /* get type */
  5171. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5172. if (wcap != AC_WID_AUD_IN) {
  5173. spec->adc_nids = alc882_adc_nids_alt;
  5174. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5175. spec->mixers[spec->num_mixers] =
  5176. alc882_capture_alt_mixer;
  5177. spec->num_mixers++;
  5178. } else {
  5179. spec->adc_nids = alc882_adc_nids;
  5180. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5181. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5182. spec->num_mixers++;
  5183. }
  5184. }
  5185. codec->patch_ops = alc_patch_ops;
  5186. if (board_config == ALC882_AUTO)
  5187. spec->init_hook = alc882_auto_init;
  5188. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5189. if (!spec->loopback.amplist)
  5190. spec->loopback.amplist = alc882_loopbacks;
  5191. #endif
  5192. return 0;
  5193. }
  5194. /*
  5195. * ALC883 support
  5196. *
  5197. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5198. * configuration. Each pin widget can choose any input DACs and a mixer.
  5199. * Each ADC is connected from a mixer of all inputs. This makes possible
  5200. * 6-channel independent captures.
  5201. *
  5202. * In addition, an independent DAC for the multi-playback (not used in this
  5203. * driver yet).
  5204. */
  5205. #define ALC883_DIGOUT_NID 0x06
  5206. #define ALC883_DIGIN_NID 0x0a
  5207. static hda_nid_t alc883_dac_nids[4] = {
  5208. /* front, rear, clfe, rear_surr */
  5209. 0x02, 0x04, 0x03, 0x05
  5210. };
  5211. static hda_nid_t alc883_adc_nids[2] = {
  5212. /* ADC1-2 */
  5213. 0x08, 0x09,
  5214. };
  5215. /* input MUX */
  5216. /* FIXME: should be a matrix-type input source selection */
  5217. static struct hda_input_mux alc883_capture_source = {
  5218. .num_items = 4,
  5219. .items = {
  5220. { "Mic", 0x0 },
  5221. { "Front Mic", 0x1 },
  5222. { "Line", 0x2 },
  5223. { "CD", 0x4 },
  5224. },
  5225. };
  5226. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5227. .num_items = 2,
  5228. .items = {
  5229. { "Mic", 0x1 },
  5230. { "Line", 0x2 },
  5231. },
  5232. };
  5233. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5234. .num_items = 4,
  5235. .items = {
  5236. { "Mic", 0x0 },
  5237. { "iMic", 0x1 },
  5238. { "Line", 0x2 },
  5239. { "CD", 0x4 },
  5240. },
  5241. };
  5242. #define alc883_mux_enum_info alc_mux_enum_info
  5243. #define alc883_mux_enum_get alc_mux_enum_get
  5244. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5245. struct snd_ctl_elem_value *ucontrol)
  5246. {
  5247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5248. struct alc_spec *spec = codec->spec;
  5249. const struct hda_input_mux *imux = spec->input_mux;
  5250. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5251. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5252. hda_nid_t nid = capture_mixers[adc_idx];
  5253. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5254. unsigned int i, idx;
  5255. idx = ucontrol->value.enumerated.item[0];
  5256. if (idx >= imux->num_items)
  5257. idx = imux->num_items - 1;
  5258. if (*cur_val == idx)
  5259. return 0;
  5260. for (i = 0; i < imux->num_items; i++) {
  5261. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5262. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5263. imux->items[i].index,
  5264. HDA_AMP_MUTE, v);
  5265. }
  5266. *cur_val = idx;
  5267. return 1;
  5268. }
  5269. /*
  5270. * 2ch mode
  5271. */
  5272. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5273. { 2, NULL }
  5274. };
  5275. /*
  5276. * 2ch mode
  5277. */
  5278. static struct hda_verb alc883_3ST_ch2_init[] = {
  5279. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5280. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5281. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5282. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5283. { } /* end */
  5284. };
  5285. /*
  5286. * 6ch mode
  5287. */
  5288. static struct hda_verb alc883_3ST_ch6_init[] = {
  5289. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5290. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5291. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5292. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5293. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5294. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5295. { } /* end */
  5296. };
  5297. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5298. { 2, alc883_3ST_ch2_init },
  5299. { 6, alc883_3ST_ch6_init },
  5300. };
  5301. /*
  5302. * 6ch mode
  5303. */
  5304. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5305. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5306. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5307. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5308. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5309. { } /* end */
  5310. };
  5311. /*
  5312. * 8ch mode
  5313. */
  5314. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5315. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5316. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5317. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5318. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5319. { } /* end */
  5320. };
  5321. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5322. { 6, alc883_sixstack_ch6_init },
  5323. { 8, alc883_sixstack_ch8_init },
  5324. };
  5325. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5326. /* eanable EAPD on medion laptop */
  5327. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5328. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5329. { }
  5330. };
  5331. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5332. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5333. */
  5334. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5335. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5336. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5338. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5339. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5340. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5341. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5342. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5343. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5344. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5345. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5346. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5347. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5348. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5349. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5350. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5351. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5352. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5353. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5355. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5356. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5357. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5358. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5359. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5360. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5361. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5362. {
  5363. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5364. /* .name = "Capture Source", */
  5365. .name = "Input Source",
  5366. .count = 2,
  5367. .info = alc883_mux_enum_info,
  5368. .get = alc883_mux_enum_get,
  5369. .put = alc883_mux_enum_put,
  5370. },
  5371. { } /* end */
  5372. };
  5373. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5374. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5375. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5376. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5377. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5378. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5380. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5382. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5383. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5384. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5386. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5387. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5388. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5389. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5390. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5391. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5392. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5393. {
  5394. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5395. /* .name = "Capture Source", */
  5396. .name = "Input Source",
  5397. .count = 2,
  5398. .info = alc883_mux_enum_info,
  5399. .get = alc883_mux_enum_get,
  5400. .put = alc883_mux_enum_put,
  5401. },
  5402. { } /* end */
  5403. };
  5404. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5405. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5406. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5408. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5409. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5410. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5411. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5412. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5413. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5414. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5415. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5416. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5417. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5418. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5419. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5420. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5421. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5422. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5423. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5424. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5425. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5426. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5427. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5428. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5429. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5430. {
  5431. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5432. /* .name = "Capture Source", */
  5433. .name = "Input Source",
  5434. .count = 2,
  5435. .info = alc883_mux_enum_info,
  5436. .get = alc883_mux_enum_get,
  5437. .put = alc883_mux_enum_put,
  5438. },
  5439. { } /* end */
  5440. };
  5441. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5442. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5443. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5444. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5445. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5446. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5447. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5448. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5449. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5450. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5451. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5452. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5453. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5454. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5455. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5456. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5457. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5458. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5459. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5460. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5461. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5462. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5463. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5464. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5465. {
  5466. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5467. /* .name = "Capture Source", */
  5468. .name = "Input Source",
  5469. .count = 1,
  5470. .info = alc883_mux_enum_info,
  5471. .get = alc883_mux_enum_get,
  5472. .put = alc883_mux_enum_put,
  5473. },
  5474. { } /* end */
  5475. };
  5476. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5477. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5478. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5479. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5480. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5481. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5482. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5483. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5484. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5485. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5486. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5487. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5488. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5489. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5490. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5491. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5492. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5493. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5494. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5495. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5496. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5497. {
  5498. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5499. /* .name = "Capture Source", */
  5500. .name = "Input Source",
  5501. .count = 2,
  5502. .info = alc883_mux_enum_info,
  5503. .get = alc883_mux_enum_get,
  5504. .put = alc883_mux_enum_put,
  5505. },
  5506. { } /* end */
  5507. };
  5508. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5509. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5510. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5511. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5512. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5513. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5514. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5515. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5516. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5517. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5518. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5519. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5520. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5521. {
  5522. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5523. /* .name = "Capture Source", */
  5524. .name = "Input Source",
  5525. .count = 2,
  5526. .info = alc883_mux_enum_info,
  5527. .get = alc883_mux_enum_get,
  5528. .put = alc883_mux_enum_put,
  5529. },
  5530. { } /* end */
  5531. };
  5532. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5533. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5534. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5535. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5536. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5537. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5538. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5539. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5540. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5541. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5542. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5543. {
  5544. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5545. /* .name = "Capture Source", */
  5546. .name = "Input Source",
  5547. .count = 1,
  5548. .info = alc883_mux_enum_info,
  5549. .get = alc883_mux_enum_get,
  5550. .put = alc883_mux_enum_put,
  5551. },
  5552. { } /* end */
  5553. };
  5554. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5555. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5556. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5557. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5558. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5559. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5560. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5561. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5562. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5563. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, 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_medion_md2_mixer[] = {
  5580. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5581. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5582. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5583. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5584. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5585. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5586. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5587. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5588. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5589. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5590. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5591. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5592. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5593. {
  5594. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5595. /* .name = "Capture Source", */
  5596. .name = "Input Source",
  5597. .count = 2,
  5598. .info = alc883_mux_enum_info,
  5599. .get = alc883_mux_enum_get,
  5600. .put = alc883_mux_enum_put,
  5601. },
  5602. { } /* end */
  5603. };
  5604. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5605. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5606. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5607. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5608. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5609. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5610. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5611. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5612. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5613. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5614. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5615. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5616. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5617. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5618. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5619. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5620. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5621. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5622. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5623. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5624. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5625. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5627. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5628. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5629. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5630. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5631. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5632. {
  5633. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5634. /* .name = "Capture Source", */
  5635. .name = "Input Source",
  5636. .count = 2,
  5637. .info = alc883_mux_enum_info,
  5638. .get = alc883_mux_enum_get,
  5639. .put = alc883_mux_enum_put,
  5640. },
  5641. { } /* end */
  5642. };
  5643. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5644. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5645. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5646. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5647. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5648. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5649. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5650. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5651. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5652. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5653. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5654. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5655. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5656. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5657. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5659. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5660. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5662. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5664. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5665. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5666. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5667. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5668. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5669. {
  5670. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5671. /* .name = "Capture Source", */
  5672. .name = "Input Source",
  5673. .count = 2,
  5674. .info = alc883_mux_enum_info,
  5675. .get = alc883_mux_enum_get,
  5676. .put = alc883_mux_enum_put,
  5677. },
  5678. { } /* end */
  5679. };
  5680. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5681. HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5682. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5683. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5684. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5686. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5687. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5688. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5689. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5690. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5691. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5692. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5693. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5694. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5695. {
  5696. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5697. /* .name = "Capture Source", */
  5698. .name = "Input Source",
  5699. .count = 2,
  5700. .info = alc883_mux_enum_info,
  5701. .get = alc883_mux_enum_get,
  5702. .put = alc883_mux_enum_put,
  5703. },
  5704. { } /* end */
  5705. };
  5706. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5707. {
  5708. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5709. .name = "Channel Mode",
  5710. .info = alc_ch_mode_info,
  5711. .get = alc_ch_mode_get,
  5712. .put = alc_ch_mode_put,
  5713. },
  5714. { } /* end */
  5715. };
  5716. static struct hda_verb alc883_init_verbs[] = {
  5717. /* ADC1: mute amp left and right */
  5718. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5719. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5720. /* ADC2: mute amp left and right */
  5721. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5722. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5723. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5724. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5727. /* Rear mixer */
  5728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5729. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5730. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5731. /* CLFE mixer */
  5732. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5733. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5734. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5735. /* Side mixer */
  5736. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5737. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5738. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5739. /* mute analog input loopbacks */
  5740. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5742. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5743. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5744. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5745. /* Front Pin: output 0 (0x0c) */
  5746. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5747. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5748. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5749. /* Rear Pin: output 1 (0x0d) */
  5750. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5751. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5752. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5753. /* CLFE Pin: output 2 (0x0e) */
  5754. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5755. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5756. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5757. /* Side Pin: output 3 (0x0f) */
  5758. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5759. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5760. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5761. /* Mic (rear) pin: input vref at 80% */
  5762. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5763. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5764. /* Front Mic pin: input vref at 80% */
  5765. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5766. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5767. /* Line In pin: input */
  5768. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5769. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5770. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5771. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5772. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5773. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5774. /* CD pin widget for input */
  5775. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5776. /* FIXME: use matrix-type input source selection */
  5777. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5778. /* Input mixer2 */
  5779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5780. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5781. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5782. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5783. /* Input mixer3 */
  5784. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5785. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5786. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5787. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5788. { }
  5789. };
  5790. static struct hda_verb alc883_tagra_verbs[] = {
  5791. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5792. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5793. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5794. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5795. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5796. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5797. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5798. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5799. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5800. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5801. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5802. { } /* end */
  5803. };
  5804. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5805. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5806. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5807. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5808. { } /* end */
  5809. };
  5810. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5811. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5812. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5813. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5814. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5815. { } /* end */
  5816. };
  5817. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5820. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5821. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5822. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5823. { } /* end */
  5824. };
  5825. static struct hda_verb alc888_6st_hp_verbs[] = {
  5826. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5827. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5828. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5829. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5830. { }
  5831. };
  5832. static struct hda_verb alc888_3st_hp_verbs[] = {
  5833. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5834. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5835. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5836. { }
  5837. };
  5838. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5839. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5840. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5841. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5842. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5843. { }
  5844. };
  5845. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5846. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5847. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5848. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5849. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5850. { }
  5851. };
  5852. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5853. { 2, alc888_3st_hp_2ch_init },
  5854. { 6, alc888_3st_hp_6ch_init },
  5855. };
  5856. /* toggle front-jack and RCA according to the hp-jack state */
  5857. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5858. {
  5859. unsigned int present;
  5860. present = snd_hda_codec_read(codec, 0x1b, 0,
  5861. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5862. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  5863. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5864. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5865. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5866. }
  5867. /* toggle RCA according to the front-jack state */
  5868. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5869. {
  5870. unsigned int present;
  5871. present = snd_hda_codec_read(codec, 0x14, 0,
  5872. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5873. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5874. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5875. }
  5876. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5877. unsigned int res)
  5878. {
  5879. if ((res >> 26) == ALC880_HP_EVENT)
  5880. alc888_lenovo_ms7195_front_automute(codec);
  5881. if ((res >> 26) == ALC880_FRONT_EVENT)
  5882. alc888_lenovo_ms7195_rca_automute(codec);
  5883. }
  5884. static struct hda_verb alc883_medion_md2_verbs[] = {
  5885. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5886. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5887. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5888. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5889. { } /* end */
  5890. };
  5891. static struct hda_verb alc883_acer_aspire_verbs[] = {
  5892. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5893. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5894. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5895. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5896. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5897. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5898. { } /* end */
  5899. };
  5900. /* toggle speaker-output according to the hp-jack state */
  5901. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5902. {
  5903. unsigned int present;
  5904. present = snd_hda_codec_read(codec, 0x14, 0,
  5905. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5906. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5907. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5908. }
  5909. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5910. unsigned int res)
  5911. {
  5912. if ((res >> 26) == ALC880_HP_EVENT)
  5913. alc883_medion_md2_automute(codec);
  5914. }
  5915. /* toggle speaker-output according to the hp-jack state */
  5916. static void alc883_tagra_automute(struct hda_codec *codec)
  5917. {
  5918. unsigned int present;
  5919. unsigned char bits;
  5920. present = snd_hda_codec_read(codec, 0x14, 0,
  5921. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5922. bits = present ? HDA_AMP_MUTE : 0;
  5923. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5924. HDA_AMP_MUTE, bits);
  5925. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5926. present ? 1 : 3);
  5927. }
  5928. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5929. {
  5930. if ((res >> 26) == ALC880_HP_EVENT)
  5931. alc883_tagra_automute(codec);
  5932. }
  5933. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5934. {
  5935. unsigned int present;
  5936. unsigned char bits;
  5937. present = snd_hda_codec_read(codec, 0x14, 0,
  5938. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5939. bits = present ? HDA_AMP_MUTE : 0;
  5940. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5941. HDA_AMP_MUTE, bits);
  5942. }
  5943. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5944. {
  5945. unsigned int present;
  5946. unsigned char bits;
  5947. present = snd_hda_codec_read(codec, 0x1b, 0,
  5948. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5949. bits = present ? HDA_AMP_MUTE : 0;
  5950. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5951. HDA_AMP_MUTE, bits);
  5952. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  5953. HDA_AMP_MUTE, bits);
  5954. }
  5955. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5956. unsigned int res)
  5957. {
  5958. if ((res >> 26) == ALC880_HP_EVENT)
  5959. alc883_lenovo_101e_all_automute(codec);
  5960. if ((res >> 26) == ALC880_FRONT_EVENT)
  5961. alc883_lenovo_101e_ispeaker_automute(codec);
  5962. }
  5963. /*
  5964. * generic initialization of ADC, input mixers and output mixers
  5965. */
  5966. static struct hda_verb alc883_auto_init_verbs[] = {
  5967. /*
  5968. * Unmute ADC0-2 and set the default input to mic-in
  5969. */
  5970. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5972. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5973. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5974. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5975. * mixer widget
  5976. * Note: PASD motherboards uses the Line In 2 as the input for
  5977. * front panel mic (mic 2)
  5978. */
  5979. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5980. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5982. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5985. /*
  5986. * Set up output mixers (0x0c - 0x0f)
  5987. */
  5988. /* set vol=0 to output mixers */
  5989. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5990. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5991. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5992. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5993. /* set up input amps for analog loopback */
  5994. /* Amp Indices: DAC = 0, mixer = 1 */
  5995. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5996. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5997. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5998. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5999. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6000. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6001. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6002. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6003. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6004. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6005. /* FIXME: use matrix-type input source selection */
  6006. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6007. /* Input mixer1 */
  6008. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6009. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6010. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6011. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6012. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6013. /* Input mixer2 */
  6014. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6015. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6016. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6017. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6018. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6019. { }
  6020. };
  6021. /* capture mixer elements */
  6022. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6023. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6024. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6025. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6026. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6027. {
  6028. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6029. /* The multiple "Capture Source" controls confuse alsamixer
  6030. * So call somewhat different..
  6031. * FIXME: the controls appear in the "playback" view!
  6032. */
  6033. /* .name = "Capture Source", */
  6034. .name = "Input Source",
  6035. .count = 2,
  6036. .info = alc882_mux_enum_info,
  6037. .get = alc882_mux_enum_get,
  6038. .put = alc882_mux_enum_put,
  6039. },
  6040. { } /* end */
  6041. };
  6042. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6043. #define alc883_loopbacks alc880_loopbacks
  6044. #endif
  6045. /* pcm configuration: identiacal with ALC880 */
  6046. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6047. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6048. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6049. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6050. /*
  6051. * configuration and preset
  6052. */
  6053. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6054. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6055. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6056. [ALC883_3ST_6ch] = "3stack-6ch",
  6057. [ALC883_6ST_DIG] = "6stack-dig",
  6058. [ALC883_TARGA_DIG] = "targa-dig",
  6059. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6060. [ALC883_ACER] = "acer",
  6061. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6062. [ALC883_MEDION] = "medion",
  6063. [ALC883_MEDION_MD2] = "medion-md2",
  6064. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6065. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6066. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6067. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6068. [ALC888_6ST_HP] = "6stack-hp",
  6069. [ALC888_3ST_HP] = "3stack-hp",
  6070. [ALC883_AUTO] = "auto",
  6071. };
  6072. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6073. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6074. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6075. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6076. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6077. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6078. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6079. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6080. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6081. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6082. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6083. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6084. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6085. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6086. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6087. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6088. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6089. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6090. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6091. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6092. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6093. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6094. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6095. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6096. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6097. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6098. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6099. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6100. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6101. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6102. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6103. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6104. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6105. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6106. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6107. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6108. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6109. {}
  6110. };
  6111. static struct alc_config_preset alc883_presets[] = {
  6112. [ALC883_3ST_2ch_DIG] = {
  6113. .mixers = { alc883_3ST_2ch_mixer },
  6114. .init_verbs = { alc883_init_verbs },
  6115. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6116. .dac_nids = alc883_dac_nids,
  6117. .dig_out_nid = ALC883_DIGOUT_NID,
  6118. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6119. .adc_nids = alc883_adc_nids,
  6120. .dig_in_nid = ALC883_DIGIN_NID,
  6121. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6122. .channel_mode = alc883_3ST_2ch_modes,
  6123. .input_mux = &alc883_capture_source,
  6124. },
  6125. [ALC883_3ST_6ch_DIG] = {
  6126. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6127. .init_verbs = { alc883_init_verbs },
  6128. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6129. .dac_nids = alc883_dac_nids,
  6130. .dig_out_nid = ALC883_DIGOUT_NID,
  6131. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6132. .adc_nids = alc883_adc_nids,
  6133. .dig_in_nid = ALC883_DIGIN_NID,
  6134. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6135. .channel_mode = alc883_3ST_6ch_modes,
  6136. .need_dac_fix = 1,
  6137. .input_mux = &alc883_capture_source,
  6138. },
  6139. [ALC883_3ST_6ch] = {
  6140. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6141. .init_verbs = { alc883_init_verbs },
  6142. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6143. .dac_nids = alc883_dac_nids,
  6144. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6145. .adc_nids = alc883_adc_nids,
  6146. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6147. .channel_mode = alc883_3ST_6ch_modes,
  6148. .need_dac_fix = 1,
  6149. .input_mux = &alc883_capture_source,
  6150. },
  6151. [ALC883_6ST_DIG] = {
  6152. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6153. .init_verbs = { alc883_init_verbs },
  6154. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6155. .dac_nids = alc883_dac_nids,
  6156. .dig_out_nid = ALC883_DIGOUT_NID,
  6157. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6158. .adc_nids = alc883_adc_nids,
  6159. .dig_in_nid = ALC883_DIGIN_NID,
  6160. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6161. .channel_mode = alc883_sixstack_modes,
  6162. .input_mux = &alc883_capture_source,
  6163. },
  6164. [ALC883_TARGA_DIG] = {
  6165. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6166. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6167. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6168. .dac_nids = alc883_dac_nids,
  6169. .dig_out_nid = ALC883_DIGOUT_NID,
  6170. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6171. .adc_nids = alc883_adc_nids,
  6172. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6173. .channel_mode = alc883_3ST_6ch_modes,
  6174. .need_dac_fix = 1,
  6175. .input_mux = &alc883_capture_source,
  6176. .unsol_event = alc883_tagra_unsol_event,
  6177. .init_hook = alc883_tagra_automute,
  6178. },
  6179. [ALC883_TARGA_2ch_DIG] = {
  6180. .mixers = { alc883_tagra_2ch_mixer},
  6181. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6182. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6183. .dac_nids = alc883_dac_nids,
  6184. .dig_out_nid = ALC883_DIGOUT_NID,
  6185. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6186. .adc_nids = alc883_adc_nids,
  6187. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6188. .channel_mode = alc883_3ST_2ch_modes,
  6189. .input_mux = &alc883_capture_source,
  6190. .unsol_event = alc883_tagra_unsol_event,
  6191. .init_hook = alc883_tagra_automute,
  6192. },
  6193. [ALC883_ACER] = {
  6194. .mixers = { alc883_base_mixer,
  6195. alc883_chmode_mixer },
  6196. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6197. * and the headphone jack. Turn this on and rely on the
  6198. * standard mute methods whenever the user wants to turn
  6199. * these outputs off.
  6200. */
  6201. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6202. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6203. .dac_nids = alc883_dac_nids,
  6204. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6205. .adc_nids = alc883_adc_nids,
  6206. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6207. .channel_mode = alc883_3ST_2ch_modes,
  6208. .input_mux = &alc883_capture_source,
  6209. },
  6210. [ALC883_ACER_ASPIRE] = {
  6211. .mixers = { alc883_acer_aspire_mixer},
  6212. .init_verbs = { alc883_init_verbs, alc883_acer_aspire_verbs},
  6213. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6214. .dac_nids = alc883_dac_nids,
  6215. .dig_out_nid = ALC883_DIGOUT_NID,
  6216. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6217. .adc_nids = alc883_adc_nids,
  6218. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6219. .channel_mode = alc883_3ST_2ch_modes,
  6220. .input_mux = &alc883_capture_source,
  6221. .unsol_event = alc883_medion_md2_unsol_event,
  6222. .init_hook = alc883_medion_md2_automute,
  6223. },
  6224. [ALC883_MEDION] = {
  6225. .mixers = { alc883_fivestack_mixer,
  6226. alc883_chmode_mixer },
  6227. .init_verbs = { alc883_init_verbs,
  6228. alc883_medion_eapd_verbs },
  6229. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6230. .dac_nids = alc883_dac_nids,
  6231. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6232. .adc_nids = alc883_adc_nids,
  6233. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6234. .channel_mode = alc883_sixstack_modes,
  6235. .input_mux = &alc883_capture_source,
  6236. },
  6237. [ALC883_MEDION_MD2] = {
  6238. .mixers = { alc883_medion_md2_mixer},
  6239. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6240. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6241. .dac_nids = alc883_dac_nids,
  6242. .dig_out_nid = ALC883_DIGOUT_NID,
  6243. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6244. .adc_nids = alc883_adc_nids,
  6245. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6246. .channel_mode = alc883_3ST_2ch_modes,
  6247. .input_mux = &alc883_capture_source,
  6248. .unsol_event = alc883_medion_md2_unsol_event,
  6249. .init_hook = alc883_medion_md2_automute,
  6250. },
  6251. [ALC883_LAPTOP_EAPD] = {
  6252. .mixers = { alc883_base_mixer,
  6253. alc883_chmode_mixer },
  6254. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6255. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6256. .dac_nids = alc883_dac_nids,
  6257. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6258. .adc_nids = alc883_adc_nids,
  6259. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6260. .channel_mode = alc883_3ST_2ch_modes,
  6261. .input_mux = &alc883_capture_source,
  6262. },
  6263. [ALC883_LENOVO_101E_2ch] = {
  6264. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6265. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6266. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6267. .dac_nids = alc883_dac_nids,
  6268. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6269. .adc_nids = alc883_adc_nids,
  6270. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6271. .channel_mode = alc883_3ST_2ch_modes,
  6272. .input_mux = &alc883_lenovo_101e_capture_source,
  6273. .unsol_event = alc883_lenovo_101e_unsol_event,
  6274. .init_hook = alc883_lenovo_101e_all_automute,
  6275. },
  6276. [ALC883_LENOVO_NB0763] = {
  6277. .mixers = { alc883_lenovo_nb0763_mixer },
  6278. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6279. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6280. .dac_nids = alc883_dac_nids,
  6281. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6282. .adc_nids = alc883_adc_nids,
  6283. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6284. .channel_mode = alc883_3ST_2ch_modes,
  6285. .need_dac_fix = 1,
  6286. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6287. .unsol_event = alc883_medion_md2_unsol_event,
  6288. .init_hook = alc883_medion_md2_automute,
  6289. },
  6290. [ALC888_LENOVO_MS7195_DIG] = {
  6291. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6292. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6293. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6294. .dac_nids = alc883_dac_nids,
  6295. .dig_out_nid = ALC883_DIGOUT_NID,
  6296. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6297. .adc_nids = alc883_adc_nids,
  6298. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6299. .channel_mode = alc883_3ST_6ch_modes,
  6300. .need_dac_fix = 1,
  6301. .input_mux = &alc883_capture_source,
  6302. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6303. .init_hook = alc888_lenovo_ms7195_front_automute,
  6304. },
  6305. [ALC888_6ST_HP] = {
  6306. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6307. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6308. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6309. .dac_nids = alc883_dac_nids,
  6310. .dig_out_nid = ALC883_DIGOUT_NID,
  6311. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6312. .adc_nids = alc883_adc_nids,
  6313. .dig_in_nid = ALC883_DIGIN_NID,
  6314. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6315. .channel_mode = alc883_sixstack_modes,
  6316. .input_mux = &alc883_capture_source,
  6317. },
  6318. [ALC888_3ST_HP] = {
  6319. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6320. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6321. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6322. .dac_nids = alc883_dac_nids,
  6323. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6324. .adc_nids = alc883_adc_nids,
  6325. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6326. .channel_mode = alc888_3st_hp_modes,
  6327. .need_dac_fix = 1,
  6328. .input_mux = &alc883_capture_source,
  6329. },
  6330. };
  6331. /*
  6332. * BIOS auto configuration
  6333. */
  6334. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6335. hda_nid_t nid, int pin_type,
  6336. int dac_idx)
  6337. {
  6338. /* set as output */
  6339. struct alc_spec *spec = codec->spec;
  6340. int idx;
  6341. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6342. idx = 4;
  6343. else
  6344. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6345. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6346. pin_type);
  6347. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6348. AMP_OUT_UNMUTE);
  6349. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6350. }
  6351. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6352. {
  6353. struct alc_spec *spec = codec->spec;
  6354. int i;
  6355. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6356. for (i = 0; i <= HDA_SIDE; i++) {
  6357. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6358. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6359. if (nid)
  6360. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6361. i);
  6362. }
  6363. }
  6364. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6365. {
  6366. struct alc_spec *spec = codec->spec;
  6367. hda_nid_t pin;
  6368. pin = spec->autocfg.hp_pins[0];
  6369. if (pin) /* connect to front */
  6370. /* use dac 0 */
  6371. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6372. }
  6373. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6374. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6375. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6376. {
  6377. struct alc_spec *spec = codec->spec;
  6378. int i;
  6379. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6380. hda_nid_t nid = spec->autocfg.input_pins[i];
  6381. if (alc883_is_input_pin(nid)) {
  6382. snd_hda_codec_write(codec, nid, 0,
  6383. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6384. (i <= AUTO_PIN_FRONT_MIC ?
  6385. PIN_VREF80 : PIN_IN));
  6386. if (nid != ALC883_PIN_CD_NID)
  6387. snd_hda_codec_write(codec, nid, 0,
  6388. AC_VERB_SET_AMP_GAIN_MUTE,
  6389. AMP_OUT_MUTE);
  6390. }
  6391. }
  6392. }
  6393. /* almost identical with ALC880 parser... */
  6394. static int alc883_parse_auto_config(struct hda_codec *codec)
  6395. {
  6396. struct alc_spec *spec = codec->spec;
  6397. int err = alc880_parse_auto_config(codec);
  6398. if (err < 0)
  6399. return err;
  6400. else if (err > 0)
  6401. /* hack - override the init verbs */
  6402. spec->init_verbs[0] = alc883_auto_init_verbs;
  6403. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6404. spec->num_mixers++;
  6405. return err;
  6406. }
  6407. /* additional initialization for auto-configuration model */
  6408. static void alc883_auto_init(struct hda_codec *codec)
  6409. {
  6410. alc883_auto_init_multi_out(codec);
  6411. alc883_auto_init_hp_out(codec);
  6412. alc883_auto_init_analog_input(codec);
  6413. }
  6414. static int patch_alc883(struct hda_codec *codec)
  6415. {
  6416. struct alc_spec *spec;
  6417. int err, board_config;
  6418. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6419. if (spec == NULL)
  6420. return -ENOMEM;
  6421. codec->spec = spec;
  6422. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6423. alc883_models,
  6424. alc883_cfg_tbl);
  6425. if (board_config < 0) {
  6426. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6427. "trying auto-probe from BIOS...\n");
  6428. board_config = ALC883_AUTO;
  6429. }
  6430. if (board_config == ALC883_AUTO) {
  6431. /* automatic parse from the BIOS config */
  6432. err = alc883_parse_auto_config(codec);
  6433. if (err < 0) {
  6434. alc_free(codec);
  6435. return err;
  6436. } else if (!err) {
  6437. printk(KERN_INFO
  6438. "hda_codec: Cannot set up configuration "
  6439. "from BIOS. Using base mode...\n");
  6440. board_config = ALC883_3ST_2ch_DIG;
  6441. }
  6442. }
  6443. if (board_config != ALC883_AUTO)
  6444. setup_preset(spec, &alc883_presets[board_config]);
  6445. spec->stream_name_analog = "ALC883 Analog";
  6446. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6447. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6448. spec->stream_name_digital = "ALC883 Digital";
  6449. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6450. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6451. if (!spec->adc_nids && spec->input_mux) {
  6452. spec->adc_nids = alc883_adc_nids;
  6453. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6454. }
  6455. codec->patch_ops = alc_patch_ops;
  6456. if (board_config == ALC883_AUTO)
  6457. spec->init_hook = alc883_auto_init;
  6458. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6459. if (!spec->loopback.amplist)
  6460. spec->loopback.amplist = alc883_loopbacks;
  6461. #endif
  6462. return 0;
  6463. }
  6464. /*
  6465. * ALC262 support
  6466. */
  6467. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6468. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6469. #define alc262_dac_nids alc260_dac_nids
  6470. #define alc262_adc_nids alc882_adc_nids
  6471. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6472. #define alc262_modes alc260_modes
  6473. #define alc262_capture_source alc882_capture_source
  6474. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6475. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6476. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6477. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6478. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6479. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6480. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6481. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6482. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6483. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6484. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6485. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6486. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6487. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6488. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6489. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6490. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6491. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6492. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6493. { } /* end */
  6494. };
  6495. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6496. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6497. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6498. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6499. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6500. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6501. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6502. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6503. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6504. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6505. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6506. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6507. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6508. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6509. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6510. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6511. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6512. { } /* end */
  6513. };
  6514. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6515. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6516. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6517. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6518. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6519. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6520. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6521. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6522. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6523. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6524. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6525. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6526. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6527. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6528. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6529. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6530. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6531. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6532. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6533. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6534. { } /* end */
  6535. };
  6536. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6537. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6538. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6539. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6540. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6541. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6542. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6543. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6544. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6545. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6546. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6547. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6548. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6549. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6550. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6551. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6552. { } /* end */
  6553. };
  6554. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6555. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6556. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6557. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6558. { } /* end */
  6559. };
  6560. static struct hda_bind_ctls alc262_sony_bind_sw = {
  6561. .ops = &snd_hda_bind_sw,
  6562. .values = {
  6563. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6564. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6565. 0,
  6566. },
  6567. };
  6568. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6569. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6570. HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
  6571. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6572. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6573. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6574. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6575. { } /* end */
  6576. };
  6577. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6578. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6579. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6580. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6581. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6582. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6583. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6584. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6585. { } /* end */
  6586. };
  6587. #define alc262_capture_mixer alc882_capture_mixer
  6588. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6589. /*
  6590. * generic initialization of ADC, input mixers and output mixers
  6591. */
  6592. static struct hda_verb alc262_init_verbs[] = {
  6593. /*
  6594. * Unmute ADC0-2 and set the default input to mic-in
  6595. */
  6596. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6597. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6598. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6599. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6600. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6601. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6602. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6603. * mixer widget
  6604. * Note: PASD motherboards uses the Line In 2 as the input for
  6605. * front panel mic (mic 2)
  6606. */
  6607. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6608. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6609. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6610. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6611. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6612. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6613. /*
  6614. * Set up output mixers (0x0c - 0x0e)
  6615. */
  6616. /* set vol=0 to output mixers */
  6617. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6618. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6619. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6620. /* set up input amps for analog loopback */
  6621. /* Amp Indices: DAC = 0, mixer = 1 */
  6622. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6623. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6624. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6625. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6626. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6627. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6628. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6629. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6630. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6631. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6632. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6633. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6634. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6635. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6636. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6637. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6638. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6639. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6640. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6641. /* FIXME: use matrix-type input source selection */
  6642. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6643. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6644. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6645. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6646. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6647. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6648. /* Input mixer2 */
  6649. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6650. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6651. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6652. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6653. /* Input mixer3 */
  6654. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6655. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6656. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6657. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6658. { }
  6659. };
  6660. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6661. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6662. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6663. {}
  6664. };
  6665. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6666. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6667. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6668. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6669. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6670. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6671. {}
  6672. };
  6673. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6674. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6675. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6676. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6677. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6678. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6679. };
  6680. /* mute/unmute internal speaker according to the hp jack and mute state */
  6681. static void alc262_hippo_automute(struct hda_codec *codec)
  6682. {
  6683. struct alc_spec *spec = codec->spec;
  6684. unsigned int mute;
  6685. unsigned int present;
  6686. /* need to execute and sync at first */
  6687. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6688. present = snd_hda_codec_read(codec, 0x15, 0,
  6689. AC_VERB_GET_PIN_SENSE, 0);
  6690. spec->jack_present = (present & 0x80000000) != 0;
  6691. if (spec->jack_present) {
  6692. /* mute internal speaker */
  6693. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6694. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6695. } else {
  6696. /* unmute internal speaker if necessary */
  6697. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6698. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6699. HDA_AMP_MUTE, mute);
  6700. }
  6701. }
  6702. /* unsolicited event for HP jack sensing */
  6703. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6704. unsigned int res)
  6705. {
  6706. if ((res >> 26) != ALC880_HP_EVENT)
  6707. return;
  6708. alc262_hippo_automute(codec);
  6709. }
  6710. static void alc262_hippo1_automute(struct hda_codec *codec)
  6711. {
  6712. unsigned int mute;
  6713. unsigned int present;
  6714. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6715. present = snd_hda_codec_read(codec, 0x1b, 0,
  6716. AC_VERB_GET_PIN_SENSE, 0);
  6717. present = (present & 0x80000000) != 0;
  6718. if (present) {
  6719. /* mute internal speaker */
  6720. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6721. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6722. } else {
  6723. /* unmute internal speaker if necessary */
  6724. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6725. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6726. HDA_AMP_MUTE, mute);
  6727. }
  6728. }
  6729. /* unsolicited event for HP jack sensing */
  6730. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6731. unsigned int res)
  6732. {
  6733. if ((res >> 26) != ALC880_HP_EVENT)
  6734. return;
  6735. alc262_hippo1_automute(codec);
  6736. }
  6737. /*
  6738. * fujitsu model
  6739. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6740. */
  6741. #define ALC_HP_EVENT 0x37
  6742. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6743. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6744. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6745. {}
  6746. };
  6747. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6748. .num_items = 2,
  6749. .items = {
  6750. { "Mic", 0x0 },
  6751. { "CD", 0x4 },
  6752. },
  6753. };
  6754. static struct hda_input_mux alc262_HP_capture_source = {
  6755. .num_items = 5,
  6756. .items = {
  6757. { "Mic", 0x0 },
  6758. { "Front Mic", 0x3 },
  6759. { "Line", 0x2 },
  6760. { "CD", 0x4 },
  6761. { "AUX IN", 0x6 },
  6762. },
  6763. };
  6764. /* mute/unmute internal speaker according to the hp jack and mute state */
  6765. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6766. {
  6767. struct alc_spec *spec = codec->spec;
  6768. unsigned int mute;
  6769. if (force || !spec->sense_updated) {
  6770. unsigned int present;
  6771. /* need to execute and sync at first */
  6772. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6773. present = snd_hda_codec_read(codec, 0x14, 0,
  6774. AC_VERB_GET_PIN_SENSE, 0);
  6775. spec->jack_present = (present & 0x80000000) != 0;
  6776. spec->sense_updated = 1;
  6777. }
  6778. if (spec->jack_present) {
  6779. /* mute internal speaker */
  6780. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6781. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6782. } else {
  6783. /* unmute internal speaker if necessary */
  6784. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6785. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6786. HDA_AMP_MUTE, mute);
  6787. }
  6788. }
  6789. /* unsolicited event for HP jack sensing */
  6790. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6791. unsigned int res)
  6792. {
  6793. if ((res >> 26) != ALC_HP_EVENT)
  6794. return;
  6795. alc262_fujitsu_automute(codec, 1);
  6796. }
  6797. /* bind volumes of both NID 0x0c and 0x0d */
  6798. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  6799. .ops = &snd_hda_bind_vol,
  6800. .values = {
  6801. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6802. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  6803. 0
  6804. },
  6805. };
  6806. /* bind hp and internal speaker mute (with plug check) */
  6807. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6808. struct snd_ctl_elem_value *ucontrol)
  6809. {
  6810. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6811. long *valp = ucontrol->value.integer.value;
  6812. int change;
  6813. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6814. HDA_AMP_MUTE,
  6815. valp[0] ? 0 : HDA_AMP_MUTE);
  6816. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6817. HDA_AMP_MUTE,
  6818. valp[1] ? 0 : HDA_AMP_MUTE);
  6819. if (change)
  6820. alc262_fujitsu_automute(codec, 0);
  6821. return change;
  6822. }
  6823. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6824. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  6825. {
  6826. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6827. .name = "Master Playback Switch",
  6828. .info = snd_hda_mixer_amp_switch_info,
  6829. .get = snd_hda_mixer_amp_switch_get,
  6830. .put = alc262_fujitsu_master_sw_put,
  6831. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6832. },
  6833. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6834. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6835. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6836. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6837. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6838. { } /* end */
  6839. };
  6840. /* additional init verbs for Benq laptops */
  6841. static struct hda_verb alc262_EAPD_verbs[] = {
  6842. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6843. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6844. {}
  6845. };
  6846. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6847. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6848. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6849. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6850. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6851. {}
  6852. };
  6853. /* add playback controls from the parsed DAC table */
  6854. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6855. const struct auto_pin_cfg *cfg)
  6856. {
  6857. hda_nid_t nid;
  6858. int err;
  6859. spec->multiout.num_dacs = 1; /* only use one dac */
  6860. spec->multiout.dac_nids = spec->private_dac_nids;
  6861. spec->multiout.dac_nids[0] = 2;
  6862. nid = cfg->line_out_pins[0];
  6863. if (nid) {
  6864. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6865. "Front Playback Volume",
  6866. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6867. if (err < 0)
  6868. return err;
  6869. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6870. "Front Playback Switch",
  6871. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6872. if (err < 0)
  6873. return err;
  6874. }
  6875. nid = cfg->speaker_pins[0];
  6876. if (nid) {
  6877. if (nid == 0x16) {
  6878. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6879. "Speaker Playback Volume",
  6880. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6881. HDA_OUTPUT));
  6882. if (err < 0)
  6883. return err;
  6884. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6885. "Speaker Playback Switch",
  6886. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6887. HDA_OUTPUT));
  6888. if (err < 0)
  6889. return err;
  6890. } else {
  6891. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6892. "Speaker Playback Switch",
  6893. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6894. HDA_OUTPUT));
  6895. if (err < 0)
  6896. return err;
  6897. }
  6898. }
  6899. nid = cfg->hp_pins[0];
  6900. if (nid) {
  6901. /* spec->multiout.hp_nid = 2; */
  6902. if (nid == 0x16) {
  6903. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6904. "Headphone Playback Volume",
  6905. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6906. HDA_OUTPUT));
  6907. if (err < 0)
  6908. return err;
  6909. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6910. "Headphone Playback Switch",
  6911. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6912. HDA_OUTPUT));
  6913. if (err < 0)
  6914. return err;
  6915. } else {
  6916. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6917. "Headphone Playback Switch",
  6918. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6919. HDA_OUTPUT));
  6920. if (err < 0)
  6921. return err;
  6922. }
  6923. }
  6924. return 0;
  6925. }
  6926. /* identical with ALC880 */
  6927. #define alc262_auto_create_analog_input_ctls \
  6928. alc880_auto_create_analog_input_ctls
  6929. /*
  6930. * generic initialization of ADC, input mixers and output mixers
  6931. */
  6932. static struct hda_verb alc262_volume_init_verbs[] = {
  6933. /*
  6934. * Unmute ADC0-2 and set the default input to mic-in
  6935. */
  6936. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6937. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6938. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6939. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6940. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6941. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6942. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6943. * mixer widget
  6944. * Note: PASD motherboards uses the Line In 2 as the input for
  6945. * front panel mic (mic 2)
  6946. */
  6947. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6948. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6949. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6950. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6951. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6952. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6953. /*
  6954. * Set up output mixers (0x0c - 0x0f)
  6955. */
  6956. /* set vol=0 to output mixers */
  6957. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6958. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6959. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6960. /* set up input amps for analog loopback */
  6961. /* Amp Indices: DAC = 0, mixer = 1 */
  6962. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6963. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6964. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6965. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6966. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6967. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6968. /* FIXME: use matrix-type input source selection */
  6969. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6970. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6971. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6972. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6973. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6974. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6975. /* Input mixer2 */
  6976. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6977. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6978. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6979. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6980. /* Input mixer3 */
  6981. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6982. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6983. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6984. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6985. { }
  6986. };
  6987. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6988. /*
  6989. * Unmute ADC0-2 and set the default input to mic-in
  6990. */
  6991. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6992. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6993. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6994. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6995. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6996. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6997. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6998. * mixer widget
  6999. * Note: PASD motherboards uses the Line In 2 as the input for
  7000. * front panel mic (mic 2)
  7001. */
  7002. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7003. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7004. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7005. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7006. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7007. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7008. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7009. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7010. /*
  7011. * Set up output mixers (0x0c - 0x0e)
  7012. */
  7013. /* set vol=0 to output mixers */
  7014. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7015. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7016. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7017. /* set up input amps for analog loopback */
  7018. /* Amp Indices: DAC = 0, mixer = 1 */
  7019. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7020. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7021. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7022. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7023. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7024. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7025. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7026. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7027. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7028. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7029. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7030. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7031. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7032. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7033. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7034. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7035. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7036. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7037. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7038. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7039. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7040. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7041. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7042. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7043. /* FIXME: use matrix-type input source selection */
  7044. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7045. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7046. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7047. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7048. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7049. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7050. /* Input mixer2 */
  7051. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7052. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7053. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7054. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7055. /* Input mixer3 */
  7056. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7057. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7058. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7059. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7060. { }
  7061. };
  7062. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7063. /*
  7064. * Unmute ADC0-2 and set the default input to mic-in
  7065. */
  7066. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7067. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7068. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7069. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7070. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7071. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7072. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7073. * mixer widget
  7074. * Note: PASD motherboards uses the Line In 2 as the input for front
  7075. * panel mic (mic 2)
  7076. */
  7077. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7078. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7079. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7080. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7081. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7082. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7083. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7084. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7085. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7086. /*
  7087. * Set up output mixers (0x0c - 0x0e)
  7088. */
  7089. /* set vol=0 to output mixers */
  7090. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7091. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7092. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7093. /* set up input amps for analog loopback */
  7094. /* Amp Indices: DAC = 0, mixer = 1 */
  7095. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7097. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7098. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7099. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7100. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7101. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7102. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7103. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7104. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7105. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7106. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7107. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7108. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7109. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7110. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7111. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7112. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7113. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7114. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7115. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7116. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7117. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7118. /* FIXME: use matrix-type input source selection */
  7119. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7120. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7121. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7122. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7123. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7124. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7125. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7126. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7128. /* Input mixer2 */
  7129. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7130. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7131. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7132. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7133. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7134. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7135. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7136. /* Input mixer3 */
  7137. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7139. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7140. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7141. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7142. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7143. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7144. { }
  7145. };
  7146. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7147. #define alc262_loopbacks alc880_loopbacks
  7148. #endif
  7149. /* pcm configuration: identiacal with ALC880 */
  7150. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7151. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7152. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7153. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7154. /*
  7155. * BIOS auto configuration
  7156. */
  7157. static int alc262_parse_auto_config(struct hda_codec *codec)
  7158. {
  7159. struct alc_spec *spec = codec->spec;
  7160. int err;
  7161. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7162. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7163. alc262_ignore);
  7164. if (err < 0)
  7165. return err;
  7166. if (!spec->autocfg.line_outs)
  7167. return 0; /* can't find valid BIOS pin config */
  7168. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7169. if (err < 0)
  7170. return err;
  7171. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7172. if (err < 0)
  7173. return err;
  7174. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7175. if (spec->autocfg.dig_out_pin)
  7176. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7177. if (spec->autocfg.dig_in_pin)
  7178. spec->dig_in_nid = ALC262_DIGIN_NID;
  7179. if (spec->kctl_alloc)
  7180. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7181. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7182. spec->num_mux_defs = 1;
  7183. spec->input_mux = &spec->private_imux;
  7184. return 1;
  7185. }
  7186. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7187. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7188. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7189. /* init callback for auto-configuration model -- overriding the default init */
  7190. static void alc262_auto_init(struct hda_codec *codec)
  7191. {
  7192. alc262_auto_init_multi_out(codec);
  7193. alc262_auto_init_hp_out(codec);
  7194. alc262_auto_init_analog_input(codec);
  7195. }
  7196. /*
  7197. * configuration and preset
  7198. */
  7199. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7200. [ALC262_BASIC] = "basic",
  7201. [ALC262_HIPPO] = "hippo",
  7202. [ALC262_HIPPO_1] = "hippo_1",
  7203. [ALC262_FUJITSU] = "fujitsu",
  7204. [ALC262_HP_BPC] = "hp-bpc",
  7205. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7206. [ALC262_BENQ_ED8] = "benq",
  7207. [ALC262_BENQ_T31] = "benq-t31",
  7208. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7209. [ALC262_AUTO] = "auto",
  7210. };
  7211. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7212. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7213. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7214. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7215. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7216. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7217. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7218. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7219. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7220. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7221. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7222. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7223. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7224. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7225. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7226. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7227. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7228. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7229. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7230. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7231. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7232. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7233. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7234. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7235. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7236. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7237. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7238. {}
  7239. };
  7240. static struct alc_config_preset alc262_presets[] = {
  7241. [ALC262_BASIC] = {
  7242. .mixers = { alc262_base_mixer },
  7243. .init_verbs = { alc262_init_verbs },
  7244. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7245. .dac_nids = alc262_dac_nids,
  7246. .hp_nid = 0x03,
  7247. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7248. .channel_mode = alc262_modes,
  7249. .input_mux = &alc262_capture_source,
  7250. },
  7251. [ALC262_HIPPO] = {
  7252. .mixers = { alc262_base_mixer },
  7253. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7254. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7255. .dac_nids = alc262_dac_nids,
  7256. .hp_nid = 0x03,
  7257. .dig_out_nid = ALC262_DIGOUT_NID,
  7258. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7259. .channel_mode = alc262_modes,
  7260. .input_mux = &alc262_capture_source,
  7261. .unsol_event = alc262_hippo_unsol_event,
  7262. .init_hook = alc262_hippo_automute,
  7263. },
  7264. [ALC262_HIPPO_1] = {
  7265. .mixers = { alc262_hippo1_mixer },
  7266. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7267. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7268. .dac_nids = alc262_dac_nids,
  7269. .hp_nid = 0x02,
  7270. .dig_out_nid = ALC262_DIGOUT_NID,
  7271. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7272. .channel_mode = alc262_modes,
  7273. .input_mux = &alc262_capture_source,
  7274. .unsol_event = alc262_hippo1_unsol_event,
  7275. .init_hook = alc262_hippo1_automute,
  7276. },
  7277. [ALC262_FUJITSU] = {
  7278. .mixers = { alc262_fujitsu_mixer },
  7279. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7280. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7281. .dac_nids = alc262_dac_nids,
  7282. .hp_nid = 0x03,
  7283. .dig_out_nid = ALC262_DIGOUT_NID,
  7284. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7285. .channel_mode = alc262_modes,
  7286. .input_mux = &alc262_fujitsu_capture_source,
  7287. .unsol_event = alc262_fujitsu_unsol_event,
  7288. },
  7289. [ALC262_HP_BPC] = {
  7290. .mixers = { alc262_HP_BPC_mixer },
  7291. .init_verbs = { alc262_HP_BPC_init_verbs },
  7292. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7293. .dac_nids = alc262_dac_nids,
  7294. .hp_nid = 0x03,
  7295. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7296. .channel_mode = alc262_modes,
  7297. .input_mux = &alc262_HP_capture_source,
  7298. },
  7299. [ALC262_HP_BPC_D7000_WF] = {
  7300. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7301. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7302. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7303. .dac_nids = alc262_dac_nids,
  7304. .hp_nid = 0x03,
  7305. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7306. .channel_mode = alc262_modes,
  7307. .input_mux = &alc262_HP_capture_source,
  7308. },
  7309. [ALC262_HP_BPC_D7000_WL] = {
  7310. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7311. alc262_HP_BPC_WildWest_option_mixer },
  7312. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7313. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7314. .dac_nids = alc262_dac_nids,
  7315. .hp_nid = 0x03,
  7316. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7317. .channel_mode = alc262_modes,
  7318. .input_mux = &alc262_HP_capture_source,
  7319. },
  7320. [ALC262_BENQ_ED8] = {
  7321. .mixers = { alc262_base_mixer },
  7322. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7323. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7324. .dac_nids = alc262_dac_nids,
  7325. .hp_nid = 0x03,
  7326. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7327. .channel_mode = alc262_modes,
  7328. .input_mux = &alc262_capture_source,
  7329. },
  7330. [ALC262_SONY_ASSAMD] = {
  7331. .mixers = { alc262_sony_mixer },
  7332. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7333. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7334. .dac_nids = alc262_dac_nids,
  7335. .hp_nid = 0x02,
  7336. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7337. .channel_mode = alc262_modes,
  7338. .input_mux = &alc262_capture_source,
  7339. .unsol_event = alc262_hippo_unsol_event,
  7340. .init_hook = alc262_hippo_automute,
  7341. },
  7342. [ALC262_BENQ_T31] = {
  7343. .mixers = { alc262_benq_t31_mixer },
  7344. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7345. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7346. .dac_nids = alc262_dac_nids,
  7347. .hp_nid = 0x03,
  7348. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7349. .channel_mode = alc262_modes,
  7350. .input_mux = &alc262_capture_source,
  7351. .unsol_event = alc262_hippo_unsol_event,
  7352. .init_hook = alc262_hippo_automute,
  7353. },
  7354. };
  7355. static int patch_alc262(struct hda_codec *codec)
  7356. {
  7357. struct alc_spec *spec;
  7358. int board_config;
  7359. int err;
  7360. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7361. if (spec == NULL)
  7362. return -ENOMEM;
  7363. codec->spec = spec;
  7364. #if 0
  7365. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7366. * under-run
  7367. */
  7368. {
  7369. int tmp;
  7370. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7371. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7372. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7373. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7374. }
  7375. #endif
  7376. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7377. alc262_models,
  7378. alc262_cfg_tbl);
  7379. if (board_config < 0) {
  7380. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7381. "trying auto-probe from BIOS...\n");
  7382. board_config = ALC262_AUTO;
  7383. }
  7384. if (board_config == ALC262_AUTO) {
  7385. /* automatic parse from the BIOS config */
  7386. err = alc262_parse_auto_config(codec);
  7387. if (err < 0) {
  7388. alc_free(codec);
  7389. return err;
  7390. } else if (!err) {
  7391. printk(KERN_INFO
  7392. "hda_codec: Cannot set up configuration "
  7393. "from BIOS. Using base mode...\n");
  7394. board_config = ALC262_BASIC;
  7395. }
  7396. }
  7397. if (board_config != ALC262_AUTO)
  7398. setup_preset(spec, &alc262_presets[board_config]);
  7399. spec->stream_name_analog = "ALC262 Analog";
  7400. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7401. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7402. spec->stream_name_digital = "ALC262 Digital";
  7403. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7404. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7405. if (!spec->adc_nids && spec->input_mux) {
  7406. /* check whether NID 0x07 is valid */
  7407. unsigned int wcap = get_wcaps(codec, 0x07);
  7408. /* get type */
  7409. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7410. if (wcap != AC_WID_AUD_IN) {
  7411. spec->adc_nids = alc262_adc_nids_alt;
  7412. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7413. spec->mixers[spec->num_mixers] =
  7414. alc262_capture_alt_mixer;
  7415. spec->num_mixers++;
  7416. } else {
  7417. spec->adc_nids = alc262_adc_nids;
  7418. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7419. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7420. spec->num_mixers++;
  7421. }
  7422. }
  7423. codec->patch_ops = alc_patch_ops;
  7424. if (board_config == ALC262_AUTO)
  7425. spec->init_hook = alc262_auto_init;
  7426. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7427. if (!spec->loopback.amplist)
  7428. spec->loopback.amplist = alc262_loopbacks;
  7429. #endif
  7430. return 0;
  7431. }
  7432. /*
  7433. * ALC268 channel source setting (2 channel)
  7434. */
  7435. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7436. #define alc268_modes alc260_modes
  7437. static hda_nid_t alc268_dac_nids[2] = {
  7438. /* front, hp */
  7439. 0x02, 0x03
  7440. };
  7441. static hda_nid_t alc268_adc_nids[2] = {
  7442. /* ADC0-1 */
  7443. 0x08, 0x07
  7444. };
  7445. static hda_nid_t alc268_adc_nids_alt[1] = {
  7446. /* ADC0 */
  7447. 0x08
  7448. };
  7449. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7450. /* output mixer control */
  7451. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7452. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7453. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7454. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7455. { }
  7456. };
  7457. /*
  7458. * generic initialization of ADC, input mixers and output mixers
  7459. */
  7460. static struct hda_verb alc268_base_init_verbs[] = {
  7461. /* Unmute DAC0-1 and set vol = 0 */
  7462. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7463. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7464. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7465. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7466. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7467. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7468. /*
  7469. * Set up output mixers (0x0c - 0x0e)
  7470. */
  7471. /* set vol=0 to output mixers */
  7472. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7473. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7474. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7475. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7476. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7477. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7478. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7480. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7481. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7482. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7483. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7484. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7485. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7486. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7487. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7488. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7489. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7490. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7492. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7493. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7494. /* FIXME: use matrix-type input source selection */
  7495. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7496. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7497. /* Input mixer2 */
  7498. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7499. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7500. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7501. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7502. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7503. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7504. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7505. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7506. { }
  7507. };
  7508. /*
  7509. * generic initialization of ADC, input mixers and output mixers
  7510. */
  7511. static struct hda_verb alc268_volume_init_verbs[] = {
  7512. /* set output DAC */
  7513. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7514. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7515. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7516. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7517. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7518. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7520. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7521. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7522. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7523. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7524. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7526. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7527. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7528. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7529. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7530. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7531. /* set PCBEEP vol = 0 */
  7532. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7533. { }
  7534. };
  7535. #define alc268_mux_enum_info alc_mux_enum_info
  7536. #define alc268_mux_enum_get alc_mux_enum_get
  7537. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7538. struct snd_ctl_elem_value *ucontrol)
  7539. {
  7540. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7541. struct alc_spec *spec = codec->spec;
  7542. const struct hda_input_mux *imux = spec->input_mux;
  7543. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7544. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7545. hda_nid_t nid = capture_mixers[adc_idx];
  7546. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7547. unsigned int i, idx;
  7548. idx = ucontrol->value.enumerated.item[0];
  7549. if (idx >= imux->num_items)
  7550. idx = imux->num_items - 1;
  7551. if (*cur_val == idx)
  7552. return 0;
  7553. for (i = 0; i < imux->num_items; i++) {
  7554. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7555. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7556. imux->items[i].index,
  7557. HDA_AMP_MUTE, v);
  7558. snd_hda_codec_write_cache(codec, nid, 0,
  7559. AC_VERB_SET_CONNECT_SEL,
  7560. idx );
  7561. }
  7562. *cur_val = idx;
  7563. return 1;
  7564. }
  7565. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7566. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7567. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7568. {
  7569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7570. /* The multiple "Capture Source" controls confuse alsamixer
  7571. * So call somewhat different..
  7572. * FIXME: the controls appear in the "playback" view!
  7573. */
  7574. /* .name = "Capture Source", */
  7575. .name = "Input Source",
  7576. .count = 1,
  7577. .info = alc268_mux_enum_info,
  7578. .get = alc268_mux_enum_get,
  7579. .put = alc268_mux_enum_put,
  7580. },
  7581. { } /* end */
  7582. };
  7583. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7584. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7585. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7586. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7587. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7588. {
  7589. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7590. /* The multiple "Capture Source" controls confuse alsamixer
  7591. * So call somewhat different..
  7592. * FIXME: the controls appear in the "playback" view!
  7593. */
  7594. /* .name = "Capture Source", */
  7595. .name = "Input Source",
  7596. .count = 2,
  7597. .info = alc268_mux_enum_info,
  7598. .get = alc268_mux_enum_get,
  7599. .put = alc268_mux_enum_put,
  7600. },
  7601. { } /* end */
  7602. };
  7603. static struct hda_input_mux alc268_capture_source = {
  7604. .num_items = 4,
  7605. .items = {
  7606. { "Mic", 0x0 },
  7607. { "Front Mic", 0x1 },
  7608. { "Line", 0x2 },
  7609. { "CD", 0x3 },
  7610. },
  7611. };
  7612. /* create input playback/capture controls for the given pin */
  7613. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7614. const char *ctlname, int idx)
  7615. {
  7616. char name[32];
  7617. int err;
  7618. sprintf(name, "%s Playback Volume", ctlname);
  7619. if (nid == 0x14) {
  7620. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7621. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7622. HDA_OUTPUT));
  7623. if (err < 0)
  7624. return err;
  7625. } else if (nid == 0x15) {
  7626. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7627. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7628. HDA_OUTPUT));
  7629. if (err < 0)
  7630. return err;
  7631. } else
  7632. return -1;
  7633. sprintf(name, "%s Playback Switch", ctlname);
  7634. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7635. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7636. if (err < 0)
  7637. return err;
  7638. return 0;
  7639. }
  7640. /* add playback controls from the parsed DAC table */
  7641. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7642. const struct auto_pin_cfg *cfg)
  7643. {
  7644. hda_nid_t nid;
  7645. int err;
  7646. spec->multiout.num_dacs = 2; /* only use one dac */
  7647. spec->multiout.dac_nids = spec->private_dac_nids;
  7648. spec->multiout.dac_nids[0] = 2;
  7649. spec->multiout.dac_nids[1] = 3;
  7650. nid = cfg->line_out_pins[0];
  7651. if (nid)
  7652. alc268_new_analog_output(spec, nid, "Front", 0);
  7653. nid = cfg->speaker_pins[0];
  7654. if (nid == 0x1d) {
  7655. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7656. "Speaker Playback Volume",
  7657. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7658. if (err < 0)
  7659. return err;
  7660. }
  7661. nid = cfg->hp_pins[0];
  7662. if (nid)
  7663. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7664. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7665. if (nid == 0x16) {
  7666. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7667. "Mono Playback Switch",
  7668. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7669. if (err < 0)
  7670. return err;
  7671. }
  7672. return 0;
  7673. }
  7674. /* create playback/capture controls for input pins */
  7675. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7676. const struct auto_pin_cfg *cfg)
  7677. {
  7678. struct hda_input_mux *imux = &spec->private_imux;
  7679. int i, idx1;
  7680. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7681. switch(cfg->input_pins[i]) {
  7682. case 0x18:
  7683. idx1 = 0; /* Mic 1 */
  7684. break;
  7685. case 0x19:
  7686. idx1 = 1; /* Mic 2 */
  7687. break;
  7688. case 0x1a:
  7689. idx1 = 2; /* Line In */
  7690. break;
  7691. case 0x1c:
  7692. idx1 = 3; /* CD */
  7693. break;
  7694. default:
  7695. continue;
  7696. }
  7697. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7698. imux->items[imux->num_items].index = idx1;
  7699. imux->num_items++;
  7700. }
  7701. return 0;
  7702. }
  7703. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7704. {
  7705. struct alc_spec *spec = codec->spec;
  7706. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7707. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7708. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7709. unsigned int dac_vol1, dac_vol2;
  7710. if (speaker_nid) {
  7711. snd_hda_codec_write(codec, speaker_nid, 0,
  7712. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7713. snd_hda_codec_write(codec, 0x0f, 0,
  7714. AC_VERB_SET_AMP_GAIN_MUTE,
  7715. AMP_IN_UNMUTE(1));
  7716. snd_hda_codec_write(codec, 0x10, 0,
  7717. AC_VERB_SET_AMP_GAIN_MUTE,
  7718. AMP_IN_UNMUTE(1));
  7719. } else {
  7720. snd_hda_codec_write(codec, 0x0f, 0,
  7721. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7722. snd_hda_codec_write(codec, 0x10, 0,
  7723. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7724. }
  7725. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7726. if (line_nid == 0x14)
  7727. dac_vol2 = AMP_OUT_ZERO;
  7728. else if (line_nid == 0x15)
  7729. dac_vol1 = AMP_OUT_ZERO;
  7730. if (hp_nid == 0x14)
  7731. dac_vol2 = AMP_OUT_ZERO;
  7732. else if (hp_nid == 0x15)
  7733. dac_vol1 = AMP_OUT_ZERO;
  7734. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7735. spec->autocfg.line_out_pins[1] != 0x16 ||
  7736. spec->autocfg.line_out_pins[2] != 0x16)
  7737. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7738. snd_hda_codec_write(codec, 0x02, 0,
  7739. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7740. snd_hda_codec_write(codec, 0x03, 0,
  7741. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7742. }
  7743. /* pcm configuration: identiacal with ALC880 */
  7744. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7745. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7746. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7747. /*
  7748. * BIOS auto configuration
  7749. */
  7750. static int alc268_parse_auto_config(struct hda_codec *codec)
  7751. {
  7752. struct alc_spec *spec = codec->spec;
  7753. int err;
  7754. static hda_nid_t alc268_ignore[] = { 0 };
  7755. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7756. alc268_ignore);
  7757. if (err < 0)
  7758. return err;
  7759. if (!spec->autocfg.line_outs)
  7760. return 0; /* can't find valid BIOS pin config */
  7761. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7762. if (err < 0)
  7763. return err;
  7764. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7765. if (err < 0)
  7766. return err;
  7767. spec->multiout.max_channels = 2;
  7768. /* digital only support output */
  7769. if (spec->autocfg.dig_out_pin)
  7770. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7771. if (spec->kctl_alloc)
  7772. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7773. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7774. spec->num_mux_defs = 1;
  7775. spec->input_mux = &spec->private_imux;
  7776. return 1;
  7777. }
  7778. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7779. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7780. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7781. /* init callback for auto-configuration model -- overriding the default init */
  7782. static void alc268_auto_init(struct hda_codec *codec)
  7783. {
  7784. alc268_auto_init_multi_out(codec);
  7785. alc268_auto_init_hp_out(codec);
  7786. alc268_auto_init_mono_speaker_out(codec);
  7787. alc268_auto_init_analog_input(codec);
  7788. }
  7789. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7790. #define alc883_loopbacks alc880_loopbacks
  7791. #endif
  7792. /*
  7793. * configuration and preset
  7794. */
  7795. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7796. [ALC268_3ST] = "3stack",
  7797. [ALC268_AUTO] = "auto",
  7798. };
  7799. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7800. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7801. {}
  7802. };
  7803. static struct alc_config_preset alc268_presets[] = {
  7804. [ALC268_3ST] = {
  7805. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7806. .init_verbs = { alc268_base_init_verbs },
  7807. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7808. .dac_nids = alc268_dac_nids,
  7809. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7810. .adc_nids = alc268_adc_nids_alt,
  7811. .hp_nid = 0x03,
  7812. .dig_out_nid = ALC268_DIGOUT_NID,
  7813. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7814. .channel_mode = alc268_modes,
  7815. .input_mux = &alc268_capture_source,
  7816. },
  7817. };
  7818. static int patch_alc268(struct hda_codec *codec)
  7819. {
  7820. struct alc_spec *spec;
  7821. int board_config;
  7822. int err;
  7823. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7824. if (spec == NULL)
  7825. return -ENOMEM;
  7826. codec->spec = spec;
  7827. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7828. alc268_models,
  7829. alc268_cfg_tbl);
  7830. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7831. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7832. "trying auto-probe from BIOS...\n");
  7833. board_config = ALC268_AUTO;
  7834. }
  7835. if (board_config == ALC268_AUTO) {
  7836. /* automatic parse from the BIOS config */
  7837. err = alc268_parse_auto_config(codec);
  7838. if (err < 0) {
  7839. alc_free(codec);
  7840. return err;
  7841. } else if (!err) {
  7842. printk(KERN_INFO
  7843. "hda_codec: Cannot set up configuration "
  7844. "from BIOS. Using base mode...\n");
  7845. board_config = ALC268_3ST;
  7846. }
  7847. }
  7848. if (board_config != ALC268_AUTO)
  7849. setup_preset(spec, &alc268_presets[board_config]);
  7850. spec->stream_name_analog = "ALC268 Analog";
  7851. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7852. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7853. spec->stream_name_digital = "ALC268 Digital";
  7854. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7855. if (board_config == ALC268_AUTO) {
  7856. if (!spec->adc_nids && spec->input_mux) {
  7857. /* check whether NID 0x07 is valid */
  7858. unsigned int wcap = get_wcaps(codec, 0x07);
  7859. /* get type */
  7860. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7861. if (wcap != AC_WID_AUD_IN) {
  7862. spec->adc_nids = alc268_adc_nids_alt;
  7863. spec->num_adc_nids =
  7864. ARRAY_SIZE(alc268_adc_nids_alt);
  7865. spec->mixers[spec->num_mixers] =
  7866. alc268_capture_alt_mixer;
  7867. spec->num_mixers++;
  7868. } else {
  7869. spec->adc_nids = alc268_adc_nids;
  7870. spec->num_adc_nids =
  7871. ARRAY_SIZE(alc268_adc_nids);
  7872. spec->mixers[spec->num_mixers] =
  7873. alc268_capture_mixer;
  7874. spec->num_mixers++;
  7875. }
  7876. }
  7877. }
  7878. codec->patch_ops = alc_patch_ops;
  7879. if (board_config == ALC268_AUTO)
  7880. spec->init_hook = alc268_auto_init;
  7881. return 0;
  7882. }
  7883. /*
  7884. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7885. */
  7886. /*
  7887. * set the path ways for 2 channel output
  7888. * need to set the codec line out and mic 1 pin widgets to inputs
  7889. */
  7890. static struct hda_verb alc861_threestack_ch2_init[] = {
  7891. /* set pin widget 1Ah (line in) for input */
  7892. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7893. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7894. * the vref
  7895. */
  7896. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7897. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7898. #if 0
  7899. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7900. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7901. #endif
  7902. { } /* end */
  7903. };
  7904. /*
  7905. * 6ch mode
  7906. * need to set the codec line out and mic 1 pin widgets to outputs
  7907. */
  7908. static struct hda_verb alc861_threestack_ch6_init[] = {
  7909. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7910. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7911. /* set pin widget 18h (mic1) for output (CLFE)*/
  7912. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7913. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7914. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7915. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7916. #if 0
  7917. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7918. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7919. #endif
  7920. { } /* end */
  7921. };
  7922. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7923. { 2, alc861_threestack_ch2_init },
  7924. { 6, alc861_threestack_ch6_init },
  7925. };
  7926. /* Set mic1 as input and unmute the mixer */
  7927. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7928. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7929. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7930. { } /* end */
  7931. };
  7932. /* Set mic1 as output and mute mixer */
  7933. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7934. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7935. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7936. { } /* end */
  7937. };
  7938. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7939. { 2, alc861_uniwill_m31_ch2_init },
  7940. { 4, alc861_uniwill_m31_ch4_init },
  7941. };
  7942. /* Set mic1 and line-in as input and unmute the mixer */
  7943. static struct hda_verb alc861_asus_ch2_init[] = {
  7944. /* set pin widget 1Ah (line in) for input */
  7945. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7946. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7947. * the vref
  7948. */
  7949. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7950. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7951. #if 0
  7952. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7953. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7954. #endif
  7955. { } /* end */
  7956. };
  7957. /* Set mic1 nad line-in as output and mute mixer */
  7958. static struct hda_verb alc861_asus_ch6_init[] = {
  7959. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7960. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7961. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7962. /* set pin widget 18h (mic1) for output (CLFE)*/
  7963. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7964. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7965. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7966. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7967. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7968. #if 0
  7969. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7970. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7971. #endif
  7972. { } /* end */
  7973. };
  7974. static struct hda_channel_mode alc861_asus_modes[2] = {
  7975. { 2, alc861_asus_ch2_init },
  7976. { 6, alc861_asus_ch6_init },
  7977. };
  7978. /* patch-ALC861 */
  7979. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7980. /* output mixer control */
  7981. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7982. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7983. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7984. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7985. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7986. /*Input mixer control */
  7987. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7988. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7989. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7990. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7991. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7992. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7993. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7994. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7995. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7996. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7997. /* Capture mixer control */
  7998. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7999. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8000. {
  8001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8002. .name = "Capture Source",
  8003. .count = 1,
  8004. .info = alc_mux_enum_info,
  8005. .get = alc_mux_enum_get,
  8006. .put = alc_mux_enum_put,
  8007. },
  8008. { } /* end */
  8009. };
  8010. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8011. /* output mixer control */
  8012. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8013. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8014. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8015. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8016. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8017. /* Input mixer control */
  8018. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8019. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8020. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8021. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8022. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8023. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8024. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8025. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8026. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8027. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8028. /* Capture mixer control */
  8029. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8030. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8031. {
  8032. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8033. .name = "Capture Source",
  8034. .count = 1,
  8035. .info = alc_mux_enum_info,
  8036. .get = alc_mux_enum_get,
  8037. .put = alc_mux_enum_put,
  8038. },
  8039. {
  8040. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8041. .name = "Channel Mode",
  8042. .info = alc_ch_mode_info,
  8043. .get = alc_ch_mode_get,
  8044. .put = alc_ch_mode_put,
  8045. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8046. },
  8047. { } /* end */
  8048. };
  8049. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8050. /* output mixer control */
  8051. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8052. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8053. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8054. /*Capture mixer control */
  8055. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8056. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8057. {
  8058. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8059. .name = "Capture Source",
  8060. .count = 1,
  8061. .info = alc_mux_enum_info,
  8062. .get = alc_mux_enum_get,
  8063. .put = alc_mux_enum_put,
  8064. },
  8065. { } /* end */
  8066. };
  8067. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8068. /* output mixer control */
  8069. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8070. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8071. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8072. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8073. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8074. /* Input mixer control */
  8075. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8076. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8077. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8078. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8079. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8080. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8081. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8082. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8083. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8084. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8085. /* Capture mixer control */
  8086. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8087. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8088. {
  8089. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8090. .name = "Capture Source",
  8091. .count = 1,
  8092. .info = alc_mux_enum_info,
  8093. .get = alc_mux_enum_get,
  8094. .put = alc_mux_enum_put,
  8095. },
  8096. {
  8097. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8098. .name = "Channel Mode",
  8099. .info = alc_ch_mode_info,
  8100. .get = alc_ch_mode_get,
  8101. .put = alc_ch_mode_put,
  8102. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8103. },
  8104. { } /* end */
  8105. };
  8106. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8107. /* output mixer control */
  8108. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8109. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8110. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8111. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8112. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8113. /* Input mixer control */
  8114. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8115. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8116. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8117. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8118. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8119. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8121. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8122. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8123. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8124. /* Capture mixer control */
  8125. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8126. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8127. {
  8128. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8129. .name = "Capture Source",
  8130. .count = 1,
  8131. .info = alc_mux_enum_info,
  8132. .get = alc_mux_enum_get,
  8133. .put = alc_mux_enum_put,
  8134. },
  8135. {
  8136. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8137. .name = "Channel Mode",
  8138. .info = alc_ch_mode_info,
  8139. .get = alc_ch_mode_get,
  8140. .put = alc_ch_mode_put,
  8141. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8142. },
  8143. { }
  8144. };
  8145. /* additional mixer */
  8146. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8147. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8148. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8149. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8150. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8151. { }
  8152. };
  8153. /*
  8154. * generic initialization of ADC, input mixers and output mixers
  8155. */
  8156. static struct hda_verb alc861_base_init_verbs[] = {
  8157. /*
  8158. * Unmute ADC0 and set the default input to mic-in
  8159. */
  8160. /* port-A for surround (rear panel) */
  8161. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8162. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8163. /* port-B for mic-in (rear panel) with vref */
  8164. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8165. /* port-C for line-in (rear panel) */
  8166. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8167. /* port-D for Front */
  8168. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8169. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8170. /* port-E for HP out (front panel) */
  8171. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8172. /* route front PCM to HP */
  8173. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8174. /* port-F for mic-in (front panel) with vref */
  8175. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8176. /* port-G for CLFE (rear panel) */
  8177. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8178. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8179. /* port-H for side (rear panel) */
  8180. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8181. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8182. /* CD-in */
  8183. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8184. /* route front mic to ADC1*/
  8185. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8186. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8187. /* Unmute DAC0~3 & spdif out*/
  8188. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8189. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8190. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8191. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8192. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8193. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8194. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8195. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8196. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8197. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8198. /* Unmute Stereo Mixer 15 */
  8199. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8200. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8201. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8202. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8203. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8204. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8205. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8206. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8207. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8208. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8209. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8210. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8211. /* hp used DAC 3 (Front) */
  8212. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8213. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8214. { }
  8215. };
  8216. static struct hda_verb alc861_threestack_init_verbs[] = {
  8217. /*
  8218. * Unmute ADC0 and set the default input to mic-in
  8219. */
  8220. /* port-A for surround (rear panel) */
  8221. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8222. /* port-B for mic-in (rear panel) with vref */
  8223. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8224. /* port-C for line-in (rear panel) */
  8225. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8226. /* port-D for Front */
  8227. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8228. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8229. /* port-E for HP out (front panel) */
  8230. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8231. /* route front PCM to HP */
  8232. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8233. /* port-F for mic-in (front panel) with vref */
  8234. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8235. /* port-G for CLFE (rear panel) */
  8236. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8237. /* port-H for side (rear panel) */
  8238. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8239. /* CD-in */
  8240. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8241. /* route front mic to ADC1*/
  8242. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8243. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8244. /* Unmute DAC0~3 & spdif out*/
  8245. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8246. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8247. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8248. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8249. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8250. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8251. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8252. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8253. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8254. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8255. /* Unmute Stereo Mixer 15 */
  8256. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8257. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8258. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8259. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8260. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8261. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8262. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8263. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8264. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8265. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8266. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8267. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8268. /* hp used DAC 3 (Front) */
  8269. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8270. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8271. { }
  8272. };
  8273. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8274. /*
  8275. * Unmute ADC0 and set the default input to mic-in
  8276. */
  8277. /* port-A for surround (rear panel) */
  8278. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8279. /* port-B for mic-in (rear panel) with vref */
  8280. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8281. /* port-C for line-in (rear panel) */
  8282. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8283. /* port-D for Front */
  8284. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8285. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8286. /* port-E for HP out (front panel) */
  8287. /* this has to be set to VREF80 */
  8288. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8289. /* route front PCM to HP */
  8290. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8291. /* port-F for mic-in (front panel) with vref */
  8292. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8293. /* port-G for CLFE (rear panel) */
  8294. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8295. /* port-H for side (rear panel) */
  8296. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8297. /* CD-in */
  8298. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8299. /* route front mic to ADC1*/
  8300. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8301. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8302. /* Unmute DAC0~3 & spdif out*/
  8303. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8304. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8305. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8306. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8308. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8309. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8310. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8311. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8312. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8313. /* Unmute Stereo Mixer 15 */
  8314. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8315. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8319. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8321. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8326. /* hp used DAC 3 (Front) */
  8327. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8329. { }
  8330. };
  8331. static struct hda_verb alc861_asus_init_verbs[] = {
  8332. /*
  8333. * Unmute ADC0 and set the default input to mic-in
  8334. */
  8335. /* port-A for surround (rear panel)
  8336. * according to codec#0 this is the HP jack
  8337. */
  8338. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8339. /* route front PCM to HP */
  8340. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8341. /* port-B for mic-in (rear panel) with vref */
  8342. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8343. /* port-C for line-in (rear panel) */
  8344. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8345. /* port-D for Front */
  8346. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8347. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8348. /* port-E for HP out (front panel) */
  8349. /* this has to be set to VREF80 */
  8350. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8351. /* route front PCM to HP */
  8352. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8353. /* port-F for mic-in (front panel) with vref */
  8354. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8355. /* port-G for CLFE (rear panel) */
  8356. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8357. /* port-H for side (rear panel) */
  8358. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8359. /* CD-in */
  8360. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8361. /* route front mic to ADC1*/
  8362. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8363. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8364. /* Unmute DAC0~3 & spdif out*/
  8365. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8366. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8367. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8368. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8369. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8370. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8371. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8372. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8373. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8374. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8375. /* Unmute Stereo Mixer 15 */
  8376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8377. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8378. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8379. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8380. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8381. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8382. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8383. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8384. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8386. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8388. /* hp used DAC 3 (Front) */
  8389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8390. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8391. { }
  8392. };
  8393. /* additional init verbs for ASUS laptops */
  8394. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8395. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8396. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8397. { }
  8398. };
  8399. /*
  8400. * generic initialization of ADC, input mixers and output mixers
  8401. */
  8402. static struct hda_verb alc861_auto_init_verbs[] = {
  8403. /*
  8404. * Unmute ADC0 and set the default input to mic-in
  8405. */
  8406. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8407. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8408. /* Unmute DAC0~3 & spdif out*/
  8409. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8410. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8411. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8412. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8413. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8414. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8415. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8416. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8417. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8418. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8419. /* Unmute Stereo Mixer 15 */
  8420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8421. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8422. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8423. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8424. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8425. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8426. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8427. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8428. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8429. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8430. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8431. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8432. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8433. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8434. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8435. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8436. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8437. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8438. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8439. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8440. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8441. { }
  8442. };
  8443. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8444. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8445. { }
  8446. };
  8447. /* toggle speaker-output according to the hp-jack state */
  8448. static void alc861_toshiba_automute(struct hda_codec *codec)
  8449. {
  8450. unsigned int present;
  8451. present = snd_hda_codec_read(codec, 0x0f, 0,
  8452. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8453. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8454. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8455. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8456. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8457. }
  8458. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8459. unsigned int res)
  8460. {
  8461. if ((res >> 26) == ALC880_HP_EVENT)
  8462. alc861_toshiba_automute(codec);
  8463. }
  8464. /* pcm configuration: identiacal with ALC880 */
  8465. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8466. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8467. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8468. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8469. #define ALC861_DIGOUT_NID 0x07
  8470. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8471. { 8, NULL }
  8472. };
  8473. static hda_nid_t alc861_dac_nids[4] = {
  8474. /* front, surround, clfe, side */
  8475. 0x03, 0x06, 0x05, 0x04
  8476. };
  8477. static hda_nid_t alc660_dac_nids[3] = {
  8478. /* front, clfe, surround */
  8479. 0x03, 0x05, 0x06
  8480. };
  8481. static hda_nid_t alc861_adc_nids[1] = {
  8482. /* ADC0-2 */
  8483. 0x08,
  8484. };
  8485. static struct hda_input_mux alc861_capture_source = {
  8486. .num_items = 5,
  8487. .items = {
  8488. { "Mic", 0x0 },
  8489. { "Front Mic", 0x3 },
  8490. { "Line", 0x1 },
  8491. { "CD", 0x4 },
  8492. { "Mixer", 0x5 },
  8493. },
  8494. };
  8495. /* fill in the dac_nids table from the parsed pin configuration */
  8496. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8497. const struct auto_pin_cfg *cfg)
  8498. {
  8499. int i;
  8500. hda_nid_t nid;
  8501. spec->multiout.dac_nids = spec->private_dac_nids;
  8502. for (i = 0; i < cfg->line_outs; i++) {
  8503. nid = cfg->line_out_pins[i];
  8504. if (nid) {
  8505. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8506. continue;
  8507. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8508. }
  8509. }
  8510. spec->multiout.num_dacs = cfg->line_outs;
  8511. return 0;
  8512. }
  8513. /* add playback controls from the parsed DAC table */
  8514. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8515. const struct auto_pin_cfg *cfg)
  8516. {
  8517. char name[32];
  8518. static const char *chname[4] = {
  8519. "Front", "Surround", NULL /*CLFE*/, "Side"
  8520. };
  8521. hda_nid_t nid;
  8522. int i, idx, err;
  8523. for (i = 0; i < cfg->line_outs; i++) {
  8524. nid = spec->multiout.dac_nids[i];
  8525. if (!nid)
  8526. continue;
  8527. if (nid == 0x05) {
  8528. /* Center/LFE */
  8529. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8530. "Center Playback Switch",
  8531. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8532. HDA_OUTPUT));
  8533. if (err < 0)
  8534. return err;
  8535. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8536. "LFE Playback Switch",
  8537. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8538. HDA_OUTPUT));
  8539. if (err < 0)
  8540. return err;
  8541. } else {
  8542. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8543. idx++)
  8544. if (nid == alc861_dac_nids[idx])
  8545. break;
  8546. sprintf(name, "%s Playback Switch", chname[idx]);
  8547. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8548. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8549. HDA_OUTPUT));
  8550. if (err < 0)
  8551. return err;
  8552. }
  8553. }
  8554. return 0;
  8555. }
  8556. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8557. {
  8558. int err;
  8559. hda_nid_t nid;
  8560. if (!pin)
  8561. return 0;
  8562. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8563. nid = 0x03;
  8564. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8565. "Headphone Playback Switch",
  8566. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8567. if (err < 0)
  8568. return err;
  8569. spec->multiout.hp_nid = nid;
  8570. }
  8571. return 0;
  8572. }
  8573. /* create playback/capture controls for input pins */
  8574. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8575. const struct auto_pin_cfg *cfg)
  8576. {
  8577. struct hda_input_mux *imux = &spec->private_imux;
  8578. int i, err, idx, idx1;
  8579. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8580. switch (cfg->input_pins[i]) {
  8581. case 0x0c:
  8582. idx1 = 1;
  8583. idx = 2; /* Line In */
  8584. break;
  8585. case 0x0f:
  8586. idx1 = 2;
  8587. idx = 2; /* Line In */
  8588. break;
  8589. case 0x0d:
  8590. idx1 = 0;
  8591. idx = 1; /* Mic In */
  8592. break;
  8593. case 0x10:
  8594. idx1 = 3;
  8595. idx = 1; /* Mic In */
  8596. break;
  8597. case 0x11:
  8598. idx1 = 4;
  8599. idx = 0; /* CD */
  8600. break;
  8601. default:
  8602. continue;
  8603. }
  8604. err = new_analog_input(spec, cfg->input_pins[i],
  8605. auto_pin_cfg_labels[i], idx, 0x15);
  8606. if (err < 0)
  8607. return err;
  8608. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8609. imux->items[imux->num_items].index = idx1;
  8610. imux->num_items++;
  8611. }
  8612. return 0;
  8613. }
  8614. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8615. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8616. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8617. {
  8618. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8619. /* The multiple "Capture Source" controls confuse alsamixer
  8620. * So call somewhat different..
  8621. *FIXME: the controls appear in the "playback" view!
  8622. */
  8623. /* .name = "Capture Source", */
  8624. .name = "Input Source",
  8625. .count = 1,
  8626. .info = alc_mux_enum_info,
  8627. .get = alc_mux_enum_get,
  8628. .put = alc_mux_enum_put,
  8629. },
  8630. { } /* end */
  8631. };
  8632. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8633. hda_nid_t nid,
  8634. int pin_type, int dac_idx)
  8635. {
  8636. /* set as output */
  8637. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8638. pin_type);
  8639. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8640. AMP_OUT_UNMUTE);
  8641. }
  8642. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8643. {
  8644. struct alc_spec *spec = codec->spec;
  8645. int i;
  8646. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8647. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8648. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8649. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8650. if (nid)
  8651. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8652. spec->multiout.dac_nids[i]);
  8653. }
  8654. }
  8655. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8656. {
  8657. struct alc_spec *spec = codec->spec;
  8658. hda_nid_t pin;
  8659. pin = spec->autocfg.hp_pins[0];
  8660. if (pin) /* connect to front */
  8661. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8662. spec->multiout.dac_nids[0]);
  8663. }
  8664. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8665. {
  8666. struct alc_spec *spec = codec->spec;
  8667. int i;
  8668. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8669. hda_nid_t nid = spec->autocfg.input_pins[i];
  8670. if (nid >= 0x0c && nid <= 0x11) {
  8671. snd_hda_codec_write(codec, nid, 0,
  8672. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8673. i <= AUTO_PIN_FRONT_MIC ?
  8674. PIN_VREF80 : PIN_IN);
  8675. }
  8676. }
  8677. }
  8678. /* parse the BIOS configuration and set up the alc_spec */
  8679. /* return 1 if successful, 0 if the proper config is not found,
  8680. * or a negative error code
  8681. */
  8682. static int alc861_parse_auto_config(struct hda_codec *codec)
  8683. {
  8684. struct alc_spec *spec = codec->spec;
  8685. int err;
  8686. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8687. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8688. alc861_ignore);
  8689. if (err < 0)
  8690. return err;
  8691. if (!spec->autocfg.line_outs)
  8692. return 0; /* can't find valid BIOS pin config */
  8693. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8694. if (err < 0)
  8695. return err;
  8696. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8697. if (err < 0)
  8698. return err;
  8699. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8700. if (err < 0)
  8701. return err;
  8702. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8703. if (err < 0)
  8704. return err;
  8705. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8706. if (spec->autocfg.dig_out_pin)
  8707. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8708. if (spec->kctl_alloc)
  8709. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8710. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8711. spec->num_mux_defs = 1;
  8712. spec->input_mux = &spec->private_imux;
  8713. spec->adc_nids = alc861_adc_nids;
  8714. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8715. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8716. spec->num_mixers++;
  8717. return 1;
  8718. }
  8719. /* additional initialization for auto-configuration model */
  8720. static void alc861_auto_init(struct hda_codec *codec)
  8721. {
  8722. alc861_auto_init_multi_out(codec);
  8723. alc861_auto_init_hp_out(codec);
  8724. alc861_auto_init_analog_input(codec);
  8725. }
  8726. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8727. static struct hda_amp_list alc861_loopbacks[] = {
  8728. { 0x15, HDA_INPUT, 0 },
  8729. { 0x15, HDA_INPUT, 1 },
  8730. { 0x15, HDA_INPUT, 2 },
  8731. { 0x15, HDA_INPUT, 3 },
  8732. { } /* end */
  8733. };
  8734. #endif
  8735. /*
  8736. * configuration and preset
  8737. */
  8738. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8739. [ALC861_3ST] = "3stack",
  8740. [ALC660_3ST] = "3stack-660",
  8741. [ALC861_3ST_DIG] = "3stack-dig",
  8742. [ALC861_6ST_DIG] = "6stack-dig",
  8743. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8744. [ALC861_TOSHIBA] = "toshiba",
  8745. [ALC861_ASUS] = "asus",
  8746. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8747. [ALC861_AUTO] = "auto",
  8748. };
  8749. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8750. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8751. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8752. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8753. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8754. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8755. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8756. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8757. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8758. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8759. * Any other models that need this preset?
  8760. */
  8761. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8762. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8763. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8764. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8765. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8766. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8767. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  8768. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  8769. {}
  8770. };
  8771. static struct alc_config_preset alc861_presets[] = {
  8772. [ALC861_3ST] = {
  8773. .mixers = { alc861_3ST_mixer },
  8774. .init_verbs = { alc861_threestack_init_verbs },
  8775. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8776. .dac_nids = alc861_dac_nids,
  8777. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8778. .channel_mode = alc861_threestack_modes,
  8779. .need_dac_fix = 1,
  8780. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8781. .adc_nids = alc861_adc_nids,
  8782. .input_mux = &alc861_capture_source,
  8783. },
  8784. [ALC861_3ST_DIG] = {
  8785. .mixers = { alc861_base_mixer },
  8786. .init_verbs = { alc861_threestack_init_verbs },
  8787. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8788. .dac_nids = alc861_dac_nids,
  8789. .dig_out_nid = ALC861_DIGOUT_NID,
  8790. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8791. .channel_mode = alc861_threestack_modes,
  8792. .need_dac_fix = 1,
  8793. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8794. .adc_nids = alc861_adc_nids,
  8795. .input_mux = &alc861_capture_source,
  8796. },
  8797. [ALC861_6ST_DIG] = {
  8798. .mixers = { alc861_base_mixer },
  8799. .init_verbs = { alc861_base_init_verbs },
  8800. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8801. .dac_nids = alc861_dac_nids,
  8802. .dig_out_nid = ALC861_DIGOUT_NID,
  8803. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8804. .channel_mode = alc861_8ch_modes,
  8805. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8806. .adc_nids = alc861_adc_nids,
  8807. .input_mux = &alc861_capture_source,
  8808. },
  8809. [ALC660_3ST] = {
  8810. .mixers = { alc861_3ST_mixer },
  8811. .init_verbs = { alc861_threestack_init_verbs },
  8812. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8813. .dac_nids = alc660_dac_nids,
  8814. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8815. .channel_mode = alc861_threestack_modes,
  8816. .need_dac_fix = 1,
  8817. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8818. .adc_nids = alc861_adc_nids,
  8819. .input_mux = &alc861_capture_source,
  8820. },
  8821. [ALC861_UNIWILL_M31] = {
  8822. .mixers = { alc861_uniwill_m31_mixer },
  8823. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8824. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8825. .dac_nids = alc861_dac_nids,
  8826. .dig_out_nid = ALC861_DIGOUT_NID,
  8827. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8828. .channel_mode = alc861_uniwill_m31_modes,
  8829. .need_dac_fix = 1,
  8830. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8831. .adc_nids = alc861_adc_nids,
  8832. .input_mux = &alc861_capture_source,
  8833. },
  8834. [ALC861_TOSHIBA] = {
  8835. .mixers = { alc861_toshiba_mixer },
  8836. .init_verbs = { alc861_base_init_verbs,
  8837. alc861_toshiba_init_verbs },
  8838. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8839. .dac_nids = alc861_dac_nids,
  8840. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8841. .channel_mode = alc883_3ST_2ch_modes,
  8842. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8843. .adc_nids = alc861_adc_nids,
  8844. .input_mux = &alc861_capture_source,
  8845. .unsol_event = alc861_toshiba_unsol_event,
  8846. .init_hook = alc861_toshiba_automute,
  8847. },
  8848. [ALC861_ASUS] = {
  8849. .mixers = { alc861_asus_mixer },
  8850. .init_verbs = { alc861_asus_init_verbs },
  8851. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8852. .dac_nids = alc861_dac_nids,
  8853. .dig_out_nid = ALC861_DIGOUT_NID,
  8854. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8855. .channel_mode = alc861_asus_modes,
  8856. .need_dac_fix = 1,
  8857. .hp_nid = 0x06,
  8858. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8859. .adc_nids = alc861_adc_nids,
  8860. .input_mux = &alc861_capture_source,
  8861. },
  8862. [ALC861_ASUS_LAPTOP] = {
  8863. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8864. .init_verbs = { alc861_asus_init_verbs,
  8865. alc861_asus_laptop_init_verbs },
  8866. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8867. .dac_nids = alc861_dac_nids,
  8868. .dig_out_nid = ALC861_DIGOUT_NID,
  8869. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8870. .channel_mode = alc883_3ST_2ch_modes,
  8871. .need_dac_fix = 1,
  8872. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8873. .adc_nids = alc861_adc_nids,
  8874. .input_mux = &alc861_capture_source,
  8875. },
  8876. };
  8877. static int patch_alc861(struct hda_codec *codec)
  8878. {
  8879. struct alc_spec *spec;
  8880. int board_config;
  8881. int err;
  8882. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8883. if (spec == NULL)
  8884. return -ENOMEM;
  8885. codec->spec = spec;
  8886. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8887. alc861_models,
  8888. alc861_cfg_tbl);
  8889. if (board_config < 0) {
  8890. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8891. "trying auto-probe from BIOS...\n");
  8892. board_config = ALC861_AUTO;
  8893. }
  8894. if (board_config == ALC861_AUTO) {
  8895. /* automatic parse from the BIOS config */
  8896. err = alc861_parse_auto_config(codec);
  8897. if (err < 0) {
  8898. alc_free(codec);
  8899. return err;
  8900. } else if (!err) {
  8901. printk(KERN_INFO
  8902. "hda_codec: Cannot set up configuration "
  8903. "from BIOS. Using base mode...\n");
  8904. board_config = ALC861_3ST_DIG;
  8905. }
  8906. }
  8907. if (board_config != ALC861_AUTO)
  8908. setup_preset(spec, &alc861_presets[board_config]);
  8909. spec->stream_name_analog = "ALC861 Analog";
  8910. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8911. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8912. spec->stream_name_digital = "ALC861 Digital";
  8913. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8914. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8915. codec->patch_ops = alc_patch_ops;
  8916. if (board_config == ALC861_AUTO)
  8917. spec->init_hook = alc861_auto_init;
  8918. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8919. if (!spec->loopback.amplist)
  8920. spec->loopback.amplist = alc861_loopbacks;
  8921. #endif
  8922. return 0;
  8923. }
  8924. /*
  8925. * ALC861-VD support
  8926. *
  8927. * Based on ALC882
  8928. *
  8929. * In addition, an independent DAC
  8930. */
  8931. #define ALC861VD_DIGOUT_NID 0x06
  8932. static hda_nid_t alc861vd_dac_nids[4] = {
  8933. /* front, surr, clfe, side surr */
  8934. 0x02, 0x03, 0x04, 0x05
  8935. };
  8936. /* dac_nids for ALC660vd are in a different order - according to
  8937. * Realtek's driver.
  8938. * This should probably tesult in a different mixer for 6stack models
  8939. * of ALC660vd codecs, but for now there is only 3stack mixer
  8940. * - and it is the same as in 861vd.
  8941. * adc_nids in ALC660vd are (is) the same as in 861vd
  8942. */
  8943. static hda_nid_t alc660vd_dac_nids[3] = {
  8944. /* front, rear, clfe, rear_surr */
  8945. 0x02, 0x04, 0x03
  8946. };
  8947. static hda_nid_t alc861vd_adc_nids[1] = {
  8948. /* ADC0 */
  8949. 0x09,
  8950. };
  8951. /* input MUX */
  8952. /* FIXME: should be a matrix-type input source selection */
  8953. static struct hda_input_mux alc861vd_capture_source = {
  8954. .num_items = 4,
  8955. .items = {
  8956. { "Mic", 0x0 },
  8957. { "Front Mic", 0x1 },
  8958. { "Line", 0x2 },
  8959. { "CD", 0x4 },
  8960. },
  8961. };
  8962. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8963. .num_items = 3,
  8964. .items = {
  8965. { "Front Mic", 0x0 },
  8966. { "ATAPI Mic", 0x1 },
  8967. { "Line In", 0x5 },
  8968. },
  8969. };
  8970. #define alc861vd_mux_enum_info alc_mux_enum_info
  8971. #define alc861vd_mux_enum_get alc_mux_enum_get
  8972. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8973. struct snd_ctl_elem_value *ucontrol)
  8974. {
  8975. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8976. struct alc_spec *spec = codec->spec;
  8977. const struct hda_input_mux *imux = spec->input_mux;
  8978. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8979. static hda_nid_t capture_mixers[1] = { 0x22 };
  8980. hda_nid_t nid = capture_mixers[adc_idx];
  8981. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8982. unsigned int i, idx;
  8983. idx = ucontrol->value.enumerated.item[0];
  8984. if (idx >= imux->num_items)
  8985. idx = imux->num_items - 1;
  8986. if (*cur_val == idx)
  8987. return 0;
  8988. for (i = 0; i < imux->num_items; i++) {
  8989. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8990. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8991. imux->items[i].index,
  8992. HDA_AMP_MUTE, v);
  8993. }
  8994. *cur_val = idx;
  8995. return 1;
  8996. }
  8997. /*
  8998. * 2ch mode
  8999. */
  9000. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9001. { 2, NULL }
  9002. };
  9003. /*
  9004. * 6ch mode
  9005. */
  9006. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9007. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9008. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9009. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9010. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9011. { } /* end */
  9012. };
  9013. /*
  9014. * 8ch mode
  9015. */
  9016. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9017. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9018. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9019. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9020. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9021. { } /* end */
  9022. };
  9023. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9024. { 6, alc861vd_6stack_ch6_init },
  9025. { 8, alc861vd_6stack_ch8_init },
  9026. };
  9027. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9028. {
  9029. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9030. .name = "Channel Mode",
  9031. .info = alc_ch_mode_info,
  9032. .get = alc_ch_mode_get,
  9033. .put = alc_ch_mode_put,
  9034. },
  9035. { } /* end */
  9036. };
  9037. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9038. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9039. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9040. {
  9041. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9042. /* The multiple "Capture Source" controls confuse alsamixer
  9043. * So call somewhat different..
  9044. *FIXME: the controls appear in the "playback" view!
  9045. */
  9046. /* .name = "Capture Source", */
  9047. .name = "Input Source",
  9048. .count = 1,
  9049. .info = alc861vd_mux_enum_info,
  9050. .get = alc861vd_mux_enum_get,
  9051. .put = alc861vd_mux_enum_put,
  9052. },
  9053. { } /* end */
  9054. };
  9055. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9056. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9057. */
  9058. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9059. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9060. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9061. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9062. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9063. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9064. HDA_OUTPUT),
  9065. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9066. HDA_OUTPUT),
  9067. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9068. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9069. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9070. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9071. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9072. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9073. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9074. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9075. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9076. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9077. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9078. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9079. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9080. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9081. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9082. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9083. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9084. { } /* end */
  9085. };
  9086. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9087. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9088. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9089. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9090. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9091. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9092. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9093. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9094. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9095. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9096. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9097. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9098. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9099. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9100. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9101. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9102. { } /* end */
  9103. };
  9104. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9105. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9106. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9107. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9108. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9109. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9110. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9111. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9112. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9113. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9114. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9115. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9116. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9117. { } /* end */
  9118. };
  9119. /* Pin assignment: Front=0x14, HP = 0x15,
  9120. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9121. */
  9122. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9123. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9124. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9125. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9126. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9127. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9128. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9129. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9130. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9131. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9132. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9133. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9134. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9135. {
  9136. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9137. /* .name = "Capture Source", */
  9138. .name = "Input Source",
  9139. .count = 1,
  9140. .info = alc882_mux_enum_info,
  9141. .get = alc882_mux_enum_get,
  9142. .put = alc882_mux_enum_put,
  9143. },
  9144. { } /* end */
  9145. };
  9146. /*
  9147. * generic initialization of ADC, input mixers and output mixers
  9148. */
  9149. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9150. /*
  9151. * Unmute ADC0 and set the default input to mic-in
  9152. */
  9153. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9154. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9155. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9156. * the analog-loopback mixer widget
  9157. */
  9158. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9159. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9160. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9161. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9162. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9163. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9164. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9165. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9166. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9167. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9168. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9169. /*
  9170. * Set up output mixers (0x02 - 0x05)
  9171. */
  9172. /* set vol=0 to output mixers */
  9173. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9174. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9175. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9176. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9177. /* set up input amps for analog loopback */
  9178. /* Amp Indices: DAC = 0, mixer = 1 */
  9179. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9180. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9181. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9182. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9183. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9184. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9185. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9187. { }
  9188. };
  9189. /*
  9190. * 3-stack pin configuration:
  9191. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9192. */
  9193. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9194. /*
  9195. * Set pin mode and muting
  9196. */
  9197. /* set front pin widgets 0x14 for output */
  9198. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9199. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9200. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9201. /* Mic (rear) pin: input vref at 80% */
  9202. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9203. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9204. /* Front Mic pin: input vref at 80% */
  9205. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9206. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9207. /* Line In pin: input */
  9208. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9209. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9210. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9211. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9212. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9213. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9214. /* CD pin widget for input */
  9215. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9216. { }
  9217. };
  9218. /*
  9219. * 6-stack pin configuration:
  9220. */
  9221. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9222. /*
  9223. * Set pin mode and muting
  9224. */
  9225. /* set front pin widgets 0x14 for output */
  9226. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9227. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9228. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9229. /* Rear Pin: output 1 (0x0d) */
  9230. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9231. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9232. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9233. /* CLFE Pin: output 2 (0x0e) */
  9234. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9235. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9236. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9237. /* Side Pin: output 3 (0x0f) */
  9238. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9239. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9240. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9241. /* Mic (rear) pin: input vref at 80% */
  9242. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9243. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9244. /* Front Mic pin: input vref at 80% */
  9245. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9246. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9247. /* Line In pin: input */
  9248. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9249. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9250. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9251. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9252. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9253. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9254. /* CD pin widget for input */
  9255. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9256. { }
  9257. };
  9258. static struct hda_verb alc861vd_eapd_verbs[] = {
  9259. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9260. { }
  9261. };
  9262. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9263. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9264. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9265. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9266. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9267. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9268. {}
  9269. };
  9270. /* toggle speaker-output according to the hp-jack state */
  9271. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9272. {
  9273. unsigned int present;
  9274. unsigned char bits;
  9275. present = snd_hda_codec_read(codec, 0x1b, 0,
  9276. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9277. bits = present ? HDA_AMP_MUTE : 0;
  9278. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9279. HDA_AMP_MUTE, bits);
  9280. }
  9281. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9282. {
  9283. unsigned int present;
  9284. unsigned char bits;
  9285. present = snd_hda_codec_read(codec, 0x18, 0,
  9286. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9287. bits = present ? HDA_AMP_MUTE : 0;
  9288. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9289. HDA_AMP_MUTE, bits);
  9290. }
  9291. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9292. {
  9293. alc861vd_lenovo_hp_automute(codec);
  9294. alc861vd_lenovo_mic_automute(codec);
  9295. }
  9296. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9297. unsigned int res)
  9298. {
  9299. switch (res >> 26) {
  9300. case ALC880_HP_EVENT:
  9301. alc861vd_lenovo_hp_automute(codec);
  9302. break;
  9303. case ALC880_MIC_EVENT:
  9304. alc861vd_lenovo_mic_automute(codec);
  9305. break;
  9306. }
  9307. }
  9308. static struct hda_verb alc861vd_dallas_verbs[] = {
  9309. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9310. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9311. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9312. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9313. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9314. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9315. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9316. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9317. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9318. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9319. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9320. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9321. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9322. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9323. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9324. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9325. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9326. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9327. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9328. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9329. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9330. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9331. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9332. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9333. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9334. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9335. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9336. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9337. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9338. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9339. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9340. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9341. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9342. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9343. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9344. { } /* end */
  9345. };
  9346. /* toggle speaker-output according to the hp-jack state */
  9347. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9348. {
  9349. unsigned int present;
  9350. present = snd_hda_codec_read(codec, 0x15, 0,
  9351. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9352. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9353. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9354. }
  9355. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9356. {
  9357. if ((res >> 26) == ALC880_HP_EVENT)
  9358. alc861vd_dallas_automute(codec);
  9359. }
  9360. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9361. #define alc861vd_loopbacks alc880_loopbacks
  9362. #endif
  9363. /* pcm configuration: identiacal with ALC880 */
  9364. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9365. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9366. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9367. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9368. /*
  9369. * configuration and preset
  9370. */
  9371. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9372. [ALC660VD_3ST] = "3stack-660",
  9373. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9374. [ALC861VD_3ST] = "3stack",
  9375. [ALC861VD_3ST_DIG] = "3stack-digout",
  9376. [ALC861VD_6ST_DIG] = "6stack-digout",
  9377. [ALC861VD_LENOVO] = "lenovo",
  9378. [ALC861VD_DALLAS] = "dallas",
  9379. [ALC861VD_AUTO] = "auto",
  9380. };
  9381. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9382. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9383. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9384. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9385. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9386. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9387. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9388. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9389. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9390. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9391. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9392. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9393. {}
  9394. };
  9395. static struct alc_config_preset alc861vd_presets[] = {
  9396. [ALC660VD_3ST] = {
  9397. .mixers = { alc861vd_3st_mixer },
  9398. .init_verbs = { alc861vd_volume_init_verbs,
  9399. alc861vd_3stack_init_verbs },
  9400. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9401. .dac_nids = alc660vd_dac_nids,
  9402. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9403. .adc_nids = alc861vd_adc_nids,
  9404. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9405. .channel_mode = alc861vd_3stack_2ch_modes,
  9406. .input_mux = &alc861vd_capture_source,
  9407. },
  9408. [ALC660VD_3ST_DIG] = {
  9409. .mixers = { alc861vd_3st_mixer },
  9410. .init_verbs = { alc861vd_volume_init_verbs,
  9411. alc861vd_3stack_init_verbs },
  9412. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9413. .dac_nids = alc660vd_dac_nids,
  9414. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9415. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9416. .adc_nids = alc861vd_adc_nids,
  9417. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9418. .channel_mode = alc861vd_3stack_2ch_modes,
  9419. .input_mux = &alc861vd_capture_source,
  9420. },
  9421. [ALC861VD_3ST] = {
  9422. .mixers = { alc861vd_3st_mixer },
  9423. .init_verbs = { alc861vd_volume_init_verbs,
  9424. alc861vd_3stack_init_verbs },
  9425. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9426. .dac_nids = alc861vd_dac_nids,
  9427. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9428. .channel_mode = alc861vd_3stack_2ch_modes,
  9429. .input_mux = &alc861vd_capture_source,
  9430. },
  9431. [ALC861VD_3ST_DIG] = {
  9432. .mixers = { alc861vd_3st_mixer },
  9433. .init_verbs = { alc861vd_volume_init_verbs,
  9434. alc861vd_3stack_init_verbs },
  9435. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9436. .dac_nids = alc861vd_dac_nids,
  9437. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9438. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9439. .channel_mode = alc861vd_3stack_2ch_modes,
  9440. .input_mux = &alc861vd_capture_source,
  9441. },
  9442. [ALC861VD_6ST_DIG] = {
  9443. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9444. .init_verbs = { alc861vd_volume_init_verbs,
  9445. alc861vd_6stack_init_verbs },
  9446. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9447. .dac_nids = alc861vd_dac_nids,
  9448. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9449. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9450. .channel_mode = alc861vd_6stack_modes,
  9451. .input_mux = &alc861vd_capture_source,
  9452. },
  9453. [ALC861VD_LENOVO] = {
  9454. .mixers = { alc861vd_lenovo_mixer },
  9455. .init_verbs = { alc861vd_volume_init_verbs,
  9456. alc861vd_3stack_init_verbs,
  9457. alc861vd_eapd_verbs,
  9458. alc861vd_lenovo_unsol_verbs },
  9459. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9460. .dac_nids = alc660vd_dac_nids,
  9461. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9462. .adc_nids = alc861vd_adc_nids,
  9463. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9464. .channel_mode = alc861vd_3stack_2ch_modes,
  9465. .input_mux = &alc861vd_capture_source,
  9466. .unsol_event = alc861vd_lenovo_unsol_event,
  9467. .init_hook = alc861vd_lenovo_automute,
  9468. },
  9469. [ALC861VD_DALLAS] = {
  9470. .mixers = { alc861vd_dallas_mixer },
  9471. .init_verbs = { alc861vd_dallas_verbs },
  9472. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9473. .dac_nids = alc861vd_dac_nids,
  9474. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9475. .adc_nids = alc861vd_adc_nids,
  9476. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9477. .channel_mode = alc861vd_3stack_2ch_modes,
  9478. .input_mux = &alc861vd_dallas_capture_source,
  9479. .unsol_event = alc861vd_dallas_unsol_event,
  9480. .init_hook = alc861vd_dallas_automute,
  9481. },
  9482. };
  9483. /*
  9484. * BIOS auto configuration
  9485. */
  9486. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9487. hda_nid_t nid, int pin_type, int dac_idx)
  9488. {
  9489. /* set as output */
  9490. snd_hda_codec_write(codec, nid, 0,
  9491. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9492. snd_hda_codec_write(codec, nid, 0,
  9493. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9494. }
  9495. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9496. {
  9497. struct alc_spec *spec = codec->spec;
  9498. int i;
  9499. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9500. for (i = 0; i <= HDA_SIDE; i++) {
  9501. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9502. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9503. if (nid)
  9504. alc861vd_auto_set_output_and_unmute(codec, nid,
  9505. pin_type, i);
  9506. }
  9507. }
  9508. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9509. {
  9510. struct alc_spec *spec = codec->spec;
  9511. hda_nid_t pin;
  9512. pin = spec->autocfg.hp_pins[0];
  9513. if (pin) /* connect to front and use dac 0 */
  9514. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9515. }
  9516. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9517. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9518. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9519. {
  9520. struct alc_spec *spec = codec->spec;
  9521. int i;
  9522. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9523. hda_nid_t nid = spec->autocfg.input_pins[i];
  9524. if (alc861vd_is_input_pin(nid)) {
  9525. snd_hda_codec_write(codec, nid, 0,
  9526. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9527. i <= AUTO_PIN_FRONT_MIC ?
  9528. PIN_VREF80 : PIN_IN);
  9529. if (nid != ALC861VD_PIN_CD_NID)
  9530. snd_hda_codec_write(codec, nid, 0,
  9531. AC_VERB_SET_AMP_GAIN_MUTE,
  9532. AMP_OUT_MUTE);
  9533. }
  9534. }
  9535. }
  9536. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9537. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9538. /* add playback controls from the parsed DAC table */
  9539. /* Based on ALC880 version. But ALC861VD has separate,
  9540. * different NIDs for mute/unmute switch and volume control */
  9541. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9542. const struct auto_pin_cfg *cfg)
  9543. {
  9544. char name[32];
  9545. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9546. hda_nid_t nid_v, nid_s;
  9547. int i, err;
  9548. for (i = 0; i < cfg->line_outs; i++) {
  9549. if (!spec->multiout.dac_nids[i])
  9550. continue;
  9551. nid_v = alc861vd_idx_to_mixer_vol(
  9552. alc880_dac_to_idx(
  9553. spec->multiout.dac_nids[i]));
  9554. nid_s = alc861vd_idx_to_mixer_switch(
  9555. alc880_dac_to_idx(
  9556. spec->multiout.dac_nids[i]));
  9557. if (i == 2) {
  9558. /* Center/LFE */
  9559. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9560. "Center Playback Volume",
  9561. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9562. HDA_OUTPUT));
  9563. if (err < 0)
  9564. return err;
  9565. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9566. "LFE Playback Volume",
  9567. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9568. HDA_OUTPUT));
  9569. if (err < 0)
  9570. return err;
  9571. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9572. "Center Playback Switch",
  9573. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9574. HDA_INPUT));
  9575. if (err < 0)
  9576. return err;
  9577. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9578. "LFE Playback Switch",
  9579. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9580. HDA_INPUT));
  9581. if (err < 0)
  9582. return err;
  9583. } else {
  9584. sprintf(name, "%s Playback Volume", chname[i]);
  9585. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9586. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9587. HDA_OUTPUT));
  9588. if (err < 0)
  9589. return err;
  9590. sprintf(name, "%s Playback Switch", chname[i]);
  9591. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9592. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9593. HDA_INPUT));
  9594. if (err < 0)
  9595. return err;
  9596. }
  9597. }
  9598. return 0;
  9599. }
  9600. /* add playback controls for speaker and HP outputs */
  9601. /* Based on ALC880 version. But ALC861VD has separate,
  9602. * different NIDs for mute/unmute switch and volume control */
  9603. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9604. hda_nid_t pin, const char *pfx)
  9605. {
  9606. hda_nid_t nid_v, nid_s;
  9607. int err;
  9608. char name[32];
  9609. if (!pin)
  9610. return 0;
  9611. if (alc880_is_fixed_pin(pin)) {
  9612. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9613. /* specify the DAC as the extra output */
  9614. if (!spec->multiout.hp_nid)
  9615. spec->multiout.hp_nid = nid_v;
  9616. else
  9617. spec->multiout.extra_out_nid[0] = nid_v;
  9618. /* control HP volume/switch on the output mixer amp */
  9619. nid_v = alc861vd_idx_to_mixer_vol(
  9620. alc880_fixed_pin_idx(pin));
  9621. nid_s = alc861vd_idx_to_mixer_switch(
  9622. alc880_fixed_pin_idx(pin));
  9623. sprintf(name, "%s Playback Volume", pfx);
  9624. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9625. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9626. if (err < 0)
  9627. return err;
  9628. sprintf(name, "%s Playback Switch", pfx);
  9629. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9630. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9631. if (err < 0)
  9632. return err;
  9633. } else if (alc880_is_multi_pin(pin)) {
  9634. /* set manual connection */
  9635. /* we have only a switch on HP-out PIN */
  9636. sprintf(name, "%s Playback Switch", pfx);
  9637. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9638. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9639. if (err < 0)
  9640. return err;
  9641. }
  9642. return 0;
  9643. }
  9644. /* parse the BIOS configuration and set up the alc_spec
  9645. * return 1 if successful, 0 if the proper config is not found,
  9646. * or a negative error code
  9647. * Based on ALC880 version - had to change it to override
  9648. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9649. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9650. {
  9651. struct alc_spec *spec = codec->spec;
  9652. int err;
  9653. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9654. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9655. alc861vd_ignore);
  9656. if (err < 0)
  9657. return err;
  9658. if (!spec->autocfg.line_outs)
  9659. return 0; /* can't find valid BIOS pin config */
  9660. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9661. if (err < 0)
  9662. return err;
  9663. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9664. if (err < 0)
  9665. return err;
  9666. err = alc861vd_auto_create_extra_out(spec,
  9667. spec->autocfg.speaker_pins[0],
  9668. "Speaker");
  9669. if (err < 0)
  9670. return err;
  9671. err = alc861vd_auto_create_extra_out(spec,
  9672. spec->autocfg.hp_pins[0],
  9673. "Headphone");
  9674. if (err < 0)
  9675. return err;
  9676. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9677. if (err < 0)
  9678. return err;
  9679. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9680. if (spec->autocfg.dig_out_pin)
  9681. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9682. if (spec->kctl_alloc)
  9683. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9684. spec->init_verbs[spec->num_init_verbs++]
  9685. = alc861vd_volume_init_verbs;
  9686. spec->num_mux_defs = 1;
  9687. spec->input_mux = &spec->private_imux;
  9688. return 1;
  9689. }
  9690. /* additional initialization for auto-configuration model */
  9691. static void alc861vd_auto_init(struct hda_codec *codec)
  9692. {
  9693. alc861vd_auto_init_multi_out(codec);
  9694. alc861vd_auto_init_hp_out(codec);
  9695. alc861vd_auto_init_analog_input(codec);
  9696. }
  9697. static int patch_alc861vd(struct hda_codec *codec)
  9698. {
  9699. struct alc_spec *spec;
  9700. int err, board_config;
  9701. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9702. if (spec == NULL)
  9703. return -ENOMEM;
  9704. codec->spec = spec;
  9705. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9706. alc861vd_models,
  9707. alc861vd_cfg_tbl);
  9708. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9709. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9710. "ALC861VD, trying auto-probe from BIOS...\n");
  9711. board_config = ALC861VD_AUTO;
  9712. }
  9713. if (board_config == ALC861VD_AUTO) {
  9714. /* automatic parse from the BIOS config */
  9715. err = alc861vd_parse_auto_config(codec);
  9716. if (err < 0) {
  9717. alc_free(codec);
  9718. return err;
  9719. } else if (!err) {
  9720. printk(KERN_INFO
  9721. "hda_codec: Cannot set up configuration "
  9722. "from BIOS. Using base mode...\n");
  9723. board_config = ALC861VD_3ST;
  9724. }
  9725. }
  9726. if (board_config != ALC861VD_AUTO)
  9727. setup_preset(spec, &alc861vd_presets[board_config]);
  9728. spec->stream_name_analog = "ALC861VD Analog";
  9729. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9730. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9731. spec->stream_name_digital = "ALC861VD Digital";
  9732. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9733. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9734. spec->adc_nids = alc861vd_adc_nids;
  9735. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9736. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9737. spec->num_mixers++;
  9738. codec->patch_ops = alc_patch_ops;
  9739. if (board_config == ALC861VD_AUTO)
  9740. spec->init_hook = alc861vd_auto_init;
  9741. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9742. if (!spec->loopback.amplist)
  9743. spec->loopback.amplist = alc861vd_loopbacks;
  9744. #endif
  9745. return 0;
  9746. }
  9747. /*
  9748. * ALC662 support
  9749. *
  9750. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9751. * configuration. Each pin widget can choose any input DACs and a mixer.
  9752. * Each ADC is connected from a mixer of all inputs. This makes possible
  9753. * 6-channel independent captures.
  9754. *
  9755. * In addition, an independent DAC for the multi-playback (not used in this
  9756. * driver yet).
  9757. */
  9758. #define ALC662_DIGOUT_NID 0x06
  9759. #define ALC662_DIGIN_NID 0x0a
  9760. static hda_nid_t alc662_dac_nids[4] = {
  9761. /* front, rear, clfe, rear_surr */
  9762. 0x02, 0x03, 0x04
  9763. };
  9764. static hda_nid_t alc662_adc_nids[1] = {
  9765. /* ADC1-2 */
  9766. 0x09,
  9767. };
  9768. /* input MUX */
  9769. /* FIXME: should be a matrix-type input source selection */
  9770. static struct hda_input_mux alc662_capture_source = {
  9771. .num_items = 4,
  9772. .items = {
  9773. { "Mic", 0x0 },
  9774. { "Front Mic", 0x1 },
  9775. { "Line", 0x2 },
  9776. { "CD", 0x4 },
  9777. },
  9778. };
  9779. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9780. .num_items = 2,
  9781. .items = {
  9782. { "Mic", 0x1 },
  9783. { "Line", 0x2 },
  9784. },
  9785. };
  9786. #define alc662_mux_enum_info alc_mux_enum_info
  9787. #define alc662_mux_enum_get alc_mux_enum_get
  9788. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9789. struct snd_ctl_elem_value *ucontrol)
  9790. {
  9791. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9792. struct alc_spec *spec = codec->spec;
  9793. const struct hda_input_mux *imux = spec->input_mux;
  9794. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9795. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9796. hda_nid_t nid = capture_mixers[adc_idx];
  9797. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9798. unsigned int i, idx;
  9799. idx = ucontrol->value.enumerated.item[0];
  9800. if (idx >= imux->num_items)
  9801. idx = imux->num_items - 1;
  9802. if (*cur_val == idx)
  9803. return 0;
  9804. for (i = 0; i < imux->num_items; i++) {
  9805. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9806. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9807. imux->items[i].index,
  9808. HDA_AMP_MUTE, v);
  9809. }
  9810. *cur_val = idx;
  9811. return 1;
  9812. }
  9813. /*
  9814. * 2ch mode
  9815. */
  9816. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9817. { 2, NULL }
  9818. };
  9819. /*
  9820. * 2ch mode
  9821. */
  9822. static struct hda_verb alc662_3ST_ch2_init[] = {
  9823. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9824. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9825. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9826. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9827. { } /* end */
  9828. };
  9829. /*
  9830. * 6ch mode
  9831. */
  9832. static struct hda_verb alc662_3ST_ch6_init[] = {
  9833. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9834. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9835. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9836. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9837. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9838. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9839. { } /* end */
  9840. };
  9841. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9842. { 2, alc662_3ST_ch2_init },
  9843. { 6, alc662_3ST_ch6_init },
  9844. };
  9845. /*
  9846. * 2ch mode
  9847. */
  9848. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9849. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9850. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9851. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9852. { } /* end */
  9853. };
  9854. /*
  9855. * 6ch mode
  9856. */
  9857. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9858. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9859. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9860. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9861. { } /* end */
  9862. };
  9863. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9864. { 2, alc662_sixstack_ch6_init },
  9865. { 6, alc662_sixstack_ch8_init },
  9866. };
  9867. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9868. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9869. */
  9870. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9871. /* output mixer control */
  9872. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9873. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9874. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9875. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9876. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9877. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9878. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9879. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9880. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9881. /*Input mixer control */
  9882. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9883. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9884. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9885. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9886. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9887. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9888. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9889. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9890. /* Capture mixer control */
  9891. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9892. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9893. {
  9894. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9895. .name = "Capture Source",
  9896. .count = 1,
  9897. .info = alc_mux_enum_info,
  9898. .get = alc_mux_enum_get,
  9899. .put = alc_mux_enum_put,
  9900. },
  9901. { } /* end */
  9902. };
  9903. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9904. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9905. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9906. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9907. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9908. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9909. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9910. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9911. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9912. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9913. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9914. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9915. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9916. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9917. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9918. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9919. {
  9920. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9921. /* .name = "Capture Source", */
  9922. .name = "Input Source",
  9923. .count = 1,
  9924. .info = alc662_mux_enum_info,
  9925. .get = alc662_mux_enum_get,
  9926. .put = alc662_mux_enum_put,
  9927. },
  9928. { } /* end */
  9929. };
  9930. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9931. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9932. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9933. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9934. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9935. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9936. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9937. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9938. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9939. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9940. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9941. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9942. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9943. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9944. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9945. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9946. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9947. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9948. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9949. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9950. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9951. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9952. {
  9953. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9954. /* .name = "Capture Source", */
  9955. .name = "Input Source",
  9956. .count = 1,
  9957. .info = alc662_mux_enum_info,
  9958. .get = alc662_mux_enum_get,
  9959. .put = alc662_mux_enum_put,
  9960. },
  9961. { } /* end */
  9962. };
  9963. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9964. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9965. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9966. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9967. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9968. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9969. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9970. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9971. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9972. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9973. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9974. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9975. {
  9976. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9977. /* .name = "Capture Source", */
  9978. .name = "Input Source",
  9979. .count = 1,
  9980. .info = alc662_mux_enum_info,
  9981. .get = alc662_mux_enum_get,
  9982. .put = alc662_mux_enum_put,
  9983. },
  9984. { } /* end */
  9985. };
  9986. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9987. {
  9988. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9989. .name = "Channel Mode",
  9990. .info = alc_ch_mode_info,
  9991. .get = alc_ch_mode_get,
  9992. .put = alc_ch_mode_put,
  9993. },
  9994. { } /* end */
  9995. };
  9996. static struct hda_verb alc662_init_verbs[] = {
  9997. /* ADC: mute amp left and right */
  9998. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9999. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10000. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10001. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10002. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10003. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10004. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10005. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10006. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10007. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10008. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10009. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10010. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10011. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10012. /* Front Pin: output 0 (0x0c) */
  10013. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10014. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10015. /* Rear Pin: output 1 (0x0d) */
  10016. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10017. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10018. /* CLFE Pin: output 2 (0x0e) */
  10019. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10020. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10021. /* Mic (rear) pin: input vref at 80% */
  10022. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10023. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10024. /* Front Mic pin: input vref at 80% */
  10025. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10026. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10027. /* Line In pin: input */
  10028. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10029. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10030. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10031. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10032. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10033. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10034. /* CD pin widget for input */
  10035. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10036. /* FIXME: use matrix-type input source selection */
  10037. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10038. /* Input mixer */
  10039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10041. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10042. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10043. { }
  10044. };
  10045. static struct hda_verb alc662_sue_init_verbs[] = {
  10046. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10047. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10048. {}
  10049. };
  10050. /*
  10051. * generic initialization of ADC, input mixers and output mixers
  10052. */
  10053. static struct hda_verb alc662_auto_init_verbs[] = {
  10054. /*
  10055. * Unmute ADC and set the default input to mic-in
  10056. */
  10057. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10058. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10059. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10060. * mixer widget
  10061. * Note: PASD motherboards uses the Line In 2 as the input for front
  10062. * panel mic (mic 2)
  10063. */
  10064. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10065. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10066. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10067. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10068. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10069. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10070. /*
  10071. * Set up output mixers (0x0c - 0x0f)
  10072. */
  10073. /* set vol=0 to output mixers */
  10074. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10075. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10076. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10077. /* set up input amps for analog loopback */
  10078. /* Amp Indices: DAC = 0, mixer = 1 */
  10079. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10080. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10081. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10082. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10083. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10084. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10085. /* FIXME: use matrix-type input source selection */
  10086. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10087. /* Input mixer */
  10088. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10089. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10090. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10091. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  10092. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10093. { }
  10094. };
  10095. /* capture mixer elements */
  10096. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10097. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10098. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10099. {
  10100. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10101. /* The multiple "Capture Source" controls confuse alsamixer
  10102. * So call somewhat different..
  10103. * FIXME: the controls appear in the "playback" view!
  10104. */
  10105. /* .name = "Capture Source", */
  10106. .name = "Input Source",
  10107. .count = 1,
  10108. .info = alc882_mux_enum_info,
  10109. .get = alc882_mux_enum_get,
  10110. .put = alc882_mux_enum_put,
  10111. },
  10112. { } /* end */
  10113. };
  10114. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10115. {
  10116. unsigned int present;
  10117. unsigned char bits;
  10118. present = snd_hda_codec_read(codec, 0x14, 0,
  10119. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10120. bits = present ? HDA_AMP_MUTE : 0;
  10121. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10122. HDA_AMP_MUTE, bits);
  10123. }
  10124. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10125. {
  10126. unsigned int present;
  10127. unsigned char bits;
  10128. present = snd_hda_codec_read(codec, 0x1b, 0,
  10129. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10130. bits = present ? HDA_AMP_MUTE : 0;
  10131. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10132. HDA_AMP_MUTE, bits);
  10133. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10134. HDA_AMP_MUTE, bits);
  10135. }
  10136. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10137. unsigned int res)
  10138. {
  10139. if ((res >> 26) == ALC880_HP_EVENT)
  10140. alc662_lenovo_101e_all_automute(codec);
  10141. if ((res >> 26) == ALC880_FRONT_EVENT)
  10142. alc662_lenovo_101e_ispeaker_automute(codec);
  10143. }
  10144. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10145. #define alc662_loopbacks alc880_loopbacks
  10146. #endif
  10147. /* pcm configuration: identiacal with ALC880 */
  10148. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10149. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10150. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10151. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10152. /*
  10153. * configuration and preset
  10154. */
  10155. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10156. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10157. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10158. [ALC662_3ST_6ch] = "3stack-6ch",
  10159. [ALC662_5ST_DIG] = "6stack-dig",
  10160. [ALC662_LENOVO_101E] = "lenovo-101e",
  10161. [ALC662_AUTO] = "auto",
  10162. };
  10163. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10164. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10165. {}
  10166. };
  10167. static struct alc_config_preset alc662_presets[] = {
  10168. [ALC662_3ST_2ch_DIG] = {
  10169. .mixers = { alc662_3ST_2ch_mixer },
  10170. .init_verbs = { alc662_init_verbs },
  10171. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10172. .dac_nids = alc662_dac_nids,
  10173. .dig_out_nid = ALC662_DIGOUT_NID,
  10174. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10175. .adc_nids = alc662_adc_nids,
  10176. .dig_in_nid = ALC662_DIGIN_NID,
  10177. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10178. .channel_mode = alc662_3ST_2ch_modes,
  10179. .input_mux = &alc662_capture_source,
  10180. },
  10181. [ALC662_3ST_6ch_DIG] = {
  10182. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10183. .init_verbs = { alc662_init_verbs },
  10184. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10185. .dac_nids = alc662_dac_nids,
  10186. .dig_out_nid = ALC662_DIGOUT_NID,
  10187. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10188. .adc_nids = alc662_adc_nids,
  10189. .dig_in_nid = ALC662_DIGIN_NID,
  10190. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10191. .channel_mode = alc662_3ST_6ch_modes,
  10192. .need_dac_fix = 1,
  10193. .input_mux = &alc662_capture_source,
  10194. },
  10195. [ALC662_3ST_6ch] = {
  10196. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10197. .init_verbs = { alc662_init_verbs },
  10198. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10199. .dac_nids = alc662_dac_nids,
  10200. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10201. .adc_nids = alc662_adc_nids,
  10202. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10203. .channel_mode = alc662_3ST_6ch_modes,
  10204. .need_dac_fix = 1,
  10205. .input_mux = &alc662_capture_source,
  10206. },
  10207. [ALC662_5ST_DIG] = {
  10208. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10209. .init_verbs = { alc662_init_verbs },
  10210. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10211. .dac_nids = alc662_dac_nids,
  10212. .dig_out_nid = ALC662_DIGOUT_NID,
  10213. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10214. .adc_nids = alc662_adc_nids,
  10215. .dig_in_nid = ALC662_DIGIN_NID,
  10216. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10217. .channel_mode = alc662_5stack_modes,
  10218. .input_mux = &alc662_capture_source,
  10219. },
  10220. [ALC662_LENOVO_101E] = {
  10221. .mixers = { alc662_lenovo_101e_mixer },
  10222. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10223. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10224. .dac_nids = alc662_dac_nids,
  10225. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10226. .adc_nids = alc662_adc_nids,
  10227. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10228. .channel_mode = alc662_3ST_2ch_modes,
  10229. .input_mux = &alc662_lenovo_101e_capture_source,
  10230. .unsol_event = alc662_lenovo_101e_unsol_event,
  10231. .init_hook = alc662_lenovo_101e_all_automute,
  10232. },
  10233. };
  10234. /*
  10235. * BIOS auto configuration
  10236. */
  10237. /* add playback controls from the parsed DAC table */
  10238. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10239. const struct auto_pin_cfg *cfg)
  10240. {
  10241. char name[32];
  10242. static const char *chname[4] = {
  10243. "Front", "Surround", NULL /*CLFE*/, "Side"
  10244. };
  10245. hda_nid_t nid;
  10246. int i, err;
  10247. for (i = 0; i < cfg->line_outs; i++) {
  10248. if (!spec->multiout.dac_nids[i])
  10249. continue;
  10250. nid = alc880_idx_to_mixer(i);
  10251. if (i == 2) {
  10252. /* Center/LFE */
  10253. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10254. "Center Playback Volume",
  10255. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10256. HDA_OUTPUT));
  10257. if (err < 0)
  10258. return err;
  10259. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10260. "LFE Playback Volume",
  10261. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10262. HDA_OUTPUT));
  10263. if (err < 0)
  10264. return err;
  10265. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10266. "Center Playback Switch",
  10267. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10268. HDA_INPUT));
  10269. if (err < 0)
  10270. return err;
  10271. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10272. "LFE Playback Switch",
  10273. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10274. HDA_INPUT));
  10275. if (err < 0)
  10276. return err;
  10277. } else {
  10278. sprintf(name, "%s Playback Volume", chname[i]);
  10279. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10280. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10281. HDA_OUTPUT));
  10282. if (err < 0)
  10283. return err;
  10284. sprintf(name, "%s Playback Switch", chname[i]);
  10285. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10286. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10287. HDA_INPUT));
  10288. if (err < 0)
  10289. return err;
  10290. }
  10291. }
  10292. return 0;
  10293. }
  10294. /* add playback controls for speaker and HP outputs */
  10295. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10296. const char *pfx)
  10297. {
  10298. hda_nid_t nid;
  10299. int err;
  10300. char name[32];
  10301. if (!pin)
  10302. return 0;
  10303. if (alc880_is_fixed_pin(pin)) {
  10304. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10305. /* printk("DAC nid=%x\n",nid); */
  10306. /* specify the DAC as the extra output */
  10307. if (!spec->multiout.hp_nid)
  10308. spec->multiout.hp_nid = nid;
  10309. else
  10310. spec->multiout.extra_out_nid[0] = nid;
  10311. /* control HP volume/switch on the output mixer amp */
  10312. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10313. sprintf(name, "%s Playback Volume", pfx);
  10314. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10315. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10316. if (err < 0)
  10317. return err;
  10318. sprintf(name, "%s Playback Switch", pfx);
  10319. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10320. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10321. if (err < 0)
  10322. return err;
  10323. } else if (alc880_is_multi_pin(pin)) {
  10324. /* set manual connection */
  10325. /* we have only a switch on HP-out PIN */
  10326. sprintf(name, "%s Playback Switch", pfx);
  10327. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10328. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10329. if (err < 0)
  10330. return err;
  10331. }
  10332. return 0;
  10333. }
  10334. /* create playback/capture controls for input pins */
  10335. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10336. const struct auto_pin_cfg *cfg)
  10337. {
  10338. struct hda_input_mux *imux = &spec->private_imux;
  10339. int i, err, idx;
  10340. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10341. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10342. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10343. err = new_analog_input(spec, cfg->input_pins[i],
  10344. auto_pin_cfg_labels[i],
  10345. idx, 0x0b);
  10346. if (err < 0)
  10347. return err;
  10348. imux->items[imux->num_items].label =
  10349. auto_pin_cfg_labels[i];
  10350. imux->items[imux->num_items].index =
  10351. alc880_input_pin_idx(cfg->input_pins[i]);
  10352. imux->num_items++;
  10353. }
  10354. }
  10355. return 0;
  10356. }
  10357. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10358. hda_nid_t nid, int pin_type,
  10359. int dac_idx)
  10360. {
  10361. /* set as output */
  10362. snd_hda_codec_write(codec, nid, 0,
  10363. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10364. snd_hda_codec_write(codec, nid, 0,
  10365. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10366. /* need the manual connection? */
  10367. if (alc880_is_multi_pin(nid)) {
  10368. struct alc_spec *spec = codec->spec;
  10369. int idx = alc880_multi_pin_idx(nid);
  10370. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10371. AC_VERB_SET_CONNECT_SEL,
  10372. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10373. }
  10374. }
  10375. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10376. {
  10377. struct alc_spec *spec = codec->spec;
  10378. int i;
  10379. for (i = 0; i <= HDA_SIDE; i++) {
  10380. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10381. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10382. if (nid)
  10383. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10384. i);
  10385. }
  10386. }
  10387. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10388. {
  10389. struct alc_spec *spec = codec->spec;
  10390. hda_nid_t pin;
  10391. pin = spec->autocfg.hp_pins[0];
  10392. if (pin) /* connect to front */
  10393. /* use dac 0 */
  10394. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10395. }
  10396. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10397. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10398. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10399. {
  10400. struct alc_spec *spec = codec->spec;
  10401. int i;
  10402. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10403. hda_nid_t nid = spec->autocfg.input_pins[i];
  10404. if (alc662_is_input_pin(nid)) {
  10405. snd_hda_codec_write(codec, nid, 0,
  10406. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10407. (i <= AUTO_PIN_FRONT_MIC ?
  10408. PIN_VREF80 : PIN_IN));
  10409. if (nid != ALC662_PIN_CD_NID)
  10410. snd_hda_codec_write(codec, nid, 0,
  10411. AC_VERB_SET_AMP_GAIN_MUTE,
  10412. AMP_OUT_MUTE);
  10413. }
  10414. }
  10415. }
  10416. static int alc662_parse_auto_config(struct hda_codec *codec)
  10417. {
  10418. struct alc_spec *spec = codec->spec;
  10419. int err;
  10420. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10421. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10422. alc662_ignore);
  10423. if (err < 0)
  10424. return err;
  10425. if (!spec->autocfg.line_outs)
  10426. return 0; /* can't find valid BIOS pin config */
  10427. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10428. if (err < 0)
  10429. return err;
  10430. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10431. if (err < 0)
  10432. return err;
  10433. err = alc662_auto_create_extra_out(spec,
  10434. spec->autocfg.speaker_pins[0],
  10435. "Speaker");
  10436. if (err < 0)
  10437. return err;
  10438. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10439. "Headphone");
  10440. if (err < 0)
  10441. return err;
  10442. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10443. if (err < 0)
  10444. return err;
  10445. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10446. if (spec->autocfg.dig_out_pin)
  10447. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10448. if (spec->kctl_alloc)
  10449. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10450. spec->num_mux_defs = 1;
  10451. spec->input_mux = &spec->private_imux;
  10452. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10453. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10454. spec->num_mixers++;
  10455. return 1;
  10456. }
  10457. /* additional initialization for auto-configuration model */
  10458. static void alc662_auto_init(struct hda_codec *codec)
  10459. {
  10460. alc662_auto_init_multi_out(codec);
  10461. alc662_auto_init_hp_out(codec);
  10462. alc662_auto_init_analog_input(codec);
  10463. }
  10464. static int patch_alc662(struct hda_codec *codec)
  10465. {
  10466. struct alc_spec *spec;
  10467. int err, board_config;
  10468. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10469. if (!spec)
  10470. return -ENOMEM;
  10471. codec->spec = spec;
  10472. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10473. alc662_models,
  10474. alc662_cfg_tbl);
  10475. if (board_config < 0) {
  10476. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10477. "trying auto-probe from BIOS...\n");
  10478. board_config = ALC662_AUTO;
  10479. }
  10480. if (board_config == ALC662_AUTO) {
  10481. /* automatic parse from the BIOS config */
  10482. err = alc662_parse_auto_config(codec);
  10483. if (err < 0) {
  10484. alc_free(codec);
  10485. return err;
  10486. } else if (!err) {
  10487. printk(KERN_INFO
  10488. "hda_codec: Cannot set up configuration "
  10489. "from BIOS. Using base mode...\n");
  10490. board_config = ALC662_3ST_2ch_DIG;
  10491. }
  10492. }
  10493. if (board_config != ALC662_AUTO)
  10494. setup_preset(spec, &alc662_presets[board_config]);
  10495. spec->stream_name_analog = "ALC662 Analog";
  10496. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10497. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10498. spec->stream_name_digital = "ALC662 Digital";
  10499. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10500. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10501. if (!spec->adc_nids && spec->input_mux) {
  10502. spec->adc_nids = alc662_adc_nids;
  10503. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10504. }
  10505. codec->patch_ops = alc_patch_ops;
  10506. if (board_config == ALC662_AUTO)
  10507. spec->init_hook = alc662_auto_init;
  10508. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10509. if (!spec->loopback.amplist)
  10510. spec->loopback.amplist = alc662_loopbacks;
  10511. #endif
  10512. return 0;
  10513. }
  10514. /*
  10515. * patch entries
  10516. */
  10517. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10518. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10519. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10520. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10521. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10522. .patch = patch_alc861 },
  10523. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10524. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10525. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10526. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10527. .patch = patch_alc883 },
  10528. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10529. .patch = patch_alc662 },
  10530. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10531. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10532. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10533. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10534. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10535. {} /* terminator */
  10536. };